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

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

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

Task.isFailed介绍

暂无

代码示例

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

/**
 * {@inheritDoc}
 */
@Override
public boolean isFailed() {
 return _task.isFailed();
}

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

@Override
 protected void doRunExample(final Engine engine) throws Exception {
  final MockService<String> httpClient = getService();

  final Task<String> fetchWithTimeout =
    fetchUrl(httpClient, "http://www.google.com")
     .withTimeout(50, TimeUnit.MILLISECONDS);

  engine.run(fetchWithTimeout);

  fetchWithTimeout.await();

  System.out.println(!fetchWithTimeout.isFailed() ? "Received result: " + fetchWithTimeout.get()
    : "Error: " + fetchWithTimeout.getError());

  ExampleUtil.printTracingResults(fetchWithTimeout);
 }
}

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

@Test
public void testTransformSuccessToFailure() {
 Task<String> success = getSuccessTask();
 final Exception failureReason = new Exception();
 Task<String> transformed = success.transform(tryT -> Failure.of(failureReason));
 try {
  runAndWait("AbstractTaskTest.testTransformSuccessToSuccess", transformed);
  fail("should have failed");
 } catch (Exception ex) {
  assertTrue(transformed.isFailed());
 }
 assertSame(transformed.getError(), failureReason);
}

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

@Test
public void testToTryCancelled() throws InterruptedException {
 Task<String> cancelMain = delayedValue("value", 6000, TimeUnit.MILLISECONDS);
 Task<Try<String>> task = cancelMain.toTry();
 run(task);
 assertTrue(cancelMain.cancel(new Exception("canceled")));
 task.await();
 assertTrue(task.isDone());
 assertTrue(task.isFailed());
 assertTrue(Exceptions.isCancellation(task.getError()));
 logTracingResults("AbstractTaskTest.testToTryCancelled", task);
}

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

public void testCancelledRecover(int expectedNumberOfTasks) {
 Task<Integer> cancelled = getCancelledTask().map("strlen", String::length).recover(e -> -1);
 try {
  runAndWait("AbstractTaskTest.testCancelledRecover", cancelled);
  fail("should have failed");
 } catch (Exception ex) {
  assertTrue(cancelled.isFailed());
  assertTrue(Exceptions.isCancellation(cancelled.getError()));
 }
 assertEquals(countTasks(cancelled.getTrace()), expectedNumberOfTasks);
}

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

@Test
public void testShutdownThenRunTask() throws InterruptedException {
 _engine.shutdown();
 final Task<String> task = Task.value("task executed");
 _engine.run(task);
 // Task should be cancelled immediately
 assertTrue(task.await(50, TimeUnit.MILLISECONDS));
 assertTrue(task.isFailed());
}

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

@Test
public void testTimeoutTaskWithError() throws InterruptedException {
 final Exception error = new Exception();
 final Task<String> task = Task.callable("task", () -> {
  throw error;
 } );
 final Task<String> timeoutTask = task.withTimeout(2000, TimeUnit.MILLISECONDS);
 getEngine().run(timeoutTask);
 // We should complete with an error almost immediately
 assertTrue(timeoutTask.await(100, TimeUnit.MILLISECONDS));
 assertTrue(timeoutTask.isFailed());
 assertEquals(error, timeoutTask.getError());
}

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

private <T> void assertDone(final Task<T> task, final T expectedValue) {
 assertTrue(task.isDone());
 assertFalse(task.isFailed());
 assertEquals(expectedValue, task.get());
 assertNull(task.getError());
 assertTrue(task.getShallowTrace().getStartNanos() > 0);
 assertTrue(task.getShallowTrace().getStartNanos() <= task.getShallowTrace().getEndNanos());
}

相关文章