/** * A shortcut for {@link #setWaitForActiveShards(ActiveShardCount)} where the numerical * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)} * to get the ActiveShardCount. */ public ClusterHealthRequestBuilder setWaitForActiveShards(int waitForActiveShards) { request.waitForActiveShards(waitForActiveShards); return this; }
/** * Sets the number of shard copies that must be active before getting the health status. * Defaults to {@link ActiveShardCount#NONE}, meaning we don't wait on any active shards. * Set this value to {@link ActiveShardCount#ALL} to wait for all shards (primary and * all replicas) to be active across all indices in the cluster. Otherwise, use * {@link ActiveShardCount#from(int)} to set this value to any non-negative integer, up to the * total number of shard copies that would exist across all indices in the cluster. */ public ClusterHealthRequestBuilder setWaitForActiveShards(ActiveShardCount waitForActiveShards) { if (waitForActiveShards.equals(ActiveShardCount.DEFAULT)) { // the default for cluster health is 0, not 1 request.waitForActiveShards(ActiveShardCount.NONE); } else { request.waitForActiveShards(waitForActiveShards); } return this; }
/** * A shortcut for {@link #waitForActiveShards(ActiveShardCount)} where the numerical * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)} * to get the ActiveShardCount. */ public ClusterHealthRequest waitForActiveShards(final int waitForActiveShards) { return waitForActiveShards(ActiveShardCount.from(waitForActiveShards)); }
waitForCounter++; if (request.waitForActiveShards().equals(ActiveShardCount.NONE) == false) { ActiveShardCount waitForActiveShards = request.waitForActiveShards(); assert waitForActiveShards.equals(ActiveShardCount.DEFAULT) == false : "waitForActiveShards must not be DEFAULT on the request object, instead it should be NONE";
/** * A shortcut for {@link #setWaitForActiveShards(ActiveShardCount)} where the numerical * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)} * to get the ActiveShardCount. */ public ClusterHealthRequestBuilder setWaitForActiveShards(int waitForActiveShards) { request.waitForActiveShards(waitForActiveShards); return this; }
/** * A shortcut for {@link #setWaitForActiveShards(ActiveShardCount)} where the numerical * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)} * to get the ActiveShardCount. */ public ClusterHealthRequestBuilder setWaitForActiveShards(int waitForActiveShards) { request.waitForActiveShards(waitForActiveShards); return this; }
/** * A shortcut for {@link #setWaitForActiveShards(ActiveShardCount)} where the numerical * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)} * to get the ActiveShardCount. */ public ClusterHealthRequestBuilder setWaitForActiveShards(int waitForActiveShards) { request.waitForActiveShards(waitForActiveShards); return this; }
public ClusterHealthRequestBuilder setWaitForActiveShards(int waitForActiveShards) { request.waitForActiveShards(waitForActiveShards); return this; }
public ClusterHealthRequestBuilder<JsonInput, JsonOutput> waitForActiveShards(int waitForActiveShards) { request.waitForActiveShards(waitForActiveShards); return this; }
/** * Sets the number of shard copies that must be active before getting the health status. * Defaults to {@link ActiveShardCount#NONE}, meaning we don't wait on any active shards. * Set this value to {@link ActiveShardCount#ALL} to wait for all shards (primary and * all replicas) to be active across all indices in the cluster. Otherwise, use * {@link ActiveShardCount#from(int)} to set this value to any non-negative integer, up to the * total number of shard copies that would exist across all indices in the cluster. */ public ClusterHealthRequestBuilder setWaitForActiveShards(ActiveShardCount waitForActiveShards) { if (waitForActiveShards.equals(ActiveShardCount.DEFAULT)) { // the default for cluster health is 0, not 1 request.waitForActiveShards(ActiveShardCount.NONE); } else { request.waitForActiveShards(waitForActiveShards); } return this; }
waitFor++; if (request.waitForActiveShards().equals(ActiveShardCount.NONE) == false) { waitFor++;
/** * Sets the number of shard copies that must be active before getting the health status. * Defaults to {@link ActiveShardCount#NONE}, meaning we don't wait on any active shards. * Set this value to {@link ActiveShardCount#ALL} to wait for all shards (primary and * all replicas) to be active across all indices in the cluster. Otherwise, use * {@link ActiveShardCount#from(int)} to set this value to any non-negative integer, up to the * total number of shard copies that would exist across all indices in the cluster. */ public ClusterHealthRequestBuilder setWaitForActiveShards(ActiveShardCount waitForActiveShards) { if (waitForActiveShards.equals(ActiveShardCount.DEFAULT)) { // the default for cluster health is 0, not 1 request.waitForActiveShards(ActiveShardCount.NONE); } else { request.waitForActiveShards(waitForActiveShards); } return this; }
/** * Sets the number of shard copies that must be active before getting the health status. * Defaults to {@link ActiveShardCount#NONE}, meaning we don't wait on any active shards. * Set this value to {@link ActiveShardCount#ALL} to wait for all shards (primary and * all replicas) to be active across all indices in the cluster. Otherwise, use * {@link ActiveShardCount#from(int)} to set this value to any non-negative integer, up to the * total number of shard copies that would exist across all indices in the cluster. */ public ClusterHealthRequestBuilder setWaitForActiveShards(ActiveShardCount waitForActiveShards) { if (waitForActiveShards.equals(ActiveShardCount.DEFAULT)) { // the default for cluster health is 0, not 1 request.waitForActiveShards(ActiveShardCount.NONE); } else { request.waitForActiveShards(waitForActiveShards); } return this; }
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { ClusterHealthRequest clusterHealthRequest = clusterHealthRequest(Strings.splitStringByCommaToArray(request.param("index"))); clusterHealthRequest.local(request.paramAsBoolean("local", clusterHealthRequest.local())); clusterHealthRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterHealthRequest.masterNodeTimeout())); clusterHealthRequest.timeout(request.paramAsTime("timeout", clusterHealthRequest.timeout())); String waitForStatus = request.param("wait_for_status"); if (waitForStatus != null) { clusterHealthRequest.waitForStatus(ClusterHealthStatus.valueOf(waitForStatus.toUpperCase(Locale.ROOT))); } clusterHealthRequest.waitForNoRelocatingShards( request.paramAsBoolean("wait_for_no_relocating_shards", clusterHealthRequest.waitForNoRelocatingShards())); clusterHealthRequest.waitForNoInitializingShards( request.paramAsBoolean("wait_for_no_initializing_shards", clusterHealthRequest.waitForNoRelocatingShards())); if (request.hasParam("wait_for_relocating_shards")) { // wait_for_relocating_shards has been removed in favor of wait_for_no_relocating_shards throw new IllegalArgumentException("wait_for_relocating_shards has been removed, " + "use wait_for_no_relocating_shards [true/false] instead"); } String waitForActiveShards = request.param("wait_for_active_shards"); if (waitForActiveShards != null) { clusterHealthRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards)); } clusterHealthRequest.waitForNodes(request.param("wait_for_nodes", clusterHealthRequest.waitForNodes())); if (request.param("wait_for_events") != null) { clusterHealthRequest.waitForEvents(Priority.valueOf(request.param("wait_for_events").toUpperCase(Locale.ROOT))); } return channel -> client.admin().cluster().health(clusterHealthRequest, new RestStatusToXContentListener<>(channel)); }
/** * A shortcut for {@link #waitForActiveShards(ActiveShardCount)} where the numerical * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)} * to get the ActiveShardCount. */ public ClusterHealthRequest waitForActiveShards(final int waitForActiveShards) { return waitForActiveShards(ActiveShardCount.from(waitForActiveShards)); }
/** * A shortcut for {@link #waitForActiveShards(ActiveShardCount)} where the numerical * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)} * to get the ActiveShardCount. */ public ClusterHealthRequest waitForActiveShards(final int waitForActiveShards) { return waitForActiveShards(ActiveShardCount.from(waitForActiveShards)); }
/** * A shortcut for {@link #waitForActiveShards(ActiveShardCount)} where the numerical * shard count is passed in, instead of having to first call {@link ActiveShardCount#from(int)} * to get the ActiveShardCount. */ public ClusterHealthRequest waitForActiveShards(final int waitForActiveShards) { return waitForActiveShards(ActiveShardCount.from(waitForActiveShards)); }
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { ClusterHealthRequest clusterHealthRequest = clusterHealthRequest(Strings.splitStringByCommaToArray(request.param("index"))); clusterHealthRequest.local(request.paramAsBoolean("local", clusterHealthRequest.local())); clusterHealthRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterHealthRequest.masterNodeTimeout())); clusterHealthRequest.timeout(request.paramAsTime("timeout", clusterHealthRequest.timeout())); String waitForStatus = request.param("wait_for_status"); if (waitForStatus != null) { clusterHealthRequest.waitForStatus(ClusterHealthStatus.valueOf(waitForStatus.toUpperCase(Locale.ROOT))); } clusterHealthRequest.waitForRelocatingShards(request.paramAsInt("wait_for_relocating_shards", clusterHealthRequest.waitForRelocatingShards())); clusterHealthRequest.waitForActiveShards(request.paramAsInt("wait_for_active_shards", clusterHealthRequest.waitForActiveShards())); clusterHealthRequest.waitForNodes(request.param("wait_for_nodes", clusterHealthRequest.waitForNodes())); client.admin().cluster().health(clusterHealthRequest, new RestStatusToXContentListener<ClusterHealthResponse>(channel)); }
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { ClusterHealthRequest clusterHealthRequest = clusterHealthRequest(Strings.splitStringByCommaToArray(request.param("index"))); clusterHealthRequest.local(request.paramAsBoolean("local", clusterHealthRequest.local())); clusterHealthRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterHealthRequest.masterNodeTimeout())); clusterHealthRequest.timeout(request.paramAsTime("timeout", clusterHealthRequest.timeout())); String waitForStatus = request.param("wait_for_status"); if (waitForStatus != null) { clusterHealthRequest.waitForStatus(ClusterHealthStatus.valueOf(waitForStatus.toUpperCase(Locale.ROOT))); } clusterHealthRequest.waitForNoRelocatingShards( request.paramAsBoolean("wait_for_no_relocating_shards", clusterHealthRequest.waitForNoRelocatingShards())); if (request.hasParam("wait_for_relocating_shards")) { // wait_for_relocating_shards has been removed in favor of wait_for_no_relocating_shards throw new IllegalArgumentException("wait_for_relocating_shards has been removed, " + "use wait_for_no_relocating_shards [true/false] instead"); } String waitForActiveShards = request.param("wait_for_active_shards"); if (waitForActiveShards != null) { clusterHealthRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards)); } clusterHealthRequest.waitForNodes(request.param("wait_for_nodes", clusterHealthRequest.waitForNodes())); if (request.param("wait_for_events") != null) { clusterHealthRequest.waitForEvents(Priority.valueOf(request.param("wait_for_events").toUpperCase(Locale.ROOT))); } return channel -> client.admin().cluster().health(clusterHealthRequest, new RestStatusToXContentListener<>(channel)); }
static Request clusterHealth(ClusterHealthRequest healthRequest) { String[] indices = healthRequest.indices() == null ? Strings.EMPTY_ARRAY : healthRequest.indices(); String endpoint = new RequestConverters.EndpointBuilder() .addPathPartAsIs("_cluster/health") .addCommaSeparatedPathParts(indices) .build(); Request request = new Request(HttpGet.METHOD_NAME, endpoint); new RequestConverters.Params(request) .withWaitForStatus(healthRequest.waitForStatus()) .withWaitForNoRelocatingShards(healthRequest.waitForNoRelocatingShards()) .withWaitForNoInitializingShards(healthRequest.waitForNoInitializingShards()) .withWaitForActiveShards(healthRequest.waitForActiveShards(), ActiveShardCount.NONE) .withWaitForNodes(healthRequest.waitForNodes()) .withWaitForEvents(healthRequest.waitForEvents()) .withTimeout(healthRequest.timeout()) .withMasterTimeout(healthRequest.masterNodeTimeout()) .withLocal(healthRequest.local()) .withLevel(healthRequest.level()); return request; } }