/** * Sets up any resources needed by the individual client. * * @param txClient the transaction client to use in accessing the transaciton service * @param table the HBase table instance to use for accessing storage */ public void init(TransactionSystemClient txClient, HTableInterface table) { txTable = new TransactionAwareHTable(table); txContext = new TransactionContext(txClient, txTable); }
/** * Sets up any resources needed by the individual client. * * @param txClient the transaction client to use in accessing the transaciton service * @param table the HBase table instance to use for accessing storage */ public void init(TransactionSystemClient txClient, HTableInterface table) { txTable = new TransactionAwareHTable(table); txContext = new TransactionContext(txClient, txTable); }
@Override public TransactionContext createTransactionManager() { return new TransactionContext(txSystemClient, Iterables.unmodifiableIterable(txAware)); }
private static TransactionContext newTransactionContext(TransactionAware... txAwares) { return new TransactionContext(txClient, txAwares); }
/** * 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))); } }
/** * 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))); } }
try { TransactionAwareHTable table = new TransactionAwareHTable(conn.getTable(TABLE)); TransactionContext context = new TransactionContext(txClient, table);
try { TransactionAwareHTable table = new TransactionAwareHTable(conn.getTable(TABLE)); TransactionContext context = new TransactionContext(txClient, table);
public SecondaryIndexTable(TransactionServiceClient transactionServiceClient, HTableInterface hTable, byte[] secondaryIndex) { secondaryIndexTableName = TableName.valueOf(hTable.getName().getNameAsString() + ".idx"); HTable secondaryIndexHTable = null; try (HBaseAdmin hBaseAdmin = new HBaseAdmin(hTable.getConfiguration())) { if (!hBaseAdmin.tableExists(secondaryIndexTableName)) { hBaseAdmin.createTable(new HTableDescriptor(secondaryIndexTableName)); } secondaryIndexHTable = new HTable(hTable.getConfiguration(), secondaryIndexTableName); } catch (Exception e) { Throwables.propagate(e); } this.secondaryIndex = secondaryIndex; this.transactionAwareHTable = new TransactionAwareHTable(hTable); this.secondaryIndexTable = new TransactionAwareHTable(secondaryIndexHTable); this.transactionContext = new TransactionContext(transactionServiceClient, transactionAwareHTable, secondaryIndexTable); }
private <I, O> O executeOnce(Function<I, O> function, I input) throws TransactionFailureException { TransactionContext txContext = new TransactionContext(txClient, txAwares); txContext.start(); O o = null; try { o = function.apply(input); } catch (Throwable e) { txContext.abort(new TransactionFailureException("Transaction function failure for transaction. ", e)); // abort will throw } // will throw if smth goes wrong txContext.finish(); return o; } }
private <I, O> O executeOnce(Function<I, O> function, I input) throws TransactionFailureException { TransactionContext txContext = new TransactionContext(txClient, txAwares); txContext.start(); O o = null; try { o = function.apply(input); } catch (Throwable e) { txContext.abort(new TransactionFailureException("Transaction function failure for transaction. ", e)); // abort will throw } // will throw if smth goes wrong txContext.finish(); return o; } }
public SecondaryIndexTable(TransactionServiceClient transactionServiceClient, HTableInterface hTable, byte[] secondaryIndex) { secondaryIndexTableName = TableName.valueOf(hTable.getName().getNameAsString() + ".idx"); HTable secondaryIndexHTable = null; try (HBaseAdmin hBaseAdmin = new HBaseAdmin(hTable.getConfiguration())) { if (!hBaseAdmin.tableExists(secondaryIndexTableName)) { hBaseAdmin.createTable(new HTableDescriptor(secondaryIndexTableName)); } secondaryIndexHTable = new HTable(hTable.getConfiguration(), secondaryIndexTableName); } catch (Exception e) { Throwables.propagate(e); } this.secondaryIndex = secondaryIndex; this.transactionAwareHTable = new TransactionAwareHTable(hTable); this.secondaryIndexTable = new TransactionAwareHTable(secondaryIndexHTable); this.transactionContext = new TransactionContext(transactionServiceClient, transactionAwareHTable, secondaryIndexTable); }
public SecondaryIndexTable(TransactionServiceClient transactionServiceClient, HTableInterface hTable, byte[] secondaryIndex) { secondaryIndexTableName = TableName.valueOf(hTable.getName().getNameAsString() + ".idx"); HTable secondaryIndexHTable = null; HBaseAdmin hBaseAdmin = null; try { hBaseAdmin = new HBaseAdmin(hTable.getConfiguration()); if (!hBaseAdmin.tableExists(secondaryIndexTableName)) { hBaseAdmin.createTable(new HTableDescriptor(secondaryIndexTableName)); } secondaryIndexHTable = new HTable(hTable.getConfiguration(), secondaryIndexTableName); } catch (Exception e) { Throwables.propagate(e); } finally { try { hBaseAdmin.close(); } catch (Exception e) { Throwables.propagate(e); } } this.secondaryIndex = secondaryIndex; this.transactionAwareHTable = new TransactionAwareHTable(hTable); this.secondaryIndexTable = new TransactionAwareHTable(secondaryIndexHTable); this.transactionContext = new TransactionContext(transactionServiceClient, transactionAwareHTable, secondaryIndexTable); }
public SecondaryIndexTable(TransactionServiceClient transactionServiceClient, HTableInterface hTable, byte[] secondaryIndex) { secondaryIndexTableName = TableName.valueOf(hTable.getName().getNameAsString() + ".idx"); HTable secondaryIndexHTable = null; HBaseAdmin hBaseAdmin = null; try { hBaseAdmin = new HBaseAdmin(hTable.getConfiguration()); if (!hBaseAdmin.tableExists(secondaryIndexTableName)) { hBaseAdmin.createTable(new HTableDescriptor(secondaryIndexTableName)); } secondaryIndexHTable = new HTable(hTable.getConfiguration(), secondaryIndexTableName); } catch (Exception e) { Throwables.propagate(e); } finally { try { hBaseAdmin.close(); } catch (Exception e) { Throwables.propagate(e); } } this.secondaryIndex = secondaryIndex; this.transactionAwareHTable = new TransactionAwareHTable(hTable); this.secondaryIndexTable = new TransactionAwareHTable(secondaryIndexHTable); this.transactionContext = new TransactionContext(transactionServiceClient, transactionAwareHTable, secondaryIndexTable); }
public SecondaryIndexTable(TransactionServiceClient transactionServiceClient, HTableInterface hTable, byte[] secondaryIndex) { secondaryIndexTableName = TableName.valueOf(hTable.getName().getNameAsString() + ".idx"); HTable secondaryIndexHTable = null; HBaseAdmin hBaseAdmin = null; try { hBaseAdmin = new HBaseAdmin(hTable.getConfiguration()); if (!hBaseAdmin.tableExists(secondaryIndexTableName)) { hBaseAdmin.createTable(new HTableDescriptor(secondaryIndexTableName)); } secondaryIndexHTable = new HTable(hTable.getConfiguration(), secondaryIndexTableName); } catch (Exception e) { Throwables.propagate(e); } finally { try { hBaseAdmin.close(); } catch (Exception e) { Throwables.propagate(e); } } this.secondaryIndex = secondaryIndex; this.transactionAwareHTable = new TransactionAwareHTable(hTable); this.secondaryIndexTable = new TransactionAwareHTable(secondaryIndexHTable); this.transactionContext = new TransactionContext(transactionServiceClient, transactionAwareHTable, secondaryIndexTable); }
public SecondaryIndexTable(TransactionServiceClient transactionServiceClient, HTableInterface hTable, byte[] secondaryIndex) { secondaryIndexTableName = TableName.valueOf(hTable.getName().getNameAsString() + ".idx"); HTable secondaryIndexHTable = null; HBaseAdmin hBaseAdmin = null; try { hBaseAdmin = new HBaseAdmin(hTable.getConfiguration()); if (!hBaseAdmin.tableExists(secondaryIndexTableName)) { hBaseAdmin.createTable(new HTableDescriptor(secondaryIndexTableName)); } secondaryIndexHTable = new HTable(hTable.getConfiguration(), secondaryIndexTableName); } catch (Exception e) { Throwables.propagate(e); } finally { try { hBaseAdmin.close(); } catch (Exception e) { Throwables.propagate(e); } } this.secondaryIndex = secondaryIndex; this.transactionAwareHTable = new TransactionAwareHTable(hTable); this.secondaryIndexTable = new TransactionAwareHTable(secondaryIndexHTable); this.transactionContext = new TransactionContext(transactionServiceClient, transactionAwareHTable, secondaryIndexTable); }
public SecondaryIndexTable(TransactionServiceClient transactionServiceClient, HTableInterface hTable, byte[] secondaryIndex) { secondaryIndexTableName = TableName.valueOf(hTable.getName().getNameAsString() + ".idx"); HTable secondaryIndexHTable = null; HBaseAdmin hBaseAdmin = null; try { hBaseAdmin = new HBaseAdmin(hTable.getConfiguration()); if (!hBaseAdmin.tableExists(secondaryIndexTableName)) { hBaseAdmin.createTable(new HTableDescriptor(secondaryIndexTableName)); } secondaryIndexHTable = new HTable(hTable.getConfiguration(), secondaryIndexTableName); } catch (Exception e) { Throwables.propagate(e); } finally { try { hBaseAdmin.close(); } catch (Exception e) { Throwables.propagate(e); } } this.secondaryIndex = secondaryIndex; this.transactionAwareHTable = new TransactionAwareHTable(hTable); this.secondaryIndexTable = new TransactionAwareHTable(secondaryIndexHTable); this.transactionContext = new TransactionContext(transactionServiceClient, transactionAwareHTable, secondaryIndexTable); }
public SecondaryIndexTable(TransactionServiceClient transactionServiceClient, HTableInterface hTable, byte[] secondaryIndex) { secondaryIndexTableName = TableName.valueOf(hTable.getName().getNameAsString() + ".idx"); HTable secondaryIndexHTable = null; HBaseAdmin hBaseAdmin = null; try { hBaseAdmin = new HBaseAdmin(hTable.getConfiguration()); if (!hBaseAdmin.tableExists(secondaryIndexTableName)) { hBaseAdmin.createTable(new HTableDescriptor(secondaryIndexTableName)); } secondaryIndexHTable = new HTable(hTable.getConfiguration(), secondaryIndexTableName); } catch (Exception e) { Throwables.propagate(e); } finally { try { hBaseAdmin.close(); } catch (Exception e) { Throwables.propagate(e); } } this.secondaryIndex = secondaryIndex; this.transactionAwareHTable = new TransactionAwareHTable(hTable); this.secondaryIndexTable = new TransactionAwareHTable(secondaryIndexHTable); this.transactionContext = new TransactionContext(transactionServiceClient, transactionAwareHTable, secondaryIndexTable); }
byte[] fenceId = "test_table".getBytes(Charsets.UTF_8); final TransactionContext fence1 = new TransactionContext(new InMemoryTxSystemClient(txManager), VisibilityFence.create(fenceId)); fence1.start();
new TransactionContext(new InMemoryTxSystemClient(txManager), readFenceCase16); readTxContextCase16.start(); readTxContextCase16.finish(); new TransactionContext(new InMemoryTxSystemClient(txManager), readFenceCase17); readTxContextCase17.start(); new TransactionContext(new InMemoryTxSystemClient(txManager), readFenceCase18); readTxContextCase18.start(); TransactionContext writeTxContext = new TransactionContext(new InMemoryTxSystemClient(txManager), writeFence); writeTxContext.start(); new TransactionContext(new InMemoryTxSystemClient(txManager), readFenceCase20); readTxContextCase20.start(); new TransactionContext(new InMemoryTxSystemClient(txManager), readFenceCase21); readTxContextCase21.start();