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);
}
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()));
}
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));
}
Aggregations