@Override
public void acquireObjectLock(List<String> lites, int timeoutInSeconds, boolean waitForLockIfLocked,
String requestUuid) throws LockingException {
Timeout timeout = new Timeout(Duration.create(timeoutInSeconds, "seconds"));
if (StringUtils.isBlank(requestUuid)) {
throw new LockingException("One must provide valid (i.e. non blank) request uuid!");
}
Object result = null;
Future<Object> future = Patterns.ask(jobsManager,
Messages.newJobsManagerAcquireLock(lites, waitForLockIfLocked, timeoutInSeconds, requestUuid), timeout);
try {
result = Await.result(future, timeout.duration());
} catch (Exception e) {
LOGGER.error("Unable to acquire locks for the objects being processed '{}'", lites, e);
throw new AcquireLockTimeoutException("Unable to acquire locks for the objects being processed '" + lites + "'");
}
if (result != null && result instanceof Messages.JobsManagerNotLockableAtTheTime) {
throw new NotLockableAtTheTimeException(
"Not lockable at the time due to requester not willing to await to obtain the lock!");
}
}