diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java index 37bcf7873c..8f5de47070 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/auth/HugeGraphAuthProxy.java @@ -974,6 +974,12 @@ public void waitUntilAllTasksCompleted(long seconds) this.taskScheduler.waitUntilAllTasksCompleted(seconds); } + @Override + public void checkRequirement(String op) { + verifyStatusPermission(); + this.taskScheduler.checkRequirement(op); + } + private void verifyTaskPermission(HugePermission actionPerm) { verifyPermission(actionPerm, ResourceType.TASK); } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/JobBuilder.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/JobBuilder.java index a0dc69d4ca..584d892281 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/JobBuilder.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/JobBuilder.java @@ -71,6 +71,9 @@ public HugeTask schedule() { E.checkArgumentNotNull(this.job, "Job callable can't be null"); E.checkArgument(this.job instanceof TaskCallable, "Job must be instance of TaskCallable"); + + this.graph.taskScheduler().checkRequirement("schedule"); + @SuppressWarnings("unchecked") TaskCallable job = (TaskCallable) this.job; diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/task/StandardTaskScheduler.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/task/StandardTaskScheduler.java index 90d3145073..ddfe78784b 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/task/StandardTaskScheduler.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/task/StandardTaskScheduler.java @@ -659,6 +659,11 @@ public void waitUntilAllTasksCompleted(long seconds) taskSize, seconds)); } + @Override + public void checkRequirement(String op) { + this.checkOnMasterNode(op); + } + private Iterator> queryTask(String key, Object value, long limit, String page) { return this.queryTask(ImmutableMap.of(key, value), limit, page); diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskScheduler.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskScheduler.java index 89c5ca2ac7..c20600a131 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskScheduler.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/task/TaskScheduler.java @@ -61,4 +61,6 @@ public HugeTask waitUntilTaskCompleted(Id id) public void waitUntilAllTasksCompleted(long seconds) throws TimeoutException; + + public void checkRequirement(String op); }