@Override public Transaction startLong() { return delegate.startLong(); }
@Override public Transaction startLong() { return delegate.startLong(); }
@Override public Transaction startLong() { return delegate.startLong(); }
@Override public Transaction startLong() { return delegate.startLong(); }
@Override public Transaction startLong() { return delegate.startLong(); }
@Override public Transaction startLong() { return delegate.startLong(); }
private Transaction startTransaction() throws IOException { Transaction tx = txClient.startLong(); LOG.trace("Transaction {} started.", tx); return tx; }
private Transaction startTransaction() throws IOException { Transaction tx = txClient.startLong(); LOG.trace("Transaction {} started.", tx); return tx; }
@Override public Transaction startLong() { try { return delegate.startLong(); } catch (RuntimeException e) { throw handleException(e); } }
@Override public Transaction startLong() { try { return delegate.startLong(); } catch (RuntimeException e) { throw handleException(e); } }
/** * Returns the {@link Transaction} associated with the job. If transaction hasn't been started, a new long * transaction will be started. * * @return the job's {@link Transaction} or {@code null} if it failed to start transaction for the job. */ @Nullable public Transaction getTransaction() { Optional<Transaction> tx = transaction; if (tx == null) { // double-checked locking synchronized (this) { tx = transaction; if (tx == null) { try { tx = transaction = Optional.of(txClient.startLong()); } catch (Throwable t) { LOG.error("Failed to start transaction for job {}", jobId, t); // Set the transaction to an absent Optional to indicate the starting of transaction failed. // This will prevent future call to this method to attempt to start a transaction again tx = transaction = Optional.absent(); } } } } return tx.orNull(); }
/** * Returns the {@link Transaction} associated with the job. If transaction hasn't been started, a new long * transaction will be started. * * @return the job's {@link Transaction} or {@code null} if it failed to start transaction for the job. */ @Nullable public Transaction getTransaction() { Optional<Transaction> tx = transaction; if (tx == null) { // double-checked locking synchronized (this) { tx = transaction; if (tx == null) { try { tx = transaction = Optional.of(txClient.startLong()); } catch (Throwable t) { LOG.error("Failed to start transaction for job {}", jobId, t); // Set the transaction to an absent Optional to indicate the starting of transaction failed. // This will prevent future call to this method to attempt to start a transaction again tx = transaction = Optional.absent(); } } } } return tx.orNull(); }
/** * Returns the {@link Transaction} associated with the job. If transaction hasn't been started, a new long * transaction will be started. * * @return the job's {@link Transaction} or {@code null} if it failed to start transaction for the job. */ @Nullable public Transaction getTransaction() { Optional<Transaction> tx = transaction; if (tx == null) { // double-checked locking synchronized (this) { tx = transaction; if (tx == null) { try { tx = transaction = Optional.of(txClient.startLong()); } catch (Throwable t) { LOG.error("Failed to start transaction for job {}", jobId, t); // Set the transaction to an absent Optional to indicate the starting of transaction failed. // This will prevent future call to this method to attempt to start a transaction again tx = transaction = Optional.absent(); } } } } return tx.orNull(); }
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(); } }
private Transaction startTx(Iterable<TransactionAware> txAwares) throws TransactionFailureException { Transaction transaction = txClient.startLong(); for (TransactionAware txAware : txAwares) { try { txAware.startTx(transaction); } catch (Throwable t) { txClient.abort(transaction); throw new TransactionFailureException( String.format("Unable to start transaction-aware '%s' for transaction %d. ", txAware.getTransactionAwareName(), transaction.getTransactionId()), t); } } return transaction; }
private Transaction startTx(Iterable<TransactionAware> txAwares) throws TransactionFailureException { Transaction transaction = txClient.startLong(); for (TransactionAware txAware : txAwares) { try { txAware.startTx(transaction); } catch (Throwable t) { txClient.abort(transaction); throw new TransactionFailureException( String.format("Unable to start transaction-aware '%s' for transaction %d. ", txAware.getTransactionAwareName(), transaction.getTransactionId()), t); } } return transaction; }
private Transaction startTx(Iterable<TransactionAware> txAwares) throws TransactionFailureException { Transaction transaction = txClient.startLong(); for (TransactionAware txAware : txAwares) { try { txAware.startTx(transaction); } catch (Throwable t) { txClient.abort(transaction); throw new TransactionFailureException( String.format("Unable to start transaction-aware '%s' for transaction %d. ", txAware.getTransactionAwareName(), transaction.getTransactionId()), t); } } return transaction; }
@Test public void testTruncateInvalidTxBefore() throws Exception { TransactionSystemClient txClient = getTxClient(); // Reset state, and assert no invalid transactions are present txClient.resetState(); Assert.assertEquals(0, txClient.getInvalidSize()); // Start few transactions and invalidate them Transaction tx1 = txClient.startShort(); Transaction tx2 = txClient.startLong(); // Sleep so that transaction ids get generated a millisecond apart for assertion // TEPHRA-63 should eliminate the need to sleep TimeUnit.MILLISECONDS.sleep(1); long beforeTx3 = System.currentTimeMillis(); Transaction tx3 = txClient.startLong(); Assert.assertTrue(txClient.invalidate(tx1.getWritePointer())); Assert.assertTrue(txClient.invalidate(tx2.getWritePointer())); Assert.assertTrue(txClient.invalidate(tx3.getWritePointer())); Assert.assertEquals(3, txClient.getInvalidSize()); // Remove all transactions in invalid list beforeTx3 HttpResponse response = doPost("/v3/transactions/invalid/remove/until", GSON.toJson(ImmutableMap.of("time", beforeTx3))); Assert.assertEquals(200, response.getResponseCode()); Assert.assertEquals(1, txClient.getInvalidSize()); }
@Test public void testTruncateInvalidTx() throws Exception { TransactionSystemClient txClient = getTxClient(); // Reset state, and assert no invalid transactions are present txClient.resetState(); Assert.assertEquals(0, txClient.getInvalidSize()); // Start few transactions and invalidate them Transaction tx1 = txClient.startShort(); Transaction tx2 = txClient.startLong(); Transaction tx3 = txClient.startLong(); Assert.assertTrue(txClient.invalidate(tx1.getWritePointer())); Assert.assertTrue(txClient.invalidate(tx2.getWritePointer())); Assert.assertTrue(txClient.invalidate(tx3.getWritePointer())); Assert.assertEquals(3, txClient.getInvalidSize()); // Remove tx1 and tx3 from invalid list HttpResponse response = doPost("/v3/transactions/invalid/remove/ids", GSON.toJson(ImmutableMap.of("ids", ImmutableSet.of(tx1.getWritePointer(), tx3.getWritePointer())))); Assert.assertEquals(200, response.getResponseCode()); Assert.assertEquals(1, txClient.getInvalidSize()); }
@Test public void testGetInvalidSize() throws Exception { TransactionSystemClient txClient = getTxClient(); // Reset state, and assert no invalid transactions are present txClient.resetState(); Assert.assertEquals(0, txClient.getInvalidSize()); // Start few transactions and invalidate them Transaction tx1 = txClient.startShort(); Transaction tx2 = txClient.startLong(); Transaction tx3 = txClient.startLong(); Assert.assertTrue(txClient.invalidate(tx1.getWritePointer())); Assert.assertTrue(txClient.invalidate(tx2.getWritePointer())); Assert.assertTrue(txClient.invalidate(tx3.getWritePointer())); Assert.assertEquals(3, txClient.getInvalidSize()); // Assert through REST API HttpResponse response = doGet("/v3/transactions/invalid/size"); Assert.assertEquals(200, response.getResponseCode()); Map<String, Integer> resultMap = GSON.fromJson(response.getResponseBodyAsString(), STRING_INT_TYPE); Assert.assertNotNull(resultMap); Assert.assertEquals(3, (int) resultMap.get("size")); }