use of com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction in project atlasdb by palantir.
the class RepairRangeFetcherTest method testRepairGivesCorrectTokenRanges.
@Test
public void testRepairGivesCorrectTokenRanges() {
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).get(BackupTestUtils.HOST_1).asRanges()).containsExactlyInAnyOrder(Range.atMost(BackupTestUtils.TOKEN_1), Range.openClosed(BackupTestUtils.TOKEN_2, OTHER_TOKEN), Range.greaterThan(BackupTestUtils.TOKEN_3));
}
use of com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction in project atlasdb by palantir.
the class RepairRangeFetcherTest method testRepairGivesTwoReplicasForRF2.
@Test
public void testRepairGivesTwoReplicasForRF2() {
when(cqlMetadata.getReplicas(eq(BackupTestUtils.NAMESPACE), any())).thenReturn(ImmutableSet.of(BackupTestUtils.HOST_1, BackupTestUtils.HOST_2));
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);
}
use of com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction in project atlasdb by palantir.
the class CassandraRepairEteTest method testRepairBothTxnTables.
@Test
public void testRepairBothTxnTables() {
List<String> tablesRepaired = new ArrayList<>();
BiConsumer<String, RangesForRepair> repairer = (table, _unused) -> tablesRepaired.add(table);
List<TransactionsTableInteraction> interactions = ImmutableList.of(new Transactions1TableInteraction(range(1L, 5L), POLICY), new Transactions2TableInteraction(range(6L, 10L), POLICY));
cassandraRepairHelper.repairTransactionsTables(ATLAS_SERVICE, interactions, repairer);
assertThat(tablesRepaired).containsExactlyInAnyOrder(TransactionConstants.TRANSACTION_TABLE.getTableName(), TransactionConstants.TRANSACTIONS2_TABLE.getTableName());
}
use of com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction in project atlasdb by palantir.
the class CassandraRepairEteTest method testRepairOnlyTxn2.
@Test
public void testRepairOnlyTxn2() {
List<String> tablesRepaired = new ArrayList<>();
BiConsumer<String, RangesForRepair> repairer = (table, _unused) -> tablesRepaired.add(table);
List<TransactionsTableInteraction> interactions = ImmutableList.of(new Transactions2TableInteraction(range(1L, 10_000_000L), POLICY));
cassandraRepairHelper.repairTransactionsTables(ATLAS_SERVICE, interactions, repairer);
assertThat(tablesRepaired).containsExactly(TransactionConstants.TRANSACTIONS2_TABLE.getTableName());
}
use of com.palantir.atlasdb.cassandra.backup.transaction.Transactions2TableInteraction in project atlasdb by palantir.
the class CassandraRepairEteTest method testRepairsEachTableOnceOnly.
@Test
public void testRepairsEachTableOnceOnly() {
List<String> tablesRepaired = new ArrayList<>();
AtomicInteger numRepairs = new AtomicInteger(0);
BiConsumer<String, RangesForRepair> repairer = (table, _unused) -> {
numRepairs.incrementAndGet();
tablesRepaired.add(table);
};
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));
cassandraRepairHelper.repairTransactionsTables(ATLAS_SERVICE, interactions, repairer);
assertThat(tablesRepaired).containsExactlyInAnyOrder(TransactionConstants.TRANSACTION_TABLE.getTableName(), TransactionConstants.TRANSACTIONS2_TABLE.getTableName());
assertThat(numRepairs).hasValue(2);
}
Aggregations