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);
}
}
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);
}
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);
}
}
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);
}
}
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();
}
}
Aggregations