Search in sources :

Example 16 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class ElasticsearchStorage method ensureIndexTemplatesAndClusterReady.

/**
 * This allows the health check to display problems, such as access, installing the index
 * template. It also helps reduce traffic sent to nodes still initializing (when guarded on the
 * check result). Finally, this reads the cluster health of the index as it can go down after the
 * one-time initialization passes.
 */
CheckResult ensureIndexTemplatesAndClusterReady(String index) {
    try {
        // ensure the version is available (even if we already cached it)
        version();
        // called only once, so we have to double-check health
        ensureIndexTemplates();
        AggregatedHttpRequest request = AggregatedHttpRequest.of(GET, "/_cluster/health/" + index);
        CheckResult result = http().newCall(request, READ_STATUS, "get-cluster-health").execute();
        if (result == null)
            throw new IllegalArgumentException("No content reading cluster health");
        return result;
    } catch (Throwable e) {
        Call.propagateIfFatal(e);
        // Unwrap any IOException from the first call to ensureIndexTemplates()
        if (e instanceof RejectedExecutionException || e instanceof UncheckedIOException) {
            e = e.getCause();
        }
        return CheckResult.failed(e);
    }
}
Also used : CheckResult(zipkin2.CheckResult) UncheckedIOException(java.io.UncheckedIOException) AggregatedHttpRequest(com.linecorp.armeria.common.AggregatedHttpRequest) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 17 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class CassandraStorageTest method check_failsInsteadOfThrowing.

@Test
public void check_failsInsteadOfThrowing() {
    CheckResult result = CassandraStorage.newBuilder().contactPoints("1.1.1.1").build().check();
    assertThat(result.ok()).isFalse();
    assertThat(result.error()).isInstanceOf(AllNodesFailedException.class);
}
Also used : CheckResult(zipkin2.CheckResult) Test(org.junit.Test)

Example 18 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class KafkaCollector method check.

@Override
public CheckResult check() {
    try {
        // check the kafka workers didn't quit
        CheckResult failure = kafkaWorkers.failure.get();
        if (failure != null)
            return failure;
        KafkaFuture<String> maybeClusterId = getAdminClient().describeCluster().clusterId();
        maybeClusterId.get(1, TimeUnit.SECONDS);
        return CheckResult.OK;
    } catch (Throwable e) {
        Call.propagateIfFatal(e);
        return CheckResult.failed(e);
    }
}
Also used : CheckResult(zipkin2.CheckResult)

Example 19 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class RabbitMQCollector method check.

@Override
public CheckResult check() {
    try {
        start();
        CheckResult failure = connection.failure.get();
        if (failure != null)
            return failure;
        return CheckResult.OK;
    } catch (Throwable e) {
        Call.propagateIfFatal(e);
        return CheckResult.failed(e);
    }
}
Also used : CheckResult(zipkin2.CheckResult)

Example 20 with CheckResult

use of zipkin2.CheckResult in project zipkin by openzipkin.

the class ScribeCollectorTest method check_failsWhenNotStarted.

@Test
void check_failsWhenNotStarted() {
    try (ScribeCollector scribe = ScribeCollector.newBuilder().storage(storage).port(0).build()) {
        CheckResult result = scribe.check();
        assertThat(result.ok()).isFalse();
        assertThat(result.error()).isInstanceOf(IllegalStateException.class);
        scribe.start();
        assertThat(scribe.check().ok()).isTrue();
    }
}
Also used : CheckResult(zipkin2.CheckResult) Test(org.junit.jupiter.api.Test)

Aggregations

CheckResult (zipkin2.CheckResult)22 Test (org.junit.Test)12 Test (org.junit.jupiter.api.Test)5 ElasticsearchStorage (zipkin2.elasticsearch.ElasticsearchStorage)4 CompletableFuture (java.util.concurrent.CompletableFuture)2 Future (java.util.concurrent.Future)2 Component (zipkin2.Component)2 AggregatedHttpRequest (com.linecorp.armeria.common.AggregatedHttpRequest)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 SQLException (java.sql.SQLException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 DataSource (javax.sql.DataSource)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 Span (zipkin2.Span)1 QueryRequest (zipkin2.storage.QueryRequest)1