This commit is contained in:
kimchy 2010-09-20 08:58:33 +02:00
parent 770bac252a
commit 3ec95f4e84
3 changed files with 34 additions and 2 deletions

View File

@ -24,19 +24,40 @@ import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
/** /**
* The cluster service allowing to both register for cluster state events ({@link ClusterStateListener})
* and submit state update tasks ({@link ClusterStateUpdateTask}.
*
* @author kimchy (shay.banon) * @author kimchy (shay.banon)
*/ */
public interface ClusterService extends LifecycleComponent<ClusterService> { public interface ClusterService extends LifecycleComponent<ClusterService> {
/**
* The local node.
*/
DiscoveryNode localNode(); DiscoveryNode localNode();
/**
* The current state.
*/
ClusterState state(); ClusterState state();
/**
* Adds a listener for updated cluster states.
*/
void add(ClusterStateListener listener); void add(ClusterStateListener listener);
/**
* Removes a listener for updated cluster states.
*/
void remove(ClusterStateListener listener); void remove(ClusterStateListener listener);
/**
* Adds a cluster state listener that will timeout after the provided timeout.
*/
void add(TimeValue timeout, TimeoutClusterStateListener listener); void add(TimeValue timeout, TimeoutClusterStateListener listener);
/**
* Submits a task that will update the cluster state.
*/
void submitStateUpdateTask(final String source, final ClusterStateUpdateTask updateTask); void submitStateUpdateTask(final String source, final ClusterStateUpdateTask updateTask);
} }

View File

@ -20,9 +20,14 @@
package org.elasticsearch.cluster; package org.elasticsearch.cluster;
/** /**
* @author kimchy (Shay Banon) * A listener to be notified when a cluster state changes.
*
* @author kimchy (shay.banon)
*/ */
public interface ClusterStateListener { public interface ClusterStateListener {
/**
* Called when cluster state changes.
*/
void clusterChanged(ClusterChangedEvent event); void clusterChanged(ClusterChangedEvent event);
} }

View File

@ -20,9 +20,15 @@
package org.elasticsearch.cluster; package org.elasticsearch.cluster;
/** /**
* @author kimchy (Shay Banon) * A task that can update the cluster state.
*
* @author kimchy (shay.banon)
*/ */
public interface ClusterStateUpdateTask { public interface ClusterStateUpdateTask {
/**
* Update the cluster state based on the current state. Return the *same instance* if no state
* should be changed.
*/
ClusterState execute(ClusterState currentState); ClusterState execute(ClusterState currentState);
} }