apply comments on tribe code

This commit is contained in:
Shay Banon 2014-01-13 12:26:53 -08:00
parent e13f55dfca
commit 7427ac206c
4 changed files with 35 additions and 4 deletions

View File

@ -51,6 +51,9 @@ public interface ClusterService extends LifecycleComponent<ClusterService> {
*/ */
void addInitialStateBlock(ClusterBlock block) throws ElasticsearchIllegalStateException; void addInitialStateBlock(ClusterBlock block) throws ElasticsearchIllegalStateException;
/**
* Remove an initial block to be set on the first cluster state created.
*/
void removeInitialStateBlock(ClusterBlock block) throws ElasticsearchIllegalStateException; void removeInitialStateBlock(ClusterBlock block) throws ElasticsearchIllegalStateException;
/** /**

View File

@ -497,6 +497,9 @@ public class ImmutableSettings implements Settings {
@Override @Override
public Map<String, Settings> getGroups(String settingPrefix, boolean ignoreNonGrouped) throws SettingsException { public Map<String, Settings> getGroups(String settingPrefix, boolean ignoreNonGrouped) throws SettingsException {
if (!Strings.hasLength(settingPrefix)) {
throw new ElasticsearchIllegalArgumentException("illegal setting prefix " + settingPrefix);
}
if (settingPrefix.charAt(settingPrefix.length() - 1) != '.') { if (settingPrefix.charAt(settingPrefix.length() - 1) != '.') {
settingPrefix = settingPrefix + "."; settingPrefix = settingPrefix + ".";
} }

View File

@ -142,6 +142,7 @@ public final class InternalNode implements Node {
this.pluginsService = new PluginsService(tuple.v1(), tuple.v2()); this.pluginsService = new PluginsService(tuple.v1(), tuple.v2());
this.settings = pluginsService.updatedSettings(); this.settings = pluginsService.updatedSettings();
// create the environment based on the finalized (processed) view of the settings
this.environment = new Environment(this.settings()); this.environment = new Environment(this.settings());
CompressorFactory.configure(settings); CompressorFactory.configure(settings);

View File

@ -22,6 +22,7 @@ package org.elasticsearch.tribe;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchInterruptedException;
import org.elasticsearch.cluster.*; import org.elasticsearch.cluster.*;
import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlock;
import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.block.ClusterBlockLevel;
@ -161,24 +162,47 @@ public class TribeService extends AbstractLifecycleComponent<TribeService> {
try { try {
latch.await(); latch.await();
} catch (InterruptedException e) { } catch (InterruptedException e) {
// ignore throw new ElasticsearchInterruptedException(e.getMessage(), e);
} }
for (InternalNode node : nodes) { for (InternalNode node : nodes) {
try {
node.start(); node.start();
} catch (Throwable e) {
// calling close is safe for non started nodes, we can just iterate over all
for (InternalNode otherNode : nodes) {
try {
otherNode.close();
} catch (Throwable t) {
logger.warn("failed to close node {} on failed start", otherNode, t);
}
}
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new ElasticsearchException(e.getMessage(), e);
}
} }
} }
@Override @Override
protected void doStop() throws ElasticsearchException { protected void doStop() throws ElasticsearchException {
for (InternalNode node : nodes) { for (InternalNode node : nodes) {
try {
node.stop(); node.stop();
} catch (Throwable t) {
logger.warn("failed to stop node {}", t, node);
}
} }
} }
@Override @Override
protected void doClose() throws ElasticsearchException { protected void doClose() throws ElasticsearchException {
for (InternalNode node : nodes) { for (InternalNode node : nodes) {
try {
node.close(); node.close();
} catch (Throwable t) {
logger.warn("failed to close node {}", t, node);
}
} }
} }