use of com.palantir.lock.CloseableLockService in project atlasdb by palantir.
the class LockCreator method createThreadPoolingLockService.
public CloseableLockService createThreadPoolingLockService() {
// TODO (jkong): Live reload slow lock timeout, plus clients (issue #2342)
// TODO (?????): Rewrite ThreadPooled to cope with live reload, and/or remove ThreadPooled (if using Async)
TimeLockRuntimeConfiguration timeLockRuntimeConfiguration = runtime.get();
CloseableLockService lockServiceNotUsingThreadPooling = createTimeLimitedLockService(timeLockRuntimeConfiguration.slowLockLogTriggerMillis());
if (!deprecated.useClientRequestLimit()) {
return lockServiceNotUsingThreadPooling;
}
int availableThreads = deprecated.availableThreads();
// TODO(nziebart): Since the number of clients can grow dynamically, we can't compute a correct and useful
// value for the local threadpool size at this point. Given that async lock service exists, and doesn't need
// a thread pool, it's likely we won't fix this and will eventually remove the thread pooled lock service.
// However, for the time being, it's still useful to have global limiting for services that need to use the
// legacy lock service.
int localThreadPoolSize = -1;
int sharedThreadPoolSize = availableThreads;
synchronized (this) {
if (sharedThreadPool.availablePermits() == -1) {
sharedThreadPool.release(sharedThreadPoolSize + 1);
}
}
return new ThreadPooledLockService(lockServiceNotUsingThreadPooling, localThreadPoolSize, sharedThreadPool);
}
use of com.palantir.lock.CloseableLockService in project atlasdb by palantir.
the class ThreadPooledLockServiceTest method closesDelegate.
@Test
public void closesDelegate() throws IOException {
CloseableLockService delegate = mock(CloseableLockService.class);
ThreadPooledLockService pooledService = new ThreadPooledLockService(delegate, 1, new Semaphore(1));
pooledService.close();
verify(delegate).close();
}
use of com.palantir.lock.CloseableLockService in project atlasdb by palantir.
the class SnapshotTransactionManagerTest method canCloseTransactionManagerWithNonCloseableLockService.
@Test
public void canCloseTransactionManagerWithNonCloseableLockService() {
SnapshotTransactionManager newTransactionManager = new SnapshotTransactionManager(keyValueService, new LegacyTimelockService(new InMemoryTimestampService(), closeableLockService, LockClient.of("lock")), // not closeable
mock(LockService.class), null, null, null, null, cleaner, false, () -> AtlasDbConstants.DEFAULT_TRANSACTION_LOCK_ACQUIRE_TIMEOUT_MS, TimestampTrackerImpl.createNoOpTracker(), TransactionTestConstants.GET_RANGES_THREAD_POOL_SIZE, TransactionTestConstants.DEFAULT_GET_RANGES_CONCURRENCY, () -> AtlasDbConstants.DEFAULT_TIMESTAMP_CACHE_SIZE, MultiTableSweepQueueWriter.NO_OP);
// should not throw
newTransactionManager.close();
}
Aggregations