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


Java ClusterRerouteResponse类代码示例

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


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

示例1: testClusterRerouteNoAcknowledgement

import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; //导入依赖的package包/类
public void testClusterRerouteNoAcknowledgement() throws InterruptedException {
    client().admin().indices().prepareCreate("test")
            .setSettings(Settings.builder()
                    .put(SETTING_NUMBER_OF_SHARDS, between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS))
                    .put(SETTING_NUMBER_OF_REPLICAS, 0)).get();
    ensureGreen();

    MoveAllocationCommand moveAllocationCommand = getAllocationCommand();

    ClusterRerouteResponse clusterRerouteResponse = client().admin().cluster().prepareReroute().setTimeout("0s").add(moveAllocationCommand).get();
    assertThat(clusterRerouteResponse.isAcknowledged(), equalTo(false));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:AckIT.java

示例2: testClusterRerouteNoAcknowledgementDryRun

import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; //导入依赖的package包/类
public void testClusterRerouteNoAcknowledgementDryRun() throws InterruptedException {
    client().admin().indices().prepareCreate("test")
            .setSettings(Settings.builder()
                    .put(SETTING_NUMBER_OF_SHARDS, between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS))
                    .put(SETTING_NUMBER_OF_REPLICAS, 0)).get();
    ensureGreen();

    MoveAllocationCommand moveAllocationCommand = getAllocationCommand();

    ClusterRerouteResponse clusterRerouteResponse = client().admin().cluster().prepareReroute().setTimeout("0s").setDryRun(true).add(moveAllocationCommand).get();
    //acknowledged anyway as no changes were made
    assertThat(clusterRerouteResponse.isAcknowledged(), equalTo(true));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:AckIT.java

示例3: toXContent

import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; //导入依赖的package包/类
@Override
protected XContentBuilder toXContent(ClusterRerouteRequest request, ClusterRerouteResponse response, XContentBuilder builder) throws IOException {
    builder.startObject();
    builder.field(Fields.OK, true);
    builder.startObject("state");
    response.getState().settingsFilter(new SettingsFilter(ImmutableSettings.settingsBuilder().build())).toXContent(builder, ToXContent.EMPTY_PARAMS);
    builder.endObject();

    builder.endObject();

    return builder;
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:13,代码来源:ClusterRerouteRequestBuilder.java

示例4: reroute

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

示例5: testRerouteExplain

import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; //导入依赖的package包/类
public void testRerouteExplain() {
    Settings commonSettings = Settings.builder().build();

    logger.info("--> starting a node");
    String node_1 = internalCluster().startNode(commonSettings);

    assertThat(cluster().size(), equalTo(1));
    ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForNodes("1").execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    logger.info("--> create an index with 1 shard");
    client().admin().indices().prepareCreate("test")
            .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0))
            .execute().actionGet();

    ensureGreen("test");

    logger.info("--> disable allocation");
    Settings newSettings = Settings.builder()
            .put(CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), Allocation.NONE.name())
            .build();
    client().admin().cluster().prepareUpdateSettings().setTransientSettings(newSettings).execute().actionGet();

    logger.info("--> starting a second node");
    String node_2 = internalCluster().startNode(commonSettings);
    assertThat(cluster().size(), equalTo(2));
    healthResponse = client().admin().cluster().prepareHealth().setWaitForNodes("2").execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    logger.info("--> try to move the shard from node1 to node2");
    MoveAllocationCommand cmd = new MoveAllocationCommand("test", 0, node_1, node_2);
    ClusterRerouteResponse resp = client().admin().cluster().prepareReroute().add(cmd).setExplain(true).execute().actionGet();
    RoutingExplanations e = resp.getExplanations();
    assertThat(e.explanations().size(), equalTo(1));
    RerouteExplanation explanation = e.explanations().get(0);
    assertThat(explanation.command().name(), equalTo(cmd.name()));
    assertThat(((MoveAllocationCommand)explanation.command()).shardId(), equalTo(cmd.shardId()));
    assertThat(((MoveAllocationCommand)explanation.command()).fromNode(), equalTo(cmd.fromNode()));
    assertThat(((MoveAllocationCommand)explanation.command()).toNode(), equalTo(cmd.toNode()));
    assertThat(explanation.decisions().type(), equalTo(Decision.Type.YES));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:42,代码来源:ClusterRerouteIT.java

示例6: testCreateShrinkIndexFails

import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; //导入依赖的package包/类
/**
 * Tests that we can manually recover from a failed allocation due to shards being moved away etc.
 */
public void testCreateShrinkIndexFails() throws Exception {
    internalCluster().ensureAtLeastNumDataNodes(2);
    prepareCreate("source").setSettings(Settings.builder().put(indexSettings())
        .put("number_of_shards", randomIntBetween(2, 7))
        .put("number_of_replicas", 0)).get();
    for (int i = 0; i < 20; i++) {
        client().prepareIndex("source", randomFrom("t1", "t2", "t3"))
            .setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
    }
    ImmutableOpenMap<String, DiscoveryNode> dataNodes = client().admin().cluster().prepareState().get().getState().nodes()
        .getDataNodes();
    assertTrue("at least 2 nodes but was: " + dataNodes.size(), dataNodes.size() >= 2);
    DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode.class);
    String spareNode = discoveryNodes[0].getName();
    String mergeNode = discoveryNodes[1].getName();
    // ensure all shards are allocated otherwise the ensure green below might not succeed since we require the merge node
    // if we change the setting too quickly we will end up with one replica unassigned which can't be assigned anymore due
    // to the require._name below.
    ensureGreen();
    // relocate all shards to one node such that we can merge it.
    client().admin().indices().prepareUpdateSettings("source")
        .setSettings(Settings.builder().put("index.routing.allocation.require._name", mergeNode)
            .put("index.blocks.write", true)).get();
    ensureGreen();

    // now merge source into a single shard index
    client().admin().indices().prepareShrinkIndex("source", "target")
        .setWaitForActiveShards(ActiveShardCount.NONE)
        .setSettings(Settings.builder()
            .put("index.routing.allocation.exclude._name", mergeNode) // we manually exclude the merge node to forcefully fuck it up
            .put("index.number_of_replicas", 0)
            .put("index.allocation.max_retries", 1).build()).get();
    client().admin().cluster().prepareHealth("target").setWaitForEvents(Priority.LANGUID).get();

    // now we move all shards away from the merge node
    client().admin().indices().prepareUpdateSettings("source")
        .setSettings(Settings.builder().put("index.routing.allocation.require._name", spareNode)
            .put("index.blocks.write", true)).get();
    ensureGreen("source");

    client().admin().indices().prepareUpdateSettings("target") // erase the forcefully fuckup!
        .setSettings(Settings.builder().putNull("index.routing.allocation.exclude._name")).get();
    // wait until it fails
    assertBusy(() -> {
        ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().get();
        RoutingTable routingTables = clusterStateResponse.getState().routingTable();
        assertTrue(routingTables.index("target").shard(0).getShards().get(0).unassigned());
        assertEquals(UnassignedInfo.Reason.ALLOCATION_FAILED,
            routingTables.index("target").shard(0).getShards().get(0).unassignedInfo().getReason());
        assertEquals(1,
            routingTables.index("target").shard(0).getShards().get(0).unassignedInfo().getNumFailedAllocations());
    });
    client().admin().indices().prepareUpdateSettings("source") // now relocate them all to the right node
        .setSettings(Settings.builder()
            .put("index.routing.allocation.require._name", mergeNode)).get();
    ensureGreen("source");

    final InternalClusterInfoService infoService = (InternalClusterInfoService) internalCluster().getInstance(ClusterInfoService.class,
        internalCluster().getMasterName());
    infoService.refresh();
    // kick off a retry and wait until it's done!
    ClusterRerouteResponse clusterRerouteResponse = client().admin().cluster().prepareReroute().setRetryFailed(true).get();
    long expectedShardSize = clusterRerouteResponse.getState().routingTable().index("target")
        .shard(0).getShards().get(0).getExpectedShardSize();
    // we support the expected shard size in the allocator to sum up over the source index shards
    assertTrue("expected shard size must be set but wasn't: " + expectedShardSize, expectedShardSize > 0);
    ensureGreen();
    assertHitCount(client().prepareSearch("target").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), 20);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:73,代码来源:ShrinkIndexIT.java

示例7: doExecute

import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; //导入依赖的package包/类
@Override
protected ActionFuture<ClusterRerouteResponse> doExecute(ClusterRerouteRequest request) {
    return client.admin().cluster().reroute(request);
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:5,代码来源:ClusterRerouteRequestBuilder.java

示例8: reroute

import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; //导入依赖的package包/类
/**
 * Reroutes allocation of shards. Advance API.
 */
ActionFuture<ClusterRerouteResponse> reroute(ClusterRerouteRequest request);
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ClusterAdminClient.java


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