use of com.b2international.snowowl.core.internal.locks.DatastoreLockContext in project snow-owl by b2ihealthcare.
the class RepositoryRestService method lockGlobal.
@Operation(summary = "Lock all repositories", description = "Places a global lock, which prevents other users from making changes to any of the repositories " + "while a backup is created. The call may block up to the specified timeout to acquire the lock; " + "if timeoutMillis is set to 0, it returns immediately.")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Lock successful"), @ApiResponse(responseCode = "409", description = "Conflicting lock already taken"), @ApiResponse(responseCode = "400", description = "Illegal timeout value, or locking-related issue") })
@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/lock")
public void lockGlobal(@Parameter(description = "lock timeout in milliseconds") @RequestParam(value = "timeoutMillis", defaultValue = "5000", required = false) final int timeoutMillis) {
checkValidTimeout(timeoutMillis);
final DatastoreLockContext context = new DatastoreLockContext(User.SYSTEM.getUsername(), DatastoreLockContextDescriptions.CREATE_BACKUP);
final DatastoreLockTarget target = DatastoreLockTarget.ALL;
doLock(timeoutMillis, context, target);
}
use of com.b2international.snowowl.core.internal.locks.DatastoreLockContext in project snow-owl by b2ihealthcare.
the class RepositoryRestService method lockRepository.
@Operation(summary = "Lock single repository", description = "Places a repository-level lock, which prevents other users from making changes to the specified repository. " + "The call may block up to the specified timeout to acquire the lock; if timeoutMillis is set to 0, " + "it returns immediately.")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Lock successful"), @ApiResponse(responseCode = "409", description = "Conflicting lock already taken"), @ApiResponse(responseCode = "404", description = "Repository not found"), @ApiResponse(responseCode = "400", description = "Illegal timeout value, or locking-related issue") })
@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/{id}/lock")
public void lockRepository(@PathVariable(value = "id") @Parameter(description = "The repository id") final String id, @Parameter(description = "lock timeout in milliseconds") @RequestParam(value = "timeoutMillis", defaultValue = "5000", required = false) final int timeoutMillis) {
checkValidRepositoryUuid(id);
checkValidTimeout(timeoutMillis);
final DatastoreLockContext context = new DatastoreLockContext(User.SYSTEM.getUsername(), DatastoreLockContextDescriptions.CREATE_REPOSITORY_BACKUP, DatastoreLockContextDescriptions.CREATE_BACKUP);
final DatastoreLockTarget target = new DatastoreLockTarget(id, null);
doLock(timeoutMillis, context, target);
}
use of com.b2international.snowowl.core.internal.locks.DatastoreLockContext in project snow-owl by b2ihealthcare.
the class VersionCreateRequest method acquireLocks.
private void acquireLocks(ServiceProvider context, String user, Collection<TerminologyResource> codeSystems) {
this.lockTargetsByContext = HashMultimap.create();
final DatastoreLockContext lockContext = new DatastoreLockContext(user, CREATE_VERSION);
for (TerminologyResource codeSystem : codeSystems) {
final DatastoreLockTarget lockTarget = new DatastoreLockTarget(codeSystem.getToolingId(), codeSystem.getBranchPath());
context.service(IOperationLockManager.class).lock(lockContext, IOperationLockManager.IMMEDIATE, lockTarget);
lockTargetsByContext.put(lockContext, lockTarget);
}
}
use of com.b2international.snowowl.core.internal.locks.DatastoreLockContext in project snow-owl by b2ihealthcare.
the class DatastoreLockTests method testLockAll.
@Test
public void testLockAll() {
final DatastoreLockContext context = createContext(USER, DatastoreLockContextDescriptions.MAINTENANCE);
final DatastoreLockTarget allLockTarget = DatastoreLockTarget.ALL;
manager.lock(context, TIMEOUT, allLockTarget);
checkIfLockExists(context, true, allLockTarget);
manager.unlockAll();
}
use of com.b2international.snowowl.core.internal.locks.DatastoreLockContext in project snow-owl by b2ihealthcare.
the class DatastoreLockTests method testUnlockAll.
@Test
public void testUnlockAll() {
final DatastoreLockContext context = createContext(USER, DatastoreLockContextDescriptions.MAINTENANCE);
final DatastoreLockTarget target1 = new DatastoreLockTarget("snomedStore", "MAIN");
final DatastoreLockTarget target2 = new DatastoreLockTarget("loincStore", "MAIN");
manager.lock(context, TIMEOUT, target1, target2);
checkIfLockExists(context, true, target1, target2);
manager.unlockAll();
checkIfLockExists(context, false, target1, target2);
}
Aggregations