Java Code Examples for org.apache.flink.runtime.akka.AkkaUtils#createDefaultActorSystem()

The following examples show how to use org.apache.flink.runtime.akka.AkkaUtils#createDefaultActorSystem() . 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: AkkaRpcActorTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that actors are properly terminated when the AkkaRpcService is shut down.
 */
@Test
public void testActorTerminationWhenServiceShutdown() throws Exception {
	final ActorSystem rpcActorSystem = AkkaUtils.createDefaultActorSystem();
	final RpcService rpcService = new AkkaRpcService(
		rpcActorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());

	try {
		SimpleRpcEndpoint rpcEndpoint = new SimpleRpcEndpoint(rpcService, SimpleRpcEndpoint.class.getSimpleName());

		rpcEndpoint.start();

		CompletableFuture<Void> terminationFuture = rpcEndpoint.getTerminationFuture();

		rpcService.stopService();

		terminationFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
	} finally {
		rpcActorSystem.terminate();
		FutureUtils.toJava(rpcActorSystem.whenTerminated()).get(timeout.getSize(), timeout.getUnit());
	}
}
 
Example 2
Source File: AkkaRpcActorTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that actors are properly terminated when the AkkaRpcService is shut down.
 */
@Test
public void testActorTerminationWhenServiceShutdown() throws Exception {
	final ActorSystem rpcActorSystem = AkkaUtils.createDefaultActorSystem();
	final RpcService rpcService = new AkkaRpcService(
		rpcActorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());

	try {
		SimpleRpcEndpoint rpcEndpoint = new SimpleRpcEndpoint(rpcService, SimpleRpcEndpoint.class.getSimpleName());

		rpcEndpoint.start();

		CompletableFuture<Void> terminationFuture = rpcEndpoint.getTerminationFuture();

		rpcService.stopService();

		terminationFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
	} finally {
		rpcActorSystem.terminate();
		Await.ready(rpcActorSystem.whenTerminated(), FutureUtils.toFiniteDuration(timeout));
	}
}
 
Example 3
Source File: AkkaRpcActorTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that actors are properly terminated when the AkkaRpcService is shut down.
 */
@Test
public void testActorTerminationWhenServiceShutdown() throws Exception {
	final ActorSystem rpcActorSystem = AkkaUtils.createDefaultActorSystem();
	final RpcService rpcService = new AkkaRpcService(
		rpcActorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());

	try {
		SimpleRpcEndpoint rpcEndpoint = new SimpleRpcEndpoint(rpcService, SimpleRpcEndpoint.class.getSimpleName());

		rpcEndpoint.start();

		CompletableFuture<Void> terminationFuture = rpcEndpoint.getTerminationFuture();

		rpcService.stopService();

		terminationFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
	} finally {
		rpcActorSystem.terminate();
		Await.ready(rpcActorSystem.whenTerminated(), FutureUtils.toFiniteDuration(timeout));
	}
}
 
Example 4
Source File: MetricRegistryImplTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that the query actor will be stopped when the MetricRegistry is shut down.
 */
@Test
public void testQueryActorShutdown() throws Exception {
	final FiniteDuration timeout = new FiniteDuration(10L, TimeUnit.SECONDS);

	MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());

	final ActorSystem actorSystem = AkkaUtils.createDefaultActorSystem();

	registry.startQueryService(actorSystem, null);

	ActorRef queryServiceActor = registry.getQueryService();

	registry.shutdown().get();

	try {
		Await.result(actorSystem.actorSelection(queryServiceActor.path()).resolveOne(timeout), timeout);

		fail("The query actor should be terminated resulting in a ActorNotFound exception.");
	} catch (ActorNotFound e) {
		// we expect the query actor to be shut down
	}
}
 
Example 5
Source File: AkkaRpcActorHandshakeTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupClass() {
	final ActorSystem actorSystem1 = AkkaUtils.createDefaultActorSystem();
	final ActorSystem actorSystem2 = AkkaUtils.createDefaultActorSystem();
	final ActorSystem wrongVersionActorSystem = AkkaUtils.createDefaultActorSystem();

	AkkaRpcServiceConfiguration akkaRpcServiceConfig = AkkaRpcServiceConfiguration.defaultConfiguration();
	akkaRpcService1 = new AkkaRpcService(actorSystem1, akkaRpcServiceConfig);
	akkaRpcService2 = new AkkaRpcService(actorSystem2, akkaRpcServiceConfig);
	wrongVersionAkkaRpcService = new WrongVersionAkkaRpcService(
		wrongVersionActorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 6
Source File: AkkaRpcActorHandshakeTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupClass() {
	final ActorSystem actorSystem1 = AkkaUtils.createDefaultActorSystem();
	final ActorSystem actorSystem2 = AkkaUtils.createDefaultActorSystem();
	final ActorSystem wrongVersionActorSystem = AkkaUtils.createDefaultActorSystem();

	AkkaRpcServiceConfiguration akkaRpcServiceConfig = AkkaRpcServiceConfiguration.defaultConfiguration();
	akkaRpcService1 = new AkkaRpcService(actorSystem1, akkaRpcServiceConfig);
	akkaRpcService2 = new AkkaRpcService(actorSystem2, akkaRpcServiceConfig);
	wrongVersionAkkaRpcService = new WrongVersionAkkaRpcService(
		wrongVersionActorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 7
Source File: AkkaRpcActorHandshakeTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupClass() {
	final ActorSystem actorSystem1 = AkkaUtils.createDefaultActorSystem();
	final ActorSystem actorSystem2 = AkkaUtils.createDefaultActorSystem();
	final ActorSystem wrongVersionActorSystem = AkkaUtils.createDefaultActorSystem();

	AkkaRpcServiceConfiguration akkaRpcServiceConfig = AkkaRpcServiceConfiguration.defaultConfiguration();
	akkaRpcService1 = new AkkaRpcService(actorSystem1, akkaRpcServiceConfig);
	akkaRpcService2 = new AkkaRpcService(actorSystem2, akkaRpcServiceConfig);
	wrongVersionAkkaRpcService = new WrongVersionAkkaRpcService(
		wrongVersionActorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 8
Source File: RpcEndpointTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
	actorSystem = AkkaUtils.createDefaultActorSystem();
	rpcService = new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 9
Source File: AkkaRpcServiceTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
	actorSystem = AkkaUtils.createDefaultActorSystem();
	akkaRpcService = new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 10
Source File: AkkaRpcServiceTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Nonnull
private AkkaRpcService startAkkaRpcService() {
	final ActorSystem actorSystem = AkkaUtils.createDefaultActorSystem();
	return new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 11
Source File: AkkaRpcServiceTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Nonnull
private AkkaRpcService startAkkaRpcService() {
	final ActorSystem actorSystem = AkkaUtils.createDefaultActorSystem();
	return new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 12
Source File: RpcEndpointTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
	actorSystem = AkkaUtils.createDefaultActorSystem();
	rpcService = new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 13
Source File: TimeoutCallStackTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
	actorSystem = AkkaUtils.createDefaultActorSystem();
	rpcService = new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 14
Source File: AkkaRpcServiceTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
	actorSystem = AkkaUtils.createDefaultActorSystem();
	akkaRpcService = new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 15
Source File: AkkaRpcServiceTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
	actorSystem = AkkaUtils.createDefaultActorSystem();
	akkaRpcService = new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 16
Source File: AkkaRpcServiceTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Nonnull
private AkkaRpcService startAkkaRpcService() {
	final ActorSystem actorSystem = AkkaUtils.createDefaultActorSystem();
	return new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}
 
Example 17
Source File: RpcEndpointTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
	actorSystem = AkkaUtils.createDefaultActorSystem();
	rpcService = new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
}