@Override public void commitOrThrow(Transaction tx) throws TransactionFailureException { delegate.commitOrThrow(tx); }
@Override public void commitOrThrow(Transaction tx) throws TransactionFailureException { delegate.commitOrThrow(tx); }
@Override public void commitOrThrow(Transaction tx) throws TransactionFailureException { delegate.commitOrThrow(tx); }
@Override public void commitOrThrow(Transaction tx) throws TransactionFailureException { delegate.commitOrThrow(tx); }
@Override public void commitOrThrow(Transaction tx) throws TransactionFailureException { delegate.commitOrThrow(tx); }
@Override public void commitOrThrow(Transaction tx) throws TransactionFailureException { delegate.commitOrThrow(tx); }
@Override public void commitOrThrow(Transaction tx) throws TransactionFailureException { try { delegate.commitOrThrow(tx); } catch (RuntimeException e) { throw handleException(e); } }
@Override public void commitOrThrow(Transaction tx) throws TransactionFailureException { try { delegate.commitOrThrow(tx); } catch (RuntimeException e) { throw handleException(e); } }
/** * Commits the current transaction. */ private void commit() throws TransactionFailureException { try { txClient.commitOrThrow(currentTx); } catch (TransactionFailureException e) { abort(e); } catch (Throwable e) { abort(new TransactionFailureException( String.format("Exception from commit for transaction %d.", currentTx.getTransactionId()), e)); } }
private void commit() throws TransactionFailureException { try { txClient.commitOrThrow(currentTx); } catch (TransactionFailureException e) { abort(e); // abort will rethrow this exception } catch (Throwable e) { String message = String.format("Exception from commit for transaction %d.", currentTx.getTransactionId()); abort(new TransactionFailureException(message, e)); // abort will throw that exception } }
public void doMain(String[] args) throws Exception { if (args.length < 1) { printHelp(); return; } String tableName = args[0]; try { startUp(); Transaction tx = txClient.startLong(); Job job = createSubmittableJob(tx, tableName); if (!job.waitForCompletion(true)) { LOG.info("MapReduce job failed!"); throw new RuntimeException("Failed to run the MapReduce job."); } // Always commit the transaction, since we are not doing any data update // operation in this tool. txClient.commitOrThrow(tx); System.out.println("Export operation complete. HFiles are stored at location " + bulkloadDir.toString()); } finally { stop(); } }
/** * Commits the current transaction. */ private void commit() throws TransactionFailureException { try { txClient.commitOrThrow(currentTx); } catch (TransactionFailureException e) { abort(e); } catch (Throwable e) { abort(new TransactionFailureException( String.format("Exception from commit for transaction %d.", currentTx.getTransactionId()), e)); } }
private void closeTransaction(QueryHandle handle, OperationInfo opInfo) { try { String txCommitted = opInfo.getSessionConf().get(Constants.Explore.TX_QUERY_CLOSED); if (txCommitted != null && Boolean.parseBoolean(txCommitted)) { LOG.trace("Transaction for handle {} has already been closed", handle); return; } Transaction tx = ConfigurationUtil.get(opInfo.getSessionConf(), Constants.Explore.TX_QUERY_KEY, TxnCodec.INSTANCE); LOG.trace("Closing transaction {} for handle {}", tx, handle); if (opInfo.isReadOnly() || (opInfo.getStatus() != null && opInfo.getStatus().getStatus() == QueryStatus.OpStatus.FINISHED)) { try { txClient.commitOrThrow(tx); } catch (TransactionFailureException e) { txClient.invalidate(tx.getWritePointer()); LOG.info("Invalidating transaction: {}", tx); } } else { txClient.invalidate(tx.getWritePointer()); } } catch (Throwable e) { LOG.error("Got exception while closing transaction.", e); } finally { opInfo.getSessionConf().put(Constants.Explore.TX_QUERY_CLOSED, "true"); } }
private void closeTransaction(QueryHandle handle, OperationInfo opInfo) { try { String txCommitted = opInfo.getSessionConf().get(Constants.Explore.TX_QUERY_CLOSED); if (txCommitted != null && Boolean.parseBoolean(txCommitted)) { LOG.trace("Transaction for handle {} has already been closed", handle); return; } Transaction tx = ConfigurationUtil.get(opInfo.getSessionConf(), Constants.Explore.TX_QUERY_KEY, TxnCodec.INSTANCE); LOG.trace("Closing transaction {} for handle {}", tx, handle); if (opInfo.isReadOnly() || (opInfo.getStatus() != null && opInfo.getStatus().getStatus() == QueryStatus.OpStatus.FINISHED)) { try { txClient.commitOrThrow(tx); } catch (TransactionFailureException e) { txClient.invalidate(tx.getWritePointer()); LOG.info("Invalidating transaction: {}", tx); } } else { txClient.invalidate(tx.getWritePointer()); } } catch (Throwable e) { LOG.error("Got exception while closing transaction.", e); } finally { opInfo.getSessionConf().put(Constants.Explore.TX_QUERY_CLOSED, "true"); } }
private void commitTx(Transaction transaction) throws IOException { try { LOG.debug("Committing MapReduce Job transaction: {}", transaction.getWritePointer()); // "Commit" the data event topic by publishing an empty message. // Need to do it with the raw MessagingService. taskContext.getMessagingService().publish( StoreRequestBuilder .of(NamespaceId.SYSTEM.topic(cConf.get(Constants.Dataset.DATA_EVENT_TOPIC))) .setTransaction(transaction.getWritePointer()) .build()); // flush dataset operations (such as from any DatasetOutputCommitters) taskContext.flushOperations(); // no need to rollback changes if commit fails, as these changes where performed by mapreduce tasks // NOTE: can't call afterCommit on datasets in this case: the changes were made by external processes. try { txClient.commitOrThrow(transaction); } catch (TransactionFailureException e) { LOG.warn("MapReduce Job transaction {} failed to commit", transaction.getTransactionId()); throw e; } taskContext.postTxCommit(); } catch (Exception e) { Throwables.propagateIfInstanceOf(e, IOException.class); throw Throwables.propagate(e); } }
private void commitTx(Transaction transaction) throws IOException { try { LOG.debug("Committing MapReduce Job transaction: {}", transaction.getWritePointer()); // "Commit" the data event topic by publishing an empty message. // Need to do it with the raw MessagingService. taskContext.getMessagingService().publish( StoreRequestBuilder .of(NamespaceId.SYSTEM.topic(cConf.get(Constants.Dataset.DATA_EVENT_TOPIC))) .setTransaction(transaction.getWritePointer()) .build()); // flush dataset operations (such as from any DatasetOutputCommitters) taskContext.flushOperations(); // no need to rollback changes if commit fails, as these changes where performed by mapreduce tasks // NOTE: can't call afterCommit on datasets in this case: the changes were made by external processes. try { txClient.commitOrThrow(transaction); } catch (TransactionFailureException e) { LOG.warn("MapReduce Job transaction {} failed to commit", transaction.getTransactionId()); throw e; } taskContext.postTxCommit(); } catch (Exception e) { Throwables.propagateIfInstanceOf(e, IOException.class); throw Throwables.propagate(e); } }
private void commitAndAssertSuccess(Transaction tx, TransactionAware txAware) throws Exception { txClient.canCommitOrThrow(tx, txAware.getTxChanges()); Assert.assertTrue(txAware.commitTx()); txClient.commitOrThrow(tx); }
@Test public void testReadOwnWrite() throws Exception { final String tableName = "readOwnWrite"; DatasetAdmin admin = getTableAdmin(CONTEXT1, tableName); admin.create(); Table table = getTable(CONTEXT1, tableName); Transaction tx = txClient.startShort(); try { ((TransactionAware) table).startTx(tx); // Write some data, then flush it by calling commitTx. table.put(new Put(R1, C1, V1)); ((TransactionAware) table).commitTx(); // Try to read the previous write. Assert.assertArrayEquals(V1, table.get(new Get(R1, C1)).get(C1)); } finally { txClient.commitOrThrow(tx); } // drop table admin.drop(); }
/** * Tests invalidating a transaction. */ @Test public void testInvalidateTx() throws Exception { TransactionSystemClient txClient = getTxClient(); Transaction tx1 = txClient.startShort(); HttpResponse response = doPost("/v3/transactions/" + tx1.getWritePointer() + "/invalidate"); Assert.assertEquals(200, response.getResponseCode()); Transaction tx2 = txClient.startShort(); txClient.commitOrThrow(tx2); response = doPost("/v3/transactions/" + tx2.getWritePointer() + "/invalidate"); Assert.assertEquals(409, response.getResponseCode()); Assert.assertEquals(400, doPost("/v3/transactions/foobar/invalidate").getResponseCode()); }
@Test public void testBatchWritableKeyIsIgnored() throws Exception { String tableName = "batchWritableTable"; getTableAdmin(CONTEXT1, tableName).create(); try { // write in a transaction, three times, with key = null, a, q, always Put with row = a Transaction tx = txClient.startShort(); Table table = getTable(CONTEXT1, tableName); ((TransactionAware) table).startTx(tx); table.write(null, new Put("a").add("x", "x")); table.write(new byte[]{'q'}, new Put("a").add("y", "y")); table.write(new byte[]{'a'}, new Put("a").add("z", "z")); txClient.canCommitOrThrow(tx, ((TransactionAware) table).getTxChanges()); ((TransactionAware) table).commitTx(); txClient.commitOrThrow(tx); // validate that all writes went to row a, and row q was not written tx = txClient.startShort(); ((TransactionAware) table).startTx(tx); Assert.assertTrue(table.get(new Get("q")).isEmpty()); Row row = table.get(new Get("a")); Assert.assertEquals(3, row.getColumns().size()); Assert.assertEquals("x", row.getString("x")); Assert.assertEquals("y", row.getString("y")); Assert.assertEquals("z", row.getString("z")); ((TransactionAware) table).commitTx(); txClient.abort(tx); } finally { getTableAdmin(CONTEXT1, tableName).drop(); } }