org.apache.flink.runtime.rpc.akka.AkkaRpcService Java Examples

The following examples show how to use org.apache.flink.runtime.rpc.akka.AkkaRpcService. 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: MiniCluster.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Factory method to instantiate the RPC service.
 *
 * @param akkaRpcServiceConfig
 *            The default RPC timeout for asynchronous "ask" requests.
 * @param remoteEnabled
 *            True, if the RPC service should be reachable from other (remote) RPC services.
 * @param bindAddress
 *            The address to bind the RPC service to. Only relevant when "remoteEnabled" is true.
 *
 * @return The instantiated RPC service
 */
protected RpcService createRpcService(
		AkkaRpcServiceConfiguration akkaRpcServiceConfig,
		boolean remoteEnabled,
		String bindAddress) {

	final Config akkaConfig;

	if (remoteEnabled) {
		akkaConfig = AkkaUtils.getAkkaConfig(akkaRpcServiceConfig.getConfiguration(), bindAddress, 0);
	} else {
		akkaConfig = AkkaUtils.getAkkaConfig(akkaRpcServiceConfig.getConfiguration());
	}

	final Config effectiveAkkaConfig = AkkaUtils.testDispatcherConfig().withFallback(akkaConfig);

	final ActorSystem actorSystem = AkkaUtils.createActorSystem(effectiveAkkaConfig);

	return new AkkaRpcService(actorSystem, akkaRpcServiceConfig);
}
 
Example #2
Source File: MiniCluster.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Factory method to instantiate the RPC service.
 *
 * @param akkaRpcServiceConfig
 *            The default RPC timeout for asynchronous "ask" requests.
 * @param remoteEnabled
 *            True, if the RPC service should be reachable from other (remote) RPC services.
 * @param bindAddress
 *            The address to bind the RPC service to. Only relevant when "remoteEnabled" is true.
 *
 * @return The instantiated RPC service
 */
protected RpcService createRpcService(
		AkkaRpcServiceConfiguration akkaRpcServiceConfig,
		boolean remoteEnabled,
		String bindAddress) {

	final Config akkaConfig;

	if (remoteEnabled) {
		akkaConfig = AkkaUtils.getAkkaConfig(akkaRpcServiceConfig.getConfiguration(), bindAddress, 0);
	} else {
		akkaConfig = AkkaUtils.getAkkaConfig(akkaRpcServiceConfig.getConfiguration());
	}

	final Config effectiveAkkaConfig = AkkaUtils.testDispatcherConfig().withFallback(akkaConfig);

	final ActorSystem actorSystem = AkkaUtils.createActorSystem(effectiveAkkaConfig);

	return new AkkaRpcService(actorSystem, akkaRpcServiceConfig);
}
 
Example #3
Source File: MetricUtilsTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that the {@link MetricUtils#startMetricsRpcService(Configuration, String)} respects
 * the given {@link MetricOptions#QUERY_SERVICE_THREAD_PRIORITY}.
 */
@Test
public void testStartMetricActorSystemRespectsThreadPriority() throws Exception {
	final Configuration configuration = new Configuration();
	final int expectedThreadPriority = 3;
	configuration.setInteger(MetricOptions.QUERY_SERVICE_THREAD_PRIORITY, expectedThreadPriority);

	final RpcService rpcService = MetricUtils.startMetricsRpcService(configuration, "localhost");
	assertThat(rpcService, instanceOf(AkkaRpcService.class));

	final ActorSystem actorSystem = ((AkkaRpcService) rpcService).getActorSystem();

	try {
		final int threadPriority = actorSystem.settings().config().getInt("akka.actor.default-dispatcher.thread-priority");

		assertThat(threadPriority, is(expectedThreadPriority));
	} finally {
		AkkaUtils.terminateActorSystem(actorSystem).get();
	}
}
 
Example #4
Source File: RemoteMiniClusterImpl.java    From beam with Apache License 2.0 6 votes vote down vote up
@Override
protected RpcService createRpcService(
    AkkaRpcServiceConfiguration akkaRpcServiceConfig, boolean remoteEnabled, String bindAddress) {

  // Enable remote connections to the mini cluster which are disabled by default
  final Config akkaConfig =
      AkkaUtils.getAkkaConfig(akkaRpcServiceConfig.getConfiguration(), bindAddress, 0);

  final Config effectiveAkkaConfig = AkkaUtils.testDispatcherConfig().withFallback(akkaConfig);

  final ActorSystem actorSystem = AkkaUtils.createActorSystem(effectiveAkkaConfig);

  final AkkaRpcService akkaRpcService = new AkkaRpcService(actorSystem, akkaRpcServiceConfig);
  this.port = akkaRpcService.getPort();

  return akkaRpcService;
}
 
Example #5
Source File: MetricUtilsTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that the {@link MetricUtils#startRemoteMetricsRpcService(Configuration, String)} respects
 * the given {@link MetricOptions#QUERY_SERVICE_THREAD_PRIORITY}.
 */
@Test
public void testStartMetricActorSystemRespectsThreadPriority() throws Exception {
	final Configuration configuration = new Configuration();
	final int expectedThreadPriority = 3;
	configuration.setInteger(MetricOptions.QUERY_SERVICE_THREAD_PRIORITY, expectedThreadPriority);

	final RpcService rpcService = MetricUtils.startRemoteMetricsRpcService(configuration, "localhost");
	assertThat(rpcService, instanceOf(AkkaRpcService.class));

	final ActorSystem actorSystem = ((AkkaRpcService) rpcService).getActorSystem();

	try {
		final int threadPriority = actorSystem.settings().config().getInt("akka.actor.default-dispatcher.thread-priority");

		assertThat(threadPriority, is(expectedThreadPriority));
	} finally {
		AkkaUtils.terminateActorSystem(actorSystem).get();
	}
}
 
Example #6
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());
}
 
Example #7
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 #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());
}