diff --git a/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java index 1cc7f378265..9814efc7f8f 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java @@ -25,6 +25,7 @@ import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.ElasticSearchParseException; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; +import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.action.support.master.MasterNodeOperationRequest; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.bytes.BytesArray; @@ -41,7 +42,6 @@ import org.elasticsearch.common.xcontent.XContentType; import java.io.IOException; import java.util.Map; -import java.util.concurrent.TimeUnit; import static com.google.common.collect.Maps.newHashMap; import static org.elasticsearch.action.ValidateActions.addValidationError; @@ -71,7 +71,7 @@ public class CreateIndexRequest extends MasterNodeOperationRequest customs = newHashMap(); - private TimeValue timeout = new TimeValue(10, TimeUnit.SECONDS); + private TimeValue timeout = AcknowledgedRequest.DEFAULT_ACK_TIMEOUT; CreateIndexRequest() { } @@ -342,7 +342,7 @@ public class CreateIndexRequest extends MasterNodeOperationRequest10s. */ - TimeValue timeout() { + public TimeValue timeout() { return timeout; } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java index 83dba5b230c..074a21f6397 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexRequest.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.indices.delete; import org.elasticsearch.action.ActionRequestValidationException; +import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.action.support.master.MasterNodeOperationRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -29,7 +30,6 @@ import java.io.IOException; import static org.elasticsearch.action.ValidateActions.addValidationError; import static org.elasticsearch.common.unit.TimeValue.readTimeValue; -import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** * A request to delete an index. Best created with {@link org.elasticsearch.client.Requests#deleteIndexRequest(String)}. @@ -38,7 +38,7 @@ public class DeleteIndexRequest extends MasterNodeOperationRequest10s. */ - TimeValue timeout() { + public TimeValue timeout() { return timeout; } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequest.java index 388fa0d5828..109ab6d15f7 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequest.java @@ -19,17 +19,17 @@ package org.elasticsearch.action.admin.indices.template.delete; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; +import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.action.support.master.MasterNodeOperationRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.unit.TimeValue; import java.io.IOException; import static org.elasticsearch.action.ValidateActions.addValidationError; import static org.elasticsearch.common.unit.TimeValue.readTimeValue; -import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; /** * A request to delete an index template. @@ -38,8 +38,6 @@ public class DeleteIndexTemplateRequest extends MasterNodeOperationRequest10s. - */ - TimeValue timeout() { - return timeout; - } - - /** - * Timeout to wait for the index template deletion to be acknowledged by current cluster nodes. Defaults - * to 10s. - */ - public DeleteIndexTemplateRequest timeout(TimeValue timeout) { - this.timeout = timeout; - return this; - } - - /** - * Timeout to wait for the index template deletion to be acknowledged by current cluster nodes. Defaults - * to 10s. - */ - public DeleteIndexTemplateRequest timeout(String timeout) { - return timeout(TimeValue.parseTimeValue(timeout, null)); - } - @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); name = in.readString(); - timeout = readTimeValue(in); + //timeout was ignored till 0.90.7, removed afterwards + if (in.getVersion().onOrBefore(Version.V_0_90_7)) { + readTimeValue(in); + } } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(name); - timeout.writeTo(out); + //timeout was ignored till 0.90.7, removed afterwards + if (out.getVersion().onOrBefore(Version.V_0_90_7)) { + AcknowledgedRequest.DEFAULT_ACK_TIMEOUT.writeTo(out); + } } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequestBuilder.java b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequestBuilder.java index f36719494e8..d04060a6c60 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateRequestBuilder.java @@ -23,7 +23,6 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder; import org.elasticsearch.client.IndicesAdminClient; import org.elasticsearch.client.internal.InternalIndicesAdminClient; -import org.elasticsearch.common.unit.TimeValue; /** * @@ -38,24 +37,6 @@ public class DeleteIndexTemplateRequestBuilder extends MasterNodeOperationReques super((InternalIndicesAdminClient) indicesClient, new DeleteIndexTemplateRequest(name)); } - /** - * Timeout to wait for the index deletion to be acknowledged by current cluster nodes. Defaults - * to 10s. - */ - public DeleteIndexTemplateRequestBuilder setTimeout(TimeValue timeout) { - request.timeout(timeout); - return this; - } - - /** - * Timeout to wait for the index deletion to be acknowledged by current cluster nodes. Defaults - * to 10s. - */ - public DeleteIndexTemplateRequestBuilder setTimeout(String timeout) { - request.timeout(timeout); - return this; - } - @Override protected void doExecute(ActionListener listener) { ((IndicesAdminClient) client).deleteTemplate(request, listener); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index d0e88eed943..ea50b301172 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -22,7 +22,9 @@ package org.elasticsearch.action.admin.indices.template.put; import org.elasticsearch.ElasticSearchGenerationException; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.ElasticSearchParseException; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; +import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.action.support.master.MasterNodeOperationRequest; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.bytes.BytesReference; @@ -31,7 +33,6 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; @@ -39,7 +40,6 @@ import org.elasticsearch.common.xcontent.support.XContentMapValues; import java.io.IOException; import java.util.Map; -import java.util.concurrent.TimeUnit; import static com.google.common.collect.Maps.newHashMap; import static org.elasticsearch.action.ValidateActions.addValidationError; @@ -69,8 +69,6 @@ public class PutIndexTemplateRequest extends MasterNodeOperationRequest customs = newHashMap(); - private TimeValue timeout = new TimeValue(10, TimeUnit.SECONDS); - PutIndexTemplateRequest() { } @@ -342,31 +340,6 @@ public class PutIndexTemplateRequest extends MasterNodeOperationRequest10s. - */ - TimeValue timeout() { - return timeout; - } - - /** - * Timeout to wait till the put mapping gets acknowledged of all current cluster nodes. Defaults to - * 10s. - */ - public PutIndexTemplateRequest timeout(TimeValue timeout) { - this.timeout = timeout; - return this; - } - - /** - * Timeout to wait till the put mapping gets acknowledged of all current cluster nodes. Defaults to - * 10s. - */ - public PutIndexTemplateRequest timeout(String timeout) { - return timeout(TimeValue.parseTimeValue(timeout, null)); - } - @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); @@ -376,7 +349,10 @@ public class PutIndexTemplateRequest extends MasterNodeOperationRequest entry : mappings.entrySet()) { out.writeString(entry.getKey()); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java b/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java index 65810c1cc23..20bf6071b9c 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java @@ -25,7 +25,6 @@ import org.elasticsearch.client.IndicesAdminClient; import org.elasticsearch.client.internal.InternalIndicesAdminClient; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; import java.util.Map; @@ -189,24 +188,6 @@ public class PutIndexTemplateRequestBuilder extends MasterNodeOperationRequestBu return this; } - /** - * Timeout to wait for the index creation to be acknowledged by current cluster nodes. Defaults - * to 10s. - */ - public PutIndexTemplateRequestBuilder setTimeout(TimeValue timeout) { - request.timeout(timeout); - return this; - } - - /** - * Timeout to wait for the index creation to be acknowledged by current cluster nodes. Defaults - * to 10s. - */ - public PutIndexTemplateRequestBuilder setTimeout(String timeout) { - request.timeout(timeout); - return this; - } - @Override protected void doExecute(ActionListener listener) { ((IndicesAdminClient) client).putTemplate(request, listener); diff --git a/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java b/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java index 6ffc7aa8e54..cda58f8fa7e 100644 --- a/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java +++ b/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java @@ -34,7 +34,9 @@ import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; */ public abstract class AcknowledgedRequest extends MasterNodeOperationRequest { - protected TimeValue timeout = timeValueSeconds(10); + public static final TimeValue DEFAULT_ACK_TIMEOUT = timeValueSeconds(30); + + protected TimeValue timeout = DEFAULT_ACK_TIMEOUT; protected AcknowledgedRequest() { } diff --git a/src/main/java/org/elasticsearch/discovery/Discovery.java b/src/main/java/org/elasticsearch/discovery/Discovery.java index 5dae73de02e..d2f8e4bd389 100644 --- a/src/main/java/org/elasticsearch/discovery/Discovery.java +++ b/src/main/java/org/elasticsearch/discovery/Discovery.java @@ -26,6 +26,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.component.LifecycleComponent; +import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.node.service.NodeService; import org.elasticsearch.rest.RestStatus; @@ -38,6 +39,8 @@ public interface Discovery extends LifecycleComponent { final ClusterBlock NO_MASTER_BLOCK = new ClusterBlock(2, "no master", true, true, RestStatus.SERVICE_UNAVAILABLE, ClusterBlockLevel.ALL); + public static final TimeValue DEFAULT_PUBLISH_TIMEOUT = TimeValue.timeValueSeconds(30); + DiscoveryNode localNode(); void addListener(InitialStateDiscoveryListener listener); diff --git a/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index d2440e43dea..17581d82713 100644 --- a/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java +++ b/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java @@ -90,7 +90,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem this.discoveryNodeService = discoveryNodeService; this.version = version; - this.publishTimeout = settings.getAsTime("discovery.zen.publish_timeout", TimeValue.timeValueSeconds(5)); + this.publishTimeout = settings.getAsTime("discovery.zen.publish_timeout", DEFAULT_PUBLISH_TIMEOUT); } @Override diff --git a/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java b/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java index b5be4819344..57c3ed4e2b7 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java +++ b/src/main/java/org/elasticsearch/discovery/zen/publish/PublishClusterStateAction.java @@ -69,7 +69,7 @@ public class PublishClusterStateAction extends AbstractComponent { this.nodesProvider = nodesProvider; this.listener = listener; - this.publishTimeout = settings.getAsTime("discovery.zen.publish_timeout", TimeValue.timeValueSeconds(5)); + this.publishTimeout = settings.getAsTime("discovery.zen.publish_timeout", Discovery.DEFAULT_PUBLISH_TIMEOUT); transportService.registerHandler(PublishClusterStateRequestHandler.ACTION, new PublishClusterStateRequestHandler()); } diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/delete/RestIndexDeleteAliasesAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/delete/RestIndexDeleteAliasesAction.java index 3e4da956fa1..5cb07e14100 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/delete/RestIndexDeleteAliasesAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/delete/RestIndexDeleteAliasesAction.java @@ -31,7 +31,6 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; import static org.elasticsearch.rest.RestRequest.Method.DELETE; import static org.elasticsearch.rest.RestStatus.OK; @@ -50,7 +49,7 @@ public class RestIndexDeleteAliasesAction extends BaseRestHandler { final String index = request.param("index"); String alias = request.param("name"); IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest(); - indicesAliasesRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); + indicesAliasesRequest.timeout(request.paramAsTime("timeout", indicesAliasesRequest.timeout())); indicesAliasesRequest.removeAlias(index, alias); indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout())); diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/put/RestIndexPutAliasAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/put/RestIndexPutAliasAction.java index 8023510fb2a..21721b12c68 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/put/RestIndexPutAliasAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/put/RestIndexPutAliasAction.java @@ -36,7 +36,6 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; import java.util.Map; -import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; import static org.elasticsearch.rest.RestRequest.Method.PUT; import static org.elasticsearch.rest.RestStatus.OK; @@ -107,7 +106,7 @@ public class RestIndexPutAliasAction extends BaseRestHandler { } IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest(); - indicesAliasesRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); + indicesAliasesRequest.timeout(request.paramAsTime("timeout", indicesAliasesRequest.timeout())); AliasAction aliasAction = new AliasAction(AliasAction.Type.ADD, index, alias); indicesAliasesRequest.addAliasAction(aliasAction); indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout())); diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java index 21abac112f6..90cb97066aa 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java @@ -31,7 +31,6 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; import static org.elasticsearch.rest.RestStatus.OK; /** @@ -64,7 +63,7 @@ public class RestCreateIndexAction extends BaseRestHandler { } } - createIndexRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); + createIndexRequest.timeout(request.paramAsTime("timeout", createIndexRequest.timeout())); createIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", createIndexRequest.masterNodeTimeout())); client.admin().indices().create(createIndexRequest, new ActionListener() { diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java index 25edc2e297c..b85cfd77cb4 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java @@ -33,7 +33,6 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; import static org.elasticsearch.rest.RestStatus.OK; /** @@ -52,7 +51,7 @@ public class RestDeleteIndexAction extends BaseRestHandler { public void handleRequest(final RestRequest request, final RestChannel channel) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(Strings.splitStringByCommaToArray(request.param("index"))); deleteIndexRequest.listenerThreaded(false); - deleteIndexRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); + deleteIndexRequest.timeout(request.paramAsTime("timeout", deleteIndexRequest.timeout())); deleteIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexRequest.masterNodeTimeout())); client.admin().indices().delete(deleteIndexRequest, new ActionListener() { @Override diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java index 2f78c3c8751..21d855c936a 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java @@ -32,7 +32,6 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; import static org.elasticsearch.rest.RestStatus.OK; /** @@ -50,7 +49,6 @@ public class RestDeleteIndexTemplateAction extends BaseRestHandler { public void handleRequest(final RestRequest request, final RestChannel channel) { DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(request.param("name")); deleteIndexTemplateRequest.listenerThreaded(false); - deleteIndexTemplateRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); deleteIndexTemplateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexTemplateRequest.masterNodeTimeout())); client.admin().indices().deleteTemplate(deleteIndexTemplateRequest, new ActionListener() { @Override diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java index 40c8074d8cc..a0e6bfa5e0e 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java @@ -32,7 +32,6 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder; import java.io.IOException; -import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; import static org.elasticsearch.rest.RestStatus.OK; /** @@ -67,7 +66,6 @@ public class RestPutIndexTemplateAction extends BaseRestHandler { try { putRequest.create(request.paramAsBoolean("create", false)); putRequest.cause(request.param("cause", "")); - putRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10))); putRequest.source(request.content()); } catch (Exception e) { try {