NameLockResult result = new NameLockResult();
/* Find the existing DatabaseImpl and establish a cursor. */
result.dbImpl = getDb(locker, databaseName, null);
if (result.dbImpl == null) {
throw new DatabaseNotFoundException
("Attempted to " + action + " non-existent database " +
databaseName);
}
/* Get effective rep context and check for replica write. */
result.repContext = getRepContext.get(result.dbImpl);
checkReplicaWrite(locker, result.repContext);
boolean success = false;
try {
result.nameCursor = new CursorImpl(nameDatabase, locker);
/* Position the cursor at the specified NameLN. */
DatabaseEntry key =
new DatabaseEntry(databaseName.getBytes("UTF-8"));
/* See [#16210]. */
boolean found =
(result.nameCursor.searchAndPosition(key, SearchMode.SET,
LockType.WRITE) &
CursorImpl.FOUND) != 0;
if (!found) {
throw new DatabaseNotFoundException
("Attempted to " + action + " non-existent database " +
databaseName);
}
/* Call getCurrentLN to write lock the nameLN. */