brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [4/6] incubator-brooklyn git commit: code review for task-cancellation mode
Date Wed, 20 Jan 2016 21:04:38 GMT
code review for task-cancellation mode


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/54cba8a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/54cba8a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/54cba8a6

Branch: refs/heads/master
Commit: 54cba8a657f151f93eb3cb504ccbb94c6d1fc9c7
Parents: aed0786
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Jan 20 21:01:20 2016 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Jan 20 21:01:38 2016 +0000

----------------------------------------------------------------------
 .../apache/brooklyn/util/core/task/BasicExecutionManager.java    | 3 ++-
 .../main/java/org/apache/brooklyn/util/core/task/BasicTask.java  | 1 +
 .../brooklyn/util/core/task/DynamicSequentialTaskTest.java       | 4 ++--
 3 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/54cba8a6/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java
b/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java
index 2010613..0aab7d5 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionManager.java
@@ -576,6 +576,7 @@ public class BasicExecutionManager implements ExecutionManager {
                         }
                     }
                 }
+                // TODO this is inefficient; might want to keep an index on submitted-by
                 for (Task<?> t: execMgmt.getAllTasks()) {
                     if (task.equals(t.getSubmittedByTask())) {
                         if (mode.isAllowedToInterruptAllSubmittedTasks() || BrooklynTaskTags.isTransient(t))
{
@@ -740,7 +741,7 @@ public class BasicExecutionManager implements ExecutionManager {
             try {
                 return ((Callable<?>)callable).call();
             } catch (Throwable t) {
-                throw Throwables.propagate(t);
+                throw Exceptions.propagate(t);
             }
         }
         if (callable instanceof Runnable) { ((Runnable)callable).run(); return null; }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/54cba8a6/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicTask.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicTask.java
b/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicTask.java
index c727d10..7c29bba 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicTask.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/util/core/task/BasicTask.java
@@ -294,6 +294,7 @@ public class BasicTask<T> implements TaskInternal<T> {
             : TaskCancellationMode.DO_NOT_INTERRUPT);
     }
     
+    @Override @Beta
     public synchronized boolean cancel(TaskCancellationMode mode) {
         if (isDone()) return false;
         if (log.isTraceEnabled()) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/54cba8a6/brooklyn-server/core/src/test/java/org/apache/brooklyn/util/core/task/DynamicSequentialTaskTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/test/java/org/apache/brooklyn/util/core/task/DynamicSequentialTaskTest.java
b/brooklyn-server/core/src/test/java/org/apache/brooklyn/util/core/task/DynamicSequentialTaskTest.java
index 95f0952..364870a 100644
--- a/brooklyn-server/core/src/test/java/org/apache/brooklyn/util/core/task/DynamicSequentialTaskTest.java
+++ b/brooklyn-server/core/src/test/java/org/apache/brooklyn/util/core/task/DynamicSequentialTaskTest.java
@@ -267,14 +267,14 @@ public class DynamicSequentialTaskTest {
         waitForMessages(Predicates.compose(MathPredicates.greaterThanOrEqual(2), CollectionFunctionals.sizeFunction()),
TIMEOUT);
         Asserts.assertEquals(MutableSet.copyOf(messages), MutableSet.of("1-wait", "2-wait"));
 
-        Time.sleep(Duration.millis(400));
-        
         if (cancellationMode==null) {
             ((TaskInternal<?>)t).cancel();
         } else if (cancellationMode instanceof Boolean) {
             t.cancel((Boolean)cancellationMode);
         } else if (cancellationMode instanceof TaskCancellationMode) {
             ((TaskInternal<?>)t).cancel((TaskCancellationMode)cancellationMode);
+        } else {
+            throw new IllegalStateException("Invalid cancellationMode: "+cancellationMode);
         }
 
         // the cancelled task always reports cancelled and done


Mime
View raw message