use of com.b2international.snowowl.core.internal.locks.DatastoreLockContext in project snow-owl by b2ihealthcare.
the class DefaultOperationLockManager method unlock.
@Override
public void unlock(final DatastoreLockContext context, final Iterable<DatastoreLockTarget> targets) throws IllegalArgumentException {
final Map<DatastoreLockTarget, DatastoreLockContext> notUnlockedTargets = Maps.newHashMap();
synchronized (syncObject) {
for (final DatastoreLockTarget targetToUnlock : targets) {
for (final IOperationLock existingLock : getExistingLocks()) {
if (existingLock.targetEquals(targetToUnlock) && !canContextUnlock(context, existingLock)) {
notUnlockedTargets.put(existingLock.getTarget(), existingLock.getContext());
}
}
}
if (!notUnlockedTargets.isEmpty()) {
LOG.warn(buildMessage(RELEASE_FAILED_MESSAGE, context, notUnlockedTargets));
}
for (final DatastoreLockTarget targetToUnlock : targets) {
final IOperationLock existingLock = getOrCreateLock(context, targetToUnlock);
try {
existingLock.release(context);
fireTargetReleased(existingLock.getTarget(), context);
} finally {
if (!existingLock.isLocked()) {
removeLock(existingLock);
}
}
}
syncObject.notifyAll();
}
}
use of com.b2international.snowowl.core.internal.locks.DatastoreLockContext in project snow-owl by b2ihealthcare.
the class DatastoreLockTests method testUnlock.
@Test
public void testUnlock() {
final DatastoreLockContext context = createContext(USER, DatastoreLockContextDescriptions.MAINTENANCE);
final DatastoreLockTarget target = new DatastoreLockTarget("snomedStore", "MAIN");
manager.lock(context, TIMEOUT, target);
checkIfLockExists(context, true, target);
manager.unlock(context, target);
checkIfLockExists(context, false, target);
}
use of com.b2international.snowowl.core.internal.locks.DatastoreLockContext in project snow-owl by b2ihealthcare.
the class DatastoreLockTests method testLockBranchAndRepository.
@Test
public void testLockBranchAndRepository() {
final DatastoreLockContext context = createContext(USER, DatastoreLockContextDescriptions.CREATE_VERSION);
final DatastoreLockTarget target = new DatastoreLockTarget("snomedStore", "MAIN");
manager.lock(context, 10_000L, target);
checkIfLockExists(context, true, target);
}
use of com.b2international.snowowl.core.internal.locks.DatastoreLockContext in project snow-owl by b2ihealthcare.
the class DatastoreLockTests method testLockAllNotAbleToLockAnother.
@Test(expected = LockedException.class)
public void testLockAllNotAbleToLockAnother() {
final DatastoreLockContext context = createContext(USER, DatastoreLockContextDescriptions.MAINTENANCE);
final DatastoreLockTarget allLockTarget = DatastoreLockTarget.ALL;
manager.lock(context, 1_000L, allLockTarget);
manager.lock(context, 1_000L, allLockTarget);
}
use of com.b2international.snowowl.core.internal.locks.DatastoreLockContext in project snow-owl by b2ihealthcare.
the class RepositoryRestService method unlockRepository.
@Operation(summary = "Unlock single repository", description = "Releases a previously acquired repository-level lock on the specified repository.")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Unlock successful"), @ApiResponse(responseCode = "404", description = "Repository not found"), @ApiResponse(responseCode = "400", description = "Unspecified unlock-related issue") })
@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/{id}/unlock")
public void unlockRepository(@Parameter(description = "The repository id") @PathVariable(value = "id") final String repositoryUuid) {
checkValidRepositoryUuid(repositoryUuid);
final DatastoreLockContext context = new DatastoreLockContext(User.SYSTEM.getUsername(), DatastoreLockContextDescriptions.CREATE_REPOSITORY_BACKUP, DatastoreLockContextDescriptions.CREATE_BACKUP);
final DatastoreLockTarget target = new DatastoreLockTarget(repositoryUuid, null);
doUnlock(context, target);
}
Aggregations