@Nonnull private static RpcService instantiateAkkaRpcService(Configuration configuration, ActorSystem actorSystem) { final Time timeout = AkkaUtils.getTimeoutAsTime(configuration); return new AkkaRpcService(actorSystem, timeout); }
@Override public <F extends Serializable, C extends FencedRpcGateway<F>> CompletableFuture<C> connect(String address, F fencingToken, Class<C> clazz) { return connectInternal( address, clazz, (ActorRef actorRef) -> { Tuple2<String, String> addressHostname = extractAddressHostname(actorRef); return new FencedAkkaInvocationHandler<>( addressHostname.f0, addressHostname.f1, actorRef, timeout, maximumFramesize, null, () -> fencingToken); }); }
@Override public Future<Void> getTerminationFuture() { return FlinkFuture.supplyAsync(new Callable<Void>(){ @Override public Void call() throws Exception { actorSystem.awaitTermination(); return null; } }, getExecutor()); }
akkaRpcActorProps = Props.create(FencedAkkaRpcActor.class, rpcEndpoint, terminationFuture, getVersion()); } else { akkaRpcActorProps = Props.create(AkkaRpcActor.class, rpcEndpoint, terminationFuture, getVersion());
final ActorSystem actorSystem = ((AkkaRpcService) rpcService).getActorSystem(); metricRegistry.startQueryService(actorSystem, resourceId);
akkaRpcActorProps = Props.create(FencedAkkaRpcActor.class, rpcEndpoint, terminationFuture, getVersion()); } else { akkaRpcActorProps = Props.create(AkkaRpcActor.class, rpcEndpoint, terminationFuture, getVersion());
protected void initializeServices(Configuration configuration) throws Exception { LOG.info("Initializing cluster services."); synchronized (lock) { final String bindAddress = configuration.getString(JobManagerOptions.ADDRESS); final String portRange = getRPCPortRange(configuration); commonRpcService = createRpcService(configuration, bindAddress, portRange); // update the configuration used to create the high availability services configuration.setString(JobManagerOptions.ADDRESS, commonRpcService.getAddress()); configuration.setInteger(JobManagerOptions.PORT, commonRpcService.getPort()); haServices = createHaServices(configuration, commonRpcService.getExecutor()); blobServer = new BlobServer(configuration, haServices.createBlobStore()); blobServer.start(); heartbeatServices = createHeartbeatServices(configuration); metricRegistry = createMetricRegistry(configuration); // TODO: This is a temporary hack until we have ported the MetricQueryService to the new RpcEndpoint // start the MetricQueryService final ActorSystem actorSystem = ((AkkaRpcService) commonRpcService).getActorSystem(); metricRegistry.startQueryService(actorSystem, null); archivedExecutionGraphStore = createSerializableExecutionGraphStore(configuration, commonRpcService.getScheduledExecutor()); clusterInformation = new ClusterInformation( commonRpcService.getAddress(), blobServer.getPort()); transientBlobCache = new TransientBlobCache( configuration, new InetSocketAddress( clusterInformation.getBlobServerHostname(), clusterInformation.getBlobServerPort())); } }
@Override public <C extends RpcGateway> CompletableFuture<C> connect( final String address, final Class<C> clazz) { return connectInternal( address, clazz, (ActorRef actorRef) -> { Tuple2<String, String> addressHostname = extractAddressHostname(actorRef); return new AkkaInvocationHandler( addressHostname.f0, addressHostname.f1, actorRef, timeout, maximumFramesize, null); }); }
@Nonnull private static RpcService instantiateAkkaRpcService(Configuration configuration, ActorSystem actorSystem) { final Time timeout = AkkaUtils.getTimeoutAsTime(configuration); return new AkkaRpcService(actorSystem, timeout); }
akkaRpcActorProps = Props.create(FencedAkkaRpcActor.class, rpcEndpoint, terminationFuture, getVersion()); } else { akkaRpcActorProps = Props.create(AkkaRpcActor.class, rpcEndpoint, terminationFuture, getVersion());
final ActorSystem actorSystem = ((AkkaRpcService) commonRpcService).getActorSystem(); metricRegistry.startQueryService(actorSystem, null);
@Override public <F extends Serializable, C extends FencedRpcGateway<F>> CompletableFuture<C> connect(String address, F fencingToken, Class<C> clazz) { return connectInternal( address, clazz, (ActorRef actorRef) -> { Tuple2<String, String> addressHostname = extractAddressHostname(actorRef); return new FencedAkkaInvocationHandler<>( addressHostname.f0, addressHostname.f1, actorRef, timeout, maximumFramesize, null, () -> fencingToken); }); }
/** * Factory method to instantiate the RPC service. * * @param configuration * The configuration of the mini cluster * @param askTimeout * 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( Configuration configuration, Time askTimeout, boolean remoteEnabled, String bindAddress) { ActorSystem actorSystem; if (remoteEnabled) { actorSystem = AkkaUtils.createActorSystem(configuration, bindAddress, 0); } else { actorSystem = AkkaUtils.createLocalActorSystem(configuration); } return new AkkaRpcService(actorSystem, askTimeout); }
(ActorRef actorRef) -> FutureUtils.toJava( Patterns .ask(actorRef, new RemoteHandshakeMessage(clazz, getVersion()), timeout.toMilliseconds()) .<HandshakeSuccessMessage>mapTo(ClassTag$.MODULE$.<HandshakeSuccessMessage>apply(HandshakeSuccessMessage.class))));
final ActorSystem actorSystem = ((AkkaRpcService) rpcService).getActorSystem(); final Time timeout = Time.milliseconds(configuration.getLong(WebOptions.TIMEOUT));
@Override public <F extends Serializable, C extends FencedRpcGateway<F>> CompletableFuture<C> connect(String address, F fencingToken, Class<C> clazz) { return connectInternal( address, clazz, (ActorRef actorRef) -> { Tuple2<String, String> addressHostname = extractAddressHostname(actorRef); return new FencedAkkaInvocationHandler<>( addressHostname.f0, addressHostname.f1, actorRef, timeout, maximumFramesize, null, () -> fencingToken); }); }
return new AkkaRpcService(actorSystem, timeout);
(ActorRef actorRef) -> FutureUtils.toJava( Patterns .ask(actorRef, new RemoteHandshakeMessage(clazz, getVersion()), timeout.toMilliseconds()) .<HandshakeSuccessMessage>mapTo(ClassTag$.MODULE$.<HandshakeSuccessMessage>apply(HandshakeSuccessMessage.class))));
@Override public <C extends RpcGateway> CompletableFuture<C> connect( final String address, final Class<C> clazz) { return connectInternal( address, clazz, (ActorRef actorRef) -> { Tuple2<String, String> addressHostname = extractAddressHostname(actorRef); return new AkkaInvocationHandler( addressHostname.f0, addressHostname.f1, actorRef, timeout, maximumFramesize, null); }); }
return new AkkaRpcService(actorSystem, timeout);