/** * Used by a reader to get a fence that can be added to its transaction context. * * @param fenceId uniquely identifies the data that this fence is used to synchronize. * If the data is a table cell then this id can be composed of the table name, row key * and column key for the data. * @return {@link TransactionAware} to be added to reader's transaction context. */ public static TransactionAware create(byte[] fenceId) { return new ReadFence(fenceId); }
/** * Used by a writer to wait on a fence so that changes are visible to all readers with in-progress transactions. * * @param fenceId uniquely identifies the data that this fence is used to synchronize. * If the data is a table cell then this id can be composed of the table name, row key * and column key for the data. * @return {@link FenceWait} object */ public static FenceWait prepareWait(byte[] fenceId, TransactionSystemClient txClient) throws TransactionFailureException, InterruptedException, TimeoutException { return new DefaultFenceWait(new TransactionContext(txClient, new WriteFence(fenceId))); } }
VisibilityFence.create(fenceId)); fence1.start(); FenceWait fenceWait = VisibilityFence.prepareWait(fenceId, customTxClient); fenceWait.await(timeout, timeUnit); Assert.fail("Expected await to fail"); } catch (TimeoutException e) { FenceWait fenceWait = VisibilityFence.prepareWait(fenceId, customTxClient); fenceWait.await(timeout, timeUnit); Assert.assertEquals(2, attempts.get());
TransactionAware readFenceCase16 = VisibilityFence.create(fenceId); TransactionContext readTxContextCase16 = new TransactionContext(new InMemoryTxSystemClient(txManager), readFenceCase16); TransactionAware readFenceCase17 = VisibilityFence.create(fenceId); TransactionContext readTxContextCase17 = new TransactionContext(new InMemoryTxSystemClient(txManager), readFenceCase17); readTxContextCase17.start(); TransactionAware readFenceCase18 = VisibilityFence.create(fenceId); TransactionContext readTxContextCase18 = new TransactionContext(new InMemoryTxSystemClient(txManager), readFenceCase18); TransactionAware writeFence = new WriteFence(fenceId); TransactionContext writeTxContext = new TransactionContext(new InMemoryTxSystemClient(txManager), writeFence); writeTxContext.start(); TransactionAware readFenceCase20 = VisibilityFence.create(fenceId); TransactionContext readTxContextCase20 = new TransactionContext(new InMemoryTxSystemClient(txManager), readFenceCase20); assertTxnConflict(writeTxContext); writeTxContext.start(); TransactionAware readFenceCase21 = VisibilityFence.create(fenceId); TransactionContext readTxContextCase21 = new TransactionContext(new InMemoryTxSystemClient(txManager), readFenceCase21); readTxContextCase21.start();
TransactionAware readFence1 = VisibilityFence.create(fenceId); TransactionContext readTxContext1 = new TransactionContext(new InMemoryTxSystemClient(txManager), readFence1); readTxContext1.start(); TransactionAware readFence2 = VisibilityFence.create(fenceId); TransactionContext readTxContext2 = new TransactionContext(new InMemoryTxSystemClient(txManager), readFence2); readTxContext2.start(); TransactionAware readFence3 = VisibilityFence.create(fenceId); TransactionContext readTxContext3 = new TransactionContext(new InMemoryTxSystemClient(txManager), readFence3); readTxContext3.start(); TransactionAware writeFence = new WriteFence(fenceId); TransactionContext writeTxContext = new TransactionContext(new InMemoryTxSystemClient(txManager), writeFence); writeTxContext.start();
/** * Used by a writer to wait on a fence so that changes are visible to all readers with in-progress transactions. * * @param fenceId uniquely identifies the data that this fence is used to synchronize. * If the data is a table cell then this id can be composed of the table name, row key * and column key for the data. * @return {@link FenceWait} object */ public static FenceWait prepareWait(byte[] fenceId, TransactionSystemClient txClient) throws TransactionFailureException, InterruptedException, TimeoutException { return new DefaultFenceWait(new TransactionContext(txClient, new WriteFence(fenceId))); } }
VisibilityFence.create(fenceId)); fence1.start(); final TransactionContext fence2 = new TransactionContext(new InMemoryTxSystemClient(txManager), VisibilityFence.create(fenceId)); fence2.start(); TransactionContext fence3 = new TransactionContext(new InMemoryTxSystemClient(txManager), VisibilityFence.create(fenceId)); fence3.start(); FenceWait fenceWait = VisibilityFence.prepareWait(fenceId, customTxClient); fenceWait.await(1000, TimeUnit.MILLISECONDS); Assert.assertEquals(3, attempts.get());
/** * Used by a reader to get a fence that can be added to its transaction context. * * @param fenceId uniquely identifies the data that this fence is used to synchronize. * If the data is a table cell then this id can be composed of the table name, row key * and column key for the data. * @return {@link TransactionAware} to be added to reader's transaction context. */ public static TransactionAware create(byte[] fenceId) { return new ReadFence(fenceId); }