Added base ClusterStateUpdateRequest class that executes on multiple indices

This commit is contained in:
Luca Cavanna 2013-11-20 09:38:40 +01:00
parent 39c606c59a
commit ec3d858cc2
5 changed files with 52 additions and 62 deletions

View File

@ -18,25 +18,14 @@
package org.elasticsearch.action.admin.indices.close; 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 * Cluster state update request that allows to close one or more indices
*/ */
public class CloseIndexClusterStateUpdateRequest extends ClusterStateUpdateRequest<CloseIndexClusterStateUpdateRequest> { public class CloseIndexClusterStateUpdateRequest extends IndicesClusterStateUpdateRequest<CloseIndexClusterStateUpdateRequest> {
private String[] indices;
CloseIndexClusterStateUpdateRequest() { CloseIndexClusterStateUpdateRequest() {
} }
public String[] indices() {
return indices;
}
public CloseIndexClusterStateUpdateRequest indices(String[] indices) {
this.indices = indices;
return this;
}
} }

View File

@ -19,35 +19,19 @@
package org.elasticsearch.action.admin.indices.mapping.delete; 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 * Cluster state update request that allows to delete a mapping
*/ */
public class DeleteMappingClusterStateUpdateRequest extends ClusterStateUpdateRequest<DeleteMappingClusterStateUpdateRequest> { public class DeleteMappingClusterStateUpdateRequest extends IndicesClusterStateUpdateRequest<DeleteMappingClusterStateUpdateRequest> {
private String[] indices;
private String type; private String type;
DeleteMappingClusterStateUpdateRequest() { 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 * Returns the type to be removed
*/ */

View File

@ -18,25 +18,14 @@
package org.elasticsearch.action.admin.indices.open; 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 * Cluster state update request that allows to open one or more indices
*/ */
public class OpenIndexClusterStateUpdateRequest extends ClusterStateUpdateRequest<OpenIndexClusterStateUpdateRequest> { public class OpenIndexClusterStateUpdateRequest extends IndicesClusterStateUpdateRequest<OpenIndexClusterStateUpdateRequest> {
private String[] indices;
OpenIndexClusterStateUpdateRequest() { OpenIndexClusterStateUpdateRequest() {
} }
public String[] indices() {
return indices;
}
public OpenIndexClusterStateUpdateRequest indices(String[] indices) {
this.indices = indices;
return this;
}
} }

View File

@ -19,35 +19,20 @@
package org.elasticsearch.action.admin.indices.settings; 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; import org.elasticsearch.common.settings.Settings;
/** /**
* Cluster state update request that allows to update settings for some indices * Cluster state update request that allows to update settings for some indices
*/ */
public class UpdateSettingsClusterStateUpdateRequest extends ClusterStateUpdateRequest<UpdateSettingsClusterStateUpdateRequest> { public class UpdateSettingsClusterStateUpdateRequest extends IndicesClusterStateUpdateRequest<UpdateSettingsClusterStateUpdateRequest> {
private Settings settings; private Settings settings;
private String[] indices;
public UpdateSettingsClusterStateUpdateRequest() { 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 * Returns the {@link Settings} to update
*/ */

View File

@ -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<T extends IndicesClusterStateUpdateRequest<T>> extends ClusterStateUpdateRequest<T> {
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;
}
}