*/
public void abortWriteTransaction(Transaction transaction) throws IOException {
refreshTransactionList(transaction.getTableName());
String lockPath = prepareLockNode(transaction.getTableName());
WriteLock wLock = new WriteLock(zkUtil.getSession(), lockPath,
Ids.OPEN_ACL_UNSAFE);
RMLockListener myLockListener = new RMLockListener();
wLock.setLockListener(myLockListener);
try {
boolean lockGrabbed = wLock.lock();
if (lockGrabbed == false) {
//TO DO : Let this request queue up and try obtaining lock.
throw new IOException(
"Unable to obtain lock while aborting transaction. "
+ transaction.toString());
} else {
String tableName = transaction.getTableName();
List<String> colFamilies = transaction.getColumnFamilies();
FamilyRevision revisionData = transaction
.getFamilyRevisionInfo();
for (String cfamily : colFamilies) {
String path = PathUtil.getRunningTxnInfoPath(
baseDir, tableName, cfamily);
zkUtil.updateData(path, revisionData,
ZKUtil.UpdateMode.REMOVE);
path = PathUtil.getAbortInformationPath(baseDir,
tableName, cfamily);
zkUtil.updateData(path, revisionData,
ZKUtil.UpdateMode.APPEND);
}
}
} catch (KeeperException e) {
throw new IOException("Exception while obtaining lock.", e);
} catch (InterruptedException e) {
throw new IOException("Exception while obtaining lock.", e);
} finally {
wLock.unlock();
}
LOG.info("Write Transaction aborted: " + transaction.toString());
}