本文整理了Java中com.linkedin.parseq.Task.withTimeout()
方法的一些代码示例,展示了Task.withTimeout()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.withTimeout()
方法的具体详情如下:
包路径:com.linkedin.parseq.Task
类名称:Task
方法名:withTimeout
[英]Equivalent to withTimeout(null, time, unit).
[中]相当于withTimeout(空、时间、单位)。
代码示例来源:origin: linkedin/parseq
/**
* Equivalent to {@code withTimeout(null, time, unit)}.
* @see #withTimeout(String, long, TimeUnit)
*/
default Task<T> withTimeout(final long time, final TimeUnit unit) {
return withTimeout(null, time, unit);
}
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple5Task<T1, T2, T3, T4, T5> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple2Task<T1, T2> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple15Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple9Task<T1, T2, T3, T4, T5, T6, T7, T8, T9> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple3Task<T1, T2, T3> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple11Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple14Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple6Task<T1, T2, T3, T4, T5, T6> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple10Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple12Task<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple8Task<T1, T2, T3, T4, T5, T6, T7, T8> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple7Task<T1, T2, T3, T4, T5, T6, T7> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
/**
* {@inheritDoc}
*/
@Override
public default Tuple4Task<T1, T2, T3, T4> withTimeout(final long time, final TimeUnit unit) {
return cast(Task.super.withTimeout(time, unit));
};
代码示例来源:origin: linkedin/parseq
private <T> Task<Response<T>> withTimeout(final Task<Response<T>> task, ConfigValue<Long> timeout) {
if (timeout.getSource().isPresent()) {
return task.withTimeout("src: " + timeout.getSource().get(), timeout.getValue(), TimeUnit.MILLISECONDS);
} else {
return task.withTimeout(timeout.getValue(), TimeUnit.MILLISECONDS);
}
}
代码示例来源: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 testWithTimeoutAsMiddleOperation() {
Task<String> task = delayedValue("value", 250, TimeUnit.MILLISECONDS).map("first", x -> x + 3)
.withTimeout(5, TimeUnit.MILLISECONDS).map("second", x -> TASK_VALUE);
try {
runAndWait("TestFusionTask.testWithTimeoutAsMiddleOperation", task);
fail("should have failed!");
} catch (Exception ex) {
assertSame(ex.getCause().getClass(), Exceptions.TIMEOUT_EXCEPTION.getClass());
}
}
代码示例来源:origin: linkedin/parseq
@Test
public void testWithTimeoutTwiceSuccess() {
Task<Integer> success = getSuccessTask().andThen(delayedValue(0, 30, TimeUnit.MILLISECONDS))
.withTimeout(100, TimeUnit.MILLISECONDS).withTimeout(5000, TimeUnit.MILLISECONDS);
runAndWait("AbstractTaskTest.testWithTimeoutTwiceSuccess", success);
assertEquals((int) success.get(), 0);
assertEquals(countTasks(success.getTrace()), 7);
}
代码示例来源:origin: linkedin/parseq
@Test
public void testWithTimeoutSuccess() {
Task<Integer> success =
getSuccessTask().andThen(delayedValue(0, 30, TimeUnit.MILLISECONDS)).withTimeout(100, TimeUnit.MILLISECONDS);
runAndWait("AbstractTaskTest.testWithTimeoutSuccess", success);
assertEquals((int) success.get(), 0);
assertEquals(countTasks(success.getTrace()), 5);
}
代码示例来源:origin: linkedin/parseq
@Test
public void testTimeoutTaskWithoutTimeout() throws InterruptedException {
final String value = "value";
final Task<String> task = Task.callable("task", () -> value);
final Task<String> timeoutTask = task.withTimeout(200, TimeUnit.MILLISECONDS);
runAndWait("TestTasks.testTimeoutTaskWithoutTimeout", timeoutTask);
assertEquals(value, task.get());
// The wrapping task should get the same value as the wrapped task
assertEquals(value, timeoutTask.get());
}
内容来源于网络,如有侵权,请联系作者删除!