當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。