List<String> nodes = _protocol.registerChildListener(this, PathDef.NODES_LIVE, new IAddRemoveListener() {
@Override
public void removed(String name) {
synchronized (Master.this) {
if (!isInSafeMode()) {
_protocol.addMasterOperation(new CheckIndicesOperation());
}
}
}
@Override
public void added(String name) {
synchronized (Master.this) {
if (!isMaster()) {
return;
}
_protocol.addMasterOperation(new RemoveObsoleteShardsOperation(name));
if (!isInSafeMode()) {
_protocol.addMasterOperation(new CheckIndicesOperation());
}
}
}
});
_protocol.addMasterOperation(new CheckIndicesOperation());
for (String node : nodes) {
_protocol.addMasterOperation(new RemoveObsoleteShardsOperation(node));
}
LOG.info("found following nodes connected: " + nodes);
}