incubator-droids-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r1452279 - in /incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids: core/AbstractDroid.java core/Droid.java core/TaskMaster.java taskmaster/SequentialTaskMaster.java
Date Mon, 04 Mar 2013 12:57:25 GMT
Author: thorsten
Date: Mon Mar  4 12:57:25 2013
New Revision: 1452279

URL: http://svn.apache.org/r1452279
Log:
Implementing stopping a running droid

Modified:
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractDroid.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Droid.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/taskmaster/SequentialTaskMaster.java

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractDroid.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractDroid.java?rev=1452279&r1=1452278&r2=1452279&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractDroid.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractDroid.java
Mon Mar  4 12:57:25 2013
@@ -78,8 +78,8 @@ public abstract class AbstractDroid<T ex
      *
      * @param parsers Parser implementations
      */
-    public void addParsers(Parser... parsers) {
-        for (Parser parser : parsers) {
+    public void addParsers(Parser<?>... parsers) {
+        for (Parser<?> parser : parsers) {
             this.parserFactory.addParser(parser);
         }
     }
@@ -120,6 +120,11 @@ public abstract class AbstractDroid<T ex
     }
 
     @Override
+    public void stop() {
+        taskMaster.stop();
+    }
+
+    @Override
     public void finished() {
         logger.info("FINISHED!!!");
     }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Droid.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Droid.java?rev=1452279&r1=1452278&r2=1452279&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Droid.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Droid.java
Mon Mar  4 12:57:25 2013
@@ -36,6 +36,11 @@ public interface Droid<T extends Task> {
     public void start();
 
     /**
+     * Stop the droid which will then stop the taskmaster 
+     */
+    public void stop();
+
+    /**
      * Invoke when the droid has completed
      */
     public void finished();

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java?rev=1452279&r1=1452278&r2=1452279&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java
Mon Mar  4 12:57:25 2013
@@ -44,6 +44,13 @@ public interface TaskMaster<T extends Ta
     void start(final Queue<T> queue, final Droid<T> droid);
 
     /**
+     * Start the process of running tasks.
+     *
+     * @param droid
+     */
+    void stop();
+
+    /**
      * Blocks until all tasks have completed execution.
      *
      * @param timeout

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/taskmaster/SequentialTaskMaster.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/taskmaster/SequentialTaskMaster.java?rev=1452279&r1=1452278&r2=1452279&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/taskmaster/SequentialTaskMaster.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/taskmaster/SequentialTaskMaster.java
Mon Mar  4 12:57:25 2013
@@ -42,6 +42,7 @@ public class SequentialTaskMaster<T exte
     private volatile ExecutionState state = ExecutionState.INITIALIZED;
     private DelayTimer delayTimer = null;
     private TaskExceptionHandler exHandler = null;
+    private boolean terminated;
 
     public SequentialTaskMaster() {
         super();
@@ -59,7 +60,7 @@ public class SequentialTaskMaster<T exte
         this.completedTask = 0;
         this.state = ExecutionState.RUNNING;
 
-        boolean terminated = false;
+        terminated = false;
         while (!terminated) {
             T task = queue.poll();
             if (task == null) {
@@ -111,6 +112,15 @@ public class SequentialTaskMaster<T exte
         }
     }
 
+    public void stop() {
+        // debug
+        if (LOG.isInfoEnabled()) {
+            LOG.info("Stop the executor service.");
+        }
+        // the next line will issue that the start loop will break.
+        terminated  = true;
+    }
+
     @Override
     public final void setExceptionHandler(TaskExceptionHandler exHandler) {
         this.exHandler = exHandler;



Mime
View raw message