本文整理汇总了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();