use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class AtlasBackupServiceTest method completeBackupUnregistersLocks.
@Test
public void completeBackupUnregistersLocks() {
Set<AtlasService> oneService = ImmutableSet.of(ATLAS_SERVICE);
Set<Namespace> oneNamespace = ImmutableSet.of(NAMESPACE);
Set<InProgressBackupToken> tokens = ImmutableSet.of(IN_PROGRESS);
when(atlasBackupClient.prepareBackup(authHeader, PrepareBackupRequest.of(oneNamespace))).thenReturn(PrepareBackupResponse.of(tokens));
CompletedBackup completedBackup = completedBackup();
when(atlasBackupClient.completeBackup(authHeader, CompleteBackupRequest.of(tokens))).thenReturn(CompleteBackupResponse.of(ImmutableSet.of(completedBackup)));
atlasBackupService.prepareBackup(oneService);
atlasBackupService.completeBackup(oneService);
verify(lockRefresher).unregisterLocks(tokens);
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class CassandraRepairEteTest method setUp.
@Before
public void setUp() {
int replicationFactor = 2;
config = ThreeNodeCassandraCluster.getKvsConfig();
runtimeConfig = ThreeNodeCassandraCluster.getRuntimeConfig(replicationFactor);
kvs = CassandraKeyValueServiceImpl.createForTesting(config, runtimeConfig);
TransactionTables.createTables(kvs);
kvs.createTable(TABLE_REF, AtlasDbConstants.GENERIC_TABLE_METADATA);
kvs.putUnlessExists(TABLE_REF, ImmutableMap.of(NONEMPTY_CELL, CONTENTS));
KvsRunner kvsRunner = KvsRunner.create(_unused -> kvs);
Function<AtlasService, CassandraKeyValueServiceConfig> configFactory = _unused -> config;
Function<AtlasService, Refreshable<CassandraKeyValueServiceRuntimeConfig>> runtimeConfigFactory = _unused -> runtimeConfig;
Function<AtlasService, CassandraClusterConfig> cassandraClusterConfigFunction = atlasService -> CassandraClusterConfig.of(configFactory.apply(atlasService), runtimeConfigFactory.apply(atlasService).get());
Function<AtlasService, Refreshable<CassandraServersConfig>> cassandraServersConfigFactory = runtimeConfigFactory.andThen(runtimeConfig -> runtimeConfig.map(CassandraKeyValueServiceRuntimeConfig::servers));
cassandraRepairHelper = new CassandraRepairHelper(kvsRunner, cassandraClusterConfigFunction, cassandraServersConfigFactory);
cluster = new ClusterFactory(Cluster::builder).constructCluster(cassandraClusterConfigFunction.apply(ATLAS_SERVICE), cassandraServersConfigFactory.apply(ATLAS_SERVICE).get());
cqlCluster = new CqlCluster(cluster, cassandraServersConfigFactory.apply(ATLAS_SERVICE).get(), NAMESPACE);
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class MultiClientCommitTimestampGetterTest method updatesCacheWhileProcessingResponse.
@Test
public void updatesCacheWhileProcessingResponse() {
Namespace client = Namespace.of("Kitty");
List<BatchElement<NamespacedRequest, Long>> batchElements = IntStream.range(0, COMMIT_TS_LIMIT_PER_REQUEST * 2).mapToObj(ind -> batchElementForNamespace(client)).collect(toList());
setupServiceAndAssertSanityOfResponse(batchElements);
LockWatchCache cache = lockWatchCacheMap.get(client);
verify(cache, times(2)).processCommitTimestampsUpdate(any(), any());
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class MultiClientCommitTimestampGetterTest method doesNotUpdateCacheIfClientNotServed.
@Test
public void doesNotUpdateCacheIfClientNotServed() {
Namespace alpha = Namespace.of("alpha" + UUID.randomUUID());
Namespace beta = Namespace.of("beta" + UUID.randomUUID());
BatchElement<NamespacedRequest, Long> requestForAlpha = batchElementForNamespace(alpha);
BatchElement<NamespacedRequest, Long> requestForBeta = batchElementForNamespace(beta);
List<BatchElement<NamespacedRequest, Long>> allRequests = ImmutableList.of(requestForAlpha, requestForBeta);
List<BatchElement<NamespacedRequest, Long>> alphaRequestList = ImmutableList.of(requestForAlpha);
Map<Namespace, GetCommitTimestampsResponse> responseMap = getCommitTimestamps(alphaRequestList);
when(timelockService.getCommitTimestamps(any())).thenReturn(responseMap).thenThrow(EXCEPTION);
assertThatThrownBy(() -> consumer.accept(allRequests)).isEqualTo(EXCEPTION);
// assert requests made by client alpha are served
assertSanityOfResponse(alphaRequestList, ImmutableMap.of(alpha, ImmutableList.of(responseMap.get(alpha))));
LockWatchCache alphaCache = lockWatchCacheMap.get(alpha);
verify(alphaCache).processCommitTimestampsUpdate(any(), any());
assertThat(requestForBeta.result().isDone()).as("No requests made by client - beta were successful").isFalse();
LockWatchCache betaCache = lockWatchCacheMap.get(beta);
verify(betaCache, never()).processCommitTimestampsUpdate(any(), any());
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class MultiClientTransactionStarterTest method servesRequestsAsSoonAsResponseIsReceived.
@Test
public void servesRequestsAsSoonAsResponseIsReceived() {
Namespace namespace = Namespace.of("Test" + UUID.randomUUID());
UUID requestorId = UUID.randomUUID();
BatchElement<NamespaceAndRequestParams, List<StartIdentifiedAtlasDbTransactionResponse>> requestToBeServed = batchElementForNamespace(namespace, 1);
BatchElement<NamespaceAndRequestParams, List<StartIdentifiedAtlasDbTransactionResponse>> requestNotToBeServed = batchElementForNamespace(namespace, PARTITIONED_TIMESTAMPS_LIMIT_PER_SERVER_CALL * 5);
ImmutableList<BatchElement<NamespaceAndRequestParams, List<StartIdentifiedAtlasDbTransactionResponse>>> requests = ImmutableList.of(requestToBeServed, requestNotToBeServed);
Map<Namespace, ConjureStartTransactionsResponse> responseMap = startTransactionsResponse(requests, requestorId);
when(timelockService.startTransactions(any())).thenReturn(responseMap).thenThrow(EXCEPTION);
assertThatThrownBy(() -> processBatch(timelockService, requestorId, requests)).isEqualTo(EXCEPTION);
// assert first request is served even if server throws on next request
assertSanityOfRequestBatch(ImmutableList.of(requestToBeServed), ImmutableMap.of(namespace, ImmutableList.of(responseMap.get(namespace))));
assertThat(requestNotToBeServed.result().isDone()).isFalse();
LockCleanupService relevantLockCleanupService = LOCK_CLEANUP_SERVICE_MAP.get(namespace);
verify(relevantLockCleanupService).refreshLockLeases(any());
verify(relevantLockCleanupService).unlock(any());
/*
* For one space, all requests are accumulated, and we attempt to fetch as many respones as possible from the
* server. Concretely, the queue here contains 25 demands for a response. The first one succeeds, but the
* next four fail (and each batch size is five), and thus we get four calls to clean up.
*/
verify(NAMESPACE_CACHE_MAP.get(namespace), times(4)).removeTransactionStateFromCache(anyLong());
}
Aggregations