StringBinding.stringToEntry(ensureNode.getName(), nodeNameKey);
DatabaseEntry value = new DatabaseEntry();
final RepGroupDB.NodeBinding mib = new RepGroupDB.NodeBinding();
Txn txn = null;
Cursor cursor = null;
try {
txn = new ReadonlyTxn(repImpl, NO_ACK);
CursorConfig config = new CursorConfig();
config.setReadCommitted(true);
cursor = makeCursor(groupDbImpl, txn, config);
OperationStatus status =
cursor.getSearchKey(nodeNameKey, value, null);
if (status == OperationStatus.SUCCESS) {
/* Let's see if the entry needs updating. */
RepNodeImpl miInDb = mib.entryToObject(value);
if (miInDb.equivalent(ensureNode)) {
if (miInDb.isQuorumAck()) {
/* Present, matched and acknowledged. */
return;
}
ensureNode.getNameIdPair().update(miInDb.getNameIdPair());
/* Not acknowledged, retry the update. */
} else {
/* Present but not equivalent. */
LoggerUtils.warning(logger, repImpl,
"Incompatible node descriptions. " +
"Membership database definition: " +
miInDb.toString() +
" Transient definition: " +
ensureNode.toString());
throw EnvironmentFailureException.unexpectedState
("Incompatible node descriptions for node ID: " +
ensureNode.getNodeId());
}
LoggerUtils.info(logger, repImpl,
"Present but not ack'd node: " +
ensureNode.getNodeId() +
" ack status: " + miInDb.isQuorumAck());
}
cursor.close();
cursor = null;
txn.commit();
txn = null;
} finally {
if (cursor != null) {
cursor.close();
}
if (txn != null) {
txn.abort();
}
}
createMember(ensureNode);