use of io.searchbox.indices.aliases.ModifyAliases in project graylog2-server by Graylog2.
the class ClientES6 method addAliasMapping.
@Override
public void addAliasMapping(String indexName, String alias) {
final AddAliasMapping addAliasMapping = new AddAliasMapping.Builder(indexName, alias).build();
final ModifyAliases addAliasRequest = new ModifyAliases.Builder(addAliasMapping).build();
executeWithExpectedSuccess(addAliasRequest, "failed to add alias " + alias + " for index " + indexName);
}
use of io.searchbox.indices.aliases.ModifyAliases in project graylog2-server by Graylog2.
the class IndicesAdapterES6 method cycleAlias.
@Override
public void cycleAlias(String aliasName, String targetIndex, String oldIndex) {
final AliasMapping addAliasMapping = new AddAliasMapping.Builder(targetIndex, aliasName).build();
final AliasMapping removeAliasMapping = new RemoveAliasMapping.Builder(oldIndex, aliasName).build();
final ModifyAliases request = new ModifyAliases.Builder(Arrays.asList(removeAliasMapping, addAliasMapping)).build();
JestUtils.execute(jestClient, request, () -> "Couldn't switch alias " + aliasName + " from index " + oldIndex + " to index " + targetIndex);
}
use of io.searchbox.indices.aliases.ModifyAliases in project herd by FINRAOS.
the class IndexFunctionsDaoImpl method createIndex.
/**
* The create index function will take as arguments the index name, document type, and mapping and will create a new index.
*/
@Override
public final void createIndex(String indexName, String documentType, String mapping, String settings, String alias) {
LOGGER.info("Creating Elasticsearch index, indexName={}, documentType={}.", indexName, documentType);
CreateIndex createIndex = new CreateIndex.Builder(indexName).settings(Settings.builder().loadFromSource(settings).build()).build();
PutMapping putMapping = new PutMapping.Builder(indexName, documentType, mapping).build();
ModifyAliases modifyAliases = new ModifyAliases.Builder(new AddAliasMapping.Builder(indexName, alias).build()).build();
JestResult jestResult = jestClientHelper.executeAction(createIndex);
LOGGER.info("Creating Elasticsearch index, indexName={}, documentType={} successful={}", indexName, documentType, jestResult.isSucceeded());
jestResult = jestClientHelper.executeAction(putMapping);
LOGGER.info("Creating Elasticsearch index put mappings, indexName={}, documentType={} successful={}", indexName, documentType, jestResult.isSucceeded());
jestResult = jestClientHelper.executeAction(modifyAliases);
LOGGER.info("Creating Elasticsearch index alias, indexName={}, alias={}", indexName, alias, jestResult.isSucceeded());
// If there are failures log them
if (!jestResult.isSucceeded()) {
LOGGER.error("Error in index creation= {}", jestResult.getErrorMessage());
}
}
use of io.searchbox.indices.aliases.ModifyAliases in project graylog2-server by Graylog2.
the class IndicesAdapterES6 method removeAliases.
@Override
public void removeAliases(Set<String> indices, String alias) {
final AliasMapping removeAliasMapping = new RemoveAliasMapping.Builder(ImmutableList.copyOf(indices), alias).build();
final ModifyAliases request = new ModifyAliases.Builder(removeAliasMapping).build();
JestUtils.execute(jestClient, request, () -> "Couldn't remove alias " + alias + " from indices " + indices);
}
use of io.searchbox.indices.aliases.ModifyAliases in project graylog2-server by Graylog2.
the class IndicesAdapterES6 method markIndexReopened.
@Override
public void markIndexReopened(String index) {
final String aliasName = index + Indices.REOPENED_ALIAS_SUFFIX;
final ModifyAliases request = new ModifyAliases.Builder(new AddAliasMapping.Builder(index, aliasName).build()).build();
JestUtils.execute(jestClient, request, () -> "Couldn't create reopened alias for index " + index);
}
Aggregations