congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
TransactionExecutor
Code IndexAdd Tabnine to your IDE (free)

How to use
TransactionExecutor
in
org.apache.tephra

Best Java code snippets using org.apache.tephra.TransactionExecutor (Showing top 20 results out of 315)

origin: cdapio/cdap

 @Override
 public String call() throws Exception {
  return executor.execute(
   new Callable<String>() {
    @Override
    public String call() throws Exception {
     KeyValueTable kvTable = datasetCache.getDataset(AppWithWorker.DATASET);
     return Bytes.toString(kvTable.read(AppWithWorker.RUN));
    }
   });
 }
}, 5, TimeUnit.SECONDS);
origin: caskdata/cdap

@Override
public void increment(final byte[] row, final Map<byte[], Long> increments) {
 txnl.executeUnchecked(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() {
   delegate.increment(row, increments);
  }
 });
}
origin: co.cask.cdap/cdap-data-fabric

 @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)));
     }
     events.clear();
    }
   });
  } catch (TransactionFailureException e) {
   throw new IOException(e);
  } catch (InterruptedException e) {
   Thread.currentThread().interrupt();
   throw new InterruptedIOException();
  }
 }
};
origin: caskdata/cdap

@Override
public void increment(final NavigableMap<byte[], NavigableMap<byte[], Long>> updates) {
 txnl.executeUnchecked(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() {
   delegate.increment(updates);
  }
 });
}
origin: caskdata/cdap

private void writeFact(final Fact fact) throws InterruptedException, TransactionFailureException {
 txnl.execute(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() throws Exception {
   long ts = fact.getTs();
   byte[] srcTag = Bytes.toBytes(fact.getDimensions().get(SRC_DEVICE_ID_TAG));
   byte[] destTag = Bytes.toBytes(fact.getDimensions().get(DEST_DEVICE_ID_TAG));
   if (fact.getDimensions().get(SRC_DEVICE_ID_TAG).equals("1.1.1.1")) {
    table.write(new TimeseriesTable.Entry(ALL_KEY, Bytes.toBytes(fact.getDimensions().get(DST_TAG)), ts));
   } else {
    table.write(new TimeseriesTable.Entry(ALL_KEY, Bytes.toBytes(fact.getDimensions().get(DST_TAG)), ts,
                       srcTag, destTag));
   }
  }
 });
}
origin: caskdata/cdap

@Override
public long incrementAndGet(final byte[] row, final byte[] column, final long delta) {
 return txnl.executeUnchecked(new Callable<Long>() {
  @Override
  public Long call() {
   return delegate.incrementAndGet(row, column, delta);
  }
 });
}
origin: cdapio/cdap

private void executeDelete(final TriggerKey triggerKey) {
 try {
  factory.createExecutor(ImmutableList.of((TransactionAware) table))
   .execute(() -> removeTrigger(table, triggerKey));
 } catch (Throwable th) {
  throw Throwables.propagate(th);
 }
}
origin: caskdata/cdap

@Override
public void delete(final byte[] row, final byte[][] columns) {
 txnl.executeUnchecked(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() {
   delegate.delete(row, columns);
  }
 });
}
origin: cdapio/cdap

private void executeDelete(final JobKey jobKey) {
 try {
  factory.createExecutor(ImmutableList.of((TransactionAware) table))
   .execute(() -> removeJob(table, jobKey));
 } catch (Throwable t) {
  throw Throwables.propagate(t);
 }
}
origin: caskdata/cdap

@Override
public void add(final CubeFact fact) {
 txnl.executeUnchecked(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() {
   delegate.add(fact);
  }
 });
}
origin: co.cask.cdap/cdap-app-fabric

private void executeDelete(final JobKey jobKey) {
 try {
  factory.createExecutor(ImmutableList.of((TransactionAware) table))
   .execute(() -> removeJob(table, jobKey));
 } catch (Throwable t) {
  throw Throwables.propagate(t);
 }
}
origin: caskdata/cdap

@Override
public Collection<TimeSeries> query(final CubeQuery query) {
 return txnl.executeUnchecked(new Callable<Collection<TimeSeries>>() {
  @Override
  public Collection<TimeSeries> call() {
   return delegate.query(query);
  }
 });
}
origin: co.cask.cdap/cdap-app-fabric

private void executeDelete(final TriggerKey triggerKey) {
 try {
  factory.createExecutor(ImmutableList.of((TransactionAware) table))
   .execute(() -> removeTrigger(table, triggerKey));
 } catch (Throwable th) {
  throw Throwables.propagate(th);
 }
}
origin: caskdata/cdap

@Override
public Collection<String> findMeasureNames(final CubeExploreQuery query) {
 return txnl.executeUnchecked(new Callable<Collection<String>>() {
  @Override
  public Collection<String> call() {
   return delegate.findMeasureNames(query);
  }
 });
}
origin: caskdata/cdap

 private void deleteAndVerifyInBatch(final ObjectStoreDataset t, TransactionExecutor txnl,
                   final SortedSet<Long> keysWritten) throws TransactionFailureException,
                   InterruptedException {
  // delete all the keys written earlier
  txnl.execute(new TransactionExecutor.Subroutine() {
   @Override
   public void apply() throws Exception {
    for (Long curKey : keysWritten) {
     t.delete(Bytes.toBytes(curKey));
    }
   }
  });

  // verify that all the keys are deleted
  txnl.execute(new TransactionExecutor.Subroutine() {
   @Override
   public void apply() throws Exception {
    for (Long curKey : keysWritten) {
     Assert.assertNull(t.read(Bytes.toBytes(curKey)));
    }
   }
  });
 }
}
origin: caskdata/cdap

@Override
public Collection<DimensionValue> findDimensionValues(final CubeExploreQuery query) {
 return txnl.executeUnchecked(new Callable<Collection<DimensionValue>>() {
  @Override
  public Collection<DimensionValue> call() {
   return delegate.findDimensionValues(query);
  }
 });
}
origin: cdapio/cdap

private void persistChangeOfState(final TriggerKey triggerKey, final Trigger.TriggerState newTriggerState) {
 try {
  Preconditions.checkNotNull(triggerKey);
  factory.createExecutor(ImmutableList.of((TransactionAware) table))
   .execute(() -> {
    TriggerStatusV2 storedTriggerStatus = readTrigger(table, triggerKey);
    if (storedTriggerStatus != null) {
     // its okay to persist the same trigger back again since during pause/resume
     // operation the trigger does not change. We persist it here with just the new trigger state
     persistTrigger(table, storedTriggerStatus.trigger, newTriggerState);
    } else {
     LOG.warn("Trigger key {} was not found in {} while trying to persist its state to {}.",
          triggerKey, ScheduleStoreTableUtil.SCHEDULE_STORE_DATASET_NAME, newTriggerState);
    }
   });
 } catch (Throwable th) {
  throw Throwables.propagate(th);
 }
}
origin: caskdata/cdap

@Override
public void putBytes(final SortedMap<byte[], ? extends SortedMap<byte[], byte[]>> updates) {
 txnl.executeUnchecked(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() {
   delegate.putBytes(updates);
  }
 });
}
origin: co.cask.cdap/cdap-app-fabric

private void persistChangeOfState(final TriggerKey triggerKey, final Trigger.TriggerState newTriggerState) {
 try {
  Preconditions.checkNotNull(triggerKey);
  factory.createExecutor(ImmutableList.of((TransactionAware) table))
   .execute(() -> {
    TriggerStatusV2 storedTriggerStatus = readTrigger(table, triggerKey);
    if (storedTriggerStatus != null) {
     // its okay to persist the same trigger back again since during pause/resume
     // operation the trigger does not change. We persist it here with just the new trigger state
     persistTrigger(table, storedTriggerStatus.trigger, newTriggerState);
    } else {
     LOG.warn("Trigger key {} was not found in {} while trying to persist its state to {}.",
          triggerKey, ScheduleStoreTableUtil.SCHEDULE_STORE_DATASET_NAME, newTriggerState);
    }
   });
 } catch (Throwable th) {
  throw Throwables.propagate(th);
 }
}
origin: caskdata/cdap

@Override
public boolean swap(final byte[] row, final byte[] column,
          final byte[] oldValue, final byte[] newValue) {
 return txnl.executeUnchecked(new Callable<Boolean>() {
  @Override
  public Boolean call() {
   return delegate.swap(row, column, oldValue, newValue);
  }
 });
}
org.apache.tephraTransactionExecutor

Javadoc

Utility that wraps the execution of a function into the context of a transaction.

Most used methods

  • execute
    Like #execute(Function,Object) but without argument or return value.
  • executeUnchecked
    Same as #execute(Subroutine) but suppresses exception with com.google.common.base.Throwables#propaga

Popular in Java

  • Making http requests using okhttp
  • putExtra (Intent)
  • getSystemService (Context)
  • findViewById (Activity)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Permission (java.security)
    Legacy security code; do not use.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • JLabel (javax.swing)
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now