本文整理汇总了Java中org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder类的典型用法代码示例。如果您正苦于以下问题:Java IndicesAliasesRequestBuilder类的具体用法?Java IndicesAliasesRequestBuilder怎么用?Java IndicesAliasesRequestBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndicesAliasesRequestBuilder类属于org.elasticsearch.action.admin.indices.alias包,在下文中一共展示了IndicesAliasesRequestBuilder类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testAddAlias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
@Test
public void testAddAlias() {
//Test data
final String indexName = "index";
final String aliasName = "alias";
final AdminClient adminClient = createMock(AdminClient.class);
final IndicesAdminClient indicesAdminClient = createMock(IndicesAdminClient.class);
final IndicesAliasesRequestBuilder indicesAliasesRequestBuilder = createMock(IndicesAliasesRequestBuilder.class);
final IndicesAliasesResponse indicesAliasesResponse = createMock(IndicesAliasesResponse.class);
//Reset
resetAll();
//Expectations
expect(esClient.admin()).andReturn(adminClient);
expect(adminClient.indices()).andReturn(indicesAdminClient);
expect(indicesAdminClient.prepareAliases()).andReturn(indicesAliasesRequestBuilder);
expect(indicesAliasesRequestBuilder.addAlias(indexName, aliasName)).andReturn(indicesAliasesRequestBuilder);
expect(indicesAliasesRequestBuilder.get()).andReturn(indicesAliasesResponse);
//Replay
replayAll();
//Run test scenario
final boolean result = elasticsearchClientWrapper.addAlias(indexName, aliasName);
//Verify
verifyAll();
assertEquals(indicesAliasesResponse.isAcknowledged(), result);
}
开发者ID:Biacode,项目名称:escommons,代码行数:26,代码来源:ElasticsearchClientWrapperImplTest.java
示例2: alias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
/**
* 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) {
boolean acknowledged = false;
if (aliases.isEmpty()) {
LOGGER.trace("The alias map is empty. Nothing to do");
return acknowledged;
}
IndicesAliasesRequestBuilder builder = this.client.admin().indices().prepareAliases();
addCommonHeaders(builder);
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;
}
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:25,代码来源:PluginClient.java
示例3: testExistsByAliasTrue
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
@Test
public void testExistsByAliasTrue () {
//create index
final CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
createIndexRequestBuilder.execute().actionGet();
//create alias
String alias = "test_alias";
IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ().addAlias (indexName, alias);
IndicesAliasesResponse response = builder.execute ().actionGet ();
assertTrue(response.isAcknowledged ());
//test exists
IndexAdminHelper helper = new IndexAdminHelperImpl (client);
assertTrue(helper.exists (alias));
}
开发者ID:dfci-cccb,项目名称:mev,代码行数:17,代码来源:TestIndexAdminHelperImpl.java
示例4: testGetIndexAliases
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
@Test
public void testGetIndexAliases(){
//Create index
final CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
@SuppressWarnings ("unused")
CreateIndexResponse createIndexResponse = createIndexRequestBuilder.execute().actionGet();
//Put the alias
String alias = "test_alias";
IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ().addAlias (indexName, alias);
IndicesAliasesResponse response = builder.execute ().actionGet ();
assertTrue(response.isAcknowledged ());
IndexAdminHelper helper = new IndexAdminHelperImpl (client);
List<AliasMetaData> aliases = helper.getIndexAliases (indexName);
if(log.isDebugEnabled ())
for(AliasMetaData aliasMetaData : aliases)
log.debug(String.format("***** Internal Index Name: %s", aliasMetaData.alias ()));
assertEquals (1, aliases.size ());
assertEquals (alias, aliases.get (0).alias ());
}
开发者ID:dfci-cccb,项目名称:mev,代码行数:25,代码来源:TestIndexAdminHelperImpl.java
示例5: testGetIndexNameForAlias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
@Test
public void testGetIndexNameForAlias() throws IndexAdminException{
//Create index
final CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
@SuppressWarnings ("unused")
CreateIndexResponse createIndexResponse = createIndexRequestBuilder.execute().actionGet();
//Put the alias
String alias = "test_alias";
IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ().addAlias (indexName, alias);
IndicesAliasesResponse response = builder.execute ().actionGet ();
assertTrue(response.isAcknowledged ());
IndexAdminHelper helper = new IndexAdminHelperImpl (client);
String theIndexName = helper.getIndexNameForAlias(alias);
log.debug(String.format("**** The index name: %s", theIndexName));
assertEquals (indexName, theIndexName);
}
开发者ID:dfci-cccb,项目名称:mev,代码行数:20,代码来源:TestIndexAdminHelperImpl.java
示例6: activateIndex
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
/**
* Activates an index by moving the alias from the old index to the new one.
*/
@Override
public void activateIndex(String indexName, String aliasName) {
Map<String, Set<String>> indexAliasMap = getIndexAliases();
IndicesAliasesRequestBuilder builder = indicesAdminClient().prepareAliases();
if (indexAliasMap.size() > 0) {
Set<String> aliasNames = indexAliasMap.keySet();
for (String an : aliasNames) {
Set<String> indexNames = indexAliasMap.get(an);
for (String in : indexNames) {
if (an.equals(aliasName)) {
log.info("Removing alias '" + an + "' from index '" + in + "'.");
builder.removeAlias(in, an);
}
}
}
}
IndicesAliasesResponse response = builder.addAlias(indexName, aliasName).execute().actionGet();
log.info("activateIndex: [indexName=" + indexName + ", aliasName=" + aliasName + ", isAcknowledged="
+ response.isAcknowledged() + "].");
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:31,代码来源:DefaultElasticsearchIndexHelper.java
示例7: updateAlias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
public IndicesAliasesResponse updateAlias(
final BuilderCallback<IndicesAliasesRequestBuilder> builder) {
final IndicesAliasesResponse actionGet = builder
.apply(client().admin().indices().prepareAliases()).execute()
.actionGet();
if (!actionGet.isAcknowledged()) {
onFailure("Failed to update aliases.", actionGet);
}
return actionGet;
}
开发者ID:codelibs,项目名称:elasticsearch-cluster-runner,代码行数:11,代码来源:ElasticsearchClusterRunner.java
示例8: redirectAndDeleteAliasedIndex
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
/**
* 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;
}
开发者ID:palantir,项目名称:stash-codesearch-plugin,代码行数:34,代码来源:SearchUpdaterImpl.java
示例9: redirectIndexAlias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
@Override
public IndicesAliasesResponse redirectIndexAlias(String alias, String oldIndexName, String newIndexName){
IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ()
.removeAlias (oldIndexName, alias)
.addAlias (newIndexName, alias);
IndicesAliasesResponse response = builder.execute ().actionGet ();
return response;
}
开发者ID:dfci-cccb,项目名称:mev,代码行数:9,代码来源:IndexAdminHelperImpl.java
示例10: addAlias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
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();
}
}
开发者ID:apache,项目名称:usergrid,代码行数:38,代码来源:EsEntityIndexImpl.java
示例11: createNextIndex
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
public void createNextIndex() {
try {
final List<String> prevIndices = new ArrayList<>();
final IndicesExistsResponse response =
client.admin().indices().prepareExists(getUpdateAlias(index)).execute().actionGet(suggestSettings.getIndicesTimeout());
if (response.isExists()) {
GetAliasesResponse getAliasesResponse =
client.admin().indices().prepareGetAliases(getUpdateAlias(index)).execute().actionGet();
getAliasesResponse.getAliases().keysIt().forEachRemaining(prevIndices::add);
}
final String mappingSource = getDefaultMappings();
final String settingsSource = getDefaultIndexSettings();
final String indexName = createIndexName(index);
CreateIndexResponse createIndexResponse =
client.admin().indices().prepareCreate(indexName).setSettings(settingsSource.toString(), XContentType.JSON)
.addMapping(type, mappingSource, XContentType.JSON).execute().actionGet(suggestSettings.getIndicesTimeout());
if (!createIndexResponse.isAcknowledged()) {
throw new SuggesterException("Failed to create index");
}
client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet(suggestSettings.getClusterTimeout());
final IndicesAliasesRequestBuilder aliasesRequestBuilder =
client.admin().indices().prepareAliases().addAlias(indexName, getUpdateAlias(index));
for (final String prevIndex : prevIndices) {
aliasesRequestBuilder.removeAlias(prevIndex, getUpdateAlias(index));
}
aliasesRequestBuilder.execute().actionGet();
} catch (final Exception e) {
throw new SuggesterException("Failed to create index.", e);
}
}
开发者ID:codelibs,项目名称:fess-suggest,代码行数:33,代码来源:Suggester.java
示例12: prepareAliases
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
@Override
public IndicesAliasesRequestBuilder prepareAliases() {
return new IndicesAliasesRequestBuilder(this, IndicesAliasesAction.INSTANCE);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java
示例13: putIndexAlias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
@Override
public IndicesAliasesResponse putIndexAlias(String indexName, String alias){
IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ().addAlias (indexName, alias);
IndicesAliasesResponse response = builder.execute ().actionGet ();
return response;
}
开发者ID:dfci-cccb,项目名称:mev,代码行数:7,代码来源:IndexAdminHelperImpl.java
示例14: removeIndexAlias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
@Override
public IndicesAliasesResponse removeIndexAlias(String indexName, String alias){
IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ().removeAlias (indexName, alias);
IndicesAliasesResponse response = builder.execute ().actionGet ();
return response;
}
开发者ID:dfci-cccb,项目名称:mev,代码行数:7,代码来源:IndexAdminHelperImpl.java
示例15: prepareAliases
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
/**
* Allows to add/remove aliases from indices.
*/
IndicesAliasesRequestBuilder prepareAliases();
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:IndicesAdminClient.java
示例16: addIndexAlias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; //导入依赖的package包/类
void addIndexAlias(IndicesAliasesRequestBuilder builder, String index, String alias);
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:2,代码来源:IndexAliasAdder.java
注:本文中的org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论