Search in sources :

Example 11 with IndicesAliasesRequest

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest in project graylog2-server by Graylog2.

the class IndicesAdapterES7 method cycleAlias.

@Override
public void cycleAlias(String aliasName, String targetIndex, String oldIndex) {
    final IndicesAliasesRequest.AliasActions addAlias = new IndicesAliasesRequest.AliasActions(IndicesAliasesRequest.AliasActions.Type.ADD).index(targetIndex).alias(aliasName);
    final IndicesAliasesRequest.AliasActions removeAlias = new IndicesAliasesRequest.AliasActions(IndicesAliasesRequest.AliasActions.Type.REMOVE).index(oldIndex).alias(aliasName);
    final IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest().addAliasAction(removeAlias).addAliasAction(addAlias);
    client.execute((c, requestOptions) -> c.indices().updateAliases(indicesAliasesRequest, requestOptions), "Couldn't switch alias " + aliasName + " from index " + oldIndex + " to index " + targetIndex);
}
Also used : IndicesAliasesRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)

Example 12 with IndicesAliasesRequest

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest in project graylog2-server by Graylog2.

the class IndicesAdapterES7 method removeAliases.

@Override
public void removeAliases(Set<String> indices, String alias) {
    final IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
    final IndicesAliasesRequest.AliasActions aliasAction = IndicesAliasesRequest.AliasActions.remove().alias(alias).indices(indices.toArray(new String[0]));
    indicesAliasesRequest.addAliasAction(aliasAction);
    client.execute((c, requestOptions) -> c.indices().updateAliases(indicesAliasesRequest, requestOptions), "Couldn't remove alias " + alias + " from indices " + indices);
}
Also used : IndicesAliasesRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)

Example 13 with IndicesAliasesRequest

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest in project graylog2-server by Graylog2.

the class ClientES7 method addAliasMapping.

@Override
public void addAliasMapping(String indexName, String alias) {
    final IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
    final AliasActions aliasAction = new AliasActions(AliasActions.Type.ADD).index(indexName).alias(alias);
    indicesAliasesRequest.addAliasAction(aliasAction);
    client.execute((c, requestOptions) -> c.indices().updateAliases(indicesAliasesRequest, requestOptions), "failed to add alias " + alias + " for index " + indexName);
}
Also used : IndicesAliasesRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest) AliasActions(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions)

Aggregations

IndicesAliasesRequest (org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)8 IndicesAliasesRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)5 IOException (java.io.IOException)3 AliasActions (org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions)3 NodeClient (org.elasticsearch.client.node.NodeClient)3 Settings (org.elasticsearch.common.settings.Settings)3 BaseRestHandler (org.elasticsearch.rest.BaseRestHandler)3 RestController (org.elasticsearch.rest.RestController)3 RestRequest (org.elasticsearch.rest.RestRequest)3 AcknowledgedRestListener (org.elasticsearch.rest.action.AcknowledgedRestListener)3 Test (org.junit.Test)3 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)2 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)2 DocTableInfo (io.crate.metadata.doc.DocTableInfo)2 IndicesAliasesResponse (org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse)2 Strings (org.elasticsearch.common.Strings)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 DocWriteRequest (org.elasticsearch.action.DocWriteRequest)1 ClusterSearchShardsRequest (org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsRequest)1