Search in sources :

Example 1 with SerializableTransactionManager

use of com.palantir.atlasdb.transaction.impl.SerializableTransactionManager in project atlasdb by palantir.

the class TimeLockServerDownIntegrationTest method getsDependencyExceptionFromTransactionsWhenDown.

@Test
public void getsDependencyExceptionFromTransactionsWhenDown() {
    SerializableTransactionManager txnManager = TimeLockTestUtils.createTransactionManager(CLUSTER);
    txnManager.getKeyValueService().createTable(TABLE, AtlasDbConstants.GENERIC_TABLE_METADATA);
    // write a value
    txnManager.runTaskWithRetry(txn -> {
        txn.put(TABLE, ImmutableMap.of(CELL, DATA));
        return null;
    });
    // read the value
    byte[] retrievedData = txnManager.runTaskWithRetry(txn -> txn.get(TABLE, ImmutableSet.of(CELL)).get(CELL));
    assertThat(retrievedData).isEqualTo(DATA);
    takeDownTimeLock();
    // Try to get again
    assertThatThrownBy(() -> txnManager.runTaskWithRetry(txn -> txn.get(TABLE, ImmutableSet.of(CELL)).get(CELL))).isExactlyInstanceOf(AtlasDbDependencyException.class);
}
Also used : SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) Test(org.junit.Test)

Example 2 with SerializableTransactionManager

use of com.palantir.atlasdb.transaction.impl.SerializableTransactionManager in project atlasdb by palantir.

the class TimeLockTestUtils method createTransactionManager.

static SerializableTransactionManager createTransactionManager(TestableTimelockCluster cluster) {
    List<String> serverUris = cluster.servers().stream().map(server -> server.serverHolder().getTimelockUri()).collect(Collectors.toList());
    AtlasDbConfig config = ImmutableAtlasDbConfig.builder().namespace("test").keyValueService(new InMemoryAtlasDbConfig()).timelock(ImmutableTimeLockClientConfig.builder().serversList(ImmutableServerListConfig.builder().servers(serverUris).sslConfiguration(SslConfiguration.of(Paths.get("var/security/trustStore.jks"))).build()).build()).build();
    return TransactionManagers.builder().config(config).userAgent("test").globalMetricsRegistry(new MetricRegistry()).globalTaggedMetricRegistry(DefaultTaggedMetricRegistry.getDefault()).build().serializable();
}
Also used : ImmutableServerListConfig(com.palantir.atlasdb.config.ImmutableServerListConfig) MetricRegistry(com.codahale.metrics.MetricRegistry) ImmutableTimeLockClientConfig(com.palantir.atlasdb.config.ImmutableTimeLockClientConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) Collectors(java.util.stream.Collectors) TransactionManagers(com.palantir.atlasdb.factory.TransactionManagers) List(java.util.List) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) SslConfiguration(com.palantir.remoting.api.config.ssl.SslConfiguration) Paths(java.nio.file.Paths) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) MetricRegistry(com.codahale.metrics.MetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig)

Example 3 with SerializableTransactionManager

use of com.palantir.atlasdb.transaction.impl.SerializableTransactionManager in project atlasdb by palantir.

the class AtlasDbServiceImplTest method setUp.

@Before
public void setUp() {
    kvs = mock(KeyValueService.class);
    SerializableTransactionManager txManager = mock(SerializableTransactionManager.class);
    TableMetadataCache metadataCache = mock(TableMetadataCache.class);
    atlasDbService = new AtlasDbServiceImpl(kvs, txManager, metadataCache);
}
Also used : KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) Before(org.junit.Before)

Example 4 with SerializableTransactionManager

use of com.palantir.atlasdb.transaction.impl.SerializableTransactionManager in project atlasdb by palantir.

the class SweepTestUtils method setupTxManager.

public static SerializableTransactionManager setupTxManager(KeyValueService kvs, TimestampService tsService, SweepStrategyManager ssm, TransactionService txService) {
    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();
    SerializableTransactionManager txManager = SerializableTransactionManager.createForTest(kvs, tsService, lockClient, lockService, txService, constraints, cdm, ssm, cleaner, AbstractTransactionTest.GET_RANGES_THREAD_POOL_SIZE, AbstractTransactionTest.DEFAULT_GET_RANGES_CONCURRENCY, () -> AtlasDbConstants.DEFAULT_TIMESTAMP_CACHE_SIZE, InMemorySweepQueue.writer());
    setupTables(kvs);
    return txManager;
}
Also used : AtlasDbConstraintCheckingMode(com.palantir.atlasdb.transaction.api.AtlasDbConstraintCheckingMode) KvsBackedPersistentLockService(com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService) NoOpPersistentLockService(com.palantir.atlasdb.persistentlock.NoOpPersistentLockService) PersistentLockService(com.palantir.atlasdb.persistentlock.PersistentLockService) LockService(com.palantir.lock.LockService) LockClient(com.palantir.lock.LockClient) NoOpCleaner(com.palantir.atlasdb.cleaner.NoOpCleaner) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) ConflictDetectionManager(com.palantir.atlasdb.transaction.impl.ConflictDetectionManager) Cleaner(com.palantir.atlasdb.cleaner.Cleaner) NoOpCleaner(com.palantir.atlasdb.cleaner.NoOpCleaner)

Example 5 with SerializableTransactionManager

use of com.palantir.atlasdb.transaction.impl.SerializableTransactionManager in project atlasdb by palantir.

the class TableTasksTest method setup.

@Before
public void setup() {
    kvs = new InMemoryKeyValueService(true);
    TimestampService tsService = new InMemoryTimestampService();
    LockClient lockClient = LockClient.of("sweep client");
    lockService = LockServiceImpl.create(LockServerOptions.builder().isStandaloneServer(false).build());
    TransactionService txService = TransactionServices.createTransactionService(kvs);
    Supplier<AtlasDbConstraintCheckingMode> constraints = Suppliers.ofInstance(AtlasDbConstraintCheckingMode.NO_CONSTRAINT_CHECKING);
    ConflictDetectionManager cdm = ConflictDetectionManagers.createWithoutWarmingCache(kvs);
    SweepStrategyManager ssm = SweepStrategyManagers.createDefault(kvs);
    Cleaner cleaner = new NoOpCleaner();
    SerializableTransactionManager transactionManager = SerializableTransactionManager.createForTest(kvs, tsService, lockClient, lockService, txService, constraints, cdm, ssm, cleaner, AbstractTransactionTest.GET_RANGES_THREAD_POOL_SIZE, AbstractTransactionTest.DEFAULT_GET_RANGES_CONCURRENCY, () -> AtlasDbConstants.DEFAULT_TIMESTAMP_CACHE_SIZE, MultiTableSweepQueueWriter.NO_OP);
    txManager = transactionManager;
}
Also used : SweepStrategyManager(com.palantir.atlasdb.transaction.impl.SweepStrategyManager) AtlasDbConstraintCheckingMode(com.palantir.atlasdb.transaction.api.AtlasDbConstraintCheckingMode) TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) LockClient(com.palantir.lock.LockClient) NoOpCleaner(com.palantir.atlasdb.cleaner.NoOpCleaner) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) ConflictDetectionManager(com.palantir.atlasdb.transaction.impl.ConflictDetectionManager) InMemoryTimestampService(com.palantir.timestamp.InMemoryTimestampService) InMemoryTimestampService(com.palantir.timestamp.InMemoryTimestampService) TimestampService(com.palantir.timestamp.TimestampService) Cleaner(com.palantir.atlasdb.cleaner.Cleaner) NoOpCleaner(com.palantir.atlasdb.cleaner.NoOpCleaner) Before(org.junit.Before)

Aggregations

SerializableTransactionManager (com.palantir.atlasdb.transaction.impl.SerializableTransactionManager)13 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)7 TimestampService (com.palantir.timestamp.TimestampService)6 Test (org.junit.Test)6 Cleaner (com.palantir.atlasdb.cleaner.Cleaner)4 SingleBackendCliTestRunner (com.palantir.atlasdb.cli.runner.SingleBackendCliTestRunner)4 DaggerTestAtlasDbServices (com.palantir.atlasdb.services.test.DaggerTestAtlasDbServices)4 TestAtlasDbServices (com.palantir.atlasdb.services.test.TestAtlasDbServices)4 ConflictDetectionManager (com.palantir.atlasdb.transaction.impl.ConflictDetectionManager)4 AtlasDbConfig (com.palantir.atlasdb.config.AtlasDbConfig)3 ImmutableAtlasDbConfig (com.palantir.atlasdb.config.ImmutableAtlasDbConfig)3 InMemoryAtlasDbConfig (com.palantir.atlasdb.memory.InMemoryAtlasDbConfig)3 SweepStrategyManager (com.palantir.atlasdb.transaction.impl.SweepStrategyManager)3 TransactionService (com.palantir.atlasdb.transaction.service.TransactionService)3 LockClient (com.palantir.lock.LockClient)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2 CleanupFollower (com.palantir.atlasdb.cleaner.CleanupFollower)2 DefaultCleanerBuilder (com.palantir.atlasdb.cleaner.DefaultCleanerBuilder)2 NoOpCleaner (com.palantir.atlasdb.cleaner.NoOpCleaner)2 KvsBackedPersistentLockService (com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService)2