@Override protected MultiTableSweepQueueWriter getSweepQueueWriterUninitialized() { return TargetedSweeper.createUninitializedForTest(() -> 128); }
public static TargetedSweeper createUninitializedForTest(Supplier<Integer> shards) { return createUninitializedForTest(MetricsManagers.createForTests(), () -> true, shards); }
@Before public void setup() { super.setup(); sweepQueue = TargetedSweeper.createUninitializedForTest(() -> 1); sweepQueue.initializeWithoutRunning( timestampsSupplier, mock(TimelockService.class), kvs, txService, mock(TargetedSweepFollower.class)); }
private TargetedSweeper getSingleShardSweeper() { TargetedSweeper sweeper = TargetedSweeper.createUninitializedForTest(() -> 1); sweeper.initializeWithoutRunning( timestampsSupplier, mock(TimelockService.class), spiedKvs, txnService, mock(TargetedSweepFollower.class)); return sweeper; }
@Test public void initializingWithUninitializedKvsThrows() { KeyValueService uninitializedKvs = mock(KeyValueService.class); when(uninitializedKvs.isInitialized()).thenReturn(false); TargetedSweeper sweeper = TargetedSweeper.createUninitializedForTest(null); assertThatThrownBy(() -> sweeper.initializeWithoutRunning( null, mock(TimelockService.class), uninitializedKvs, txnService, mock(TargetedSweepFollower.class))) .isInstanceOf(IllegalStateException.class); }
@Test public void callingEnqueueAndSweepOnUninitializedSweeperThrows() { TargetedSweeper uninitializedSweeper = TargetedSweeper.createUninitializedForTest(null); assertThatThrownBy(() -> uninitializedSweeper.enqueue(ImmutableList.of())) .isInstanceOf(NotInitializedException.class) .hasMessageContaining("Targeted Sweeper"); assertThatThrownBy(() -> uninitializedSweeper.sweepNextBatch(ShardAndStrategy.conservative(0))) .isInstanceOf(NotInitializedException.class) .hasMessageContaining("Targeted Sweeper"); }
@Before public void setup() { super.setup(); sweepQueue = TargetedSweeper.createUninitializedForTest(metricsManager, () -> enabled, () -> DEFAULT_SHARDS); mockFollower = mock(TargetedSweepFollower.class); timelockService = mock(TimelockService.class); sweepQueue.initializeWithoutRunning(timestampsSupplier, timelockService, spiedKvs, txnService, mockFollower); progress = new ShardProgress(spiedKvs); sweepableTimestamps = new SweepableTimestamps(spiedKvs, partitioner); sweepableCells = new SweepableCells(spiedKvs, partitioner, null, txnService); puncherStore = KeyValueServicePuncherStore.create(spiedKvs, false); }
when(mockServices.getTransactionService()).thenReturn(transactionService); when(mockServices.getKeyValueService()).thenReturn(kvs); TargetedSweeper sweeper = TargetedSweeper.createUninitializedForTest(() -> 1); SerializableTransactionManager txManager = SerializableTransactionManager.createForTest( MetricsManagers.createForTests(),
public static TransactionManager setupTxManager(KeyValueService kvs, TimestampService tsService, TimestampManagementService tsmService, SweepStrategyManager ssm, TransactionService txService) { MetricsManager metricsManager = MetricsManagers.createForTests(); LockClient lockClient = LockClient.of("sweep client"); LockService lockService = LockServiceImpl.create( LockServerOptions.builder().isStandaloneServer(false).build()); Supplier<AtlasDbConstraintCheckingMode> constraints = () -> AtlasDbConstraintCheckingMode.NO_CONSTRAINT_CHECKING; ConflictDetectionManager cdm = ConflictDetectionManagers.createWithoutWarmingCache(kvs); Cleaner cleaner = new NoOpCleaner(); MultiTableSweepQueueWriter writer = TargetedSweeper.createUninitializedForTest(() -> 1); TransactionManager txManager = SerializableTransactionManager.createForTest( metricsManager, kvs, tsService, tsmService, lockClient, lockService, txService, constraints, cdm, ssm, cleaner, AbstractTransactionTest.GET_RANGES_THREAD_POOL_SIZE, AbstractTransactionTest.DEFAULT_GET_RANGES_CONCURRENCY, writer); setupTables(kvs); writer.initialize(txManager); return txManager; }
@Override public void run(AtlasDbEteConfiguration config, final Environment environment) throws Exception { TaggedMetricRegistry taggedMetrics = new DefaultTaggedMetricRegistry(); TransactionManager txManager = tryToCreateTransactionManager(config, environment, taggedMetrics); Supplier<SweepTaskRunner> sweepTaskRunner = Suppliers.memoize(() -> getSweepTaskRunner(txManager, environment.metrics(), taggedMetrics)); TargetedSweeper sweeper = TargetedSweeper.createUninitializedForTest(() -> 1); Supplier<TargetedSweeper> sweeperSupplier = Suppliers.memoize(() -> initializeAndGet(sweeper, txManager)); environment.jersey().register(new SimpleTodoResource(new TodoClient( txManager, sweepTaskRunner, sweeperSupplier))); environment.jersey().register(InstanceManagingCoordinationResource.create(txManager)); environment.jersey().register(new SimpleCheckAndSetResource(new CheckAndSetClient(txManager))); environment.jersey().register(HttpRemotingJerseyFeature.INSTANCE); environment.jersey().register(new NotInitializedExceptionMapper()); environment.jersey().register(new SimpleEteTimestampResource(txManager)); }
@Before public void setUp() throws Exception { timestampService = new InMemoryTimestampService(); KeyValueService kvs = getBaseKeyValueService(); keyValueServiceWithStats = new StatsTrackingKeyValueService(kvs); keyValueService = spy(new TrackingKeyValueService(keyValueServiceWithStats)); TransactionTables.createTables(kvs); transactionService = TransactionServices.createForTesting(keyValueService, timestampService, false); conflictDetectionManager = ConflictDetectionManagers.createWithoutWarmingCache(keyValueService); sweepStrategyManager = SweepStrategyManagers.createDefault(keyValueService); sweepQueue = spy(TargetedSweeper.createUninitializedForTest(() -> sweepQueueShards)); serializableTxManager = new TestTransactionManagerImpl( metricsManager, keyValueService, timestampService, timestampService, lockClient, lockService, transactionService, conflictDetectionManager, sweepStrategyManager, sweepQueue, MoreExecutors.newDirectExecutorService()); sweepQueue.initialize(serializableTxManager); txManager = new CachingTestTransactionManager(serializableTxManager); }
public static TargetedSweeper createUninitializedForTest(Supplier<Integer> shards) { return createUninitializedForTest(MetricsManagers.createForTests(), () -> true, shards); }
@Before public void setup() { super.setup(); sweepQueue = TargetedSweeper.createUninitializedForTest(() -> 1); sweepQueue.initializeWithoutRunning( timestampsSupplier, mock(TimelockService.class), kvs, txService, mock(TargetedSweepFollower.class)); }
public static TransactionManager setupTxManager(KeyValueService kvs, TimestampService tsService, TimestampManagementService tsmService, SweepStrategyManager ssm, TransactionService txService) { MetricsManager metricsManager = MetricsManagers.createForTests(); LockClient lockClient = LockClient.of("sweep client"); LockService lockService = LockServiceImpl.create( LockServerOptions.builder().isStandaloneServer(false).build()); Supplier<AtlasDbConstraintCheckingMode> constraints = () -> AtlasDbConstraintCheckingMode.NO_CONSTRAINT_CHECKING; ConflictDetectionManager cdm = ConflictDetectionManagers.createWithoutWarmingCache(kvs); Cleaner cleaner = new NoOpCleaner(); MultiTableSweepQueueWriter writer = TargetedSweeper.createUninitializedForTest(() -> 1); TransactionManager txManager = SerializableTransactionManager.createForTest( metricsManager, kvs, tsService, tsmService, lockClient, lockService, txService, constraints, cdm, ssm, cleaner, AbstractTransactionTest.GET_RANGES_THREAD_POOL_SIZE, AbstractTransactionTest.DEFAULT_GET_RANGES_CONCURRENCY, writer); setupTables(kvs); writer.initialize(txManager); return txManager; }