use of org.apache.hudi.common.lock.LockProvider in project hudi by apache.
the class LockManager method lock.
public void lock() {
if (writeConfig.getWriteConcurrencyMode().supportsOptimisticConcurrencyControl()) {
LockProvider lockProvider = getLockProvider();
int retryCount = 0;
boolean acquired = false;
while (retryCount <= maxRetries) {
try {
acquired = lockProvider.tryLock(writeConfig.getLockAcquireWaitTimeoutInMs(), TimeUnit.MILLISECONDS);
if (acquired) {
break;
}
LOG.info("Retrying to acquire lock...");
Thread.sleep(maxWaitTimeInMs);
retryCount++;
} catch (HoodieLockException | InterruptedException e) {
if (retryCount >= maxRetries) {
throw new HoodieLockException("Unable to acquire lock, lock object ", e);
}
}
}
if (!acquired) {
throw new HoodieLockException("Unable to acquire lock, lock object " + lockProvider.getLock());
}
}
}
Aggregations