[Remove] AliasesExistAction (#3149)

With the removal of Transport Client AliasesExistAction is no longer needed and
is removed.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
This commit is contained in:
Nick Knize 2022-05-03 11:05:41 -05:00 committed by GitHub
parent 15f035b479
commit 5f531b366e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 35 additions and 419 deletions

View File

@ -33,7 +33,6 @@
package org.opensearch.action.admin.indices.alias;
import org.opensearch.action.RequestValidators;
import org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse;
import org.opensearch.action.admin.indices.alias.get.GetAliasesRequest;
import org.opensearch.action.admin.indices.alias.get.GetAliasesResponse;
import org.opensearch.cluster.metadata.AliasMetadata;
@ -143,8 +142,6 @@ public class ValidateIndicesAliasesRequestIT extends OpenSearchSingleNodeTestCas
final Exception e = expectThrows(IllegalStateException.class, () -> client().admin().indices().aliases(request).actionGet());
final String index = "foo_allowed".equals(origin) ? "bar" : "foo";
assertThat(e, hasToString(containsString("origin [" + origin + "] not allowed for index [" + index + "]")));
final AliasesExistResponse response = client().admin().indices().aliasesExist(new GetAliasesRequest("alias")).actionGet();
assertFalse(response.exists());
assertTrue(client().admin().indices().getAliases(new GetAliasesRequest("alias")).actionGet().getAliases().isEmpty());
}
}

View File

@ -35,7 +35,6 @@ package org.opensearch.aliases;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.opensearch.action.admin.indices.alias.Alias;
import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions;
import org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse;
import org.opensearch.action.admin.indices.alias.get.GetAliasesResponse;
import org.opensearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.opensearch.action.delete.DeleteResponse;
@ -684,8 +683,9 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
assertAliasesVersionIncreases(indices, () -> admin().indices().prepareAliases().removeAlias(indices, aliases).get());
AliasesExistResponse response = admin().indices().prepareAliasesExist(aliases).get();
assertThat(response.exists(), equalTo(false));
for (String alias : aliases) {
assertTrue(admin().indices().prepareGetAliases(alias).get().getAliases().isEmpty());
}
logger.info("--> creating index [foo_foo] and [bar_bar]");
assertAcked(prepareCreate("foo_foo"));
@ -701,9 +701,9 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
() -> assertAcked(admin().indices().prepareAliases().addAliasAction(AliasActions.remove().index("foo*").alias("foo")))
);
assertTrue(admin().indices().prepareAliasesExist("foo").get().exists());
assertFalse(admin().indices().prepareAliasesExist("foo").setIndices("foo_foo").get().exists());
assertTrue(admin().indices().prepareAliasesExist("foo").setIndices("bar_bar").get().exists());
assertFalse(admin().indices().prepareGetAliases("foo").get().getAliases().isEmpty());
assertTrue(admin().indices().prepareGetAliases("foo").setIndices("foo_foo").get().getAliases().isEmpty());
assertFalse(admin().indices().prepareGetAliases("foo").setIndices("bar_bar").get().getAliases().isEmpty());
IllegalArgumentException iae = expectThrows(
IllegalArgumentException.class,
() -> admin().indices().prepareAliases().addAliasAction(AliasActions.remove().index("foo").alias("foo")).execute().actionGet()
@ -880,8 +880,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
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());
AliasesExistResponse existsResponse = admin().indices().prepareAliasesExist("alias1").get();
assertThat(existsResponse.exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("alias1").get().getAliases().isEmpty());
logger.info("--> getting all aliases that start with alias*");
getResponse = admin().indices().prepareGetAliases("alias*").get();
@ -898,8 +897,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
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 = admin().indices().prepareAliasesExist("alias*").get();
assertThat(existsResponse.exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("alias*").get().getAliases().isEmpty());
logger.info("--> creating aliases [bar, baz, foo]");
assertAliasesVersionIncreases(
@ -937,8 +935,10 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
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 = admin().indices().prepareAliasesExist("bar", "bac").addIndices("bazbar").get();
assertThat(existsResponse.exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("bar").get().getAliases().isEmpty());
assertFalse(admin().indices().prepareGetAliases("bac").get().getAliases().isEmpty());
assertFalse(admin().indices().prepareGetAliases("bar").addIndices("bazbar").get().getAliases().isEmpty());
assertFalse(admin().indices().prepareGetAliases("bac").addIndices("bazbar").get().getAliases().isEmpty());
logger.info("--> getting *b* for index baz*");
getResponse = admin().indices().prepareGetAliases("*b*").addIndices("baz*").get();
@ -957,8 +957,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
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 = admin().indices().prepareAliasesExist("*b*").addIndices("baz*").get();
assertThat(existsResponse.exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("*b*").addIndices("baz*").get().getAliases().isEmpty());
logger.info("--> getting *b* for index *bar");
getResponse = admin().indices().prepareGetAliases("b*").addIndices("*bar").get();
@ -982,8 +981,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
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 = admin().indices().prepareAliasesExist("b*").addIndices("*bar").get();
assertThat(existsResponse.exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("b*").addIndices("*bar").get().getAliases().isEmpty());
logger.info("--> getting f* for index *bar");
getResponse = admin().indices().prepareGetAliases("f*").addIndices("*bar").get();
@ -994,8 +992,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
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 = admin().indices().prepareAliasesExist("f*").addIndices("*bar").get();
assertThat(existsResponse.exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("f*").addIndices("*bar").get().getAliases().isEmpty());
// alias at work
logger.info("--> getting f* for index *bac");
@ -1008,8 +1005,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
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 = admin().indices().prepareAliasesExist("foo").addIndices("*bac").get();
assertThat(existsResponse.exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("foo").addIndices("*bac").get().getAliases().isEmpty());
logger.info("--> getting foo for index foobar");
getResponse = admin().indices().prepareGetAliases("foo").addIndices("foobar").get();
@ -1020,8 +1016,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
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 = admin().indices().prepareAliasesExist("foo").addIndices("foobar").get();
assertThat(existsResponse.exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("foo").addIndices("foobar").get().getAliases().isEmpty());
for (String aliasName : new String[] { null, "_all", "*" }) {
logger.info("--> getting {} alias for index foobar", aliasName);
@ -1044,8 +1039,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
assertThat(getResponse.getAliases().size(), equalTo(2));
assertThat(getResponse.getAliases().get("foobar").size(), equalTo(4));
assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2));
existsResponse = admin().indices().prepareAliasesExist("*").addIndices("*bac").get();
assertThat(existsResponse.exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("*").addIndices("*bac").get().getAliases().isEmpty());
assertAcked(admin().indices().prepareAliases().removeAlias("foobar", "foo"));
@ -1053,8 +1047,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
for (final ObjectObjectCursor<String, List<AliasMetadata>> entry : getResponse.getAliases()) {
assertTrue(entry.value.isEmpty());
}
existsResponse = admin().indices().prepareAliasesExist("foo").addIndices("foobar").get();
assertThat(existsResponse.exists(), equalTo(false));
assertTrue(admin().indices().prepareGetAliases("foo").addIndices("foobar").get().getAliases().isEmpty());
}
public void testGetAllAliasesWorks() {
@ -1226,7 +1219,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
);
assertAliasesVersionIncreases("test", () -> assertAcked(admin().indices().prepareAliases().removeAlias("test", "alias1")));
assertThat(admin().indices().prepareGetAliases("alias2").execute().actionGet().getAliases().get("test").size(), equalTo(1));
assertThat(admin().indices().prepareAliasesExist("alias2").get().exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("alias2").get().getAliases().isEmpty());
} finally {
disableIndexBlock("test", block);
}
@ -1244,8 +1237,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
() -> assertBlocked(admin().indices().prepareAliases().removeAlias("test", "alias2"), INDEX_READ_ONLY_BLOCK)
);
assertThat(admin().indices().prepareGetAliases("alias2").execute().actionGet().getAliases().get("test").size(), equalTo(1));
assertThat(admin().indices().prepareAliasesExist("alias2").get().exists(), equalTo(true));
assertFalse(admin().indices().prepareGetAliases("alias2").get().getAliases().isEmpty());
} finally {
disableIndexBlock("test", SETTING_READ_ONLY);
}
@ -1262,8 +1254,7 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
() -> assertBlocked(admin().indices().prepareAliases().removeAlias("test", "alias2"), INDEX_METADATA_BLOCK)
);
assertBlocked(admin().indices().prepareGetAliases("alias2"), INDEX_METADATA_BLOCK);
assertBlocked(admin().indices().prepareAliasesExist("alias2"), INDEX_METADATA_BLOCK);
assertBlocked(admin().indices().prepareGetAliases("alias2"), INDEX_METADATA_BLOCK);
} finally {
disableIndexBlock("test", SETTING_BLOCKS_METADATA);
}
@ -1288,12 +1279,12 @@ public class IndexAliasesIT extends OpenSearchIntegTestCase {
assertAcked(client().admin().indices().prepareAliases().removeIndex("foo*"));
assertFalse(client().admin().indices().prepareExists("foo_foo").execute().actionGet().isExists());
assertTrue(admin().indices().prepareAliasesExist("foo").get().exists());
assertFalse(admin().indices().prepareGetAliases("foo").get().getAliases().isEmpty());
assertTrue(client().admin().indices().prepareExists("bar_bar").execute().actionGet().isExists());
assertTrue(admin().indices().prepareAliasesExist("foo").setIndices("bar_bar").get().exists());
assertFalse(admin().indices().prepareGetAliases("foo").setIndices("bar_bar").get().getAliases().isEmpty());
assertAcked(client().admin().indices().prepareAliases().removeIndex("bar_bar"));
assertFalse(admin().indices().prepareAliasesExist("foo").get().exists());
assertTrue(admin().indices().prepareGetAliases("foo").get().getAliases().isEmpty());
assertFalse(client().admin().indices().prepareExists("bar_bar").execute().actionGet().isExists());
}

View File

@ -34,7 +34,6 @@ package org.opensearch.indices;
import org.opensearch.action.ActionRequestBuilder;
import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotRequestBuilder;
import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequestBuilder;
import org.opensearch.action.admin.indices.alias.exists.AliasesExistRequestBuilder;
import org.opensearch.action.admin.indices.alias.get.GetAliasesRequestBuilder;
import org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheRequestBuilder;
import org.opensearch.action.admin.indices.flush.FlushRequestBuilder;
@ -97,7 +96,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge("test1", "test2"), true);
verify(refreshBuilder("test1", "test2"), true);
verify(validateQuery("test1", "test2"), true);
verify(aliasExists("test1", "test2"), true);
verify(getAliases("test1", "test2"), true);
verify(getFieldMapping("test1", "test2"), true);
verify(getMapping("test1", "test2"), true);
@ -113,7 +111,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge("test1", "test2").setIndicesOptions(options), true);
verify(refreshBuilder("test1", "test2").setIndicesOptions(options), true);
verify(validateQuery("test1", "test2").setIndicesOptions(options), true);
verify(aliasExists("test1", "test2").setIndicesOptions(options), true);
verify(getAliases("test1", "test2").setIndicesOptions(options), true);
verify(getFieldMapping("test1", "test2").setIndicesOptions(options), true);
verify(getMapping("test1", "test2").setIndicesOptions(options), true);
@ -129,7 +126,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge("test1", "test2").setIndicesOptions(options), false);
verify(refreshBuilder("test1", "test2").setIndicesOptions(options), false);
verify(validateQuery("test1", "test2").setIndicesOptions(options), false);
verify(aliasExists("test1", "test2").setIndicesOptions(options), false);
verify(getAliases("test1", "test2").setIndicesOptions(options), false);
verify(getFieldMapping("test1", "test2").setIndicesOptions(options), false);
verify(getMapping("test1", "test2").setIndicesOptions(options), false);
@ -146,7 +142,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge("test1", "test2").setIndicesOptions(options), false);
verify(refreshBuilder("test1", "test2").setIndicesOptions(options), false);
verify(validateQuery("test1", "test2").setIndicesOptions(options), false);
verify(aliasExists("test1", "test2").setIndicesOptions(options), false);
verify(getAliases("test1", "test2").setIndicesOptions(options), false);
verify(getFieldMapping("test1", "test2").setIndicesOptions(options), false);
verify(getMapping("test1", "test2").setIndicesOptions(options), false);
@ -172,7 +167,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge("test1").setIndicesOptions(options), true);
verify(refreshBuilder("test1").setIndicesOptions(options), true);
verify(validateQuery("test1").setIndicesOptions(options), true);
verify(aliasExists("test1").setIndicesOptions(options), true);
verify(getAliases("test1").setIndicesOptions(options), true);
verify(getFieldMapping("test1").setIndicesOptions(options), true);
verify(getMapping("test1").setIndicesOptions(options), true);
@ -194,7 +188,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge("test1").setIndicesOptions(options), false);
verify(refreshBuilder("test1").setIndicesOptions(options), false);
verify(validateQuery("test1").setIndicesOptions(options), false);
verify(aliasExists("test1").setIndicesOptions(options), false);
verify(getAliases("test1").setIndicesOptions(options), false);
verify(getFieldMapping("test1").setIndicesOptions(options), false);
verify(getMapping("test1").setIndicesOptions(options), false);
@ -213,7 +206,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge("test1").setIndicesOptions(options), false);
verify(refreshBuilder("test1").setIndicesOptions(options), false);
verify(validateQuery("test1").setIndicesOptions(options), false);
verify(aliasExists("test1").setIndicesOptions(options), false);
verify(getAliases("test1").setIndicesOptions(options), false);
verify(getFieldMapping("test1").setIndicesOptions(options), false);
verify(getMapping("test1").setIndicesOptions(options), false);
@ -231,7 +223,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge("test1").setIndicesOptions(options), true);
verify(refreshBuilder("test1").setIndicesOptions(options), true);
verify(validateQuery("test1").setIndicesOptions(options), true);
verify(aliasExists("test1").setIndicesOptions(options), true);
verify(getAliases("test1").setIndicesOptions(options), true);
verify(getFieldMapping("test1").setIndicesOptions(options), true);
verify(getMapping("test1").setIndicesOptions(options), true);
@ -253,7 +244,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge("test1").setIndicesOptions(options), false);
verify(refreshBuilder("test1").setIndicesOptions(options), false);
verify(validateQuery("test1").setIndicesOptions(options), false);
verify(aliasExists("test1").setIndicesOptions(options), false);
verify(getAliases("test1").setIndicesOptions(options), false);
verify(getFieldMapping("test1").setIndicesOptions(options), false);
verify(getMapping("test1").setIndicesOptions(options), false);
@ -271,7 +261,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge("test1").setIndicesOptions(options), false);
verify(refreshBuilder("test1").setIndicesOptions(options), false);
verify(validateQuery("test1").setIndicesOptions(options), false);
verify(aliasExists("test1").setIndicesOptions(options), false);
verify(getAliases("test1").setIndicesOptions(options), false);
verify(getFieldMapping("test1").setIndicesOptions(options), false);
verify(getMapping("test1").setIndicesOptions(options), false);
@ -324,7 +313,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge(indices), false);
verify(refreshBuilder(indices), false);
verify(validateQuery(indices), true);
verify(aliasExists(indices), false);
verify(getAliases(indices), false);
verify(getFieldMapping(indices), false);
verify(getMapping(indices), false);
@ -341,7 +329,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge(indices).setIndicesOptions(options), false);
verify(refreshBuilder(indices).setIndicesOptions(options), false);
verify(validateQuery(indices).setIndicesOptions(options), false);
verify(aliasExists(indices).setIndicesOptions(options), false);
verify(getAliases(indices).setIndicesOptions(options), false);
verify(getFieldMapping(indices).setIndicesOptions(options), false);
verify(getMapping(indices).setIndicesOptions(options), false);
@ -361,7 +348,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge(indices), false);
verify(refreshBuilder(indices), false);
verify(validateQuery(indices), false);
verify(aliasExists(indices), false);
verify(getAliases(indices), false);
verify(getFieldMapping(indices), false);
verify(getMapping(indices), false);
@ -378,7 +364,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge(indices), false);
verify(refreshBuilder(indices), false);
verify(validateQuery(indices), true);
verify(aliasExists(indices), false);
verify(getAliases(indices), false);
verify(getFieldMapping(indices), false);
verify(getMapping(indices), false);
@ -395,7 +380,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
verify(forceMerge(indices).setIndicesOptions(options), false);
verify(refreshBuilder(indices).setIndicesOptions(options), false);
verify(validateQuery(indices).setIndicesOptions(options), false);
verify(aliasExists(indices).setIndicesOptions(options), false);
verify(getAliases(indices).setIndicesOptions(options), false);
verify(getFieldMapping(indices).setIndicesOptions(options), false);
verify(getMapping(indices).setIndicesOptions(options), false);
@ -557,25 +541,23 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
public void testPutAlias() throws Exception {
createIndex("foobar");
verify(client().admin().indices().prepareAliases().addAlias("foobar", "foobar_alias"), false);
assertThat(client().admin().indices().prepareAliasesExist("foobar_alias").setIndices("foobar").get().exists(), equalTo(true));
assertFalse(client().admin().indices().prepareGetAliases("foobar_alias").setIndices("foobar").get().getAliases().isEmpty());
}
public void testPutAliasWildcard() throws Exception {
createIndex("foo", "foobar", "bar", "barbaz");
verify(client().admin().indices().prepareAliases().addAlias("foo*", "foobar_alias"), false);
assertThat(client().admin().indices().prepareAliasesExist("foobar_alias").setIndices("foo").get().exists(), equalTo(true));
assertThat(client().admin().indices().prepareAliasesExist("foobar_alias").setIndices("foobar").get().exists(), equalTo(true));
assertThat(client().admin().indices().prepareAliasesExist("foobar_alias").setIndices("bar").get().exists(), equalTo(false));
assertThat(client().admin().indices().prepareAliasesExist("foobar_alias").setIndices("barbaz").get().exists(), equalTo(false));
assertFalse(client().admin().indices().prepareGetAliases("foobar_alias").setIndices("foo").get().getAliases().isEmpty());
assertFalse(client().admin().indices().prepareGetAliases("foobar_alias").setIndices("foobar").get().getAliases().isEmpty());
assertTrue(client().admin().indices().prepareGetAliases("foobar_alias").setIndices("bar").get().getAliases().isEmpty());
assertTrue(client().admin().indices().prepareGetAliases("foobar_alias").setIndices("barbaz").get().getAliases().isEmpty());
verify(client().admin().indices().prepareAliases().addAlias("*", "foobar_alias"), false);
assertThat(client().admin().indices().prepareAliasesExist("foobar_alias").setIndices("foo").get().exists(), equalTo(true));
assertThat(client().admin().indices().prepareAliasesExist("foobar_alias").setIndices("foobar").get().exists(), equalTo(true));
assertThat(client().admin().indices().prepareAliasesExist("foobar_alias").setIndices("bar").get().exists(), equalTo(true));
assertThat(client().admin().indices().prepareAliasesExist("foobar_alias").setIndices("barbaz").get().exists(), equalTo(true));
assertFalse(client().admin().indices().prepareGetAliases("foobar_alias").setIndices("foo").get().getAliases().isEmpty());
assertFalse(client().admin().indices().prepareGetAliases("foobar_alias").setIndices("foobar").get().getAliases().isEmpty());
assertFalse(client().admin().indices().prepareGetAliases("foobar_alias").setIndices("bar").get().getAliases().isEmpty());
assertFalse(client().admin().indices().prepareGetAliases("foobar_alias").setIndices("barbaz").get().getAliases().isEmpty());
}
public void testPutMapping() throws Exception {
@ -705,10 +687,6 @@ public class IndicesOptionsIntegrationIT extends OpenSearchIntegTestCase {
return client().admin().indices().prepareValidateQuery(indices);
}
private static AliasesExistRequestBuilder aliasExists(String... indices) {
return client().admin().indices().prepareAliasesExist("dummy").addIndices(indices);
}
static GetAliasesRequestBuilder getAliases(String... indices) {
return client().admin().indices().prepareGetAliases("dummy").addIndices(indices);
}

View File

@ -108,8 +108,6 @@ import org.opensearch.action.admin.cluster.tasks.TransportPendingClusterTasksAct
import org.opensearch.action.admin.indices.alias.IndicesAliasesAction;
import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest;
import org.opensearch.action.admin.indices.alias.TransportIndicesAliasesAction;
import org.opensearch.action.admin.indices.alias.exists.AliasesExistAction;
import org.opensearch.action.admin.indices.alias.exists.TransportAliasesExistAction;
import org.opensearch.action.admin.indices.alias.get.GetAliasesAction;
import org.opensearch.action.admin.indices.alias.get.TransportGetAliasesAction;
import org.opensearch.action.admin.indices.analyze.AnalyzeAction;
@ -590,7 +588,6 @@ public class ActionModule extends AbstractModule {
actions.register(UpgradeSettingsAction.INSTANCE, TransportUpgradeSettingsAction.class);
actions.register(ClearIndicesCacheAction.INSTANCE, TransportClearIndicesCacheAction.class);
actions.register(GetAliasesAction.INSTANCE, TransportGetAliasesAction.class);
actions.register(AliasesExistAction.INSTANCE, TransportAliasesExistAction.class);
actions.register(GetSettingsAction.INSTANCE, TransportGetSettingsAction.class);
actions.register(IndexAction.INSTANCE, TransportIndexAction.class);

View File

@ -1,45 +0,0 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/*
* Licensed to Elasticsearch 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
package org.opensearch.action.admin.indices.alias.exists;
import org.opensearch.action.ActionType;
public class AliasesExistAction extends ActionType<AliasesExistResponse> {
public static final AliasesExistAction INSTANCE = new AliasesExistAction();
public static final String NAME = "indices:admin/aliases/exists";
private AliasesExistAction() {
super(NAME, AliasesExistResponse::new);
}
}

View File

@ -1,43 +0,0 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/*
* Licensed to Elasticsearch 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
package org.opensearch.action.admin.indices.alias.exists;
import org.opensearch.action.admin.indices.alias.get.BaseAliasesRequestBuilder;
import org.opensearch.client.OpenSearchClient;
public class AliasesExistRequestBuilder extends BaseAliasesRequestBuilder<AliasesExistResponse, AliasesExistRequestBuilder> {
public AliasesExistRequestBuilder(OpenSearchClient client, AliasesExistAction action, String... aliases) {
super(client, action, aliases);
}
}

View File

@ -1,66 +0,0 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/*
* Licensed to Elasticsearch 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
package org.opensearch.action.admin.indices.alias.exists;
import org.opensearch.action.ActionResponse;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import java.io.IOException;
public class AliasesExistResponse extends ActionResponse {
private boolean exists;
public AliasesExistResponse(boolean exists) {
this.exists = exists;
}
AliasesExistResponse(StreamInput in) throws IOException {
super(in);
exists = in.readBoolean();
}
public boolean exists() {
return exists;
}
public boolean isExists() {
return exists();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(exists);
}
}

View File

@ -1,95 +0,0 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/*
* Licensed to Elasticsearch 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
package org.opensearch.action.admin.indices.alias.exists;
import org.opensearch.action.ActionListener;
import org.opensearch.action.admin.indices.alias.get.GetAliasesRequest;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.master.TransportMasterNodeReadAction;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.block.ClusterBlockException;
import org.opensearch.cluster.block.ClusterBlockLevel;
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;
import java.io.IOException;
public class TransportAliasesExistAction extends TransportMasterNodeReadAction<GetAliasesRequest, AliasesExistResponse> {
@Inject
public TransportAliasesExistAction(
TransportService transportService,
ClusterService clusterService,
ThreadPool threadPool,
ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver
) {
super(
AliasesExistAction.NAME,
transportService,
clusterService,
threadPool,
actionFilters,
GetAliasesRequest::new,
indexNameExpressionResolver
);
}
@Override
protected String executor() {
// very lightweight operation, no need to fork
return ThreadPool.Names.SAME;
}
@Override
protected AliasesExistResponse read(StreamInput in) throws IOException {
return new AliasesExistResponse(in);
}
@Override
protected ClusterBlockException checkBlock(GetAliasesRequest request, ClusterState state) {
return state.blocks()
.indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndexNames(state, request));
}
@Override
protected void masterOperation(GetAliasesRequest request, ClusterState state, ActionListener<AliasesExistResponse> listener) {
String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(state, request);
boolean result = state.metadata().hasAliases(request.aliases(), concreteIndices);
listener.onResponse(new AliasesExistResponse(result));
}
}

View File

@ -1,10 +0,0 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/** Alias Exists transport handler. */
package org.opensearch.action.admin.indices.alias.exists;

View File

@ -36,8 +36,6 @@ import org.opensearch.action.ActionFuture;
import org.opensearch.action.ActionListener;
import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest;
import org.opensearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
import org.opensearch.action.admin.indices.alias.exists.AliasesExistRequestBuilder;
import org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse;
import org.opensearch.action.admin.indices.alias.get.GetAliasesRequest;
import org.opensearch.action.admin.indices.alias.get.GetAliasesRequestBuilder;
import org.opensearch.action.admin.indices.alias.get.GetAliasesResponse;
@ -564,26 +562,6 @@ public interface IndicesAdminClient extends OpenSearchClient {
*/
GetAliasesRequestBuilder prepareGetAliases(String... aliases);
/**
* Allows to check to existence of aliases from indices.
*/
AliasesExistRequestBuilder prepareAliasesExist(String... aliases);
/**
* Check to existence of index aliases.
*
* @param request The result future
*/
ActionFuture<AliasesExistResponse> aliasesExist(GetAliasesRequest request);
/**
* Check the existence of specified index aliases.
*
* @param request The index aliases request
* @param listener A listener to be notified with a result
*/
void aliasesExist(GetAliasesRequest request, ActionListener<AliasesExistResponse> listener);
/**
* Get index metadata for particular indices.
*

View File

@ -154,9 +154,6 @@ import org.opensearch.action.admin.cluster.tasks.PendingClusterTasksResponse;
import org.opensearch.action.admin.indices.alias.IndicesAliasesAction;
import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest;
import org.opensearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
import org.opensearch.action.admin.indices.alias.exists.AliasesExistAction;
import org.opensearch.action.admin.indices.alias.exists.AliasesExistRequestBuilder;
import org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse;
import org.opensearch.action.admin.indices.alias.get.GetAliasesAction;
import org.opensearch.action.admin.indices.alias.get.GetAliasesRequest;
import org.opensearch.action.admin.indices.alias.get.GetAliasesRequestBuilder;
@ -1363,21 +1360,6 @@ public abstract class AbstractClient implements Client {
return execute(ClearIndicesCacheAction.INSTANCE, request);
}
@Override
public void aliasesExist(GetAliasesRequest request, ActionListener<AliasesExistResponse> listener) {
execute(AliasesExistAction.INSTANCE, request, listener);
}
@Override
public ActionFuture<AliasesExistResponse> aliasesExist(GetAliasesRequest request) {
return execute(AliasesExistAction.INSTANCE, request);
}
@Override
public AliasesExistRequestBuilder prepareAliasesExist(String... aliases) {
return new AliasesExistRequestBuilder(this, AliasesExistAction.INSTANCE, aliases);
}
@Override
public ActionFuture<GetIndexResponse> getIndex(GetIndexRequest request) {
return execute(GetIndexAction.INSTANCE, request);

View File

@ -421,38 +421,6 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
return mapBuilder.build();
}
/**
* Checks if at least one of the specified aliases exists in the specified concrete indices. Wildcards are supported in the
* alias names for partial matches.
*
* @param aliases The names of the index aliases to find
* @param concreteIndices The concrete indexes the index aliases must point to order to be returned.
* @return whether at least one of the specified aliases exists in one of the specified concrete indices.
*/
public boolean hasAliases(final String[] aliases, String[] concreteIndices) {
assert aliases != null;
assert concreteIndices != null;
if (concreteIndices.length == 0) {
return false;
}
Iterable<String> intersection = HppcMaps.intersection(ObjectHashSet.from(concreteIndices), indices.keys());
for (String index : intersection) {
IndexMetadata indexMetadata = indices.get(index);
List<AliasMetadata> filteredValues = new ArrayList<>();
for (ObjectCursor<AliasMetadata> cursor : indexMetadata.getAliases().values()) {
AliasMetadata value = cursor.value;
if (Regex.simpleMatch(aliases, value.alias())) {
filteredValues.add(value);
}
}
if (!filteredValues.isEmpty()) {
return true;
}
}
return false;
}
/**
* Finds all mappings for concrete indices. Only fields that match the provided field
* filter will be returned (default is a predicate that always returns true, which can be

View File

@ -40,7 +40,6 @@ import org.opensearch.action.ActionFuture;
import org.opensearch.action.ActionRequestBuilder;
import org.opensearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
import org.opensearch.action.admin.cluster.health.ClusterHealthResponse;
import org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse;
import org.opensearch.action.admin.indices.create.CreateIndexResponse;
import org.opensearch.action.admin.indices.delete.DeleteIndexRequestBuilder;
import org.opensearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
@ -104,7 +103,6 @@ import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -518,20 +516,6 @@ public class OpenSearchAssertions {
assertThat(templateNames, hasItem(name));
}
/**
* Assert that aliases are missing
*/
public static void assertAliasesMissing(AliasesExistResponse aliasesExistResponse) {
assertFalse("Aliases shouldn't exist", aliasesExistResponse.exists());
}
/**
* Assert that aliases exist
*/
public static void assertAliasesExist(AliasesExistResponse aliasesExistResponse) {
assertTrue("Aliases should exist", aliasesExistResponse.exists());
}
/*
* matchers
*/