本文整理匯總了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));
}
示例2: prepareReroute
import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder; //導入依賴的package包/類
@Override
public ClusterRerouteRequestBuilder prepareReroute() {
return new ClusterRerouteRequestBuilder(this, ClusterRerouteAction.INSTANCE);
}
示例3: prepareReroute
import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder; //導入依賴的package包/類
/**
* Update settings in the cluster.
*/
ClusterRerouteRequestBuilder prepareReroute();