org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse Java Examples

The following examples show how to use org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse. 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: ClusterRerouteManager.java    From foxtrot with Apache License 2.0 6 votes vote down vote up
private boolean reallocateShard(ShardId shardId, String fromNode, String toNode) {
    MoveAllocationCommand moveAllocationCommand = new MoveAllocationCommand(shardId.getIndexName(),
                                                                            shardId.getId(),
                                                                            fromNode,
                                                                            toNode);
    ClusterRerouteRequest clusterRerouteRequest = new ClusterRerouteRequest();
    clusterRerouteRequest.add(moveAllocationCommand);
    try {
        ClusterRerouteResponse clusterRerouteResponse = connection.getClient()
                .admin()
                .cluster()
                .reroute(clusterRerouteRequest)
                .actionGet();
        log.info(String.format("Reallocating Shard. From Node: %s To Node: %s", fromNode, toNode));
        Thread.sleep((new Date(DateTime.now()).getHourOfDay() + 1) * 4000L);
        return clusterRerouteResponse.isAcknowledged();
    }
    catch (Exception e) {
        log.error(String.format("Error in Reallocating Shard. From Node: %s To Node: %s. Error Message: %s",
                                fromNode,
                                toNode,
                                e.getMessage()), e);
        return false;
    }
}
 
Example #2
Source File: ClusterRerouteRequestBuilder.java    From elasticshell with Apache License 2.0 5 votes vote down vote up
@Override
protected XContentBuilder toXContent(ClusterRerouteRequest request, ClusterRerouteResponse response, XContentBuilder builder) throws IOException {
    builder.startObject();
    builder.field(Fields.OK, true);
    builder.startObject("state");
    response.getState().settingsFilter(new SettingsFilter(ImmutableSettings.settingsBuilder().build())).toXContent(builder, ToXContent.EMPTY_PARAMS);
    builder.endObject();

    builder.endObject();

    return builder;
}
 
Example #3
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<ClusterRerouteResponse> reroute(final ClusterRerouteRequest request) {
    return execute(ClusterRerouteAction.INSTANCE, request);
}
 
Example #4
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void reroute(final ClusterRerouteRequest request, final ActionListener<ClusterRerouteResponse> listener) {
    execute(ClusterRerouteAction.INSTANCE, request, listener);
}
 
Example #5
Source File: ClusterRerouteRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
@Override
protected ActionFuture<ClusterRerouteResponse> doExecute(ClusterRerouteRequest request) {
    return client.admin().cluster().reroute(request);
}
 
Example #6
Source File: ClusterAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Reroutes allocation of shards. Advance API.
 */
ActionFuture<ClusterRerouteResponse> reroute(ClusterRerouteRequest request);
 
Example #7
Source File: ClusterAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Reroutes allocation of shards. Advance API.
 */
void reroute(ClusterRerouteRequest request, ActionListener<ClusterRerouteResponse> listener);