use of org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse in project fesen-httpclient by codelibs.
the class HttpAliasesExistAction method execute.
public void execute(final GetAliasesRequest request, final ActionListener<AliasesExistResponse> listener) {
getCurlRequest(request).execute(response -> {
boolean exists = false;
switch(response.getHttpStatusCode()) {
case 200:
exists = true;
break;
case 404:
exists = false;
break;
default:
throw new OpenSearchException("Unexpected status: " + response.getHttpStatusCode());
}
try {
final AliasesExistResponse aliasesExistResponse = new AliasesExistResponse(exists);
listener.onResponse(aliasesExistResponse);
} catch (final Exception e) {
listener.onFailure(toOpenSearchException(response, e));
}
}, e -> unwrapOpenSearchException(listener, e));
}
use of org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse in project fesen-httpclient by codelibs.
the class OpenSearchClientTest method test_aliases_exist.
@Test
void test_aliases_exist() throws Exception {
final String index = "test_aliases_exist";
final String alias1 = "test_alias1";
final String alias2 = "test_alias2";
CountDownLatch latch = new CountDownLatch(1);
client.admin().indices().prepareCreate(index).execute().actionGet();
client.admin().indices().prepareAliases().addAlias(index, alias1).execute().actionGet();
client.admin().indices().prepareAliasesExist(alias1).execute(wrap(res -> {
assertTrue(res.isExists());
latch.countDown();
}, e -> {
e.printStackTrace();
try {
fail();
} finally {
latch.countDown();
}
}));
latch.await();
{
client.admin().indices().prepareAliases().addAlias(index, alias2).execute().actionGet();
AliasesExistResponse aliasesExistResponse = client.admin().indices().prepareAliasesExist(alias2).execute().actionGet();
assertTrue(aliasesExistResponse.isExists());
}
}
use of org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse in project fesen-httpclient by codelibs.
the class Elasticsearch7ClientTest method test_aliases_exist.
@Test
void test_aliases_exist() throws Exception {
final String index = "test_aliases_exist";
final String alias1 = "test_alias1";
final String alias2 = "test_alias2";
CountDownLatch latch = new CountDownLatch(1);
client.admin().indices().prepareCreate(index).execute().actionGet();
client.admin().indices().prepareAliases().addAlias(index, alias1).execute().actionGet();
client.admin().indices().prepareAliasesExist(alias1).execute(wrap(res -> {
assertTrue(res.isExists());
latch.countDown();
}, e -> {
e.printStackTrace();
try {
fail();
} finally {
latch.countDown();
}
}));
latch.await();
{
client.admin().indices().prepareAliases().addAlias(index, alias2).execute().actionGet();
AliasesExistResponse aliasesExistResponse = client.admin().indices().prepareAliasesExist(alias2).execute().actionGet();
assertTrue(aliasesExistResponse.isExists());
}
}
use of org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse in project fesen-httpclient by codelibs.
the class Elasticsearch8ClientTest method test_aliases_exist.
@Test
void test_aliases_exist() throws Exception {
final String index = "test_aliases_exist";
final String alias1 = "test_alias1";
final String alias2 = "test_alias2";
CountDownLatch latch = new CountDownLatch(1);
client.admin().indices().prepareCreate(index).execute().actionGet();
client.admin().indices().prepareAliases().addAlias(index, alias1).execute().actionGet();
client.admin().indices().prepareAliasesExist(alias1).execute(wrap(res -> {
assertTrue(res.isExists());
latch.countDown();
}, e -> {
e.printStackTrace();
try {
fail();
} finally {
latch.countDown();
}
}));
latch.await();
{
client.admin().indices().prepareAliases().addAlias(index, alias2).execute().actionGet();
AliasesExistResponse aliasesExistResponse = client.admin().indices().prepareAliasesExist(alias2).execute().actionGet();
assertTrue(aliasesExistResponse.isExists());
}
}
Aggregations