}
@Override
public List<OperationId> execute(MasterContext context, List<MasterOperation> runningOperations) throws Exception {
InteractionProtocol protocol = context.getProtocol();
IndexMetaData indexMD = protocol.getIndexMD(_indexName);
if (indexMD == null) {// could be undeployed in meantime
LOG.info("skip balancing for index '" + _indexName + "' cause it is already undeployed");
return null;
}
if (!canAndShouldRegulateReplication(protocol, indexMD)) {
LOG.info("skip balancing for index '" + _indexName + "' cause there is no possible optimization");
return null;
}
try {
FileSystem fileSystem = context.getFileSystem(indexMD);
Path path = new Path(indexMD.getPath());
if (!fileSystem.exists(path)) {
LOG.warn("skip balancing for index '" + _indexName + "' cause source '" + path + "' does not exists anymore");
return null;
}
} catch (Exception e) {
LOG.error("skip balancing of index '" + _indexName + "' cause failed to access source '" + indexMD.getPath()
+ "'", e);
return null;
}
LOG.info("balancing shards for index '" + _indexName + "'");