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

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

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

Task.getTrace介绍

[英]Returns the Trace for this task. The Trace will be a point-in-time snapshot and may change over time until the task is completed.
[中]返回此任务的跟踪。跟踪将是一个时间点快照,可能会随着时间的推移而改变,直到任务完成。

代码示例

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

/**
 * {@inheritDoc}
 */
@Override
public Trace getTrace() {
 return _task.getTrace();
}

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

@Test
public void testWithTimeoutTwiceFailure() {
 Task<Integer> failure = getSuccessTask().andThen(delayedValue(0, 2000, TimeUnit.MILLISECONDS))
   .withTimeout(5000, TimeUnit.MILLISECONDS).withTimeout(100, TimeUnit.MILLISECONDS);
 try {
  runAndWait("AbstractTaskTest.testWithTimeoutTwiceFailure", failure);
  fail("should have failed!");
 } catch (Exception ex) {
  assertEquals(ex.getCause().getClass(), Exceptions.TIMEOUT_EXCEPTION.getClass());
 }
 assertEquals(countTasks(failure.getTrace()), 7);
}

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

@Test
public void testGetRequests() {
 Task<?> task = Task.par(greetingGet(1L), greetingGet(2L));
 runAndWait(getTestClassName() + ".testGetRequests", task);
 if (expectBatching()) {
  assertTrue(hasTask("greetings batch_get(reqs: 2, ids: 2)", task.getTrace()));
 } else {
  assertFalse(hasTask("greetings batch_get(reqs: 2, ids: 2)", task.getTrace()));
 }
}

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

@Test
public void testPar4AndThen() {
 AtomicInteger value = new AtomicInteger();
 Task<?> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4)).andThen((a, b, c, d) -> value.set(a + b + c + d));
 runAndWait("TestTaskFactoryMethods.testPar4AndThen", task);
 assertEquals(value.get(), 1 + 2 + 3 + 4);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 4);
}

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

@Test
public void testSingleGetRequestIsNotBatchedOverrides() {
 Task<?> task = greetingGet(1L, overrides());
 runAndWait(getTestClassName() + ".testSingleGetRequestIsNotBatchedOverrides", task);
 assertFalse(hasTask("greetings batch_get(reqs: 1, ids: 1)", task.getTrace()));
}

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

@Test
public void testBatchGetRequestsOverrides() {
 Task<?> task = Task.par(greetings(overrides(), 1L, 2L), greetings(overrides(), 3L, 4L));
 runAndWait(getTestClassName() + ".testBatchGetRequestsOverrides", task);
 if (expectBatchingOverrides()) {
  assertTrue(hasTask("greetings batch_get(reqs: 2, ids: 4)", task.getTrace()));
 } else {
  assertFalse(hasTask("greetings batch_get(reqs: 2, ids: 4)", task.getTrace()));
 }
}

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

@Test
public void testGetAndBatchGetRequestsWithProjection() {
 Task<?> task = Task.par(greetingGetWithProjection(1L, Greeting.fields().message()), greetingsWithProjection(
   Arrays.asList(Greeting.fields().tone()),2L, 3L));
 runAndWait(getTestClassName() + ".testGetAndBatchGetRequests", task);
 if (expectBatching()) {
  assertTrue(hasTask("greetings batch_get(reqs: 2, ids: 3)", task.getTrace()));
 } else {
  assertFalse(hasTask("greetings batch_get(reqs: 2, ids: 3)", task.getTrace()));
 }
}

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

public void testRecoverWithRecoverd(int expectedNumberOfTasks) {
 Task<String> recovered = getFailureTask().recoverWith(e -> Task.callable("recover success", () -> "recovered"));
 runAndWait("AbstractTaskTest.testRecoverWithRecoverd", recovered);
 assertEquals(recovered.get(), "recovered");
 assertEquals(countTasks(recovered.getTrace()), expectedNumberOfTasks);
}

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

@Test
public void testGetRequestsWithError() {
 Task<String> task = Task.par(toMessage(greetingGet(1L)), toMessage(greetingGet(-1L)).recover(e -> "failed"))
   .map("combine", (x, y) -> x + y);
 runAndWait(getTestClassName() + ".testGetRequestsWithError", task);
 assertEquals(task.get(), "Good morning!failed");
 if (expectBatching()) {
  assertTrue(hasTask("greetings batch_get(reqs: 2, ids: 2)", task.getTrace()));
 } else {
  assertFalse(hasTask("greetings batch_get(reqs: 2, ids: 2)", task.getTrace()));
 }
}

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

@Test
public void testPar8AndThenDsc() {
 AtomicInteger value = new AtomicInteger();
 Task<?> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6), Task.value(7), Task.value(8))
   .andThen("test", (a, b, c, d, e, f, g, h) -> value.set(a + b + c + d + e + f + g + h));
 runAndWait("TestTaskFactoryMethods.testPar8AndThenDsc", task);
 assertEquals(value.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 8);
}

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

@Test
public void testDuplicateGetRequestIsNotBatchedOverrides() {
 Task<?> task = Task.par(greetingGet(1L, overrides()), greetingGet(1L, overrides()));
 runAndWait(getTestClassName() + ".testDuplicateGetRequestIsNotBatchedOverrides", task);
 assertFalse(hasTask("greetings batch_get(reqs: 1, ids: 1)", task.getTrace()));
}

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

@Test
public void testPar4FlatMap() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4)).flatMap((a, b, c, d) -> Task.value(a + b + c + d));
 runAndWait("TestTaskFactoryMethods.testPar4FlatMap", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4);
 assertEquals(countTasks(task.getTrace()), 2 + 3 + 4);
}

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

@Test
public void testPar5FlatMap() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5))
   .flatMap((a, b, c, d, e) -> Task.value(a + b + c + d + e));
 runAndWait("TestTaskFactoryMethods.testPar5FlatMap", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4 + 5);
 assertEquals(countTasks(task.getTrace()), 2 + 3 + 5);
}

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

@Test
public void testPar8() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6),
   Task.value(7), Task.value(8))
   .map((a, b, c, d, e, f, g, h) -> a + b + c + d + e + f + g + h);
 runAndWait("TestTaskFactoryMethods.testPar8", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 8);
}

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

@Test
public void testPar11() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6),
   Task.value(7), Task.value(8), Task.value(9), Task.value(10), Task.value(11))
   .map((a, b, c, d, e, f, g, h, i, j, k) -> a + b + c + d + e + f + g + h + i + j + k);
 runAndWait("TestTaskFactoryMethods.testPar11", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 11);
}

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

@Test
public void testPar10FlatMap() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6), Task.value(7), Task.value(8), Task.value(9), Task.value(10))
   .flatMap((a, b, c, d, e, f, g, h, i, j) -> Task.value(a + b + c + d + e + f + g + h + i + j));
 runAndWait("TestTaskFactoryMethods.testPar10FlatMap", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10);
 assertEquals(countTasks(task.getTrace()), 2 + 3 + 10);
}

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

@Test
public void testPar10FlatMapDsc() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6), Task.value(7), Task.value(8), Task.value(9), Task.value(10))
   .flatMap("test", (a, b, c, d, e, f, g, h, i, j) -> Task.value(a + b + c + d + e + f + g + h + i + j));
 runAndWait("TestTaskFactoryMethods.testPar10FlatMapDsc", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10);
 assertEquals(countTasks(task.getTrace()), 2 + 3 + 10);
}

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

@Test
public void testGetRequestsWithDifferentCustomQueryParamsNoBatching() {
 Task<?> t1 = _parseqClient.createTask(new GreetingsBuilders().get().id(1L)
   .addParam("K1", "V1").build());
 Task<?> t2 = _parseqClient.createTask(new GreetingsBuilders().get().id(2L)
   .addParam("K2", "V1").build());
 Task<?> task = Task.par(t1, t2);
 runAndWait(getTestClassName() + ".testGetRequestsWithDifferentCustomQueryParamsNoBatching", task);
 assertFalse(hasTask("greetings batch_get(reqs: 2, ids: 2)", task.getTrace()));
}

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

@Test
public void testPar15Dsc() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6),
   Task.value(7), Task.value(8), Task.value(9), Task.value(10), Task.value(11), Task.value(12), Task.value(13),
   Task.value(14), Task.value(15))
   .map("test", (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> a + b + c + d + e + f + g + h + i + j + k + l + m
     + n + o);
 runAndWait("TestTaskFactoryMethods.testPar15Dsc", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 15);
}

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

@Test
public void testGetRequestsWithDifferentCustomHeadersNoBatchingOverrides() {
 Task<?> t1 = _parseqClient.createTask(new GreetingsBuilders().get().id(1L)
   .addHeader("H1", "V1").build(), overrides());
 Task<?> t2 = _parseqClient.createTask(new GreetingsBuilders().get().id(2L)
   .addHeader("H2", "V1").build(), overrides());
 Task<?> task = Task.par(t1, t2);
 runAndWait(getTestClassName() + ".testGetRequestsWithDifferentCustomHeadersNoBatchingOverrides", task);
 assertFalse(hasTask("greetings batch_get(reqs: 2, ids: 2)", task.getTrace()));
}

相关文章