diff --git a/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexClusterStateUpdateRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexClusterStateUpdateRequest.java index dc8537c6f76..3db6e4b1505 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexClusterStateUpdateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexClusterStateUpdateRequest.java @@ -18,25 +18,14 @@ package org.elasticsearch.action.admin.indices.close; -import org.elasticsearch.cluster.ack.ClusterStateUpdateRequest; +import org.elasticsearch.cluster.ack.IndicesClusterStateUpdateRequest; /** * Cluster state update request that allows to close one or more indices */ -public class CloseIndexClusterStateUpdateRequest extends ClusterStateUpdateRequest { - - private String[] indices; +public class CloseIndexClusterStateUpdateRequest extends IndicesClusterStateUpdateRequest { CloseIndexClusterStateUpdateRequest() { } - - public String[] indices() { - return indices; - } - - public CloseIndexClusterStateUpdateRequest indices(String[] indices) { - this.indices = indices; - return this; - } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingClusterStateUpdateRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingClusterStateUpdateRequest.java index bfee37d4370..5a895bf778f 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingClusterStateUpdateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingClusterStateUpdateRequest.java @@ -19,35 +19,19 @@ package org.elasticsearch.action.admin.indices.mapping.delete; -import org.elasticsearch.cluster.ack.ClusterStateUpdateRequest; +import org.elasticsearch.cluster.ack.IndicesClusterStateUpdateRequest; /** * Cluster state update request that allows to delete a mapping */ -public class DeleteMappingClusterStateUpdateRequest extends ClusterStateUpdateRequest { +public class DeleteMappingClusterStateUpdateRequest extends IndicesClusterStateUpdateRequest { - private String[] indices; private String type; DeleteMappingClusterStateUpdateRequest() { } - /** - * Returns the indices the operation needs to be executed on - */ - public String[] indices() { - return indices; - } - - /** - * Sets the indices the operation needs to be executed on - */ - public DeleteMappingClusterStateUpdateRequest indices(String[] indices) { - this.indices = indices; - return this; - } - /** * Returns the type to be removed */ diff --git a/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexClusterStateUpdateRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexClusterStateUpdateRequest.java index 3d80627597e..06e01726f1c 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexClusterStateUpdateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexClusterStateUpdateRequest.java @@ -18,25 +18,14 @@ package org.elasticsearch.action.admin.indices.open; -import org.elasticsearch.cluster.ack.ClusterStateUpdateRequest; +import org.elasticsearch.cluster.ack.IndicesClusterStateUpdateRequest; /** * Cluster state update request that allows to open one or more indices */ -public class OpenIndexClusterStateUpdateRequest extends ClusterStateUpdateRequest { - - private String[] indices; +public class OpenIndexClusterStateUpdateRequest extends IndicesClusterStateUpdateRequest { OpenIndexClusterStateUpdateRequest() { } - - public String[] indices() { - return indices; - } - - public OpenIndexClusterStateUpdateRequest indices(String[] indices) { - this.indices = indices; - return this; - } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsClusterStateUpdateRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsClusterStateUpdateRequest.java index 5130fa67271..afce509dfe8 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsClusterStateUpdateRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/settings/UpdateSettingsClusterStateUpdateRequest.java @@ -19,35 +19,20 @@ package org.elasticsearch.action.admin.indices.settings; -import org.elasticsearch.cluster.ack.ClusterStateUpdateRequest; +import org.elasticsearch.cluster.ack.IndicesClusterStateUpdateRequest; import org.elasticsearch.common.settings.Settings; /** * Cluster state update request that allows to update settings for some indices */ -public class UpdateSettingsClusterStateUpdateRequest extends ClusterStateUpdateRequest { +public class UpdateSettingsClusterStateUpdateRequest extends IndicesClusterStateUpdateRequest { + private Settings settings; - private String[] indices; public UpdateSettingsClusterStateUpdateRequest() { } - /** - * Returns the indices that needs to be updated - */ - public String[] indices() { - return indices; - } - - /** - * Sets the indices to update - */ - public UpdateSettingsClusterStateUpdateRequest indices(String[] indices) { - this.indices = indices; - return this; - } - /** * Returns the {@link Settings} to update */ diff --git a/src/main/java/org/elasticsearch/cluster/ack/IndicesClusterStateUpdateRequest.java b/src/main/java/org/elasticsearch/cluster/ack/IndicesClusterStateUpdateRequest.java new file mode 100644 index 00000000000..27bc0c91472 --- /dev/null +++ b/src/main/java/org/elasticsearch/cluster/ack/IndicesClusterStateUpdateRequest.java @@ -0,0 +1,43 @@ +/* + * Licensed to ElasticSearch and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. ElasticSearch licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package org.elasticsearch.cluster.ack; + +/** + * Base cluster state update request that allows to execute update against multiple indices + */ +public abstract class IndicesClusterStateUpdateRequest> extends ClusterStateUpdateRequest { + + private String[] indices; + + /** + * Returns the indices the operation needs to be executed on + */ + public String[] indices() { + return indices; + } + + /** + * Sets the indices the operation needs to be executed on + */ + @SuppressWarnings("unchecked") + public T indices(String[] indices) { + this.indices = indices; + return (T)this; + } +}