Simon Hunt

Magic numbers are bad! (Bad Juju!!) A step closer to being configurable.

Change-Id: I12e0115301cf02b8cb5af23d4d441efd82b4a3d1
...@@ -55,6 +55,8 @@ public class MastershipLoadBalancer { ...@@ -55,6 +55,8 @@ public class MastershipLoadBalancer {
55 55
56 private final Logger log = getLogger(getClass()); 56 private final Logger log = getLogger(getClass());
57 57
58 + // TODO: parameterize via component config
59 + private static final int SCHEDULE_PERIOD = 5;
58 private static final String REBALANCE_MASTERSHIP = "rebalance/mastership"; 60 private static final String REBALANCE_MASTERSHIP = "rebalance/mastership";
59 61
60 private NodeId localId; 62 private NodeId localId;
...@@ -120,8 +122,9 @@ public class MastershipLoadBalancer { ...@@ -120,8 +122,9 @@ public class MastershipLoadBalancer {
120 private void scheduleBalance() { 122 private void scheduleBalance() {
121 if (isLeader.get() && nextTask.get() == null) { 123 if (isLeader.get() && nextTask.get() == null) {
122 124
123 - ListenableScheduledFuture task = executorService.schedule(mastershipAdminService::balanceRoles, 30, 125 + ListenableScheduledFuture task =
124 - TimeUnit.SECONDS); 126 + executorService.schedule(mastershipAdminService::balanceRoles,
127 + SCHEDULE_PERIOD, TimeUnit.SECONDS);
125 task.addListener(() -> { 128 task.addListener(() -> {
126 log.info("Completed balance roles"); 129 log.info("Completed balance roles");
127 nextTask.set(null); 130 nextTask.set(null);
......