use of io.strimzi.operator.common.BackOff in project strimzi by strimzi.
the class KafkaConnectApiMockTest method testStatusWithBackOffOtherExceptionStillFails.
@Test
public void testStatusWithBackOffOtherExceptionStillFails(VertxTestContext context) {
Queue<Future<Map<String, Object>>> statusResults = new ArrayBlockingQueue<>(1);
statusResults.add(Future.failedFuture(new ConnectRestException(null, null, 500, null, null)));
KafkaConnectApi api = new MockKafkaConnectApi(vertx, statusResults);
Checkpoint async = context.checkpoint();
api.statusWithBackOff(Reconciliation.DUMMY_RECONCILIATION, backOff, "some-host", 8083, "some-connector").onComplete(context.failing(res -> async.flag()));
}
use of io.strimzi.operator.common.BackOff in project strimzi by strimzi.
the class KafkaConnectApiMockTest method testStatusWithBackOffSucceedingImmediately.
@Test
public void testStatusWithBackOffSucceedingImmediately(VertxTestContext context) {
Queue<Future<Map<String, Object>>> statusResults = new ArrayBlockingQueue<>(1);
statusResults.add(Future.succeededFuture(Collections.emptyMap()));
KafkaConnectApi api = new MockKafkaConnectApi(vertx, statusResults);
Checkpoint async = context.checkpoint();
api.statusWithBackOff(Reconciliation.DUMMY_RECONCILIATION, backOff, "some-host", 8083, "some-connector").onComplete(context.succeeding(res -> async.flag()));
}
use of io.strimzi.operator.common.BackOff in project strimzi by strimzi.
the class KafkaConnectApiMockTest method testStatusWithBackOffFailingRepeatedly.
@Test
public void testStatusWithBackOffFailingRepeatedly(VertxTestContext context) {
Queue<Future<Map<String, Object>>> statusResults = new ArrayBlockingQueue<>(4);
statusResults.add(Future.failedFuture(new ConnectRestException(null, null, 404, null, null)));
statusResults.add(Future.failedFuture(new ConnectRestException(null, null, 404, null, null)));
statusResults.add(Future.failedFuture(new ConnectRestException(null, null, 404, null, null)));
statusResults.add(Future.failedFuture(new ConnectRestException(null, null, 404, null, null)));
KafkaConnectApi api = new MockKafkaConnectApi(vertx, statusResults);
Checkpoint async = context.checkpoint();
api.statusWithBackOff(Reconciliation.DUMMY_RECONCILIATION, backOff, "some-host", 8083, "some-connector").onComplete(context.failing(res -> async.flag()));
}
use of io.strimzi.operator.common.BackOff in project strimzi by strimzi.
the class KafkaConnectApiMockTest method testStatusWithBackOffSuccedingEventually.
@Test
public void testStatusWithBackOffSuccedingEventually(VertxTestContext context) {
Queue<Future<Map<String, Object>>> statusResults = new ArrayBlockingQueue<>(3);
statusResults.add(Future.failedFuture(new ConnectRestException(null, null, 404, null, null)));
statusResults.add(Future.failedFuture(new ConnectRestException(null, null, 404, null, null)));
statusResults.add(Future.succeededFuture(Collections.emptyMap()));
KafkaConnectApi api = new MockKafkaConnectApi(vertx, statusResults);
Checkpoint async = context.checkpoint();
api.statusWithBackOff(Reconciliation.DUMMY_RECONCILIATION, backOff, "some-host", 8083, "some-connector").onComplete(context.succeeding(res -> async.flag()));
}
use of io.strimzi.operator.common.BackOff in project strimzi-kafka-operator by strimzi.
the class ZookeeperLeaderFinder method zookeeperLeaderWithBackoff.
private Future<String> zookeeperLeaderWithBackoff(Reconciliation reconciliation, Set<String> pods, NetClientOptions netClientOptions) {
Promise<String> result = Promise.promise();
BackOff backOff = backOffSupplier.get();
Handler<Long> handler = new Handler<Long>() {
@Override
public void handle(Long tid) {
zookeeperLeader(reconciliation, pods, netClientOptions).onComplete(leader -> {
if (leader.succeeded()) {
if (!UNKNOWN_LEADER.equals(leader.result())) {
result.complete(leader.result());
} else {
rescheduleOrComplete(reconciliation, tid);
}
} else {
LOGGER.debugOp("Ignoring error", leader.cause());
if (backOff.done()) {
result.complete(UNKNOWN_LEADER);
} else {
rescheduleOrComplete(reconciliation, tid);
}
}
});
}
void rescheduleOrComplete(Reconciliation reconciliation, Long tid) {
if (backOff.done()) {
LOGGER.warnCr(reconciliation, "Giving up trying to find the leader of {}/{} after {} attempts taking {}ms", reconciliation.name(), reconciliation.namespace(), backOff.maxAttempts(), backOff.totalDelayMs());
result.complete(UNKNOWN_LEADER);
} else {
// Schedule ourselves to run again
long delay = backOff.delayMs();
LOGGER.infoCr(reconciliation, "No leader found for cluster {} in namespace {}; " + "backing off for {}ms (cumulative {}ms)", reconciliation.name(), reconciliation.namespace(), delay, backOff.cumulativeDelayMs());
if (delay < 1) {
this.handle(tid);
} else {
vertx.setTimer(delay, this);
}
}
}
};
handler.handle(null);
return result.future();
}
Aggregations