use of io.opentelemetry.context.Scope in project hbase by apache.
the class RecoverableZooKeeper method delete.
/**
* delete is an idempotent operation. Retry before throwing exception.
* This function will not throw NoNodeException if the path does not
* exist.
*/
public void delete(String path, int version) throws InterruptedException, KeeperException {
Span span = TraceUtil.getGlobalTracer().spanBuilder("RecoverableZookeeper.delete").startSpan();
try (Scope scope = span.makeCurrent()) {
RetryCounter retryCounter = retryCounterFactory.create();
// False for first attempt, true for all retries.
boolean isRetry = false;
while (true) {
try {
checkZk().delete(path, version);
return;
} catch (KeeperException e) {
switch(e.code()) {
case NONODE:
if (isRetry) {
LOG.debug("Node " + path + " already deleted. Assuming a " + "previous attempt succeeded.");
return;
}
LOG.debug("Node {} already deleted, retry={}", path, isRetry);
throw e;
case CONNECTIONLOSS:
case OPERATIONTIMEOUT:
case REQUESTTIMEOUT:
retryOrThrow(retryCounter, e, "delete");
break;
default:
throw e;
}
}
retryCounter.sleepUntilNextRetry();
isRetry = true;
}
} finally {
span.end();
}
}
Aggregations