@Override public void abortTransaction(ITransactionContext txnCtx, DatasetId datasetId, int PKHashVal) throws ACIDException { if (txnCtx.getTxnState() != ITransactionManager.ABORTED) { txnCtx.setTxnState(ITransactionManager.ABORTED); } try { if (txnCtx.isWriteTxn()) { LogRecord logRecord = ((TransactionContext) txnCtx).getLogRecord(); logRecord.formJobTerminateLogRecord(txnCtx, false); txnSubsystem.getLogManager().log(logRecord); txnSubsystem.getRecoveryManager().rollbackTransaction(txnCtx); } } catch (Exception ae) { String msg = "Could not complete rollback! System is in an inconsistent state"; if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe(msg); } ae.printStackTrace(); throw new ACIDException(msg, ae); } finally { ((TransactionContext) txnCtx).cleanupForAbort(); txnSubsystem.getLockManager().releaseLocks(txnCtx); transactionContextRepository.remove(txnCtx.getJobId()); } }
@Override public void commitTransaction(ITransactionContext txnCtx, DatasetId datasetId, int PKHashVal) throws ACIDException { // Only job-level commits call this method. try { if (txnCtx.isWriteTxn()) { LogRecord logRecord = ((TransactionContext) txnCtx).getLogRecord(); logRecord.formJobTerminateLogRecord(txnCtx, true); txnSubsystem.getLogManager().log(logRecord); } } catch (Exception ae) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe(" caused exception in commit !" + txnCtx.getJobId()); } throw ae; } finally { txnSubsystem.getLockManager().releaseLocks(txnCtx); // release transactionContextRepository.remove(txnCtx.getJobId()); txnCtx.setTxnState(ITransactionManager.COMMITTED); } }