org.elasticsearch.discovery.MasterNotDiscoveredException Java Examples

The following examples show how to use org.elasticsearch.discovery.MasterNotDiscoveredException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransportMasterNodeAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
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
    );
}
 
Example #2
Source File: TransportMasterNodeAction.java    From crate with Apache License 2.0 6 votes vote down vote up
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(() -> new ParameterizedMessage("timed out while retrying [{}] after failure (timeout [{}])",
                    actionName, timeout), failure);
                listener.onFailure(new MasterNotDiscoveredException(failure));
            }
        }, statePredicate
    );
}
 
Example #3
Source File: LocalAllocateDangledIndices.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
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;
        }
    });
}
 
Example #4
Source File: LocalAllocateDangledIndices.java    From crate with Apache License 2.0 5 votes vote down vote up
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 read(StreamInput in) throws IOException {
            return new AllocateDangledResponse(in);
        }

        @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;
        }
    });
}