Codota Logo
TransactionExecutor.execute
Code IndexAdd Codota to your IDE (free)

How to use
execute
method
in
org.apache.tephra.TransactionExecutor

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
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

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: 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: 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: 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: 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: cdapio/cdap

@After
public void tearDown() throws Exception {
 txExecutor.execute(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() throws Exception {
   for (Job job : getAllJobs(jobQueue, true)) {
    jobQueue.deleteJob(job);
   }
  }
 });
}
origin: cdapio/cdap

private void fillTestInputData(TransactionExecutorFactory txExecutorFactory,
                final TimeseriesTable table,
                final boolean withBadData) throws TransactionFailureException, InterruptedException {
 TransactionExecutor executor = Transactions.createTransactionExecutor(txExecutorFactory, table);
 executor.execute(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() {
   fillTestInputData(table, withBadData);
  }
 });
}
origin: cdapio/cdap

private void writeRunRecordMeta(RunRecordMeta runRecordMeta,
                long timestampInMillis) throws InterruptedException, TransactionFailureException {
 heartBeatTxnl.execute(() -> programHeartbeatDataset.writeRunRecordMeta(runRecordMeta, timestampInMillis));
}
origin: cdapio/cdap

/**
 * writes heart beat messages starting from startTime + interval up to endTime, each heartbeat separated by interval
 */
private void setUpProgramHeartBeats(RunRecordMeta runRecordMeta,
                  long startTime, long endTime, long interval,
                  TransactionExecutor txnl, ProgramHeartbeatDataset programHeartbeatDataset)
 throws InterruptedException, TransactionFailureException {
 txnl.execute(() -> {
  for (long time = startTime + interval; time < endTime; time += interval) {
   programHeartbeatDataset.writeRunRecordMeta(runRecordMeta, time);
  }
 });
}
origin: caskdata/cdap

@Test(expected = TransactionFailureException.class)
public void testInvalidTimeRangeCondition() throws Exception {
 TransactionExecutor txnl = dsFrameworkUtil.newTransactionExecutor(table);
 txnl.execute(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() throws Exception {
   long ts = System.currentTimeMillis();
   table.read(Bytes.toBytes("any"), ts, ts - 100);
  }
 });
}
origin: caskdata/cdap

@Test
public void test() throws Exception {
 final long now = System.currentTimeMillis();
 sendData(now);
 // verify
 txnl.execute(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() throws Exception {
   testScan(now);
   testNoRow(now);
   testFilter(now);
   testNoTagMatch(now);
   testReadEntryWithoutTag(now);
  }
 });
}
origin: cdapio/cdap

private void heartbeatDatasetStatusCheck(long startTime, ProgramRunStatus expectedStatus)
 throws InterruptedException, ExecutionException, TimeoutException {
 Tasks.waitFor(expectedStatus, () -> heartBeatTxnl.execute(() -> {
  Collection<RunRecordMeta> runRecordMetas =
   // programHeartbeatDataset uses seconds for timeunit for recording runrecords
   programHeartbeatDataset.scan(
    TimeUnit.MILLISECONDS.toSeconds(startTime), TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),
    ImmutableSet.of(NamespaceId.DEFAULT.getNamespace()));
  if (runRecordMetas.size() == 0) {
   return null;
  }
  Assert.assertEquals(1, runRecordMetas.size());
  return runRecordMetas.iterator().next().getStatus();
 }), 10, TimeUnit.SECONDS);
}
origin: cdapio/cdap

private List<ProgramRunId> addProgramCount(TransactionExecutor txnl, AppMetadataStore store,
                      ProgramId programId, int count) throws Exception {
 List<ProgramRunId> runIds = new ArrayList<>();
 for (int i = 0; i < count; i++) {
  RunId runId = RunIds.generate(i * 1000);
  ProgramRunId run = programId.run(runId);
  runIds.add(run);
  txnl.execute(() -> {
   recordProvisionAndStart(run, store);
  });
 }
 return runIds;
}
origin: caskdata/cdap

private void testInputConfigurationFailure(Map<String, String> arguments, final String why) throws Exception {
 final TimePartitionedFileSet dataset = dsFrameworkUtil.getInstance(TPFS_INSTANCE, arguments);
 TransactionAware txAwareDataset = (TransactionAware) dataset;
 dsFrameworkUtil.newInMemoryTransactionExecutor(txAwareDataset).execute(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() throws Exception {
   try {
    dataset.getInputFormatConfiguration();
    Assert.fail("getInputFormatConfiguration should fail " + why);
   } catch (Exception e) {
    // expected
   }
  }});
}
origin: caskdata/cdap

@Test
public void testValidTimeRangesAreAllowed() throws Exception {
 TransactionExecutor txnl = dsFrameworkUtil.newTransactionExecutor(table);
 txnl.execute(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() throws Exception {
   long ts = System.currentTimeMillis();
   Iterator<TimeseriesTable.Entry> temp = table.read(Bytes.toBytes("any"), ts, ts);
   Assert.assertFalse(temp.hasNext());
   temp = table.read(Bytes.toBytes("any"), ts, ts + 100);
   Assert.assertFalse(temp.hasNext());
  }
 });
}
origin: caskdata/cdap

private void testInputConfiguration(Map<String, String> arguments, final String expectedPath) throws Exception {
 final TimePartitionedFileSet dataset = dsFrameworkUtil.getInstance(TPFS_INSTANCE, arguments);
 TransactionAware txAwareDataset = (TransactionAware) dataset;
 dsFrameworkUtil.newInMemoryTransactionExecutor(txAwareDataset).execute(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() throws Exception {
   Map<String, String> inputConf = dataset.getInputFormatConfiguration();
   String input = inputConf.get(FileInputFormat.INPUT_DIR);
   Assert.assertNotNull(input);
   String[] inputs = input.split(",");
   Assert.assertEquals(1, inputs.length);
   Assert.assertTrue(inputs[0].endsWith(expectedPath));
  }
 });
}
origin: caskdata/cdap

@Test
public void testInvalidPartitionFilter() throws Exception {
 final PartitionedFileSet pfs = dsFrameworkUtil.getInstance(pfsInstance);
 dsFrameworkUtil.newTransactionExecutor((TransactionAware) pfs).execute(new TransactionExecutor.Subroutine() {
  @Override
  public void apply() throws Exception {
   // this should succeed without error (but log a warning)
   Assert.assertEquals(Collections.EMPTY_SET,
             pfs.getPartitions(PartitionFilter.builder().addValueCondition("me-not-there", 42).build()));
  }
 });
}
origin: cdapio/cdap

private void checkProgramStatus(ArtifactId artifactId, ProgramRunId runId, ProgramRunStatus expectedStatus)
 throws InterruptedException, ExecutionException, TimeoutException {
 Tasks.waitFor(expectedStatus, () -> txnl.execute(() -> {
         RunRecordMeta meta = metadataStoreDataset.getRun(runId);
         if (meta == null) {
          return null;
         }
         Assert.assertEquals(artifactId, meta.getArtifactId());
         return meta.getStatus();
        }),
        10, TimeUnit.SECONDS);
}
origin: cdapio/cdap

@After
public void cleanupTest() throws Exception {
 txnl.execute(() -> {
  Scanner scanner = appMetaTable.scan(null, null);
  Row row;
  while ((row = scanner.next()) != null) {
   appMetaTable.delete(row.getRow());
  }
 });
}
org.apache.tephraTransactionExecutorexecute

Javadoc

Like #execute(Function,Object) but the callable has no argument.

Popular methods of TransactionExecutor

  • executeUnchecked
    Same as #execute(Subroutine) but suppresses exception with com.google.common.base.Throwables#propaga

Popular in Java

  • Reading from database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • PrintStream (java.io)
    A PrintStream adds functionality to another output stream, namely the ability to print representatio
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • JButton (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now