Repository: accumulo
Updated Branches:
  refs/heads/ACCUMULO-378 58fbf1438 -> 49fc9855f


ACCUMULO-378 Allow for dynamic reconfiguration of the WorkAssigner impl


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/db10cfe2
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/db10cfe2
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/db10cfe2

Branch: refs/heads/ACCUMULO-378
Commit: db10cfe26823f5a31b516070521f54e5b890fb7b
Parents: 58fbf14
Author: Josh Elser <els...@apache.org>
Authored: Wed May 28 16:55:39 2014 -0400
Committer: Josh Elser <els...@apache.org>
Committed: Wed May 28 16:55:39 2014 -0400

----------------------------------------------------------------------
 .../accumulo/master/replication/WorkDriver.java | 33 +++++++++++++-------
 1 file changed, 22 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/db10cfe2/server/master/src/main/java/org/apache/accumulo/master/replication/WorkDriver.java
----------------------------------------------------------------------
diff --git 
a/server/master/src/main/java/org/apache/accumulo/master/replication/WorkDriver.java
 
b/server/master/src/main/java/org/apache/accumulo/master/replication/WorkDriver.java
index 00b0480..8c3e3e3 100644
--- 
a/server/master/src/main/java/org/apache/accumulo/master/replication/WorkDriver.java
+++ 
b/server/master/src/main/java/org/apache/accumulo/master/replication/WorkDriver.java
@@ -44,20 +44,28 @@ public class WorkDriver extends Daemon {
     this.master = master;
     this.conn = conn;
     this.conf = master.getConfiguration().getConfiguration();
+    configureWorkAssigner();
+  }
 
+  protected void configureWorkAssigner() {
     String workAssignerClass = conf.get(Property.REPLICATION_WORK_ASSIGNER);
-    try {
-      Class<?> clz = Class.forName(workAssignerClass);
-      Class<? extends WorkAssigner> workAssignerClz = 
clz.asSubclass(WorkAssigner.class);
-      this.assigner = workAssignerClz.newInstance();
-    } catch (ClassNotFoundException | InstantiationException | 
IllegalAccessException e) {
-      log.error("Could not instantiate configured work assigner {}", 
workAssignerClass, e);
-      throw new RuntimeException(e);
-    }
 
-    this.assigner.configure(conf, conn);
-    this.assignerImplName = assigner.getClass().getName();
-    this.setName(assigner.getName());
+    if (null == assigner || 
!assigner.getClass().getName().equals(workAssignerClass)) {
+      log.info("Initializing work assigner implementation of {}", 
workAssignerClass);
+
+      try {
+        Class<?> clz = Class.forName(workAssignerClass);
+        Class<? extends WorkAssigner> workAssignerClz = 
clz.asSubclass(WorkAssigner.class);
+        this.assigner = workAssignerClz.newInstance();
+      } catch (ClassNotFoundException | InstantiationException | 
IllegalAccessException e) {
+        log.error("Could not instantiate configured work assigner {}", 
workAssignerClass, e);
+        throw new RuntimeException(e);
+      }
+  
+      this.assigner.configure(conf, conn);
+      this.assignerImplName = assigner.getClass().getName();
+      this.setName(assigner.getName());
+    }
   }
 
   /*
@@ -90,6 +98,9 @@ public class WorkDriver extends Daemon {
       long sleepTime = 
conf.getTimeInMillis(Property.REPLICATION_WORK_ASSIGNMENT_SLEEP);
       log.debug("Sleeping {} ms before next work assignment", sleepTime);
       UtilWaitThread.sleep(sleepTime);
+
+      // After each loop, make sure that the WorkAssigner implementation 
didn't change
+      configureWorkAssigner();
     }
   }
 }

Reply via email to