nicer code

This commit is contained in:
kimchy 2010-04-03 01:56:31 +03:00
parent 1521222534
commit d633b3dfbb
4 changed files with 24 additions and 4 deletions

View File

@ -41,6 +41,7 @@
<w>ngram</w>
<w>param</w>
<w>params</w>
<w>pluggable</w>
<w>plugins</w>
<w>porterstem</w>
<w>rebalance</w>

View File

@ -60,10 +60,22 @@ public class Nodes implements Iterable<Node> {
return nodes.values().iterator();
}
/**
* Is this a valid nodes that has the minimal information set. The minimal set is defined
* by the localNodeId being set.
*/
public boolean valid() {
return localNodeId != null;
}
/**
* Returns <tt>true</tt> if the local node is the master node.
*/
public boolean localNodeMaster() {
if (localNodeId == null) {
// we don't know yet the local node id, return false
return false;
}
return localNodeId.equals(masterNodeId);
}

View File

@ -23,7 +23,11 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.util.component.LifecycleComponent;
/**
* @author kimchy (Shay Banon)
* A pluggable module allowing to implement discovery of other nodes, publishing of the cluster
* state to all nodes, electing a master of the cluster that raises cluster state change
* events.
*
* @author kimchy (shay.banon)
*/
public interface Discovery extends LifecycleComponent<Discovery> {
@ -33,6 +37,9 @@ public interface Discovery extends LifecycleComponent<Discovery> {
String nodeDescription();
/**
* Is the discovery of this node caused this node to be the first master in the cluster.
*/
boolean firstMaster();
/**

View File

@ -27,17 +27,17 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.metadata.MetaDataService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.util.component.AbstractLifecycleComponent;
import org.elasticsearch.util.concurrent.DynamicExecutors;
import org.elasticsearch.util.settings.Settings;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static java.util.concurrent.Executors.*;
import static org.elasticsearch.cluster.ClusterState.*;
import static org.elasticsearch.cluster.metadata.MetaData.*;
import static org.elasticsearch.util.TimeValue.*;
import static org.elasticsearch.util.concurrent.DynamicExecutors.*;
/**
* @author kimchy (Shay Banon)
@ -67,7 +67,7 @@ public class GatewayService extends AbstractLifecycleComponent<GatewayService> i
@Override protected void doStart() throws ElasticSearchException {
gateway.start();
this.executor = Executors.newSingleThreadExecutor(DynamicExecutors.daemonThreadFactory(settings, "gateway"));
this.executor = newSingleThreadExecutor(daemonThreadFactory(settings, "gateway"));
clusterService.add(this);
}