Search in sources :

Example 1 with CheckResult.failed

use of zipkin2.CheckResult.failed in project zipkin by openzipkin.

the class ForwardingStorageComponentTest method delegatesCheck.

@Test
public void delegatesCheck() {
    CheckResult down = CheckResult.failed(new RuntimeException("failed"));
    when(delegate.check()).thenReturn(down);
    assertThat(forwarder.check()).isEqualTo(down);
    verify(delegate).check();
}
Also used : CheckResult(zipkin2.CheckResult) Test(org.junit.Test)

Example 2 with CheckResult.failed

use of zipkin2.CheckResult.failed in project zipkin by openzipkin.

the class ComponentHealthTest method addsMessageToDetails.

@Test
public void addsMessageToDetails() {
    ComponentHealth health = ComponentHealth.ofComponent(new Component() {

        @Override
        public CheckResult check() {
            return CheckResult.failed(new IOException("socket disconnect"));
        }
    });
    assertThat(health.error).isEqualTo("java.io.IOException: socket disconnect");
}
Also used : CheckResult(zipkin2.CheckResult) IOException(java.io.IOException) Component(zipkin2.Component) Test(org.junit.Test)

Example 3 with CheckResult.failed

use of zipkin2.CheckResult.failed in project zipkin by openzipkin.

the class ComponentHealthTest method doesntAddNullMessageToDetails.

@Test
public void doesntAddNullMessageToDetails() {
    ComponentHealth health = ComponentHealth.ofComponent(new Component() {

        @Override
        public CheckResult check() {
            return CheckResult.failed(ClosedSessionException.get());
        }
    });
    assertThat(health.error).isEqualTo("com.linecorp.armeria.common.ClosedSessionException");
}
Also used : CheckResult(zipkin2.CheckResult) Component(zipkin2.Component) Test(org.junit.Test)

Example 4 with CheckResult.failed

use of zipkin2.CheckResult.failed 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 5 with CheckResult.failed

use of zipkin2.CheckResult.failed 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)

Aggregations

CheckResult (zipkin2.CheckResult)6 Test (org.junit.Test)3 Component (zipkin2.Component)2 AggregatedHttpRequest (com.linecorp.armeria.common.AggregatedHttpRequest)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1