use of com.emc.storageos.coordinator.client.service.impl.ReaperLeaderSelectorListener in project coprhd-controller by CoprHD.
the class CoordinatorImpl method startMutexReaper.
/**
* Reaper mutex dirs generated from InterProcessMutex
*/
private void startMutexReaper() {
Thread childReaperThread = new Thread(new Runnable() {
public void run() {
try {
// from LoggingBean, needs to wait for CoordinatorSvc started.
while (!_coordinatorClient.isConnected()) {
_log.info("Waiting for connection to cluster ...");
Thread.sleep(3 * 1000);
}
_log.info("Connected to cluster");
DrUtil drUtil = new DrUtil(_coordinatorClient);
if (drUtil.isStandby()) {
_log.info("Skip mutex reapter on standby site");
return;
}
/**
* Reaper empty dirs under /mutex in zookeeper
* It leverages curator Reaper and ChildReaper to remove empty sub dirs.
* It leverages LeaderSelector to assure only one reaper running at the same time.
* Note: Please use autoRequeue() to requeue for competing leader automatically
* while connection broken and reconnected. The requeue() has a bug in curator
* 1.3.4 and should not be used.
*/
LeaderSelectorListener listener = new ReaperLeaderSelectorListener(ZkPath.MUTEX.toString());
String _leaderRelativePath = "mutexReaper";
LeaderSelector leaderSel = _coordinatorClient.getLeaderSelector(_leaderRelativePath, listener);
leaderSel.autoRequeue();
leaderSel.start();
} catch (Exception e) {
_log.warn("reaper task threw", e);
}
}
}, "reaper thread");
childReaperThread.start();
}
Aggregations