本文整理汇总了Java中org.elasticsearch.discovery.MasterNotDiscoveredException类的典型用法代码示例。如果您正苦于以下问题:Java MasterNotDiscoveredException类的具体用法?Java MasterNotDiscoveredException怎么用?Java MasterNotDiscoveredException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MasterNotDiscoveredException类属于org.elasticsearch.discovery包,在下文中一共展示了MasterNotDiscoveredException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: retry
import org.elasticsearch.discovery.MasterNotDiscoveredException; //导入依赖的package包/类
private void retry(final Throwable failure, final Predicate<ClusterState> statePredicate) {
observer.waitForNextChange(
new ClusterStateObserver.Listener() {
@Override
public void onNewClusterState(ClusterState state) {
doStart(state);
}
@Override
public void onClusterServiceClose() {
listener.onFailure(new NodeClosedException(clusterService.localNode()));
}
@Override
public void onTimeout(TimeValue timeout) {
logger.debug((org.apache.logging.log4j.util.Supplier<?>) () -> new ParameterizedMessage("timed out while retrying [{}] after failure (timeout [{}])", actionName, timeout), failure);
listener.onFailure(new MasterNotDiscoveredException(failure));
}
}, statePredicate
);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:TransportMasterNodeAction.java
示例2: checkUpdateAction
import org.elasticsearch.discovery.MasterNotDiscoveredException; //导入依赖的package包/类
void checkUpdateAction(boolean autoCreateIndex, TimeValue timeout, ActionRequestBuilder<?, ?, ?> builder) {
// we clean the metadata when loosing a master, therefore all operations on indices will auto create it, if allowed
long now = System.currentTimeMillis();
try {
builder.get();
fail("expected ClusterBlockException or MasterNotDiscoveredException");
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
if (e instanceof MasterNotDiscoveredException) {
assertTrue(autoCreateIndex);
} else {
assertFalse(autoCreateIndex);
}
// verify we waited before giving up...
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
assertThat(System.currentTimeMillis() - now, greaterThan(timeout.millis() - 50));
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:NoMasterNodeIT.java
示例3: testElectOnlyBetweenMasterNodes
import org.elasticsearch.discovery.MasterNotDiscoveredException; //导入依赖的package包/类
public void testElectOnlyBetweenMasterNodes() throws IOException {
logger.info("--> start data node / non master node");
internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), true).put(Node.NODE_MASTER_SETTING.getKey(), false).put("discovery.initial_state_timeout", "1s"));
try {
assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().getMasterNodeId(), nullValue());
fail("should not be able to find master");
} catch (MasterNotDiscoveredException e) {
// all is well, no master elected
}
logger.info("--> start master node (1)");
final String masterNodeName = internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true));
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
logger.info("--> start master node (2)");
final String nextMasterEligableNodeName = internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true));
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
logger.info("--> closing master node (1)");
internalCluster().stopCurrentMasterNode();
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligableNodeName));
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligableNodeName));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:SpecificMasterNodesIT.java
示例4: retry
import org.elasticsearch.discovery.MasterNotDiscoveredException; //导入依赖的package包/类
private void retry(final Throwable failure, final ClusterStateObserver.ChangePredicate changePredicate) {
observer.waitForNextChange(
new ClusterStateObserver.Listener() {
@Override
public void onNewClusterState(ClusterState state) {
doStart();
}
@Override
public void onClusterServiceClose() {
listener.onFailure(new NodeClosedException(clusterService.localNode()));
}
@Override
public void onTimeout(TimeValue timeout) {
logger.debug("timed out while retrying [{}] after failure (timeout [{}])", failure, actionName, timeout);
listener.onFailure(new MasterNotDiscoveredException(failure));
}
}, changePredicate
);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:TransportMasterNodeAction.java
示例5: allocateDangled
import org.elasticsearch.discovery.MasterNotDiscoveredException; //导入依赖的package包/类
public void allocateDangled(Collection<IndexMetaData> indices, final Listener listener) {
ClusterState clusterState = clusterService.state();
DiscoveryNode masterNode = clusterState.nodes().getMasterNode();
if (masterNode == null) {
listener.onFailure(new MasterNotDiscoveredException("no master to send allocate dangled request"));
return;
}
AllocateDangledRequest request = new AllocateDangledRequest(clusterService.localNode(), indices.toArray(new IndexMetaData[indices.size()]));
transportService.sendRequest(masterNode, ACTION_NAME, request, new TransportResponseHandler<AllocateDangledResponse>() {
@Override
public AllocateDangledResponse newInstance() {
return new AllocateDangledResponse();
}
@Override
public void handleResponse(AllocateDangledResponse response) {
listener.onResponse(response);
}
@Override
public void handleException(TransportException exp) {
listener.onFailure(exp);
}
@Override
public String executor() {
return ThreadPool.Names.SAME;
}
});
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:LocalAllocateDangledIndices.java
示例6: testIndexExistsWithBlocksInPlace
import org.elasticsearch.discovery.MasterNotDiscoveredException; //导入依赖的package包/类
public void testIndexExistsWithBlocksInPlace() throws IOException {
Settings settings = Settings.builder()
.put(GatewayService.RECOVER_AFTER_NODES_SETTING.getKey(), 99)
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), 1).build();
String node = internalCluster().startNode(settings);
assertThrows(client(node).admin().indices().prepareExists("test").setMasterNodeTimeout(TimeValue.timeValueSeconds(0)),
MasterNotDiscoveredException.class);
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(node)); // shut down node so that test properly cleans up
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:IndicesExistsIT.java
示例7: testMasterNotAvailable
import org.elasticsearch.discovery.MasterNotDiscoveredException; //导入依赖的package包/类
public void testMasterNotAvailable() throws ExecutionException, InterruptedException {
Request request = new Request().masterNodeTimeout(TimeValue.timeValueSeconds(0));
setState(clusterService, ClusterStateCreationUtils.state(localNode, null, allNodes));
PlainActionFuture<Response> listener = new PlainActionFuture<>();
new Action(Settings.EMPTY, "testAction", transportService, clusterService, threadPool).execute(request, listener);
assertTrue(listener.isDone());
assertListenerThrows("MasterNotDiscoveredException should be thrown", listener, MasterNotDiscoveredException.class);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:TransportMasterNodeActionTests.java
示例8: allocateDangled
import org.elasticsearch.discovery.MasterNotDiscoveredException; //导入依赖的package包/类
public void allocateDangled(Collection<IndexMetaData> indices, final Listener listener) {
ClusterState clusterState = clusterService.state();
DiscoveryNode masterNode = clusterState.nodes().masterNode();
if (masterNode == null) {
listener.onFailure(new MasterNotDiscoveredException("no master to send allocate dangled request"));
return;
}
AllocateDangledRequest request = new AllocateDangledRequest(clusterService.localNode(), indices.toArray(new IndexMetaData[indices.size()]));
transportService.sendRequest(masterNode, ACTION_NAME, request, new TransportResponseHandler<AllocateDangledResponse>() {
@Override
public AllocateDangledResponse newInstance() {
return new AllocateDangledResponse();
}
@Override
public void handleResponse(AllocateDangledResponse response) {
listener.onResponse(response);
}
@Override
public void handleException(TransportException exp) {
listener.onFailure(exp);
}
@Override
public String executor() {
return ThreadPool.Names.SAME;
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:31,代码来源:LocalAllocateDangledIndices.java
注:本文中的org.elasticsearch.discovery.MasterNotDiscoveredException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论