示例#1
0
  @Test
  public void testClusterRerouteNoAcknowledgementDryRun() throws InterruptedException {
    client()
        .admin()
        .indices()
        .prepareCreate("test")
        .setSettings(
            settingsBuilder()
                .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));
  }