use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdaterTest method doesNotReEnableIfSomeNamespaceDisabledWithOtherLock.
// Case B: re-enable with wrong lock -> don't re-enable anywhere
@Test
public void doesNotReEnableIfSomeNamespaceDisabledWithOtherLock() {
Set<Namespace> disabledNamespaces = ImmutableSet.of(OTHER_NAMESPACE);
SingleNodeUpdateResponse unsuccessfulResponse = singleNodeUpdateFailure(disabledNamespaces);
when(remote1.reenable(any(), any())).thenReturn(unsuccessfulResponse);
when(remote2.reenable(any(), any())).thenReturn(unsuccessfulResponse);
when(localUpdater.reEnable(any())).thenReturn(unsuccessfulResponse);
ReenableNamespacesResponse response = updater.reEnableOnAllNodes(AUTH_HEADER, ReenableNamespacesRequest.of(BOTH_NAMESPACES, LOCK_ID));
assertThat(response).isEqualTo(consistentlyLocked(disabledNamespaces));
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class AllNodesDisabledNamespacesUpdaterTest method reportsRollbackFailures.
@Test
public void reportsRollbackFailures() {
Set<Namespace> failedNamespaces = ImmutableSet.of(OTHER_NAMESPACE);
when(remote1.disable(any(), any())).thenReturn(SUCCESSFUL_SINGLE_NODE_UPDATE);
when(remote2.disable(any(), any())).thenReturn(singleNodeUpdateFailure(failedNamespaces));
when(localUpdater.getNamespacesLockedWithDifferentLockId(any(), any())).thenReturn(ImmutableMap.of());
when(remote1.reenable(any(), any())).thenReturn(singleNodeUpdateFailure(failedNamespaces));
DisableNamespacesResponse response = updater.disableOnAllNodes(AUTH_HEADER, disableNamespacesRequest(BOTH_NAMESPACES));
verify(remote1).reenable(any(), any());
verify(remote2, never()).reenable(any(), any());
verify(localUpdater).getNamespacesLockedWithDifferentLockId(any(), any());
verifyNoMoreInteractions(localUpdater);
assertThat(response).isEqualTo(partiallyDisabled(failedNamespaces));
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class MultiClientConjureTimelockResourceTest method handlesNotCurrentLeaderExceptions.
@Test
public void handlesNotCurrentLeaderExceptions() {
String throwingClient = "alpha";
Set<Namespace> namespaces = ImmutableSet.of(Namespace.of(throwingClient), Namespace.of("beta"));
when(getServiceForClient(throwingClient).leaderTime()).thenThrow(new NotCurrentLeaderException("Not the leader!"));
assertThatThrownBy(() -> Futures.getUnchecked(resource.leaderTimes(AUTH_HEADER, namespaces))).hasCauseInstanceOf(RetryOther.class).hasRootCauseMessage("Suggesting request retry against: " + REMOTE);
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class TokenRangeFetcher method getTokenRange.
public Map<InetSocketAddress, RangeSet<LightweightOppToken>> getTokenRange(String tableName) {
KeyspaceMetadata keyspaceMetadata = cqlMetadata.getKeyspaceMetadata(namespace);
if (keyspaceMetadata == null) {
log.error("Could not find metadata for a keyspace that is supposed to exist", SafeArg.of("keyspace", namespace));
return ImmutableMap.of();
}
TableMetadata tableMetadata = keyspaceMetadata.getTable(tableName);
if (tableMetadata == null) {
log.error("Could not find metadata for table that is supposed to exist", SafeArg.of("keyspace", namespace), SafeArg.of("tableName", tableName));
return ImmutableMap.of();
}
Set<LightweightOppToken> partitionTokens = getPartitionTokens(tableMetadata);
Map<InetSocketAddress, RangeSet<LightweightOppToken>> tokenRangesByNode = ClusterMetadataUtils.getTokenMapping(CassandraServersConfigs.getCqlHosts(cassandraServersConfig), cqlMetadata, namespace, partitionTokens);
if (!partitionTokens.isEmpty() && log.isDebugEnabled()) {
int numTokenRanges = tokenRangesByNode.values().stream().mapToInt(ranges -> ranges.asRanges().size()).sum();
log.debug("Identified token ranges requiring repair", SafeArg.of("keyspace", namespace), SafeArg.of("table", tableName), SafeArg.of("numPartitionKeys", partitionTokens.size()), SafeArg.of("numTokenRanges", numTokenRanges));
}
return tokenRangesByNode;
}
use of com.palantir.atlasdb.timelock.api.Namespace in project atlasdb by palantir.
the class AtlasBackupServiceTest method completeBackupStoresBackupInfoAndMetadata.
@Test
public void completeBackupStoresBackupInfoAndMetadata() {
ImmutableSet<Namespace> oneNamespace = ImmutableSet.of(NAMESPACE);
ImmutableSet<AtlasService> oneService = ImmutableSet.of(ATLAS_SERVICE);
when(atlasBackupClient.prepareBackup(authHeader, PrepareBackupRequest.of(oneNamespace))).thenReturn(PrepareBackupResponse.of(ImmutableSet.of(IN_PROGRESS)));
CompletedBackup completedBackup = completedBackup();
when(atlasBackupClient.completeBackup(authHeader, CompleteBackupRequest.of(ImmutableSet.of(IN_PROGRESS)))).thenReturn(CompleteBackupResponse.of(ImmutableSet.of(completedBackup)));
atlasBackupService.prepareBackup(oneService);
atlasBackupService.completeBackup(oneService);
verify(coordinationServiceRecorder).storeFastForwardState(ATLAS_SERVICE, completedBackup);
assertThat(backupPersister.getCompletedBackup(ATLAS_SERVICE)).contains(completedBackup);
}
Aggregations