Search in sources :

Example 1 with AkkaRpcService

use of org.apache.flink.runtime.rpc.akka.AkkaRpcService in project flink by apache.

the class RpcServiceUtils method createRpcService.

// ------------------------------------------------------------------------
//  RPC instantiation
// ------------------------------------------------------------------------
/**
	 * Utility method to create RPC service from configuration and hostname, port.
	 *
	 * @param hostname   The hostname/address that describes the TaskManager's data location.
	 * @param port           If true, the TaskManager will not initiate the TCP network stack.
	 * @param configuration                 The configuration for the TaskManager.
	 * @return   The rpc service which is used to start and connect to the TaskManager RpcEndpoint .
	 * @throws IOException      Thrown, if the actor system can not bind to the address
	 * @throws Exception      Thrown is some other error occurs while creating akka actor system
	 */
public static RpcService createRpcService(String hostname, int port, Configuration configuration) throws Exception {
    LOG.info("Starting AkkaRpcService at {}.", NetUtils.hostAndPortToUrlString(hostname, port));
    final ActorSystem actorSystem;
    try {
        Config akkaConfig;
        if (hostname != null && !hostname.isEmpty()) {
            // remote akka config
            akkaConfig = AkkaUtils.getAkkaConfig(configuration, hostname, port);
        } else {
            // local akka config
            akkaConfig = AkkaUtils.getAkkaConfig(configuration);
        }
        LOG.debug("Using akka configuration \n {}.", akkaConfig);
        actorSystem = AkkaUtils.createActorSystem(akkaConfig);
    } catch (Throwable t) {
        if (t instanceof ChannelException) {
            Throwable cause = t.getCause();
            if (cause != null && t.getCause() instanceof java.net.BindException) {
                String address = NetUtils.hostAndPortToUrlString(hostname, port);
                throw new IOException("Unable to bind AkkaRpcService actor system to address " + address + " - " + cause.getMessage(), t);
            }
        }
        throw new Exception("Could not create TaskManager actor system", t);
    }
    final Time timeout = Time.milliseconds(AkkaUtils.getTimeout(configuration).toMillis());
    return new AkkaRpcService(actorSystem, timeout);
}
Also used : ActorSystem(akka.actor.ActorSystem) AkkaRpcService(org.apache.flink.runtime.rpc.akka.AkkaRpcService) Config(com.typesafe.config.Config) Time(org.apache.flink.api.common.time.Time) IOException(java.io.IOException) ChannelException(org.jboss.netty.channel.ChannelException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ChannelException(org.jboss.netty.channel.ChannelException)

Example 2 with AkkaRpcService

use of org.apache.flink.runtime.rpc.akka.AkkaRpcService in project flink by apache.

the class YarnFlinkApplicationMasterRunner method createRpcService.

// ------------------------------------------------------------------------
//  Utilities
// ------------------------------------------------------------------------
protected RpcService createRpcService(Configuration configuration, String bindAddress, String portRange) throws Exception {
    ActorSystem actorSystem = BootstrapTools.startActorSystem(configuration, bindAddress, portRange, LOG);
    FiniteDuration duration = AkkaUtils.getTimeout(configuration);
    return new AkkaRpcService(actorSystem, Time.of(duration.length(), duration.unit()));
}
Also used : ActorSystem(akka.actor.ActorSystem) AkkaRpcService(org.apache.flink.runtime.rpc.akka.AkkaRpcService) FiniteDuration(scala.concurrent.duration.FiniteDuration)

Example 3 with AkkaRpcService

use of org.apache.flink.runtime.rpc.akka.AkkaRpcService in project flink by apache.

the class SlotPoolRpcTest method setup.

// ------------------------------------------------------------------------
//  setup
// ------------------------------------------------------------------------
@BeforeClass
public static void setup() {
    ActorSystem actorSystem = AkkaUtils.createLocalActorSystem(new Configuration());
    rpcService = new AkkaRpcService(actorSystem, Time.seconds(10));
}
Also used : ActorSystem(akka.actor.ActorSystem) AkkaRpcService(org.apache.flink.runtime.rpc.akka.AkkaRpcService) Configuration(org.apache.flink.configuration.Configuration) BeforeClass(org.junit.BeforeClass)

Aggregations

ActorSystem (akka.actor.ActorSystem)3 AkkaRpcService (org.apache.flink.runtime.rpc.akka.AkkaRpcService)3 Config (com.typesafe.config.Config)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 Time (org.apache.flink.api.common.time.Time)1 Configuration (org.apache.flink.configuration.Configuration)1 ChannelException (org.jboss.netty.channel.ChannelException)1 BeforeClass (org.junit.BeforeClass)1 FiniteDuration (scala.concurrent.duration.FiniteDuration)1