Search in sources :

Example 1 with DeletingStreamStore

use of com.palantir.atlasdb.schema.stream.generated.DeletingStreamStore in project atlasdb by palantir.

the class StreamTest method testStreamMetadataConflictWriteFirst.

@Test
public void testStreamMetadataConflictWriteFirst() throws Exception {
    long streamId = timestampService.getFreshTimestamp();
    runConflictingTasksConcurrently(streamId, new TwoConflictingTasks() {

        @Override
        public void startFirstAndFail(Transaction tx, long streamId) {
            DeletingStreamStore deletingStreamStore = new DeletingStreamStore(StreamTestStreamStore.of(txManager, StreamTestTableFactory.of()));
            deletingStreamStore.deleteStreams(tx, ImmutableSet.of(streamId));
        }

        @Override
        public void startSecondAndFinish(Transaction tx, long streamId) {
            StreamTestStreamStore ss = StreamTestStreamStore.of(txManager, StreamTestTableFactory.of());
            ss.storeStreams(tx, ImmutableMap.of(streamId, new ByteArrayInputStream(new byte[1])));
        }
    });
    Optional<InputStream> stream = getStream(streamId);
    assertTrue(stream.isPresent());
    assertNotNull(stream.get());
}
Also used : StreamTestStreamStore(com.palantir.atlasdb.schema.stream.generated.StreamTestStreamStore) Transaction(com.palantir.atlasdb.transaction.api.Transaction) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DeletingStreamStore(com.palantir.atlasdb.schema.stream.generated.DeletingStreamStore) Test(org.junit.Test)

Example 2 with DeletingStreamStore

use of com.palantir.atlasdb.schema.stream.generated.DeletingStreamStore in project atlasdb by palantir.

the class StreamTest method testStreamMetadataConflictDeleteFirst.

@Test
public void testStreamMetadataConflictDeleteFirst() throws Exception {
    long streamId = timestampService.getFreshTimestamp();
    runConflictingTasksConcurrently(streamId, new TwoConflictingTasks() {

        @Override
        public void startFirstAndFail(Transaction tx, long streamId) {
            StreamTestStreamStore ss = StreamTestStreamStore.of(txManager, StreamTestTableFactory.of());
            ss.storeStreams(tx, ImmutableMap.of(streamId, new ByteArrayInputStream(new byte[1])));
        }

        @Override
        public void startSecondAndFinish(Transaction tx, long streamId) {
            DeletingStreamStore deletingStreamStore = new DeletingStreamStore(StreamTestStreamStore.of(txManager, StreamTestTableFactory.of()));
            deletingStreamStore.deleteStreams(tx, ImmutableSet.of(streamId));
        }
    });
    assertStreamDoesNotExist(streamId);
}
Also used : StreamTestStreamStore(com.palantir.atlasdb.schema.stream.generated.StreamTestStreamStore) Transaction(com.palantir.atlasdb.transaction.api.Transaction) ByteArrayInputStream(java.io.ByteArrayInputStream) DeletingStreamStore(com.palantir.atlasdb.schema.stream.generated.DeletingStreamStore) Test(org.junit.Test)

Aggregations

DeletingStreamStore (com.palantir.atlasdb.schema.stream.generated.DeletingStreamStore)2 StreamTestStreamStore (com.palantir.atlasdb.schema.stream.generated.StreamTestStreamStore)2 Transaction (com.palantir.atlasdb.transaction.api.Transaction)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Test (org.junit.Test)2 InputStream (java.io.InputStream)1