final RepGroupDB.NodeBinding mib = new RepGroupDB.NodeBinding();
final RepGroupImpl.BarrierState barrierState =
new RepGroupImpl.BarrierState(newCBVLSN,
System.currentTimeMillis());
Txn txn = null;
Cursor cursor = null;
boolean ok = false;
try {
txn = new MasterTxn(repImpl,
NO_ACK_NO_SYNC,
repImpl.getNameIdPair());
cursor = makeCursor(groupDbImpl, txn, CursorConfig.DEFAULT);
OperationStatus status =
cursor.getSearchKey(nodeNameKey, value, LockMode.RMW);
if (status != OperationStatus.SUCCESS) {
throw EnvironmentFailureException.unexpectedState
("Node ID: " + nameIdPair + " not present in group db");
}
/* Let's see if the entry needs updating. */
RepNodeImpl node = mib.entryToObject(value);
final VLSN lastCBVLSN = node.getBarrierState().getLastCBVLSN();
if (lastCBVLSN.equals(newCBVLSN)) {
ok = true;
return true;
}
node.setBarrierState(barrierState);
mib.objectToEntry(node, value);
status = cursor.putCurrent(value);
if (status != OperationStatus.SUCCESS) {
throw EnvironmentFailureException.unexpectedState
("Node ID: " + nameIdPair +
" stored localCBVLSN could not be updated. Status: " +
status);
}
LoggerUtils.fine(logger, repImpl,
"Local CBVLSN updated to " + newCBVLSN +
" for node " + nameIdPair);
ok = true;
} finally {
if (cursor != null) {
cursor.close();
}
if (txn != null) {
if (ok) {
txn.commit(NO_ACK_NO_SYNC_DURABILITY);