Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ void onGloballyTerminalState(JobStatus globallyTerminalState) {
}

private void goToSubsequentState() {
if (availableParallelismNotChanged(restartWithParallelism)) {
if (availableParallelismNotChanged(restartWithParallelism)
|| context.hasDesiredResources()) {
context.goToCreatingExecutionGraph(getExecutionGraph());
} else {
context.goToWaitingForResources(getExecutionGraph());
Expand Down Expand Up @@ -163,6 +164,13 @@ interface Context
* slots.
*/
Optional<VertexParallelism> getAvailableVertexParallelism();

/**
* Checks whether we have the desired resources.
*
* @return {@code true} if we have enough resources; otherwise {@code false}
*/
boolean hasDesiredResources();
}

static class Factory implements StateFactory<Restarting> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class MockRestartingContext extends MockStateWithExecutionGraphContext

@Nullable private VertexParallelism availableVertexParallelism;

private boolean hasDesiredResources = false;

public void setExpectCancelling(Consumer<ExecutingTest.CancellingArguments> asserter) {
cancellingStateValidator.expectInput(asserter);
}
Expand All @@ -68,6 +70,15 @@ public void setAvailableVertexParallelism(
this.availableVertexParallelism = availableVertexParallelism;
}

public void setHasDesiredResources(boolean hasDesiredResources) {
this.hasDesiredResources = hasDesiredResources;
}

@Override
public boolean hasDesiredResources() {
return hasDesiredResources;
}

@Override
public void goToCanceling(
ExecutionGraph executionGraph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -76,8 +77,10 @@ public void testTransitionToSubsequentStateWhenCancellationComplete(
}
}

@Test
public void testTransitionToSubsequentStateWhenResourceChanged() throws Exception {
@ParameterizedTest
@ValueSource(booleans = {true, false})
public void testTransitionToSubsequentStateWhenResourceChanged(boolean hasDesiredResources)
throws Exception {
try (MockRestartingContext ctx = new MockRestartingContext()) {
JobVertexID jobVertexId = new JobVertexID();
VertexParallelism availableParallelism =
Expand All @@ -86,8 +89,13 @@ public void testTransitionToSubsequentStateWhenResourceChanged() throws Exceptio
new VertexParallelism(singletonMap(jobVertexId, 2));

ctx.setAvailableVertexParallelism(availableParallelism);
ctx.setHasDesiredResources(hasDesiredResources);
Restarting restarting = createRestartingState(ctx, requiredParallelismForForcedRestart);
ctx.setExpectWaitingForResources();
if (hasDesiredResources) {
ctx.setExpectCreatingExecutionGraph();
} else {
ctx.setExpectWaitingForResources();
}
restarting.onGloballyTerminalState(JobStatus.CANCELED);
}
}
Expand Down