Search in sources :

Example 1 with TransactionTask

use of com.palantir.atlasdb.transaction.api.TransactionTask in project atlasdb by palantir.

the class StreamTest method testAddDelete.

@Test
public void testAddDelete() throws Exception {
    final byte[] data = PtBytes.toBytes("streamed");
    final long streamId = txManager.runTaskWithRetry((TransactionTask<Long, Exception>) t -> {
        Sha256Hash hash = Sha256Hash.computeHash(data);
        byte[] reference = "ref".getBytes();
        return defaultStore.getByHashOrStoreStreamAndMarkAsUsed(t, hash, new ByteArrayInputStream(data), reference);
    });
    txManager.runTaskWithRetry((TransactionTask<Void, Exception>) t -> {
        Optional<InputStream> inputStream = defaultStore.loadSingleStream(t, streamId);
        assertTrue(inputStream.isPresent());
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        outputStream.write(inputStream.get());
        assertArrayEquals(data, outputStream.toByteArray());
        return null;
    });
}
Also used : StreamTestWithHashStreamMetadataRow(com.palantir.atlasdb.schema.stream.generated.StreamTestWithHashStreamMetadataTable.StreamTestWithHashStreamMetadataRow) Arrays(java.util.Arrays) Matchers.not(org.hamcrest.Matchers.not) TestHashComponentsStreamValueRow(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamValueTable.TestHashComponentsStreamValueRow) Random(java.util.Random) Assert.assertThat(org.junit.Assert.assertThat) Future(java.util.concurrent.Future) TestHashComponentsStreamIdxRow(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamIdxTable.TestHashComponentsStreamIdxRow) ByteArrayInputStream(java.io.ByteArrayInputStream) PTExecutors(com.palantir.common.concurrent.PTExecutors) StreamTestTableFactory(com.palantir.atlasdb.schema.stream.generated.StreamTestTableFactory) Map(java.util.Map) Assert.fail(org.junit.Assert.fail) StreamTestWithHashStreamMetadataTable(com.palantir.atlasdb.schema.stream.generated.StreamTestWithHashStreamMetadataTable) StreamTestWithHashStreamStore(com.palantir.atlasdb.schema.stream.generated.StreamTestWithHashStreamStore) Parameterized(org.junit.runners.Parameterized) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) Set(java.util.Set) StreamTestStreamHashAidxTable(com.palantir.atlasdb.schema.stream.generated.StreamTestStreamHashAidxTable) Sets(com.google.common.collect.Sets) ByteString(com.google.protobuf.ByteString) TransactionConflictException(com.palantir.atlasdb.transaction.api.TransactionConflictException) CountDownLatch(java.util.concurrent.CountDownLatch) IOUtils(org.apache.commons.io.IOUtils) Transaction(com.palantir.atlasdb.transaction.api.Transaction) Assert.assertFalse(org.junit.Assert.assertFalse) StreamTestStreamStore(com.palantir.atlasdb.schema.stream.generated.StreamTestStreamStore) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) TestHashComponentsStreamStore(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamStore) Iterables(com.google.common.collect.Iterables) StreamMetadata(com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata) StreamTestStreamMetadataTable(com.palantir.atlasdb.schema.stream.generated.StreamTestStreamMetadataTable) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) Schemas(com.palantir.atlasdb.table.description.Schemas) Multimap(com.google.common.collect.Multimap) AtlasDbTestCase(com.palantir.atlasdb.AtlasDbTestCase) PtBytes(com.palantir.atlasdb.encoding.PtBytes) StreamTestStreamValueTable(com.palantir.atlasdb.schema.stream.generated.StreamTestStreamValueTable) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) TestHashComponentsStreamMetadataRow(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamMetadataTable.TestHashComponentsStreamMetadataRow) StreamTestWithHashStreamIdxRow(com.palantir.atlasdb.schema.stream.generated.StreamTestWithHashStreamIdxTable.StreamTestWithHashStreamIdxRow) StreamTestWithHashStreamValueRow(com.palantir.atlasdb.schema.stream.generated.StreamTestWithHashStreamValueTable.StreamTestWithHashStreamValueRow) PersistentStreamStore(com.palantir.atlasdb.stream.PersistentStreamStore) TestHashComponentsStreamMetadataTable(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamMetadataTable) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) Sha256Hash(com.palantir.util.crypto.Sha256Hash) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) Assert.assertNotNull(org.junit.Assert.assertNotNull) TestHashComponentsStreamHashAidxTable(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamHashAidxTable) Assert.assertTrue(org.junit.Assert.assertTrue) Throwables(com.google.common.base.Throwables) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) File(java.io.File) DeletingStreamStore(com.palantir.atlasdb.schema.stream.generated.DeletingStreamStore) Pair(com.palantir.util.Pair) Futures(com.google.common.util.concurrent.Futures) StreamPersistence(com.palantir.atlasdb.protos.generated.StreamPersistence) Assert.assertNull(org.junit.Assert.assertNull) Rule(org.junit.Rule) TransactionTask(com.palantir.atlasdb.transaction.api.TransactionTask) StreamTestMaxMemStreamStore(com.palantir.atlasdb.schema.stream.generated.StreamTestMaxMemStreamStore) Assert.assertEquals(org.junit.Assert.assertEquals) TemporaryFolder(org.junit.rules.TemporaryFolder) InputStream(java.io.InputStream) KeyValueTable(com.palantir.atlasdb.schema.stream.generated.KeyValueTable) Optional(java.util.Optional) ByteArrayInputStream(java.io.ByteArrayInputStream) Sha256Hash(com.palantir.util.crypto.Sha256Hash) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) TransactionConflictException(com.palantir.atlasdb.transaction.api.TransactionConflictException) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with TransactionTask

use of com.palantir.atlasdb.transaction.api.TransactionTask in project atlasdb by palantir.

the class StreamTest method runConflictingTasksConcurrently.

private void runConflictingTasksConcurrently(long streamId, TwoConflictingTasks tasks) throws InterruptedException {
    final CountDownLatch firstLatch = new CountDownLatch(1);
    final CountDownLatch secondLatch = new CountDownLatch(1);
    ExecutorService exec = PTExecutors.newFixedThreadPool(2);
    Future<?> firstFuture = exec.submit(() -> {
        try {
            txManager.runTaskThrowOnConflict(t -> {
                tasks.startFirstAndFail(t, streamId);
                letOtherTaskFinish(firstLatch, secondLatch);
                return null;
            });
            fail("Because we concurrently wrote, we should have failed with TransactionConflictException.");
        } catch (TransactionConflictException e) {
        // expected
        }
    });
    firstLatch.await();
    Future<?> secondFuture = exec.submit((Runnable) () -> txManager.runTaskThrowOnConflict((TransactionTask<Void, RuntimeException>) t -> {
        tasks.startSecondAndFinish(t, streamId);
        return null;
    }));
    exec.shutdown();
    Futures.getUnchecked(secondFuture);
    secondLatch.countDown();
    Futures.getUnchecked(firstFuture);
}
Also used : StreamTestWithHashStreamMetadataRow(com.palantir.atlasdb.schema.stream.generated.StreamTestWithHashStreamMetadataTable.StreamTestWithHashStreamMetadataRow) Arrays(java.util.Arrays) Matchers.not(org.hamcrest.Matchers.not) TestHashComponentsStreamValueRow(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamValueTable.TestHashComponentsStreamValueRow) Random(java.util.Random) Assert.assertThat(org.junit.Assert.assertThat) Future(java.util.concurrent.Future) TestHashComponentsStreamIdxRow(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamIdxTable.TestHashComponentsStreamIdxRow) ByteArrayInputStream(java.io.ByteArrayInputStream) PTExecutors(com.palantir.common.concurrent.PTExecutors) StreamTestTableFactory(com.palantir.atlasdb.schema.stream.generated.StreamTestTableFactory) Map(java.util.Map) Assert.fail(org.junit.Assert.fail) StreamTestWithHashStreamMetadataTable(com.palantir.atlasdb.schema.stream.generated.StreamTestWithHashStreamMetadataTable) StreamTestWithHashStreamStore(com.palantir.atlasdb.schema.stream.generated.StreamTestWithHashStreamStore) Parameterized(org.junit.runners.Parameterized) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) Set(java.util.Set) StreamTestStreamHashAidxTable(com.palantir.atlasdb.schema.stream.generated.StreamTestStreamHashAidxTable) Sets(com.google.common.collect.Sets) ByteString(com.google.protobuf.ByteString) TransactionConflictException(com.palantir.atlasdb.transaction.api.TransactionConflictException) CountDownLatch(java.util.concurrent.CountDownLatch) IOUtils(org.apache.commons.io.IOUtils) Transaction(com.palantir.atlasdb.transaction.api.Transaction) Assert.assertFalse(org.junit.Assert.assertFalse) StreamTestStreamStore(com.palantir.atlasdb.schema.stream.generated.StreamTestStreamStore) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) TestHashComponentsStreamStore(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamStore) Iterables(com.google.common.collect.Iterables) StreamMetadata(com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata) StreamTestStreamMetadataTable(com.palantir.atlasdb.schema.stream.generated.StreamTestStreamMetadataTable) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) Schemas(com.palantir.atlasdb.table.description.Schemas) Multimap(com.google.common.collect.Multimap) AtlasDbTestCase(com.palantir.atlasdb.AtlasDbTestCase) PtBytes(com.palantir.atlasdb.encoding.PtBytes) StreamTestStreamValueTable(com.palantir.atlasdb.schema.stream.generated.StreamTestStreamValueTable) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) TestHashComponentsStreamMetadataRow(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamMetadataTable.TestHashComponentsStreamMetadataRow) StreamTestWithHashStreamIdxRow(com.palantir.atlasdb.schema.stream.generated.StreamTestWithHashStreamIdxTable.StreamTestWithHashStreamIdxRow) StreamTestWithHashStreamValueRow(com.palantir.atlasdb.schema.stream.generated.StreamTestWithHashStreamValueTable.StreamTestWithHashStreamValueRow) PersistentStreamStore(com.palantir.atlasdb.stream.PersistentStreamStore) TestHashComponentsStreamMetadataTable(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamMetadataTable) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) Sha256Hash(com.palantir.util.crypto.Sha256Hash) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) Assert.assertNotNull(org.junit.Assert.assertNotNull) TestHashComponentsStreamHashAidxTable(com.palantir.atlasdb.schema.stream.generated.TestHashComponentsStreamHashAidxTable) Assert.assertTrue(org.junit.Assert.assertTrue) Throwables(com.google.common.base.Throwables) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) File(java.io.File) DeletingStreamStore(com.palantir.atlasdb.schema.stream.generated.DeletingStreamStore) Pair(com.palantir.util.Pair) Futures(com.google.common.util.concurrent.Futures) StreamPersistence(com.palantir.atlasdb.protos.generated.StreamPersistence) Assert.assertNull(org.junit.Assert.assertNull) Rule(org.junit.Rule) TransactionTask(com.palantir.atlasdb.transaction.api.TransactionTask) StreamTestMaxMemStreamStore(com.palantir.atlasdb.schema.stream.generated.StreamTestMaxMemStreamStore) Assert.assertEquals(org.junit.Assert.assertEquals) TemporaryFolder(org.junit.rules.TemporaryFolder) InputStream(java.io.InputStream) KeyValueTable(com.palantir.atlasdb.schema.stream.generated.KeyValueTable) ExecutorService(java.util.concurrent.ExecutorService) TransactionConflictException(com.palantir.atlasdb.transaction.api.TransactionConflictException) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 3 with TransactionTask

use of com.palantir.atlasdb.transaction.api.TransactionTask in project atlasdb by palantir.

the class SweeperTestSetup method mockTxManager.

public static LockAwareTransactionManager mockTxManager() {
    LockAwareTransactionManager txManager = mock(LockAwareTransactionManager.class);
    Answer runTaskAnswer = inv -> {
        Object[] args = inv.getArguments();
        TransactionTask<?, ?> task = (TransactionTask<?, ?>) args[0];
        return task.execute(mock(Transaction.class));
    };
    doAnswer(runTaskAnswer).when(txManager).runTaskReadOnly(any());
    doAnswer(runTaskAnswer).when(txManager).runTaskWithRetry(any());
    return txManager;
}
Also used : LockAwareTransactionManager(com.palantir.atlasdb.transaction.api.LockAwareTransactionManager) SweepProgress(com.palantir.atlasdb.sweep.progress.SweepProgress) BeforeClass(org.junit.BeforeClass) SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults) SweepProgressStore(com.palantir.atlasdb.sweep.progress.SweepProgressStore) Matchers.any(org.mockito.Matchers.any) NextTableToSweepProvider(com.palantir.atlasdb.sweep.priority.NextTableToSweepProvider) Answer(org.mockito.stubbing.Answer) Transaction(com.palantir.atlasdb.transaction.api.Transaction) LockService(com.palantir.lock.LockService) Matchers.eq(org.mockito.Matchers.eq) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) TransactionTask(com.palantir.atlasdb.transaction.api.TransactionTask) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Matchers.anyLong(org.mockito.Matchers.anyLong) Optional(java.util.Optional) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Mockito.doReturn(org.mockito.Mockito.doReturn) Mockito.mock(org.mockito.Mockito.mock) Before(org.junit.Before) SweepMetricsManager(com.palantir.atlasdb.sweep.metrics.SweepMetricsManager) SweepPriorityStore(com.palantir.atlasdb.sweep.priority.SweepPriorityStore) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) LockAwareTransactionManager(com.palantir.atlasdb.transaction.api.LockAwareTransactionManager) TransactionTask(com.palantir.atlasdb.transaction.api.TransactionTask)

Example 4 with TransactionTask

use of com.palantir.atlasdb.transaction.api.TransactionTask in project atlasdb by palantir.

the class TableMigratorTest method testMigrationToDifferentKvs.

// Table/IndexDefinition syntax
@SuppressWarnings({ "checkstyle:Indentation", "checkstyle:RightCurly" })
@Test
public void testMigrationToDifferentKvs() throws TableMappingNotFoundException {
    final TableReference tableRef = TableReference.create(Namespace.DEFAULT_NAMESPACE, "table");
    final TableReference namespacedTableRef = TableReference.createFromFullyQualifiedName("namespace." + tableRef.getTablename());
    TableDefinition definition = new TableDefinition() {

        {
            rowName();
            rowComponent("r", ValueType.BLOB);
            columns();
            column("c", "c", ValueType.BLOB);
        }
    };
    keyValueService.createTable(tableRef, definition.toTableMetadata().persistToBytes());
    keyValueService.createTable(namespacedTableRef, definition.toTableMetadata().persistToBytes());
    keyValueService.putMetadataForTable(namespacedTableRef, definition.toTableMetadata().persistToBytes());
    final Cell theCell = Cell.create(PtBytes.toBytes("r1"), PtBytes.toBytes("c"));
    final byte[] theValue = PtBytes.toBytes("v1");
    txManager.runTaskWithRetry((TransactionTask<Void, RuntimeException>) txn -> {
        Map<Cell, byte[]> values = ImmutableMap.of(theCell, theValue);
        txn.put(tableRef, values);
        txn.put(namespacedTableRef, values);
        return null;
    });
    final InMemoryKeyValueService kvs2 = new InMemoryKeyValueService(false);
    final ConflictDetectionManager cdm2 = ConflictDetectionManagers.createWithNoConflictDetection();
    final SweepStrategyManager ssm2 = SweepStrategyManagers.completelyConservative(kvs2);
    final TestTransactionManagerImpl txManager2 = new TestTransactionManagerImpl(kvs2, timestampService, lockClient, lockService, transactionService, cdm2, ssm2, MultiTableSweepQueueWriter.NO_OP);
    kvs2.createTable(tableRef, definition.toTableMetadata().persistToBytes());
    kvs2.createTable(namespacedTableRef, definition.toTableMetadata().persistToBytes());
    TableReference checkpointTable = TableReference.create(Namespace.DEFAULT_NAMESPACE, "checkpoint");
    GeneralTaskCheckpointer checkpointer = new GeneralTaskCheckpointer(checkpointTable, kvs2, txManager2);
    for (final TableReference name : Lists.newArrayList(tableRef, namespacedTableRef)) {
        TransactionRangeMigrator rangeMigrator = new TransactionRangeMigratorBuilder().srcTable(name).readTxManager(txManager).txManager(txManager2).checkpointer(checkpointer).build();
        TableMigratorBuilder builder = new TableMigratorBuilder().srcTable(name).partitions(1).executor(PTExecutors.newSingleThreadExecutor()).checkpointer(checkpointer).rangeMigrator(rangeMigrator);
        TableMigrator migrator = builder.build();
        migrator.migrate();
    }
    checkpointer.deleteCheckpoints();
    final ConflictDetectionManager verifyCdm = ConflictDetectionManagers.createWithNoConflictDetection();
    final SweepStrategyManager verifySsm = SweepStrategyManagers.completelyConservative(kvs2);
    final TestTransactionManagerImpl verifyTxManager = new TestTransactionManagerImpl(kvs2, timestampService, lockClient, lockService, transactionService, verifyCdm, verifySsm, MultiTableSweepQueueWriter.NO_OP);
    final MutableLong count = new MutableLong();
    for (final TableReference name : Lists.newArrayList(tableRef, namespacedTableRef)) {
        verifyTxManager.runTaskReadOnly((TransactionTask<Void, RuntimeException>) txn -> {
            BatchingVisitable<RowResult<byte[]>> bv = txn.getRange(name, RangeRequest.all());
            bv.batchAccept(1000, AbortingVisitors.batching(new AbortingVisitor<RowResult<byte[]>, RuntimeException>() {

                @Override
                public boolean visit(RowResult<byte[]> item) throws RuntimeException {
                    Iterable<Entry<Cell, byte[]>> cells = item.getCells();
                    Entry<Cell, byte[]> entry = Iterables.getOnlyElement(cells);
                    Assert.assertEquals(theCell, entry.getKey());
                    Assert.assertArrayEquals(theValue, entry.getValue());
                    count.increment();
                    return true;
                }
            }));
            return null;
        });
    }
    Assert.assertEquals(2L, count.longValue());
}
Also used : ConflictDetectionManager(com.palantir.atlasdb.transaction.impl.ConflictDetectionManager) Iterables(com.google.common.collect.Iterables) SweepStrategyManager(com.palantir.atlasdb.transaction.impl.SweepStrategyManager) BatchingVisitable(com.palantir.common.base.BatchingVisitable) InMemoryKeyValueService(com.palantir.atlasdb.keyvalue.impl.InMemoryKeyValueService) AtlasDbTestCase(com.palantir.atlasdb.AtlasDbTestCase) PtBytes(com.palantir.atlasdb.encoding.PtBytes) Lists(com.google.common.collect.Lists) PTExecutors(com.palantir.common.concurrent.PTExecutors) MutableLong(org.apache.commons.lang3.mutable.MutableLong) Map(java.util.Map) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) AbortingVisitors(com.palantir.common.base.AbortingVisitors) ConflictDetectionManagers(com.palantir.atlasdb.transaction.impl.ConflictDetectionManagers) SweepStrategyManagers(com.palantir.atlasdb.transaction.impl.SweepStrategyManagers) Namespace(com.palantir.atlasdb.keyvalue.api.Namespace) ImmutableMap(com.google.common.collect.ImmutableMap) Cell(com.palantir.atlasdb.keyvalue.api.Cell) Test(org.junit.Test) TableDefinition(com.palantir.atlasdb.table.description.TableDefinition) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) ValueType(com.palantir.atlasdb.table.description.ValueType) TransactionTask(com.palantir.atlasdb.transaction.api.TransactionTask) TableMappingNotFoundException(com.palantir.atlasdb.keyvalue.impl.TableMappingNotFoundException) Entry(java.util.Map.Entry) TestTransactionManagerImpl(com.palantir.atlasdb.transaction.impl.TestTransactionManagerImpl) MultiTableSweepQueueWriter(com.palantir.atlasdb.sweep.queue.MultiTableSweepQueueWriter) Assert(org.junit.Assert) AbortingVisitor(com.palantir.common.base.AbortingVisitor) InMemoryKeyValueService(com.palantir.atlasdb.keyvalue.impl.InMemoryKeyValueService) BatchingVisitable(com.palantir.common.base.BatchingVisitable) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Entry(java.util.Map.Entry) TableDefinition(com.palantir.atlasdb.table.description.TableDefinition) Cell(com.palantir.atlasdb.keyvalue.api.Cell) SweepStrategyManager(com.palantir.atlasdb.transaction.impl.SweepStrategyManager) TestTransactionManagerImpl(com.palantir.atlasdb.transaction.impl.TestTransactionManagerImpl) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) MutableLong(org.apache.commons.lang3.mutable.MutableLong) ConflictDetectionManager(com.palantir.atlasdb.transaction.impl.ConflictDetectionManager) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 5 with TransactionTask

use of com.palantir.atlasdb.transaction.api.TransactionTask in project atlasdb by palantir.

the class ProfileStoreTest method testDeleteImage.

@Test
public void testDeleteImage() {
    final UUID userId = storeUser();
    storeImage(userId);
    runWithRetry(Transaction.TransactionType.AGGRESSIVE_HARD_DELETE, store -> {
        store.deleteImage(userId);
        return userId;
    });
    txnMgr.runTaskWithRetry((TransactionTask<Void, RuntimeException>) txn -> {
        ProfileTableFactory tables = ProfileTableFactory.of();
        UserPhotosStreamValueTable streams = tables.getUserPhotosStreamValueTable(txn);
        Assert.assertTrue(streams.getAllRowsUnordered().isEmpty());
        return null;
    });
}
Also used : Throwables(com.palantir.common.base.Throwables) UserPhotosStreamValueTable(com.palantir.example.profile.schema.generated.UserPhotosStreamValueTable) Function(java.util.function.Function) TransactionManagers(com.palantir.atlasdb.factory.TransactionManagers) Assert.assertThat(org.junit.Assert.assertThat) ByteArrayInputStream(java.io.ByteArrayInputStream) Matchers.nullValue(org.hamcrest.Matchers.nullValue) After(org.junit.After) Closeables(com.google.common.io.Closeables) Sha256Hash(com.palantir.util.crypto.Sha256Hash) ExpectedException(org.junit.rules.ExpectedException) ImmutableSet(com.google.common.collect.ImmutableSet) ProfileSchema(com.palantir.example.profile.schema.ProfileSchema) Set(java.util.Set) IOException(java.io.IOException) Test(org.junit.Test) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) UUID(java.util.UUID) Rule(org.junit.Rule) Transaction(com.palantir.atlasdb.transaction.api.Transaction) TransactionTask(com.palantir.atlasdb.transaction.api.TransactionTask) UserProfile(com.palantir.example.profile.protos.generated.ProfilePersistence.UserProfile) ProfileTableFactory(com.palantir.example.profile.schema.generated.ProfileTableFactory) Assert(org.junit.Assert) InputStream(java.io.InputStream) ProfileTableFactory(com.palantir.example.profile.schema.generated.ProfileTableFactory) UserPhotosStreamValueTable(com.palantir.example.profile.schema.generated.UserPhotosStreamValueTable) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

TransactionTask (com.palantir.atlasdb.transaction.api.TransactionTask)5 Transaction (com.palantir.atlasdb.transaction.api.Transaction)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 Iterables (com.google.common.collect.Iterables)3 AtlasDbTestCase (com.palantir.atlasdb.AtlasDbTestCase)3 PtBytes (com.palantir.atlasdb.encoding.PtBytes)3 Throwables (com.google.common.base.Throwables)2 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)2 Multimap (com.google.common.collect.Multimap)2 Sets (com.google.common.collect.Sets)2 Futures (com.google.common.util.concurrent.Futures)2 ByteString (com.google.protobuf.ByteString)2 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)2 StreamPersistence (com.palantir.atlasdb.protos.generated.StreamPersistence)2 StreamMetadata (com.palantir.atlasdb.protos.generated.StreamPersistence.StreamMetadata)2 DeletingStreamStore (com.palantir.atlasdb.schema.stream.generated.DeletingStreamStore)2 KeyValueTable (com.palantir.atlasdb.schema.stream.generated.KeyValueTable)2 StreamTestMaxMemStreamStore (com.palantir.atlasdb.schema.stream.generated.StreamTestMaxMemStreamStore)2 StreamTestStreamHashAidxTable (com.palantir.atlasdb.schema.stream.generated.StreamTestStreamHashAidxTable)2