当前位置: 首页>>代码示例>>Java>>正文


Java ClusterRerouteRequestBuilder类代码示例

本文整理汇总了Java中org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder的典型用法代码示例。如果您正苦于以下问题:Java ClusterRerouteRequestBuilder类的具体用法?Java ClusterRerouteRequestBuilder怎么用?Java ClusterRerouteRequestBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClusterRerouteRequestBuilder类属于org.elasticsearch.action.admin.cluster.reroute包,在下文中一共展示了ClusterRerouteRequestBuilder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testForceStaleReplicaToBePromotedToPrimary

import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder; //导入依赖的package包/类
public void testForceStaleReplicaToBePromotedToPrimary() throws Exception {
    boolean useStaleReplica = randomBoolean(); // if true, use stale replica, otherwise a completely empty copy
    createStaleReplicaScenario();

    logger.info("--> explicitly promote old primary shard");
    final String idxName = "test";
    ImmutableOpenIntMap<List<IndicesShardStoresResponse.StoreStatus>> storeStatuses = client().admin().indices().prepareShardStores(idxName).get().getStoreStatuses().get(idxName);
    ClusterRerouteRequestBuilder rerouteBuilder = client().admin().cluster().prepareReroute();
    for (IntObjectCursor<List<IndicesShardStoresResponse.StoreStatus>> shardStoreStatuses : storeStatuses) {
        int shardId = shardStoreStatuses.key;
        IndicesShardStoresResponse.StoreStatus storeStatus = randomFrom(shardStoreStatuses.value);
        logger.info("--> adding allocation command for shard {}", shardId);
        // force allocation based on node id
        if (useStaleReplica) {
            rerouteBuilder.add(new AllocateStalePrimaryAllocationCommand(idxName, shardId, storeStatus.getNode().getId(), true));
        } else {
            rerouteBuilder.add(new AllocateEmptyPrimaryAllocationCommand(idxName, shardId, storeStatus.getNode().getId(), true));
        }
    }
    rerouteBuilder.get();

    logger.info("--> check that the stale primary shard gets allocated and that documents are available");
    ensureYellow(idxName);

    if (useStaleReplica == false) {
        // When invoking AllocateEmptyPrimaryAllocationCommand, due to the UnassignedInfo.Reason being changed to INDEX_CREATION,
        // its possible that the shard has not completed initialization, even though the cluster health is yellow, so the
        // search can throw an "all shards failed" exception.  We will wait until the shard initialization has completed before
        // verifying the search hit count.
        assertBusy(() -> assertTrue(client().admin().cluster().prepareState().get()
                                        .getState().routingTable().index(idxName).allPrimaryShardsActive()));
    }
    assertHitCount(client().prepareSearch(idxName).setSize(0).setQuery(matchAllQuery()).get(), useStaleReplica ? 1L : 0L);

    // allocation id of old primary was cleaned from the in-sync set
    ClusterState state = client().admin().cluster().prepareState().get().getState();
    assertEquals(Collections.singleton(state.routingTable().index(idxName).shard(0).primary.allocationId().getId()),
        state.metaData().index(idxName).inSyncAllocationIds(0));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:PrimaryAllocationIT.java

示例2: prepareReroute

import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder; //导入依赖的package包/类
@Override
public ClusterRerouteRequestBuilder prepareReroute() {
    return new ClusterRerouteRequestBuilder(this, ClusterRerouteAction.INSTANCE);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java

示例3: prepareReroute

import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder; //导入依赖的package包/类
/**
 * Update settings in the cluster.
 */
ClusterRerouteRequestBuilder prepareReroute();
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ClusterAdminClient.java


注:本文中的org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。