Rename IndicesAdminClient#existsAliases to IndicesAdminClient#aliasesExist.

Closes #3330
This commit is contained in:
Martijn van Groningen 2013-07-15 14:28:09 +02:00
parent 1310f02e6c
commit 127c62924b
10 changed files with 56 additions and 63 deletions

View File

@ -42,8 +42,8 @@ import org.elasticsearch.action.admin.cluster.state.ClusterStateAction;
import org.elasticsearch.action.admin.cluster.state.TransportClusterStateAction;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction;
import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction;
import org.elasticsearch.action.admin.indices.alias.exists.IndicesExistsAliasesAction;
import org.elasticsearch.action.admin.indices.alias.exists.TransportIndicesExistsAliasesAction;
import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistAction;
import org.elasticsearch.action.admin.indices.alias.exists.TransportAliasesExistAction;
import org.elasticsearch.action.admin.indices.alias.get.IndicesGetAliasesAction;
import org.elasticsearch.action.admin.indices.alias.get.TransportIndicesGetAliasesAction;
import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction;
@ -214,7 +214,7 @@ public class ActionModule extends AbstractModule {
registerAction(DeleteWarmerAction.INSTANCE, TransportDeleteWarmerAction.class);
registerAction(GetWarmersAction.INSTANCE, TransportGetWarmersAction.class);
registerAction(IndicesGetAliasesAction.INSTANCE, TransportIndicesGetAliasesAction.class);
registerAction(IndicesExistsAliasesAction.INSTANCE, TransportIndicesExistsAliasesAction.class);
registerAction(AliasesExistAction.INSTANCE, TransportAliasesExistAction.class);
registerAction(IndexAction.INSTANCE, TransportIndexAction.class);
registerAction(GetAction.INSTANCE, TransportGetAction.class);

View File

@ -25,22 +25,22 @@ import org.elasticsearch.client.IndicesAdminClient;
/**
*/
public class IndicesExistsAliasesAction extends IndicesAction<IndicesGetAliasesRequest, IndicesExistsAliasesResponse, IndicesExistsAliasesRequestBuilder> {
public class AliasesExistAction extends IndicesAction<IndicesGetAliasesRequest, AliasesExistResponse, AliasesExistRequestBuilder> {
public static final IndicesExistsAliasesAction INSTANCE = new IndicesExistsAliasesAction();
public static final AliasesExistAction INSTANCE = new AliasesExistAction();
public static final String NAME = "indices/exists/aliases";
private IndicesExistsAliasesAction() {
private AliasesExistAction() {
super(NAME);
}
@Override
public IndicesExistsAliasesRequestBuilder newRequestBuilder(IndicesAdminClient client) {
return new IndicesExistsAliasesRequestBuilder(client);
public AliasesExistRequestBuilder newRequestBuilder(IndicesAdminClient client) {
return new AliasesExistRequestBuilder(client);
}
@Override
public IndicesExistsAliasesResponse newResponse() {
return new IndicesExistsAliasesResponse();
public AliasesExistResponse newResponse() {
return new AliasesExistResponse();
}
}

View File

@ -25,15 +25,15 @@ import org.elasticsearch.client.IndicesAdminClient;
/**
*/
public class IndicesExistsAliasesRequestBuilder extends BaseIndicesAliasesRequestBuilder<IndicesExistsAliasesResponse, IndicesExistsAliasesRequestBuilder> {
public class AliasesExistRequestBuilder extends BaseIndicesAliasesRequestBuilder<AliasesExistResponse, AliasesExistRequestBuilder> {
public IndicesExistsAliasesRequestBuilder(IndicesAdminClient client, String... aliases) {
public AliasesExistRequestBuilder(IndicesAdminClient client, String... aliases) {
super(client, aliases);
}
@Override
protected void doExecute(ActionListener<IndicesExistsAliasesResponse> listener) {
((IndicesAdminClient) client).existsAliases(request, listener);
protected void doExecute(ActionListener<AliasesExistResponse> listener) {
((IndicesAdminClient) client).aliasesExist(request, listener);
}
}

View File

@ -27,15 +27,15 @@ import java.io.IOException;
/**
*/
public class IndicesExistsAliasesResponse extends ActionResponse {
public class AliasesExistResponse extends ActionResponse {
private boolean exists;
public IndicesExistsAliasesResponse(boolean exists) {
public AliasesExistResponse(boolean exists) {
this.exists = exists;
}
IndicesExistsAliasesResponse() {
AliasesExistResponse() {
}
public boolean exists() {

View File

@ -30,16 +30,16 @@ import org.elasticsearch.transport.TransportService;
/**
*/
public class TransportIndicesExistsAliasesAction extends TransportMasterNodeOperationAction<IndicesGetAliasesRequest, IndicesExistsAliasesResponse> {
public class TransportAliasesExistAction extends TransportMasterNodeOperationAction<IndicesGetAliasesRequest, AliasesExistResponse> {
@Inject
public TransportIndicesExistsAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool) {
public TransportAliasesExistAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool) {
super(settings, transportService, clusterService, threadPool);
}
@Override
protected String transportAction() {
return IndicesExistsAliasesAction.NAME;
return AliasesExistAction.NAME;
}
@Override
@ -53,17 +53,17 @@ public class TransportIndicesExistsAliasesAction extends TransportMasterNodeOper
}
@Override
protected IndicesExistsAliasesResponse newResponse() {
return new IndicesExistsAliasesResponse();
protected AliasesExistResponse newResponse() {
return new AliasesExistResponse();
}
@Override
protected IndicesExistsAliasesResponse masterOperation(IndicesGetAliasesRequest request, ClusterState state) throws ElasticSearchException {
protected AliasesExistResponse masterOperation(IndicesGetAliasesRequest request, ClusterState state) throws ElasticSearchException {
String[] concreteIndices = state.metaData().concreteIndices(request.indices(), request.ignoreIndices(), true);
request.indices(concreteIndices);
boolean result = state.metaData().hasAliases(request.aliases(), request.indices());
return new IndicesExistsAliasesResponse(result);
return new AliasesExistResponse(result);
}
}

View File

@ -24,8 +24,8 @@ import org.elasticsearch.action.admin.indices.IndicesAction;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
import org.elasticsearch.action.admin.indices.alias.exists.IndicesExistsAliasesRequestBuilder;
import org.elasticsearch.action.admin.indices.alias.exists.IndicesExistsAliasesResponse;
import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistRequestBuilder;
import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistResponse;
import org.elasticsearch.action.admin.indices.alias.get.IndicesGetAliasesRequest;
import org.elasticsearch.action.admin.indices.alias.get.IndicesGetAliasesRequestBuilder;
import org.elasticsearch.action.admin.indices.alias.get.IndicesGetAliasesResponse;
@ -516,14 +516,14 @@ public interface IndicesAdminClient {
/**
* Allows to check to existence of aliases from indices.
*/
IndicesExistsAliasesRequestBuilder prepareExistsAliases(String... aliases);
AliasesExistRequestBuilder prepareAliasesExist(String... aliases);
/**
* Check to existence of index aliases.
*
* @param request The result future
*/
ActionFuture<IndicesExistsAliasesResponse> existsAliases(IndicesGetAliasesRequest request);
ActionFuture<AliasesExistResponse> aliasesExist(IndicesGetAliasesRequest request);
/**
* Check the existence of specified index aliases.
@ -531,7 +531,7 @@ public interface IndicesAdminClient {
* @param request The index aliases request
* @param listener A listener to be notified with a result
*/
void existsAliases(IndicesGetAliasesRequest request, ActionListener<IndicesExistsAliasesResponse> listener);
void aliasesExist(IndicesGetAliasesRequest request, ActionListener<AliasesExistResponse> listener);
/**
* Clear indices cache.

View File

@ -25,9 +25,9 @@ import org.elasticsearch.action.admin.indices.alias.IndicesAliasesAction;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
import org.elasticsearch.action.admin.indices.alias.exists.IndicesExistsAliasesAction;
import org.elasticsearch.action.admin.indices.alias.exists.IndicesExistsAliasesRequestBuilder;
import org.elasticsearch.action.admin.indices.alias.exists.IndicesExistsAliasesResponse;
import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistAction;
import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistRequestBuilder;
import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistResponse;
import org.elasticsearch.action.admin.indices.alias.get.IndicesGetAliasesAction;
import org.elasticsearch.action.admin.indices.alias.get.IndicesGetAliasesRequest;
import org.elasticsearch.action.admin.indices.alias.get.IndicesGetAliasesRequestBuilder;
@ -211,18 +211,18 @@ public abstract class AbstractIndicesAdminClient implements InternalIndicesAdmin
}
@Override
public void existsAliases(IndicesGetAliasesRequest request, ActionListener<IndicesExistsAliasesResponse> listener) {
execute(IndicesExistsAliasesAction.INSTANCE, request, listener);
public void aliasesExist(IndicesGetAliasesRequest request, ActionListener<AliasesExistResponse> listener) {
execute(AliasesExistAction.INSTANCE, request, listener);
}
@Override
public ActionFuture<IndicesExistsAliasesResponse> existsAliases(IndicesGetAliasesRequest request) {
return execute(IndicesExistsAliasesAction.INSTANCE, request);
public ActionFuture<AliasesExistResponse> aliasesExist(IndicesGetAliasesRequest request) {
return execute(AliasesExistAction.INSTANCE, request);
}
@Override
public IndicesExistsAliasesRequestBuilder prepareExistsAliases(String... aliases) {
return new IndicesExistsAliasesRequestBuilder(this, aliases);
public AliasesExistRequestBuilder prepareAliasesExist(String... aliases) {
return new AliasesExistRequestBuilder(this, aliases);
}
@Override

View File

@ -37,7 +37,7 @@ import org.elasticsearch.rest.action.admin.indices.alias.RestGetIndicesAliasesAc
import org.elasticsearch.rest.action.admin.indices.alias.RestIndicesAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.delete.RestIndexDeleteAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.get.RestIndicesGetAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.head.RestIndicesHeadAliasesAction;
import org.elasticsearch.rest.action.admin.indices.alias.head.RestAliasesExistAction;
import org.elasticsearch.rest.action.admin.indices.alias.put.RestIndexPutAliasAction;
import org.elasticsearch.rest.action.admin.indices.analyze.RestAnalyzeAction;
import org.elasticsearch.rest.action.admin.indices.cache.clear.RestClearIndicesCacheAction;
@ -128,7 +128,7 @@ public class RestActionModule extends AbstractModule {
bind(RestIndicesSegmentsAction.class).asEagerSingleton();
bind(RestGetIndicesAliasesAction.class).asEagerSingleton();
bind(RestIndicesGetAliasesAction.class).asEagerSingleton();
bind(RestIndicesHeadAliasesAction.class).asEagerSingleton();
bind(RestAliasesExistAction.class).asEagerSingleton();
bind(RestIndexDeleteAliasesAction.class).asEagerSingleton();
bind(RestIndexPutAliasAction.class).asEagerSingleton();
bind(RestIndicesAliasesAction.class).asEagerSingleton();

View File

@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.indices.alias.head;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.alias.exists.IndicesExistsAliasesResponse;
import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistResponse;
import org.elasticsearch.action.admin.indices.alias.get.IndicesGetAliasesRequest;
import org.elasticsearch.action.support.IgnoreIndices;
import org.elasticsearch.client.Client;
@ -37,10 +37,10 @@ import static org.elasticsearch.rest.RestStatus.OK;
/**
*/
public class RestIndicesHeadAliasesAction extends BaseRestHandler {
public class RestAliasesExistAction extends BaseRestHandler {
@Inject
public RestIndicesHeadAliasesAction(Settings settings, Client client, RestController controller) {
public RestAliasesExistAction(Settings settings, Client client, RestController controller) {
super(settings, client);
controller.registerHandler(HEAD, "/_alias/{name}", this);
controller.registerHandler(HEAD, "/{index}/_alias/{name}", this);
@ -57,10 +57,10 @@ public class RestIndicesHeadAliasesAction extends BaseRestHandler {
getAliasesRequest.ignoreIndices(IgnoreIndices.fromString(request.param("ignore_indices")));
}
client.admin().indices().existsAliases(getAliasesRequest, new ActionListener<IndicesExistsAliasesResponse>() {
client.admin().indices().aliasesExist(getAliasesRequest, new ActionListener<AliasesExistResponse>() {
@Override
public void onResponse(IndicesExistsAliasesResponse response) {
public void onResponse(AliasesExistResponse response) {
try {
if (response.isExists()) {
channel.sendResponse(new StringRestResponse(OK));

View File

@ -22,12 +22,10 @@ package org.elasticsearch.test.integration.aliases;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
import org.elasticsearch.action.admin.indices.alias.exists.IndicesExistsAliasesResponse;
import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistResponse;
import org.elasticsearch.action.admin.indices.alias.get.IndicesGetAliasesResponse;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.AliasAction;
import org.elasticsearch.cluster.metadata.AliasMetaData;
@ -39,20 +37,15 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.query.FilterBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.indices.AliasMissingException;
import org.elasticsearch.indices.IndexMissingException;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.facet.FacetBuilders;
import org.elasticsearch.search.facet.terms.TermsFacet;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.integration.AbstractNodesTests;
import org.elasticsearch.test.integration.AbstractSharedClusterTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -632,7 +625,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
IndicesExistsAliasesResponse existsResponse = client().admin().indices().prepareExistsAliases("alias1").execute().actionGet();
AliasesExistResponse existsResponse = client().admin().indices().prepareAliasesExist("alias1").execute().actionGet();
assertThat(existsResponse.exists(), equalTo(true));
logger.info("--> getting all aliases that start with alias*");
@ -650,7 +643,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
assertThat(getResponse.getAliases().get("foobar").get(1).getFilter(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(1).getIndexRouting(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(1).getSearchRouting(), nullValue());
existsResponse = client().admin().indices().prepareExistsAliases("alias*").execute().actionGet();
existsResponse = client().admin().indices().prepareAliasesExist("alias*").execute().actionGet();
assertThat(existsResponse.exists(), equalTo(true));
@ -683,7 +676,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
assertThat(getResponse.getAliases().get("bazbar").get(1).getFilter(), nullValue());
assertThat(getResponse.getAliases().get("bazbar").get(1).getIndexRouting(), nullValue());
assertThat(getResponse.getAliases().get("bazbar").get(1).getSearchRouting(), nullValue());
existsResponse = client().admin().indices().prepareExistsAliases("bar", "bac")
existsResponse = client().admin().indices().prepareAliasesExist("bar", "bac")
.addIndices("bazbar").execute().actionGet();
assertThat(existsResponse.exists(), equalTo(true));
@ -704,7 +697,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
assertThat(getResponse.getAliases().get("bazbar").get(1).getFilter(), nullValue());
assertThat(getResponse.getAliases().get("bazbar").get(1).getIndexRouting(), nullValue());
assertThat(getResponse.getAliases().get("bazbar").get(1).getSearchRouting(), nullValue());
existsResponse = client().admin().indices().prepareExistsAliases("*b*")
existsResponse = client().admin().indices().prepareAliasesExist("*b*")
.addIndices("baz*").execute().actionGet();
assertThat(existsResponse.exists(), equalTo(true));
@ -730,7 +723,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), equalTo("bla"));
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), equalTo("bla"));
existsResponse = client().admin().indices().prepareExistsAliases("b*")
existsResponse = client().admin().indices().prepareAliasesExist("b*")
.addIndices("*bar").execute().actionGet();
assertThat(existsResponse.exists(), equalTo(true));
@ -743,7 +736,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
existsResponse = client().admin().indices().prepareExistsAliases("f*")
existsResponse = client().admin().indices().prepareAliasesExist("f*")
.addIndices("*bar").execute().actionGet();
assertThat(existsResponse.exists(), equalTo(true));
@ -758,7 +751,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
existsResponse = client().admin().indices().prepareExistsAliases("foo")
existsResponse = client().admin().indices().prepareAliasesExist("foo")
.addIndices("*bac").execute().actionGet();
assertThat(existsResponse.exists(), equalTo(true));
@ -771,7 +764,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue());
assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue());
existsResponse = client().admin().indices().prepareExistsAliases("foo")
existsResponse = client().admin().indices().prepareAliasesExist("foo")
.addIndices("foobar").execute().actionGet();
assertThat(existsResponse.exists(), equalTo(true));
@ -782,7 +775,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
assertThat(getResponse.getAliases().size(), equalTo(2));
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(4));
assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2));
existsResponse = client().admin().indices().prepareExistsAliases("*")
existsResponse = client().admin().indices().prepareAliasesExist("*")
.addIndices("*bac").execute().actionGet();
assertThat(existsResponse.exists(), equalTo(true));
@ -797,7 +790,7 @@ public class IndexAliasesTests extends AbstractSharedClusterTest {
} catch (AliasMissingException e) {
assertThat(e.getMessage(), equalTo("alias [foo] missing"));
}
existsResponse = client().admin().indices().prepareExistsAliases("foo")
existsResponse = client().admin().indices().prepareAliasesExist("foo")
.addIndices("foobar").execute().actionGet();
assertThat(existsResponse.exists(), equalTo(false));
}