From eee90cc3e34f4e5a7d562ee9e60c66a61816985c Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Tue, 16 Oct 2007 20:19:45 +0000
Subject: [PATCH] Issue 2368: tasks should be interruptable.  The four schedulable task (import-ldif, export-ldif, backup, and restore) can now be interrupted for purposes of cancellation.  The manage-tasks utility now allows the user to cancel any one of these tasks if they are currently running.  If interrupted while executing, the tasks try to break out of their work loop as soon as possible and return a 'stopped by administrator' status.  Both the backup and export-ldif tasks perform some cleanup (removing the abandoned backup or exported LDIF file) if they are cancelled.

---
 opends/src/server/org/opends/server/backends/task/TaskState.java |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/task/TaskState.java b/opends/src/server/org/opends/server/backends/task/TaskState.java
index fb5dbaf..43c78a7 100644
--- a/opends/src/server/org/opends/server/backends/task/TaskState.java
+++ b/opends/src/server/org/opends/server/backends/task/TaskState.java
@@ -224,6 +224,26 @@
   }
 
 
+  /**
+   * Indicates whether or not this task has been cancelled.
+   *
+   * @param  taskState  The task state for which to make the determination.
+   *
+   * @return  <CODE>true</CODE> if the task state indicates that the task
+   *          was cancelled either before or during execution, or
+   *          <CODE>false</CODE> otherwise.
+   */
+  public static boolean isCancelled(TaskState taskState)
+  {
+    switch(taskState)
+    {
+      case STOPPED_BY_ADMINISTRATOR:
+      case CANCELED_BEFORE_STARTING:
+        return true;
+      default:
+        return false;
+    }
+  }
 
   /**
    * Retrieves the task state that corresponds to the provided string value.

--
Gitblit v1.10.0