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/replication/server/ReplicationBackend.java |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java b/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
index fc2bb7c..a935278 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
@@ -505,6 +505,10 @@
     {
       for (ReplicationCache exportContainer : exportContainers)
       {
+        if (exportConfig.isCancelled())
+        {
+          break;
+        }
         processContainer(exportContainer, exportConfig, ldifWriter, null);
       }
     }
@@ -571,6 +575,11 @@
 
     for (ReplicationCache exportContainer : exportContainers)
     {
+      if (exportConfig != null && exportConfig.isCancelled())
+      {
+        break;
+      }
+
       attributes.clear();
       ldapAttrList.clear();
 
@@ -630,6 +639,11 @@
     // Walk through the servers
     for (Short serverId : rc.getServers())
     {
+      if (exportConfig != null && exportConfig.isCancelled())
+      {
+        break;
+      }
+
       ReplicationIterator ri = rc.getChangelogIterator(serverId,
           null);
 
@@ -640,6 +654,10 @@
           // Walk through the changes
           while (ri.getChange() != null)
           {
+            if (exportConfig != null && exportConfig.isCancelled())
+            {
+              break;
+            }
             UpdateMessage msg = ri.getChange();
             processChange(msg, exportConfig, ldifWriter, searchOperation);
             if (!ri.next())

--
Gitblit v1.10.0