[ https://issues.apache.org/jira/browse/FLINK-10056?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16569169#comment-16569169 ]
ASF GitHub Bot commented on FLINK-10056: ---------------------------------------- yanghua commented on a change in pull request #6490: [FLINK-10056] [test] Add JobMasterTest#testRequestNextInputSplit URL: https://github.com/apache/flink/pull/6490#discussion_r207707318 ########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphTestUtils.java ########## @@ -144,7 +146,48 @@ public static void waitUntilExecutionState(Execution execution, ExecutionState s } if (System.nanoTime() >= deadline) { - throw new TimeoutException(); + throw new TimeoutException( + "The execution did not reach state " + state + " in time. " + + "Current status is " + execution.getState() + '.'); + } + } + + /** + * Waits until the Execution vertex has reached a certain state. + * + * <p>This method is based on polling and might miss very fast state transitions! + */ + public static void waitUntilExecutionVertexState(ExecutionVertex executionVertex, ExecutionState state, long maxWaitMillis) + throws TimeoutException { + + checkNotNull(executionVertex); + checkNotNull(state); + checkArgument(maxWaitMillis >= 0); + + // this is a poor implementation - we may want to improve it eventually + final long deadline = maxWaitMillis == 0 ? Long.MAX_VALUE : System.nanoTime() + (maxWaitMillis * 1_000_000); + + while (true) { + Execution execution = executionVertex.getCurrentExecutionAttempt(); + + if (execution == null || (execution.getState() != state && System.nanoTime() < deadline)) { + try { + Thread.sleep(2); + } catch (InterruptedException ignored) { } + } else { + break; + } + + if (System.nanoTime() >= deadline) { + if (execution != null) { + throw new TimeoutException( + "The execution vertex did not reach state " + state + " in time. " + + "Current status is " + execution.getState() + '.'); Review comment: same as above~ ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Add testRequestNextInputSplit > ----------------------------- > > Key: FLINK-10056 > URL: https://issues.apache.org/jira/browse/FLINK-10056 > Project: Flink > Issue Type: Improvement > Components: JobManager, Tests > Affects Versions: 1.5.0 > Reporter: 陈梓立 > Assignee: 陈梓立 > Priority: Major > Labels: pull-request-available > > Add testRequestNextInputSplit to make sure JobMaster#requestNextInputSplit > works as expected. -- This message was sent by Atlassian JIRA (v7.6.3#76005)