@Override public void execute(TxRunnable runnable) throws TransactionFailureException { throw new TransactionFailureException("Attempted to start a transaction within a MapReduce transaction"); }
/** * Wraps the given {@link Throwable} as a {@link TransactionFailureException} if it is not already an instance of * {@link TransactionFailureException}. * * @param t the original exception * @param message the exception message to use in case wrapping is needed */ public static TransactionFailureException asTransactionFailure(Throwable t, String message) { if (t instanceof TransactionFailureException) { return (TransactionFailureException) t; } return new TransactionFailureException(message, t); }
@Override public void execute(int timeoutInSeconds, TxRunnable runnable) throws TransactionFailureException { throw new TransactionFailureException("Attempted to start a transaction within a MapReduce transaction"); }
/** * Wraps the given {@link Throwable} as a {@link TransactionFailureException} if it is not already an instance of * {@link TransactionFailureException}. * * @param t the original exception * @param message the exception message to use in case wrapping is needed */ public static TransactionFailureException asTransactionFailure(Throwable t, String message) { if (t instanceof TransactionFailureException) { return (TransactionFailureException) t; } return new TransactionFailureException(message, t); }
@Override public void execute(int timeout, TxRunnable runnable) throws TransactionFailureException { throw new TransactionFailureException("Transaction with explicit timeout is not supported in Spark"); }
@Override public void execute(int timeout, TxRunnable runnable) throws TransactionFailureException { throw new TransactionFailureException("Transaction with explicit timeout is not supported in Spark"); }
@Override public void execute(int timeoutInSeconds, TxRunnable runnable) throws TransactionFailureException { throw new TransactionFailureException("Attempted to start a transaction within a MapReduce transaction"); }
@Override public void execute(int timeout, TxRunnable runnable) throws TransactionFailureException { throw new TransactionFailureException("Transaction with explicit timeout is not supported in Spark"); }
@Override public void execute(TxRunnable runnable) throws TransactionFailureException { throw new TransactionFailureException("Attempted to start a transaction within a MapReduce transaction"); }
private void finishExecute(TransactionContext txContext, TxRunnable runnable) throws TransactionFailureException { try { runnable.run(datasetCache); } catch (Exception e) { txContext.abort(new TransactionFailureException("Exception raised from TxRunnable.run() " + runnable, e)); } // The call the txContext.abort above will always have exception thrown // Hence we'll only reach here if and only if the runnable.run() returns normally. txContext.finish(); } }
public void execute(Runnable runnable) throws TransactionFailureException { TransactionContext txCtx = new TransactionContext(txSystemClient, (TransactionAware) dataset); txCtx.start(); try { runnable.run(); } catch (Throwable t) { txCtx.abort(new TransactionFailureException("runnable failed", t)); } txCtx.finish(); } }
public void execute(Runnable runnable) throws TransactionFailureException { TransactionContext txCtx = new TransactionContext(txSystemClient, (TransactionAware) dataset); txCtx.start(); try { runnable.run(); } catch (Throwable t) { txCtx.abort(new TransactionFailureException("runnable failed", t)); } txCtx.finish(); } }
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 } }
private void finishExecute(TransactionContext txContext, TxRunnable runnable) throws TransactionFailureException { try { runnable.run(datasetCache); } catch (Exception e) { txContext.abort(new TransactionFailureException("Exception raised from TxRunnable.run() " + runnable, e)); } // The call the txContext.abort above will always have exception thrown // Hence we'll only reach here if and only if the runnable.run() returns normally. txContext.finish(); } }
/** * 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)); } }
/** * 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)); } }
@Override public TransactionContext newTransactionContext() throws TransactionFailureException { if (txContext != null && txContext.getCurrentTransaction() != null) { throw new TransactionFailureException("Attempted to start a transaction within active transaction " + txContext.getCurrentTransaction().getTransactionId()); } dismissTransactionContext(); txContext = new DelayedDiscardingTransactionContext(txClient, activeTxAwares.values()); return txContext; }
@Override public TransactionContext newTransactionContext() throws TransactionFailureException { if (txContext != null && txContext.getCurrentTransaction() != null) { throw new TransactionFailureException("Attempted to start a transaction within active transaction " + txContext.getCurrentTransaction().getTransactionId()); } dismissTransactionContext(); txContext = new DelayedDiscardingTransactionContext(txClient, activeTxAwares.values()); return txContext; }
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; }