Пример #1
0
 private boolean waitForStatus(ClusterHealthStatus status) {
   ClusterHealthRequestBuilder healthRequest = client.admin().cluster().prepareHealth();
   healthRequest.setTimeout(TIMEOUT);
   healthRequest.setWaitForStatus(status);
   ClusterHealthResponse response = (ClusterHealthResponse) healthRequest.execute().actionGet();
   return !response.isTimedOut();
 }
  @Test
  public void trace_logs() {
    logTester.setLevel(LoggerLevel.TRACE);

    ClusterHealthRequestBuilder requestBuilder = esTester.client().prepareHealth();
    ClusterHealthResponse state = requestBuilder.get();
    assertThat(state.getStatus()).isEqualTo(ClusterHealthStatus.GREEN);

    assertThat(logTester.logs()).hasSize(1);
  }
  @Override
  public ClusterHealthResponse getClusterHealthResponse(long timeout) {
    Client client = getClient();

    AdminClient adminClient = client.admin();

    ClusterAdminClient clusterAdminClient = adminClient.cluster();

    ClusterHealthRequestBuilder clusterHealthRequestBuilder = clusterAdminClient.prepareHealth();

    clusterHealthRequestBuilder.setTimeout(TimeValue.timeValueMillis(timeout));

    clusterHealthRequestBuilder.setWaitForYellowStatus();

    Future<ClusterHealthResponse> future = clusterHealthRequestBuilder.execute();

    try {
      return future.get();
    } catch (Exception e) {
      throw new IllegalStateException(e);
    }
  }
 @Test
 public void state() {
   ClusterHealthRequestBuilder requestBuilder = esTester.client().prepareHealth();
   ClusterHealthResponse state = requestBuilder.get();
   assertThat(state.getStatus()).isEqualTo(ClusterHealthStatus.GREEN);
 }