Java Code Examples for org.apache.flink.runtime.highavailability.HighAvailabilityServices#closeAndCleanupAllData()

The following examples show how to use org.apache.flink.runtime.highavailability.HighAvailabilityServices#closeAndCleanupAllData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskManagerRunnerConfigurationTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskManagerRpcServiceShouldBindToConfiguredTaskManagerHostname() throws Exception {
	final String taskmanagerHost = "testhostname";
	final Configuration config = createFlinkConfigWithPredefinedTaskManagerHostname(taskmanagerHost);
	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	RpcService taskManagerRpcService = null;
	try {
		taskManagerRpcService = TaskManagerRunner.createRpcService(config, highAvailabilityServices);

		assertThat(taskManagerRpcService.getPort(), is(greaterThanOrEqualTo(0)));
		assertThat(taskManagerRpcService.getAddress(), is(equalTo(taskmanagerHost)));
	} finally {
		maybeCloseRpcService(taskManagerRpcService);
		highAvailabilityServices.closeAndCleanupAllData();
	}
}
 
Example 2
Source File: TaskManagerRunnerConfigurationTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskManagerRpcServiceShouldBindToIpAddressDeterminedByConnectingToResourceManager() throws Exception {
	final ServerSocket testJobManagerSocket = openServerSocket();
	final Configuration config = createFlinkConfigWithJobManagerPort(testJobManagerSocket.getLocalPort());
	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	RpcService taskManagerRpcService = null;
	try {
		taskManagerRpcService = TaskManagerRunner.createRpcService(config, highAvailabilityServices);
		assertThat(taskManagerRpcService.getAddress(), is(ipAddress()));
	} finally {
		maybeCloseRpcService(taskManagerRpcService);
		highAvailabilityServices.closeAndCleanupAllData();
		IOUtils.closeQuietly(testJobManagerSocket);
	}
}
 
Example 3
Source File: TaskManagerRunnerConfigurationTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreatingTaskManagerRpcServiceShouldFailIfRpcPortRangeIsInvalid() throws Exception {
	final Configuration config = new Configuration(createFlinkConfigWithPredefinedTaskManagerHostname("example.org"));
	config.setString(TaskManagerOptions.RPC_PORT, "-1");

	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	try {
		TaskManagerRunner.createRpcService(config, highAvailabilityServices);
		fail("Should fail because -1 is not a valid port range");
	} catch (final IllegalArgumentException e) {
		assertThat(e.getMessage(),  containsString("Invalid port range definition: -1"));
	} finally {
		highAvailabilityServices.closeAndCleanupAllData();
	}
}
 
Example 4
Source File: TaskManagerRunnerConfigurationTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskManagerRpcServiceShouldBindToConfiguredTaskManagerHostname() throws Exception {
	final String taskmanagerHost = "testhostname";
	final Configuration config = createFlinkConfigWithPredefinedTaskManagerHostname(taskmanagerHost);
	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	RpcService taskManagerRpcService = null;
	try {
		taskManagerRpcService = TaskManagerRunner.createRpcService(config, highAvailabilityServices);

		assertThat(taskManagerRpcService.getPort(), is(greaterThanOrEqualTo(0)));
		assertThat(taskManagerRpcService.getAddress(), is(equalTo(taskmanagerHost)));
	} finally {
		maybeCloseRpcService(taskManagerRpcService);
		highAvailabilityServices.closeAndCleanupAllData();
	}
}
 
Example 5
Source File: TaskManagerRunnerConfigurationTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskManagerRpcServiceShouldBindToIpAddressDeterminedByConnectingToResourceManager() throws Exception {
	final ServerSocket testJobManagerSocket = openServerSocket();
	final Configuration config = createFlinkConfigWithJobManagerPort(testJobManagerSocket.getLocalPort());
	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	RpcService taskManagerRpcService = null;
	try {
		taskManagerRpcService = TaskManagerRunner.createRpcService(config, highAvailabilityServices);
		assertThat(taskManagerRpcService.getAddress(), is(ipAddress()));
	} finally {
		maybeCloseRpcService(taskManagerRpcService);
		highAvailabilityServices.closeAndCleanupAllData();
		IOUtils.closeQuietly(testJobManagerSocket);
	}
}
 
Example 6
Source File: TaskManagerRunnerConfigurationTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreatingTaskManagerRpcServiceShouldFailIfRpcPortRangeIsInvalid() throws Exception {
	final Configuration config = new Configuration(createFlinkConfigWithPredefinedTaskManagerHostname("example.org"));
	config.setString(TaskManagerOptions.RPC_PORT, "-1");

	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	try {
		TaskManagerRunner.createRpcService(config, highAvailabilityServices);
		fail("Should fail because -1 is not a valid port range");
	} catch (final IllegalArgumentException e) {
		assertThat(e.getMessage(),  containsString("Invalid port range definition: -1"));
	} finally {
		highAvailabilityServices.closeAndCleanupAllData();
	}
}
 
Example 7
Source File: TaskManagerRunnerConfigurationTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskManagerRpcServiceShouldBindToConfiguredTaskManagerHostname() throws Exception {
	final String taskmanagerHost = "testhostname";
	final Configuration config = createFlinkConfigWithPredefinedTaskManagerHostname(taskmanagerHost);
	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	RpcService taskManagerRpcService = null;
	try {
		taskManagerRpcService = TaskManagerRunner.createRpcService(config, highAvailabilityServices);

		assertThat(taskManagerRpcService.getPort(), is(greaterThanOrEqualTo(0)));
		assertThat(taskManagerRpcService.getAddress(), is(equalTo(taskmanagerHost)));
	} finally {
		maybeCloseRpcService(taskManagerRpcService);
		highAvailabilityServices.closeAndCleanupAllData();
	}
}
 
Example 8
Source File: TaskManagerRunnerConfigurationTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskManagerRpcServiceShouldBindToIpAddressDeterminedByConnectingToResourceManager() throws Exception {
	final ServerSocket testJobManagerSocket = openServerSocket();
	final Configuration config = createFlinkConfigWithJobManagerPort(testJobManagerSocket.getLocalPort());
	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	RpcService taskManagerRpcService = null;
	try {
		taskManagerRpcService = TaskManagerRunner.createRpcService(config, highAvailabilityServices);
		assertThat(taskManagerRpcService.getAddress(), is(ipAddress()));
	} finally {
		maybeCloseRpcService(taskManagerRpcService);
		highAvailabilityServices.closeAndCleanupAllData();
		IOUtils.closeQuietly(testJobManagerSocket);
	}
}
 
Example 9
Source File: TaskManagerRunnerConfigurationTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreatingTaskManagerRpcServiceShouldFailIfRpcPortRangeIsInvalid() throws Exception {
	final Configuration config = new Configuration(createFlinkConfigWithPredefinedTaskManagerHostname("example.org"));
	config.setString(TaskManagerOptions.RPC_PORT, "-1");

	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	try {
		TaskManagerRunner.createRpcService(config, highAvailabilityServices);
		fail("Should fail because -1 is not a valid port range");
	} catch (final IllegalArgumentException e) {
		assertThat(e.getMessage(),  containsString("Invalid port range definition: -1"));
	} finally {
		highAvailabilityServices.closeAndCleanupAllData();
	}
}
 
Example 10
Source File: TaskManagerRunnerConfigurationTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskManagerRpcServiceShouldBindToHostnameAddress() throws Exception {
	final Configuration config = createFlinkConfigWithHostBindPolicy(HostBindPolicy.NAME);
	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	RpcService taskManagerRpcService = null;
	try {
		taskManagerRpcService = TaskManagerRunner.createRpcService(config, highAvailabilityServices);
		assertThat(taskManagerRpcService.getAddress(), not(isEmptyOrNullString()));
	} finally {
		maybeCloseRpcService(taskManagerRpcService);
		highAvailabilityServices.closeAndCleanupAllData();
	}
}
 
Example 11
Source File: TaskManagerRunnerConfigurationTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskManagerRpcServiceShouldBindToHostnameAddress() throws Exception {
	final Configuration config = createFlinkConfigWithHostBindPolicy(HostBindPolicy.NAME);
	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	RpcService taskManagerRpcService = null;
	try {
		taskManagerRpcService = TaskManagerRunner.createRpcService(config, highAvailabilityServices);
		assertThat(taskManagerRpcService.getAddress(), not(isEmptyOrNullString()));
	} finally {
		maybeCloseRpcService(taskManagerRpcService);
		highAvailabilityServices.closeAndCleanupAllData();
	}
}
 
Example 12
Source File: TaskManagerRunnerConfigurationTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskManagerRpcServiceShouldBindToHostnameAddress() throws Exception {
	final Configuration config = createFlinkConfigWithHostBindPolicy(HostBindPolicy.NAME);
	final HighAvailabilityServices highAvailabilityServices = createHighAvailabilityServices(config);

	RpcService taskManagerRpcService = null;
	try {
		taskManagerRpcService = TaskManagerRunner.createRpcService(config, highAvailabilityServices);
		assertThat(taskManagerRpcService.getAddress(), not(isEmptyOrNullString()));
	} finally {
		maybeCloseRpcService(taskManagerRpcService);
		highAvailabilityServices.closeAndCleanupAllData();
	}
}