Package co.cask.tephra

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


    try {
      if (consumer != null && consumer instanceof Closeable) {
        // Call close in a new transaction.
        // 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.");
View Full Code Here


    }

    // Begin transaction and dequeue
    final TransactionContext txContext = flowletContext.createTransactionContext();
    try {
      txContext.start();

      try {
        InputDatum<T> input = entry.getProcessSpec().getQueueReader().dequeue(0, TimeUnit.MILLISECONDS);
        if (!input.needProcess()) {
          entry.backOff();
View Full Code Here

  private InputAcknowledger createInputAcknowledger(final InputDatum input) {
    return new InputAcknowledger() {
      @Override
      public void ack() throws TransactionFailureException {
        TransactionContext txContext = dataFabricFacade.createTransactionManager();
        txContext.start();
        input.reclaim();
        txContext.finish();
      }
    };
  }
View Full Code Here

  }

  private void initFlowlet() throws InterruptedException {
    final TransactionContext txContext = flowletContext.createTransactionContext();
    try {
      txContext.start();
      try {
        LOG.info("Initializing flowlet: " + flowletContext);

        flowlet.initialize(flowletContext);
View Full Code Here

  }

  private void destroyFlowlet() {
    final TransactionContext txContext = flowletContext.createTransactionContext();
    try {
      txContext.start();
      try {
        LOG.info("Destroying flowlet: " + flowletContext);
        flowlet.destroy();
        LOG.info("Flowlet destroyed: " + flowletContext);
      } catch (Throwable t) {
View Full Code Here

  @Override
  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) {
View Full Code Here

    }

    // Begin transaction and dequeue
    TransactionContext txContext = dataFabricFacade.createTransactionManager();
    try {
      txContext.start();

      try {
        InputDatum<T> input = entry.getProcessSpec().getQueueReader().dequeue(0, TimeUnit.MILLISECONDS);
        if (!input.needProcess()) {
          entry.backOff();
View Full Code Here

  private InputAcknowledger createInputAcknowledger(final InputDatum input) {
    return new InputAcknowledger() {
      @Override
      public void ack() throws TransactionFailureException {
        TransactionContext txContext = dataFabricFacade.createTransactionManager();
        txContext.start();
        input.reclaim();
        txContext.finish();
      }
    };
  }
View Full Code Here

    final T dataSet = (T) datasetFramework.getDataset(datasetInstanceName, new HashMap<String, String>(), null);
    try {
      TransactionAware txAwareDataset = (TransactionAware) dataSet;
      final TransactionContext txContext =
        new TransactionContext(txSystemClient, Lists.newArrayList(txAwareDataset));
      txContext.start();
      return new DataSetManager<T>() {
        @Override
        public T get() {
          return dataSet;
        }
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.