Package co.cask.tephra

Examples of co.cask.tephra.TransactionExecutor


    final QueueProducer producer = queueClientFactory.createProducer(QueueName.fromStream(config.getName()));
    final List<TransactionAware> txAwares = Lists.newArrayList();
    if (producer instanceof TransactionAware) {
      txAwares.add((TransactionAware) producer);
    }
    final TransactionExecutor txExecutor = executorFactory.createExecutor(txAwares);

    // Adapt the FileWriter interface into Queue2Producer
    return new FileWriter<StreamEvent>() {

      private final List<StreamEvent> events = Lists.newArrayList();

      @Override
      public void append(StreamEvent event) throws IOException {
        events.add(event);
      }

      @Override
      public void close() throws IOException {
        if (producer instanceof Closeable) {
          ((Closeable) producer).close();
        }
      }

      @Override
      public void flush() throws IOException {
        try {
          txExecutor.execute(new TransactionExecutor.Subroutine() {
            @Override
            public void apply() throws Exception {
              for (StreamEvent event : events) {
                producer.enqueue(new QueueEntry(STREAM_EVENT_CODEC.encodePayload(event)));
              }
View Full Code Here


      if (dataset instanceof TransactionAware) {
        txAwares.add((TransactionAware) dataset);
      }
    }

    TransactionExecutor txExecutor = new DefaultTransactionExecutor(txClient, txAwares);

    RETURN_TYPE result = txExecutor.execute(new Callable<RETURN_TYPE>() {
      @Override
      public RETURN_TYPE call() throws Exception {
        return tx.call(context);
      }
    });
View Full Code Here

      public TransactionAware apply(V input) {
        return (TransactionAware) input;
      }
    });

    TransactionExecutor executor = txFactory.createExecutor(txAwares);
    try {
      return executor.execute(func, it);
    } finally {
      for (V t : it) {
        if (t instanceof Closeable) {
          ((Closeable) t).close();
        }
View Full Code Here

TOP

Related Classes of co.cask.tephra.TransactionExecutor

Copyright © 2018 www.massapicom. 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.