org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder Java Examples
The following examples show how to use
org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginClient.java From openshift-elasticsearch-plugin with Apache License 2.0 | 6 votes |
/** * Create an alias for a pattern * * @param aliases * a map of patterns to alias * @return true if the request was acknowledged */ public boolean alias(Map<String, String> aliases) { return execute(new Callable<Boolean>() { @Override public Boolean call() throws Exception { boolean acknowledged = false; if (aliases.isEmpty()) { LOGGER.trace("The alias map is empty. Nothing to do"); return acknowledged; } IndicesAliasesRequestBuilder builder = client.admin().indices().prepareAliases(); for (Map.Entry<String, String> entry : aliases.entrySet()) { LOGGER.debug("Creating alias for {} as {}", entry.getKey(), entry.getValue()); builder.addAlias(entry.getKey(), entry.getValue()); } IndicesAliasesResponse response = builder.get(); acknowledged = response.isAcknowledged(); LOGGER.debug("Aliases request acknowledged? {}", acknowledged); return acknowledged; } }); }
Example #2
Source File: ElasticsearchClusterRunner.java From elasticsearch-cluster-runner with Apache License 2.0 | 5 votes |
public AcknowledgedResponse updateAlias(final BuilderCallback<IndicesAliasesRequestBuilder> builder) { final AcknowledgedResponse actionGet = builder.apply(client().admin().indices().prepareAliases()).execute().actionGet(); if (!actionGet.isAcknowledged()) { onFailure("Failed to update aliases.", actionGet); } return actionGet; }
Example #3
Source File: SearchUpdaterImpl.java From stash-codesearch-plugin with Apache License 2.0 | 5 votes |
/** * Makes one alias point to another's index, deleting the old index afterwards. Returns true * iff the operation was successful. */ private synchronized boolean redirectAndDeleteAliasedIndex(String fromAlias, String toAlias) { // Find indices corresponding to aliases String fromIndex = getIndexFromAlias(fromAlias); String toIndex = getIndexFromAlias(toAlias); if (toIndex == null) { log.error("{} does not resolve to an index", toAlias); return false; } if (toIndex.equals(fromIndex)) { log.warn("{} and {} resolve to the same index", fromAlias, toAlias); return false; } // Perform alias switch IndicesAliasesRequestBuilder builder = es.getClient().admin().indices().prepareAliases(); if (fromIndex != null) { builder.removeAlias(fromIndex, fromAlias); } builder.addAlias(toIndex, fromAlias).get(); // Delete old index if (fromIndex != null) { es.getClient().admin().indices().prepareDelete(fromIndex).get(); } return true; }
Example #4
Source File: EsEntityIndexImpl.java From usergrid with Apache License 2.0 | 5 votes |
private void addAlias(String indexName) { Timer.Context timer = updateAliasTimer.time(); try { Boolean isAck; final AdminClient adminClient = esProvider.getClient().admin(); String[] indexNames = getIndexes(AliasType.Write); int count = 0; IndicesAliasesRequestBuilder aliasesRequestBuilder = adminClient.indices().prepareAliases(); for (String currentIndex : indexNames) { aliasesRequestBuilder.removeAlias(currentIndex, alias.getWriteAlias()); count++; } if (count > 0) { isAck = aliasesRequestBuilder.execute().actionGet().isAcknowledged(); logger.info("Removed Index Name from Alias=[{}] ACK=[{}]", alias, isAck); } aliasesRequestBuilder = adminClient.indices().prepareAliases(); //Added For Graphite Metrics //add write alias aliasesRequestBuilder.addAlias(indexName, alias.getWriteAlias()); //Added For Graphite Metrics // add read alias aliasesRequestBuilder.addAlias(indexName, alias.getReadAlias()); isAck = aliasesRequestBuilder.execute().actionGet().isAcknowledged(); logger.info("Created new read and write aliases ACK=[{}]", isAck); aliasCache.invalidate(alias); } catch (Exception e) { logger.warn("Failed to create alias ", e); } finally { timer.stop(); } }
Example #5
Source File: AbstractClient.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public IndicesAliasesRequestBuilder prepareAliases() { return new IndicesAliasesRequestBuilder(this, IndicesAliasesAction.INSTANCE); }
Example #6
Source File: IndicesAdminClient.java From Elasticsearch with Apache License 2.0 | 2 votes |
/** * Allows to add/remove aliases from indices. */ IndicesAliasesRequestBuilder prepareAliases();
Example #7
Source File: IndexAliasAdder.java From elasticsearch-helper with Apache License 2.0 | votes |
void addIndexAlias(IndicesAliasesRequestBuilder builder, String index, String alias);