Search in sources :

Example 1 with Transactions2TableInteraction

use of com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction in project atlasdb by palantir.

the class CoordinationServiceUtilitiesTest method cleanMultipleRangesWithSchemasWithinBounds.

@Test
public void cleanMultipleRangesWithSchemasWithinBounds() {
    final long migrateToTxns2 = IMMUTABLE_TIMESTAMP + FASTFORWARD_TIMESTAMP / 2;
    Map<Range<Long>, Integer> rangesWithSchemas = ImmutableMap.of(Range.closedOpen(AtlasDbConstants.STARTING_TS, migrateToTxns2), 1, Range.atLeast(migrateToTxns2), 2);
    final long coordServiceBound = FASTFORWARD_TIMESTAMP + 1000L;
    Optional<InternalSchemaMetadataState> coordService = createCoordService(rangesWithSchemas, coordServiceBound);
    List<TransactionsTableInteraction> txnInteractions = TransactionsTableInteraction.getTransactionTableInteractions(CoordinationServiceUtilities.getCoordinationMapOnRestore(coordService, FASTFORWARD_TIMESTAMP, IMMUTABLE_TIMESTAMP), POLICY);
    assertThat(txnInteractions).hasSize(2);
    TransactionsTableInteraction txn1 = txnInteractions.stream().filter(txn -> txn instanceof Transactions1TableInteraction).findFirst().get();
    TransactionsTableInteraction txn2 = txnInteractions.stream().filter(txn -> txn instanceof Transactions2TableInteraction).findFirst().get();
    assertThat(txn1).extracting(TransactionsTableInteraction::getTimestampRange).isEqualTo(FullyBoundedTimestampRange.of(Range.closedOpen(IMMUTABLE_TIMESTAMP, migrateToTxns2)));
    assertThat(txn2).extracting(TransactionsTableInteraction::getTimestampRange).isEqualTo(FullyBoundedTimestampRange.of(Range.closed(migrateToTxns2, FASTFORWARD_TIMESTAMP)));
}
Also used : InternalSchemaMetadataState(com.palantir.atlasdb.internalschema.InternalSchemaMetadataState) Transactions2TableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction) Transactions1TableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.Transactions1TableInteraction) Range(com.google.common.collect.Range) FullyBoundedTimestampRange(com.palantir.timestamp.FullyBoundedTimestampRange) TransactionsTableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.TransactionsTableInteraction) Test(org.junit.Test)

Example 2 with Transactions2TableInteraction

use of com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction in project atlasdb by palantir.

the class RepairRangeFetcherTest method testRepairGivesAllReplicas.

@Test
public void testRepairGivesAllReplicas() {
    List<TransactionsTableInteraction> interactions = ImmutableList.of(new Transactions2TableInteraction(range(1L, 10_000_000L), POLICY));
    Map<String, Map<InetSocketAddress, RangeSet<LightweightOppToken>>> rangesForRepair = repairRangeFetcher.getTransactionTableRangesForRepair(interactions);
    assertThat(rangesForRepair.get(TXN_2).keySet()).containsExactlyInAnyOrder(BackupTestUtils.HOST_1, BackupTestUtils.HOST_2, BackupTestUtils.HOST_3);
}
Also used : Transactions2TableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction) LightweightOppToken(com.palantir.atlasdb.keyvalue.cassandra.LightweightOppToken) Map(java.util.Map) TransactionsTableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.TransactionsTableInteraction) Test(org.junit.Test)

Example 3 with Transactions2TableInteraction

use of com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction in project atlasdb by palantir.

the class RepairRangeFetcherTest method testRepairBothTxnTables.

@Test
public void testRepairBothTxnTables() {
    List<TransactionsTableInteraction> interactions = ImmutableList.of(new Transactions1TableInteraction(range(1L, 5L), POLICY), new Transactions2TableInteraction(range(6L, 10L), POLICY));
    Map<String, Map<InetSocketAddress, RangeSet<LightweightOppToken>>> rangesForRepair = repairRangeFetcher.getTransactionTableRangesForRepair(interactions);
    assertThat(rangesForRepair.keySet()).containsExactlyInAnyOrder(TXN_1, TXN_2);
}
Also used : Transactions2TableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction) LightweightOppToken(com.palantir.atlasdb.keyvalue.cassandra.LightweightOppToken) Transactions1TableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.Transactions1TableInteraction) Map(java.util.Map) TransactionsTableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.TransactionsTableInteraction) Test(org.junit.Test)

Example 4 with Transactions2TableInteraction

use of com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction in project atlasdb by palantir.

the class RepairRangeFetcherTest method testRepairOnlyTxn2.

@Test
public void testRepairOnlyTxn2() {
    List<TransactionsTableInteraction> interactions = ImmutableList.of(new Transactions2TableInteraction(range(1L, 10_000_000L), POLICY));
    Map<String, Map<InetSocketAddress, RangeSet<LightweightOppToken>>> rangesForRepair = repairRangeFetcher.getTransactionTableRangesForRepair(interactions);
    assertThat(rangesForRepair.keySet()).containsExactly(TXN_2);
}
Also used : Transactions2TableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction) LightweightOppToken(com.palantir.atlasdb.keyvalue.cassandra.LightweightOppToken) Map(java.util.Map) TransactionsTableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.TransactionsTableInteraction) Test(org.junit.Test)

Example 5 with Transactions2TableInteraction

use of com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction in project atlasdb by palantir.

the class RepairRangeFetcherTest method testRepairsEachTableOnceOnly.

@Test
public void testRepairsEachTableOnceOnly() {
    List<TransactionsTableInteraction> interactions = ImmutableList.of(new Transactions1TableInteraction(range(1L, 5L), POLICY), new Transactions2TableInteraction(range(6L, 10L), POLICY), new Transactions1TableInteraction(range(11L, 15L), POLICY), new Transactions2TableInteraction(range(16L, 20L), POLICY));
    Map<String, Map<InetSocketAddress, RangeSet<LightweightOppToken>>> rangesForRepair = repairRangeFetcher.getTransactionTableRangesForRepair(interactions);
    assertThat(rangesForRepair.keySet()).containsExactlyInAnyOrder(TXN_1, TXN_2);
}
Also used : Transactions2TableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction) LightweightOppToken(com.palantir.atlasdb.keyvalue.cassandra.LightweightOppToken) Transactions1TableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.Transactions1TableInteraction) Map(java.util.Map) TransactionsTableInteraction(com.palantir.atlasdb.cassandra.backup.transaction.TransactionsTableInteraction) Test(org.junit.Test)

Aggregations

Transactions2TableInteraction (com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction)10 TransactionsTableInteraction (com.palantir.atlasdb.cassandra.backup.transaction.TransactionsTableInteraction)10 Test (org.junit.Test)10 LightweightOppToken (com.palantir.atlasdb.keyvalue.cassandra.LightweightOppToken)9 Map (java.util.Map)9 Transactions1TableInteraction (com.palantir.atlasdb.cassandra.backup.transaction.Transactions1TableInteraction)6 Range (com.google.common.collect.Range)4 Cluster (com.datastax.driver.core.Cluster)3 DefaultRetryPolicy (com.datastax.driver.core.policies.DefaultRetryPolicy)3 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableRangeSet.toImmutableRangeSet (com.google.common.collect.ImmutableRangeSet.toImmutableRangeSet)3 RangeMap (com.google.common.collect.RangeMap)3 RangeSet (com.google.common.collect.RangeSet)3 AtlasDbConstants (com.palantir.atlasdb.AtlasDbConstants)3 KvsRunner (com.palantir.atlasdb.backup.KvsRunner)3 AtlasService (com.palantir.atlasdb.backup.api.AtlasService)3 ServiceId (com.palantir.atlasdb.backup.api.ServiceId)3 CassandraKeyValueServiceConfig (com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig)3 CassandraKeyValueServiceRuntimeConfig (com.palantir.atlasdb.cassandra.CassandraKeyValueServiceRuntimeConfig)3