Search in sources :

Example 1 with ReaperLeaderSelectorListener

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();
}
Also used : ReaperLeaderSelectorListener(com.emc.storageos.coordinator.client.service.impl.ReaperLeaderSelectorListener) LeaderSelectorListener(org.apache.curator.framework.recipes.leader.LeaderSelectorListener) ReaperLeaderSelectorListener(com.emc.storageos.coordinator.client.service.impl.ReaperLeaderSelectorListener) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) LeaderSelector(org.apache.curator.framework.recipes.leader.LeaderSelector) IOException(java.io.IOException) JMException(javax.management.JMException)

Aggregations

DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)1 ReaperLeaderSelectorListener (com.emc.storageos.coordinator.client.service.impl.ReaperLeaderSelectorListener)1 IOException (java.io.IOException)1 JMException (javax.management.JMException)1 LeaderSelector (org.apache.curator.framework.recipes.leader.LeaderSelector)1 LeaderSelectorListener (org.apache.curator.framework.recipes.leader.LeaderSelectorListener)1