use of com.thinkbiganalytics.metadata.modeshape.support.MetadataLockException in project kylo by Teradata.
the class JcrMetadataAccess method doCommit.
protected <R> R doCommit(Credentials creds, MetadataCommand<R> cmd, MetadataRollbackCommand rollbackCmd) throws RepositoryException, Exception {
TransactionManager txnMgr = this.txnLookup.getTransactionManager();
try {
txnMgr.begin();
R result = execute(creds, cmd);
activeSession.get().session.save();
checkinNodes();
txnMgr.commit();
performPostTransactionActions(true);
return result;
} catch (MetadataLockException | LockException e) {
try {
txnMgr.rollback();
} catch (SystemException se) {
log.error("Failed to rollback transaction as a result of lock acquisition failure", se);
}
activeSession.get().session.refresh(false);
throw e;
} catch (Exception e) {
log.warn("Exception while execution a transactional operation - rolling back", e);
try {
txnMgr.rollback();
} catch (SystemException se) {
log.error("Failed to rollback transaction as a result of other transactional errors", se);
}
if (rollbackCmd != null) {
try {
rollbackCmd.execute(e);
} catch (Exception rbe) {
log.error("Failed to execution rollback command", rbe);
}
}
activeSession.get().session.refresh(false);
performPostTransactionActions(false);
throw e;
} finally {
activeSession.get().session.logout();
}
}
use of com.thinkbiganalytics.metadata.modeshape.support.MetadataLockException in project kylo by Teradata.
the class JcrMetadataAccess method commit.
public <R> R commit(Credentials creds, MetadataCommand<R> cmd, MetadataRollbackCommand rollbackCmd) {
ActiveSession active = activeSession.get();
if (active == null) {
try {
activeSession.set(new ActiveSession(this.repository.login(creds)));
try {
Exception failException = null;
while (failException == null) {
try {
return doCommit(creds, cmd, rollbackCmd);
} catch (MetadataLockException | LockException e) {
// If a lock acquisition failed then retry the command if the number of retries has not been exceeded.
if (activeSession.get().retriesRemaining > 0) {
activeSession.get().decrementRetry();
log.debug("Failed to aquire lock - retries remaining: {}", activeSession.get().retriesRemaining, e);
try {
Thread.sleep(activeSession.get().retryDelay);
} catch (InterruptedException ie) {
// Just continue.
}
// Start a new session before the retry.
activeSession.get().updateSession(this.repository.login(creds));
} else {
performPostTransactionActions(false);
failException = e;
}
} catch (Exception e) {
failException = e;
}
}
throw failException;
} finally {
activeSession.remove();
postTransactionActions.remove();
checkedOutNodes.remove();
}
} catch (RuntimeException e) {
throw e;
} catch (RepositoryException e) {
throw new MetadataAccessException("Failure accessing the metadata store", e);
} catch (Exception e) {
throw new MetadataExecutionException(e);
}
} else {
try {
return cmd.execute();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new MetadataExecutionException(e);
}
}
}
Aggregations