Package co.cask.tephra

Examples of co.cask.tephra.TransactionContext.finish()


        // TODO (terence): Actually need to coordinates with other flowlets to drain the queue.
        TransactionContext txContext = dataFabricFacade.createTransactionManager();
        txContext.start();
        try {
          ((Closeable) consumer).close();
          txContext.finish();
        } catch (TransactionFailureException e) {
          LOG.warn("Fail to commit transaction when closing consumer.");
          txContext.abort();
        }
      }
View Full Code Here


      try {
        InputDatum<T> input = entry.getProcessSpec().getQueueReader().dequeue(0, TimeUnit.MILLISECONDS);
        if (!input.needProcess()) {
          entry.backOff();
          // End the transaction if nothing in the queue
          txContext.finish();
          return false;
        }
        // Resetting back-off time to minimum back-off time,
        // since an entry to process was de-queued and most likely more entries will follow.
        entry.resetBackOff();
View Full Code Here

      @Override
      public void ack() throws TransactionFailureException {
        TransactionContext txContext = dataFabricFacade.createTransactionManager();
        txContext.start();
        input.reclaim();
        txContext.finish();
      }
    };
  }

  private void initFlowlet() throws InterruptedException {
View Full Code Here

      } catch (Throwable t) {
        LOG.error("User code exception. Aborting transaction.", t);
        txContext.abort(new TransactionFailureException("User code exception. Aborting transaction", t));
        throw Throwables.propagate(t);
      }
      txContext.finish();
    } catch (TransactionFailureException e) {
      LOG.error("Flowlet throws exception during flowlet initialize: " + flowletContext, e);
      throw Throwables.propagate(e);
    }
  }
View Full Code Here

      } catch (Throwable t) {
        LOG.error("User code exception. Aborting transaction.", t);
        txContext.abort(new TransactionFailureException("User code exception. Aborting transaction", t));
        // No need to propagate, as it is shutting down.
      }
      txContext.finish();
    } catch (TransactionFailureException e) {
      LOG.error("Flowlet throws exception during flowlet destroy: " + flowletContext, e);
      // No need to propagate, as it is shutting down.
    }
  }
View Full Code Here

  public void execute(TxRunnable runnable) {
    final TransactionContext context = new TransactionContext(transactionSystemClient);
    try {
      context.start();
      runnable.run(new ServiceWorkerDatasetContext(context));
      context.finish();
    } catch (TransactionFailureException e) {
      abortTransaction(e, "Failed to commit. Aborting transaction.", context);
    } catch (Exception e) {
      abortTransaction(e, "Exception occurred running user code. Aborting transaction.", context);
    }
View Full Code Here

      try {
        InputDatum<T> input = entry.getProcessSpec().getQueueReader().dequeue(0, TimeUnit.MILLISECONDS);
        if (!input.needProcess()) {
          entry.backOff();
          // End the transaction if nothing in the queue
          txContext.finish();
          return false;
        }
        // Resetting back-off time to minimum back-off time,
        // since an entry to process was de-queued and most likely more entries will follow.
        entry.resetBackOff();
View Full Code Here

      @Override
      public void ack() throws TransactionFailureException {
        TransactionContext txContext = dataFabricFacade.createTransactionManager();
        txContext.start();
        input.reclaim();
        txContext.finish();
      }
    };
  }

  private void initFlowlet() throws InterruptedException {
View Full Code Here

        }

        @Override
        public void flush() {
          try {
            txContext.finish();
            txContext.start();
          } catch (TransactionFailureException e) {
            throw Throwables.propagate(e);
          }
        }
View Full Code Here

        }

        @Override
        public void flush() {
          try {
            txContext.finish();
            txContext.start();
          } catch (TransactionFailureException e) {
            throw Throwables.propagate(e);
          }
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.