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 @@ -27,6 +27,7 @@
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import org.apache.flink.configuration.Configuration;
Expand Down Expand Up @@ -373,11 +374,15 @@ protected TableLoader tableLoader() {
protected static String closeJobClient(JobClient jobClient, File savepointDir) {
if (jobClient != null) {
if (savepointDir != null) {
// Stop with savepoint
jobClient.stopWithSavepoint(false, savepointDir.getPath(), SavepointFormatType.CANONICAL);
// Wait until the savepoint is created and the job has been stopped
Awaitility.await().until(() -> savepointDir.listFiles(File::isDirectory).length == 1);
return savepointDir.listFiles(File::isDirectory)[0].getAbsolutePath();
// Stop with a savepoint; get() blocks until it is fully written and returns its path, so
// that a job restoring from it does not race the savepoint completion
try {
return jobClient
.stopWithSavepoint(false, savepointDir.getPath(), SavepointFormatType.CANONICAL)
.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
} else {
jobClient.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ void testStateRestore(
streamGraph.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(savepointPath));
CompletableFuture<JobID> jobIDCompletableFuture = clusterClient.submitJob(streamGraph);
try {
assertThat(resultWithSavepoint.poll(Duration.ofSeconds(5L))).isEqualTo(EMPTY_EVENT);
// Restoring from a savepoint on a busy cluster may take longer than the default 5s poll
assertThat(resultWithSavepoint.poll(Duration.ofSeconds(30L))).isEqualTo(EMPTY_EVENT);
} finally {
clusterClient.cancel(jobIDCompletableFuture.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import org.apache.flink.configuration.Configuration;
Expand Down Expand Up @@ -373,11 +374,15 @@ protected TableLoader tableLoader() {
protected static String closeJobClient(JobClient jobClient, File savepointDir) {
if (jobClient != null) {
if (savepointDir != null) {
// Stop with savepoint
jobClient.stopWithSavepoint(false, savepointDir.getPath(), SavepointFormatType.CANONICAL);
// Wait until the savepoint is created and the job has been stopped
Awaitility.await().until(() -> savepointDir.listFiles(File::isDirectory).length == 1);
return savepointDir.listFiles(File::isDirectory)[0].getAbsolutePath();
// Stop with a savepoint; get() blocks until it is fully written and returns its path, so
// that a job restoring from it does not race the savepoint completion
try {
return jobClient
.stopWithSavepoint(false, savepointDir.getPath(), SavepointFormatType.CANONICAL)
.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
} else {
jobClient.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ void testStateRestore(
streamGraph.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(savepointPath));
CompletableFuture<JobID> jobIDCompletableFuture = clusterClient.submitJob(streamGraph);
try {
assertThat(resultWithSavepoint.poll(Duration.ofSeconds(5L))).isEqualTo(EMPTY_EVENT);
// Restoring from a savepoint on a busy cluster may take longer than the default 5s poll
assertThat(resultWithSavepoint.poll(Duration.ofSeconds(30L))).isEqualTo(EMPTY_EVENT);
} finally {
clusterClient.cancel(jobIDCompletableFuture.get());
}
Expand Down