use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest in project elasticsearch by elastic.
the class RestIndicesAliasesAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout()));
indicesAliasesRequest.timeout(request.paramAsTime("timeout", indicesAliasesRequest.timeout()));
try (XContentParser parser = request.contentParser()) {
PARSER.parse(parser, indicesAliasesRequest, null);
}
if (indicesAliasesRequest.getAliasActions().isEmpty()) {
throw new IllegalArgumentException("No action specified");
}
return channel -> client.admin().indices().aliases(indicesAliasesRequest, new AcknowledgedRestListener<>(channel));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest in project crate by crate.
the class SchemasITest method testTableAlias.
@Test
public void testTableAlias() throws Exception {
execute("create table terminator (model string, good boolean, actor object)");
IndicesAliasesRequest request = new IndicesAliasesRequest();
request.addAlias("entsafter", "terminator");
client().admin().indices().aliases(request).actionGet();
ensureYellow();
DocTableInfo terminatorTable = (DocTableInfo) schemas.getTableInfo(new TableIdent(null, "terminator"));
DocTableInfo entsafterTable = (DocTableInfo) schemas.getTableInfo(new TableIdent(null, "entsafter"));
assertNotNull(terminatorTable);
assertFalse(terminatorTable.isAlias());
assertNotNull(entsafterTable);
assertTrue(entsafterTable.isAlias());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest in project crate by crate.
the class SchemasITest method testAliasPartitions.
@Test
public void testAliasPartitions() throws Exception {
execute("create table terminator (model string, good boolean, actor object)");
execute("create table transformer (model string, good boolean, actor object)");
IndicesAliasesRequest request = new IndicesAliasesRequest();
request.addAlias("entsafter", "terminator");
request.addAlias("entsafter", "transformer");
client().admin().indices().aliases(request).actionGet();
ensureYellow();
DocTableInfo entsafterTable = (DocTableInfo) schemas.getTableInfo(new TableIdent(null, "entsafter"));
assertNotNull(entsafterTable);
assertThat(entsafterTable.concreteIndices().length, is(2));
assertThat(Arrays.asList(entsafterTable.concreteIndices()), containsInAnyOrder("terminator", "transformer"));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest in project graylog2-server by Graylog2.
the class IndicesTest method testAliasTarget.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testAliasTarget() throws Exception {
assertThat(indices.aliasTarget("graylog_alias")).isNull();
final IndicesAdminClient adminClient = client.admin().indices();
final IndicesAliasesRequest request = adminClient.prepareAliases().addAlias(INDEX_NAME, "graylog_alias").request();
final IndicesAliasesResponse response = adminClient.aliases(request).actionGet(ES_TIMEOUT);
assertThat(response.isAcknowledged()).isTrue();
assertThat(indices.aliasTarget("graylog_alias")).isEqualTo(INDEX_NAME);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest in project graylog2-server by Graylog2.
the class ClientES7 method removeAliasMapping.
@Override
public void removeAliasMapping(String indexName, String alias) {
final IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
final AliasActions aliasAction = new AliasActions(AliasActions.Type.REMOVE).index(indexName).alias(alias);
indicesAliasesRequest.addAliasAction(aliasAction);
client.execute((c, requestOptions) -> c.indices().updateAliases(indicesAliasesRequest, requestOptions), "failed to remove alias " + alias + " for index " + indexName);
}
Aggregations