Skip to content

Commit

Permalink
[hotfix] Let ClusterEntrypoint implement AutoCloseableAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
tillrohrmann committed Sep 28, 2018
1 parent 87c27e4 commit 20447b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.apache.flink.runtime.security.SecurityContext;
import org.apache.flink.runtime.security.SecurityUtils;
import org.apache.flink.runtime.util.ZooKeeperUtils;
import org.apache.flink.util.AutoCloseableAsync;
import org.apache.flink.util.ExceptionUtils;
import org.apache.flink.util.FileUtils;
import org.apache.flink.util.Preconditions;
Expand Down Expand Up @@ -88,7 +89,7 @@
*
* <p>Specialization of this class can be used for the session mode and the per-job mode
*/
public abstract class ClusterEntrypoint implements FatalErrorHandler {
public abstract class ClusterEntrypoint implements AutoCloseableAsync, FatalErrorHandler {

public static final ConfigOption<String> EXECUTION_MODE = ConfigOptions
.key("internal.cluster.execution-mode")
Expand Down Expand Up @@ -312,6 +313,14 @@ protected MetricRegistryImpl createMetricRegistry(Configuration configuration) {
return new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(configuration));
}

@Override
public CompletableFuture<Void> closeAsync() {
return shutDownAsync(
ApplicationStatus.UNKNOWN,
"Cluster entrypoint has been closed externally.",
true).thenAccept(ignored -> {});
}

protected CompletableFuture<Void> stopClusterServices(boolean cleanupHaData) {
synchronized (lock) {
Throwable exception = null;
Expand Down Expand Up @@ -392,7 +401,7 @@ private Configuration generateClusterConfiguration(Configuration configuration)
return resultConfiguration;
}

public CompletableFuture<ApplicationStatus> shutDownAsync(
private CompletableFuture<ApplicationStatus> shutDownAsync(
ApplicationStatus applicationStatus,
@Nullable String diagnostics,
boolean cleanupHaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.flink.configuration.JobManagerOptions;
import org.apache.flink.configuration.RestOptions;
import org.apache.flink.configuration.TaskManagerOptions;
import org.apache.flink.runtime.clusterframework.ApplicationStatus;
import org.apache.flink.runtime.clusterframework.types.ResourceID;
import org.apache.flink.runtime.entrypoint.StandaloneSessionClusterEntrypoint;
import org.apache.flink.runtime.taskexecutor.TaskManagerRunner;
Expand Down Expand Up @@ -101,9 +100,7 @@ public void testTaskManagerProcessFailure() throws Exception {
jmConfig.setLong(HeartbeatManagerOptions.HEARTBEAT_TIMEOUT, 10000L);
jmConfig.setInteger(RestOptions.PORT, restPort);

final StandaloneSessionClusterEntrypoint clusterEntrypoint = new StandaloneSessionClusterEntrypoint(jmConfig);

try {
try (final StandaloneSessionClusterEntrypoint clusterEntrypoint = new StandaloneSessionClusterEntrypoint(jmConfig)) {
// check that we run this test only if the java command
// is available on this machine
String javaCommand = getJavaCommandPath();
Expand Down Expand Up @@ -228,8 +225,6 @@ public void run() {
if (taskManagerProcess3 != null) {
taskManagerProcess3.destroy();
}

clusterEntrypoint.shutDownAsync(ApplicationStatus.SUCCEEDED, null, true).get();
}
}

Expand Down

0 comments on commit 20447b2

Please sign in to comment.