com.linkedin.parseq.Task.addListener()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中com.linkedin.parseq.Task.addListener()方法的一些代码示例,展示了Task.addListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.addListener()方法的具体详情如下:
包路径:com.linkedin.parseq.Task
类名称:Task
方法名:addListener

Task.addListener介绍

暂无

代码示例

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple8<T1, T2, T3, T4, T5, T6, T7, T8>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple4<T1, T2, T3, T4>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple2<T1, T2>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple5<T1, T2, T3, T4, T5>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple6<T1, T2, T3, T4, T5, T6>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple9<T1, T2, T3, T4, T5, T6, T7, T8, T9>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple3<T1, T2, T3>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

/**
 * {@inheritDoc}
 */
@Override
public void addListener(PromiseListener<Tuple7<T1, T2, T3, T4, T5, T6, T7>> listener) {
 _task.addListener(listener);
}

代码示例来源:origin: linkedin/parseq

private PlanContext(Task<?> root,
  Long id,
  Engine engine,
  SerialExecutor serialExecutor,
  DelayedExecutor scheduler,
  String planClass,
  TaskLogger taskLogger,
  TraceBuilder relationshipsBuilder,
  PlanCompletionListener planCompletionListener) {
 _root = root;
 _id = id;
 _engine = engine;
 _taskExecutor = serialExecutor;
 _timerScheduler = scheduler;
 _planClass = planClass;
 _taskLogger = taskLogger;
 _relationshipsBuilder = relationshipsBuilder;
 _planCompletionListener = planCompletionListener;
 _pending = new AtomicInteger(1);
 _root.addListener(p -> done());
}

代码示例来源:origin: linkedin/parseq

@Test
public void testTraceCompletness() throws InterruptedException {
 final Task<String> task = delayedValue("value", 10, TimeUnit.MILLISECONDS).map("duplicate", x -> x + x);
 final CountDownLatch latch = new CountDownLatch(1);
 final AtomicReference<Trace> trace = new AtomicReference<>();
 task.addListener(s -> {
  trace.set(task.getTrace());
  latch.countDown();
  });
 runAndWait("TestFusionTask.testTraceCompletness", task);
 assertTrue(latch.await(100, TimeUnit.MILLISECONDS), "trace was not abtained in time");
 assertTrue(trace.get().getTraceMap().values().stream()
   .allMatch(shallowTrace -> shallowTrace.getResultType().equals(ResultType.SUCCESS)),
   "all tasks in the trace should have ResultType=SUCCESS");
}

代码示例来源:origin: linkedin/parseq

@Test
public void testAwait() throws InterruptedException {
 final String value = "value";
 final Task<String> task = value("value", value);
 final AtomicReference<Boolean> resultRef = new AtomicReference<Boolean>(false);
 task.addListener(new PromiseListener<String>() {
  @Override
  public void onResolved(Promise<String> stringPromise) {
   try {
    Thread.sleep(100);
   } catch (InterruptedException e) {
    //ignore
   } finally {
    resultRef.set(true);
   }
  }
 });
 runAndWait("TestTasks.testAwait", task);
 assertEquals(Boolean.TRUE, resultRef.get());
}

代码示例来源:origin: linkedin/parseq

@Test
public void testTaskCancellationAfterCompleted() throws InterruptedException {
 final AtomicReference<Throwable> cancelActionValue = new AtomicReference<>();
 Task<?> completed = Task.value(10);
 completed.addListener(p -> {
  if (p.isFailed() && Exceptions.isCancellation(p.getError())) {
   cancelActionValue.set(p.getError().getCause());
  }
 } );
 runAndWait("TestTaskCancellation.testTaskCancellationAfterCompleted", completed);
 Exception cancelReason = new Exception();
 assertFalse(completed.cancel(cancelReason));
 assertNull(cancelActionValue.get());
}

代码示例来源:origin: linkedin/parseq

@Test
public void testTaskCancellationTimeout() throws InterruptedException {
 final AtomicReference<Throwable> cancelActionValue = new AtomicReference<>();
 final CountDownLatch runLatch = new CountDownLatch(1);
 final CountDownLatch listenerLatch = new CountDownLatch(1);
 Task<Integer> uncompleted = Task.async(() -> {
  runLatch.countDown();
  return Promises.settable();
 });
 uncompleted.addListener(p -> {
  if (p.isFailed() && Exceptions.isCancellation(p.getError())) {
   cancelActionValue.set(p.getError().getCause());
  }
  listenerLatch.countDown();
 } );
 Task<?> task = uncompleted.withTimeout(10, TimeUnit.MILLISECONDS).recover(e -> 0);
 runAndWait("TestTaskCancellation.testTaskCancellationTimeout", task);
 assertTrue(listenerLatch.await(5, TimeUnit.SECONDS));
 assertTrue(cancelActionValue.get() instanceof EarlyFinishException);
}

代码示例来源:origin: linkedin/parseq

@Test
public void testTaskCancellationBeforeRun() throws InterruptedException {
 final AtomicReference<Throwable> cancelActionValue = new AtomicReference<>();
 Task<?> uncompleted = Task.async(() -> Promises.settable());
 uncompleted.addListener(p -> {
  if (p.isFailed() && Exceptions.isCancellation(p.getError())) {
   cancelActionValue.set(p.getError().getCause());
  }
 } );
 Exception cancelReason = new Exception();
 assertTrue(uncompleted.cancel(cancelReason));
 getEngine().run(uncompleted);
 uncompleted.await(5, TimeUnit.SECONDS);
 logTracingResults("TestTaskCancellation.testTaskCancellationBeforeRun", uncompleted);
 assertEquals(cancelActionValue.get(), cancelReason);
}

相关文章