use of org.apache.flink.runtime.entrypoint.SessionClusterEntrypoint in project flink by apache.
the class TaskManagerDisconnectOnShutdownITCase method testTaskManagerProcessFailure.
@Test
public void testTaskManagerProcessFailure() {
Configuration config = new Configuration();
config.setString(JobManagerOptions.ADDRESS, "localhost");
// disable heartbeats
config.set(HeartbeatManagerOptions.HEARTBEAT_RPC_FAILURE_THRESHOLD, -1);
config.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 2);
config.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, MemorySize.parse("4m"));
config.set(TaskManagerOptions.NETWORK_MEMORY_MIN, MemorySize.parse("3200k"));
config.set(TaskManagerOptions.NETWORK_MEMORY_MAX, MemorySize.parse("3200k"));
config.set(TaskManagerOptions.TASK_HEAP_MEMORY, MemorySize.parse("128m"));
config.set(TaskManagerOptions.CPU_CORES, 1.0);
config.setString(JobManagerOptions.EXECUTION_FAILOVER_STRATEGY, "full");
config.set(JobManagerOptions.RESOURCE_WAIT_TIMEOUT, Duration.ofSeconds(30L));
// check that we run this test only if the java command
// is available on this machine
String javaCommand = getJavaCommandPath();
if (javaCommand == null) {
fail("cannot find java executable");
}
final TaskManagerConnectionTracker tracker = new TaskManagerConnectionTracker();
TestProcessBuilder.TestProcess taskManagerProcess = null;
try (final SessionClusterEntrypoint clusterEntrypoint = new SessionClusterEntrypoint(config) {
@Override
protected DefaultDispatcherResourceManagerComponentFactory createDispatcherResourceManagerComponentFactory(Configuration configuration) {
return DefaultDispatcherResourceManagerComponentFactory.createSessionComponentFactory(new TestingStandaloneResourceManagerFactory(tracker));
}
}) {
clusterEntrypoint.startCluster();
TestProcessBuilder taskManagerProcessBuilder = new TestProcessBuilder(TaskExecutorProcessEntryPoint.class.getName());
taskManagerProcessBuilder.addConfigAsMainClassArgs(config);
// start the TaskManager processes
taskManagerProcess = taskManagerProcessBuilder.start();
tracker.waitForTaskManagerConnected();
// shutdown TaskManager
taskManagerProcess.destroy();
tracker.waitForTaskManagerDisconnected();
assertThat(tracker.getNumberOfConnectedTaskManager()).isEqualTo(1);
} catch (Throwable t) {
printProcessLog(taskManagerProcess);
fail(t.getMessage());
} finally {
if (taskManagerProcess != null && taskManagerProcess.getProcess().isAlive()) {
LOG.error("TaskManager did not shutdown in time.");
printProcessLog(taskManagerProcess);
taskManagerProcess.getProcess().destroyForcibly();
}
}
}
Aggregations