本文整理汇总了Java中scala.concurrent.duration.Deadline.isOverdue方法的典型用法代码示例。如果您正苦于以下问题:Java Deadline.isOverdue方法的具体用法?Java Deadline.isOverdue怎么用?Java Deadline.isOverdue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scala.concurrent.duration.Deadline
的用法示例。
在下文中一共展示了Deadline.isOverdue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: awaitJobManagerGatewayAndWebPort
import scala.concurrent.duration.Deadline; //导入方法依赖的package包/类
/**
* Awaits the leading job manager gateway and its web monitor port.
*/
public Tuple2<ActorGateway, Integer> awaitJobManagerGatewayAndWebPort() throws Exception {
Future<Tuple2<ActorGateway, Integer>> gatewayPortFuture = null;
Deadline deadline = timeout.fromNow();
while (!deadline.isOverdue()) {
synchronized (waitLock) {
gatewayPortFuture = leaderGatewayPortFuture;
if (gatewayPortFuture != null) {
break;
}
waitLock.wait(deadline.timeLeft().toMillis());
}
}
if (gatewayPortFuture == null) {
throw new TimeoutException("There is no JobManager available.");
} else {
return Await.result(gatewayPortFuture, deadline.timeLeft());
}
}
示例2: testJobClientRecovery
import scala.concurrent.duration.Deadline; //导入方法依赖的package包/类
/**
* Tests whether the JobClientActor can connect to a newly elected leading job manager to obtain
* the JobExecutionResult. The submitted job blocks for the first execution attempt. The
* leading job manager will be killed so that the second job manager will be elected as the
* leader. The newly elected leader has to retrieve the checkpointed job from ZooKeeper
* and continue its execution. This time, the job does not block and, thus, can be finished.
* The execution result should be sent to the JobClientActor which originally submitted the
* job.
*
* @throws Exception
*/
@Test
public void testJobClientRecovery() throws Exception {
File rootFolder = tempFolder.getRoot();
Configuration config = ZooKeeperTestUtils.createZooKeeperHAConfig(
zkServer.getConnectString(),
rootFolder.getPath());
config.setInteger(ConfigConstants.LOCAL_NUMBER_JOB_MANAGER, 2);
config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, 1);
final TestingCluster cluster = new TestingCluster(config);
cluster.start();
JobVertex blockingVertex = new JobVertex("Blocking Vertex");
blockingVertex.setInvokableClass(BlockingTask.class);
blockingVertex.setParallelism(1);
final JobGraph jobGraph = new JobGraph("Blocking Test Job", blockingVertex);
final Promise<JobExecutionResult> promise = new scala.concurrent.impl.Promise.DefaultPromise<>();
Deadline deadline = new FiniteDuration(2, TimeUnit.MINUTES).fromNow();
try {
Thread submitter = new Thread(new Runnable() {
@Override
public void run() {
try {
JobExecutionResult result = cluster.submitJobAndWait(jobGraph, false);
promise.success(result);
} catch (Exception e) {
promise.failure(e);
}
}
});
submitter.start();
synchronized (BlockingTask.waitLock) {
while (BlockingTask.HasBlockedExecution < 1 && deadline.hasTimeLeft()) {
BlockingTask.waitLock.wait(deadline.timeLeft().toMillis());
}
}
if (deadline.isOverdue()) {
Assert.fail("The job has not blocked within the given deadline.");
}
ActorGateway gateway = cluster.getLeaderGateway(deadline.timeLeft());
gateway.tell(TestingJobManagerMessages.getDisablePostStop());
gateway.tell(PoisonPill.getInstance());
// if the job fails then an exception is thrown here
Await.result(promise.future(), deadline.timeLeft());
} finally {
cluster.stop();
}
}