@Test public void verifySerializedBatchOfLockRequestsSmallerThan45MB() throws InterruptedException, IOException { Set<LockRefreshToken> tokens = new HashSet<>(); for (int i = 0; i < LockRefreshingLockService.REFRESH_BATCH_SIZE / 1000; i++) { LockRequest request = LockRequest.builder( ImmutableSortedMap.of(StringLockDescriptor.of(UUID.randomUUID().toString()), LockMode.READ)) .timeoutAfter(SimpleTimeDuration.of(10, TimeUnit.MILLISECONDS)) .build(); tokens.add(lockServiceWithSlowLogDisabled.lock("test", request)); } Assertions.assertThat(new ObjectMapper().writeValueAsString(tokens).length()).isLessThan(45_000); }
@Override public LockRefreshToken lock(String client, LockRequest request) throws InterruptedException { com.palantir.logsafe.Preconditions.checkArgument(request.getLockGroupBehavior() == LockGroupBehavior.LOCK_ALL_OR_NONE, "lock() only supports LockGroupBehavior.LOCK_ALL_OR_NONE. Consider using lockAndGetHeldLocks()."); LockResponse result = lockWithFullLockResponse(LockClient.of(client), request); return result.success() ? result.getLockRefreshToken() : null; }
LockServiceImpl implements LockService, CloseableRemoteLockService, CloseableLockService, RemoteLockService, LockServiceImplMBean { @Override public LockRefreshToken lock(String client, LockRequest request) throws InterruptedException { com.palantir.logsafe.Preconditions.checkArgument(request.getLockGroupBehavior() == LockGroupBehavior.LOCK_ALL_OR_NONE, "lock() only supports LockGroupBehavior.LOCK_ALL_OR_NONE. Consider using lockAndGetHeldLocks()."); LockResponse result = lockWithFullLockResponse(LockClient.of(client), request); return result.success() ? result.getLockRefreshToken() : null; } }
LockServiceImpl implements LockService, CloseableRemoteLockService, CloseableLockService, RemoteLockService, LockServiceImplMBean { @Override public LockRefreshToken lock(String client, LockRequest request) throws InterruptedException { com.palantir.logsafe.Preconditions.checkArgument(request.getLockGroupBehavior() == LockGroupBehavior.LOCK_ALL_OR_NONE, "lock() only supports LockGroupBehavior.LOCK_ALL_OR_NONE. Consider using lockAndGetHeldLocks()."); LockResponse result = lockWithFullLockResponse(LockClient.of(client), request); return result.success() ? result.getLockRefreshToken() : null; } private  LockServiceImpl(LockServerOptions options, Runnable callOnClose, Ownable<ExecutorService> executor); }
LockServiceImpl implements LockService, CloseableRemoteLockService, CloseableLockService, RemoteLockService, LockServiceImplMBean { @Override public LockRefreshToken lock(String client, LockRequest request) throws InterruptedException { com.palantir.logsafe.Preconditions.checkArgument(request.getLockGroupBehavior() == LockGroupBehavior.LOCK_ALL_OR_NONE, "lock() only supports LockGroupBehavior.LOCK_ALL_OR_NONE. Consider using lockAndGetHeldLocks()."); LockResponse result = lockWithFullLockResponse(LockClient.of(client), request); return result.success() ? result.getLockRefreshToken() : null; } private  LockServiceImpl(LockServerOptions options, Runnable callOnClose, Ownable<ExecutorService> executor); static LockServiceImpl create(); static LockServiceImpl create(LockServerOptions options); static LockServiceImpl create(LockServerOptions options, ExecutorService injectedExecutor); @Override LockRefreshToken lock(String client, LockRequest request); @Override HeldLocksToken lockAndGetHeldLocks(String client, LockRequest request); @Override // We're concerned about sanitizing logs at the info level and above. This method just logs at debug and info. LockResponse lockWithFullLockResponse(LockClient client, LockRequest request); @Override boolean unlock(LockRefreshToken token); @Override boolean unlock(HeldLocksToken token); @Override boolean unlockSimple(SimpleHeldLocksToken token); @Override boolean unlockAndFreeze(HeldLocksToken token); @Override Set<HeldLocksToken> getTokens(LockClient client); @Override Set<HeldLocksToken> refreshTokens(Iterable<HeldLocksToken> tokens); @Override Set<LockRefreshToken> refreshLockRefreshTokens(Iterable<LockRefreshToken> tokens); @Override @Nullable HeldLocksGrant refreshGrant(HeldLocksGrant grant); @Override @Nullable HeldLocksGrant refreshGrant(BigInteger grantId); @Override HeldLocksGrant convertToGrant(HeldLocksToken token); @Override HeldLocksToken useGrant(LockClient client, HeldLocksGrant grant); @Override HeldLocksToken useGrant(LockClient client, BigInteger grantId); @Override @Nullable Long getMinLockedInVersionId(); @Override Long getMinLockedInVersionId(String client); @Override @Nullable Long getMinLockedInVersionId(LockClient client); @Override LockServerOptions getLockServerOptions(); @Override void logCurrentState(); @Override void close(); @Override long currentTimeMillis(); }
LockServiceImpl implements LockService, CloseableRemoteLockService, CloseableLockService, RemoteLockService, LockServiceImplMBean { @Override public LockRefreshToken lock(String client, LockRequest request) throws InterruptedException { com.palantir.logsafe.Preconditions.checkArgument(request.getLockGroupBehavior() == LockGroupBehavior.LOCK_ALL_OR_NONE, "lock() only supports LockGroupBehavior.LOCK_ALL_OR_NONE. Consider using lockAndGetHeldLocks()."); LockResponse result = lockWithFullLockResponse(LockClient.of(client), request); return result.success() ? result.getLockRefreshToken() : null; } private  LockServiceImpl(LockServerOptions options, Runnable callOnClose, Ownable<ExecutorService> executor); static LockServiceImpl create(); static LockServiceImpl create(LockServerOptions options); static LockServiceImpl create(LockServerOptions options, ExecutorService injectedExecutor); @Override LockRefreshToken lock(String client, LockRequest request); @Override HeldLocksToken lockAndGetHeldLocks(String client, LockRequest request); @Override // We're concerned about sanitizing logs at the info level and above. This method just logs at debug and info. LockResponse lockWithFullLockResponse(LockClient client, LockRequest request); @Override boolean unlock(LockRefreshToken token); @Override boolean unlock(HeldLocksToken token); @Override boolean unlockSimple(SimpleHeldLocksToken token); @Override boolean unlockAndFreeze(HeldLocksToken token); @Override Set<HeldLocksToken> getTokens(LockClient client); @Override Set<HeldLocksToken> refreshTokens(Iterable<HeldLocksToken> tokens); @Override Set<LockRefreshToken> refreshLockRefreshTokens(Iterable<LockRefreshToken> tokens); @Override @Nullable HeldLocksGrant refreshGrant(HeldLocksGrant grant); @Override @Nullable HeldLocksGrant refreshGrant(BigInteger grantId); @Override HeldLocksGrant convertToGrant(HeldLocksToken token); @Override HeldLocksToken useGrant(LockClient client, HeldLocksGrant grant); @Override HeldLocksToken useGrant(LockClient client, BigInteger grantId); @Override @Nullable Long getMinLockedInVersionId(); @Override Long getMinLockedInVersionId(String client); @Override @Nullable Long getMinLockedInVersionId(LockClient client); @Override LockServerOptions getLockServerOptions(); @Override void logCurrentState(); @Override void close(); @Override long currentTimeMillis(); static final int RANDOM_BIT_COUNT; static final String SECURE_RANDOM_ALGORITHM; static final int SECURE_RANDOM_POOL_SIZE; }