use of com.palantir.lock.LockClient in project atlasdb by palantir.
the class LockServiceSerDeTest method testSerialisationAndDeserialisationOfLockResponseWithLockHolders.
@Test
public void testSerialisationAndDeserialisationOfLockResponseWithLockHolders() throws Exception {
HeldLocksToken token = LockServiceTestUtils.getFakeHeldLocksToken("client A", "Fake thread", new BigInteger("1"), "held-lock-1", "logger-lock");
Map<LockDescriptor, LockClient> lockHolders = ImmutableMap.of(StringLockDescriptor.of("lock_id"), LockClient.ANONYMOUS, StringLockDescriptor.of("lock_id2"), LockClient.of("client"));
LockResponse response = new LockResponse(token, lockHolders);
ObjectMapper mapper = new ObjectMapper();
LockResponse deserializedLockResponse = mapper.readValue(mapper.writeValueAsString(response), LockResponse.class);
assertEquals(lockHolders, deserializedLockResponse.getLockHolders());
}
use of com.palantir.lock.LockClient in project atlasdb by palantir.
the class LockServiceSerDeTest method testPathParamSerDeOfAnonymousLockClient.
@Test
public void testPathParamSerDeOfAnonymousLockClient() throws Exception {
LockClient lockClient = LockClient.ANONYMOUS;
String serializedForm = lockClient.toString();
LockClient lockClient1 = new LockClient(serializedForm);
assertEquals(lockClient, lockClient1);
}
use of com.palantir.lock.LockClient in project atlasdb by palantir.
the class LockServiceStateLoggerTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
LockServiceTestUtils.cleanUpLogStateDir();
LockClient clientA = LockClient.of("Client A");
LockClient clientB = LockClient.of("Client B");
LockDescriptor descriptor1 = StringLockDescriptor.of("logger-lock");
LockDescriptor descriptor2 = StringLockDescriptor.of("logger-AAA");
LockRequest request1 = LockRequest.builder(LockCollections.of(ImmutableSortedMap.of(descriptor1, LockMode.WRITE))).blockForAtMost(SimpleTimeDuration.of(1000, TimeUnit.MILLISECONDS)).build();
LockRequest request2 = LockRequest.builder(LockCollections.of(ImmutableSortedMap.of(descriptor2, LockMode.WRITE))).blockForAtMost(SimpleTimeDuration.of(1000, TimeUnit.MILLISECONDS)).build();
outstandingLockRequestMultimap.put(clientA, request1);
outstandingLockRequestMultimap.put(clientB, request2);
outstandingLockRequestMultimap.put(clientA, request2);
HeldLocksToken token = LockServiceTestUtils.getFakeHeldLocksToken("client A", "Fake thread", new BigInteger("1"), "held-lock-1", "logger-lock");
HeldLocksToken token2 = LockServiceTestUtils.getFakeHeldLocksToken("client B", "Fake thread 2", new BigInteger("2"), "held-lock-2", "held-lock-3");
heldLocksTokenMap.putIfAbsent(token, LockServiceImpl.HeldLocks.of(token, LockCollections.of()));
heldLocksTokenMap.putIfAbsent(token2, LockServiceImpl.HeldLocks.of(token2, LockCollections.of()));
LockServiceStateLogger logger = new LockServiceStateLogger(heldLocksTokenMap, outstandingLockRequestMultimap, LockServiceTestUtils.TEST_LOG_STATE_DIR);
logger.logLocks();
}
Aggregations