private ActorRef getService(ActorSystem system) { return system.actorFor("akka://BettingServiceActorSystem@127.0.0.1:2552/user/bettingService"); } }
ActorSystem system = ActorSystem.create("master", ConfigFactory.load().getConfig("master")) ActorRef master = system.actorFor("akka://master@your-master-host-name:your-master-port/user/master")
/** * Helper util to access the private[akka] system.actorFor method * * This is used for performance optimization, we encode the session Id * in the ActorRef path. Session Id is used to identity sender Task. */ public static ActorRef actorFor(ActorSystem system, String path) { return system.actorFor(path); } }
/** * Helper util to access the private[akka] system.actorFor method * * This is used for performance optimization, we encode the session Id * in the ActorRef path. Session Id is used to identity sender Task. * * @param system ActorSystem * @param path Relative or absolute path of this Actor System. * @return Full qualified ActorRef. */ @SuppressWarnings("deprecation") public static ActorRef actorFor(ActorSystem system, String path) { return system.actorFor(path); } }
/** * Returns the typed actor with given path, proxied with given interface. * * @param system Akka system. * @param path Absolute path to actor. * @param interfaceClass Type of the proxy interface. * @param <T> Type of the proxy interface. * @return Typed actor. */ @Nonnull public static <T> T actorFor( @Nonnull final ActorSystem system, @Nonnull final ActorPath path, @Nonnull final Class<T> interfaceClass) { assert system != null; assert path != null; assert interfaceClass != null; final ActorRef actorRef = system.actorFor(path); return TypedActor.get(system).typedActorOf(new TypedProps<>(interfaceClass), actorRef); }
@Override public void onSuccess(Object result) throws Throwable { Iterable<Instance> taskManagers = ((JobManagerMessages.RegisteredTaskManagers) result).asJavaIterable(); List<String> activeTaskManagers = new ArrayList<>(); for (Instance taskManager : taskManagers) { activeTaskManagers.add(taskManager.getId().toString()); String taskManagerPath = taskManager.getTaskManagerGateway().getAddress(); String queryServicePath = taskManagerPath.substring(0, taskManagerPath.lastIndexOf('/') + 1) + MetricQueryService.METRIC_QUERY_SERVICE_NAME + "_" + taskManager.getTaskManagerID().getResourceIdString(); ActorRef taskManagerQueryService = actorSystem.actorFor(queryServicePath); queryMetrics(taskManagerQueryService); } synchronized (metrics) { // remove all metrics belonging to unregistered task managers metrics.taskManagers.keySet().retainAll(activeTaskManagers); } } }, ctx);
ActorRef jobManagerQueryService = actorSystem.actorFor(queryServicePath);
protected final ActorRef obtainWorkerRef(final NamedWorkerMetadata inputClassId) { ActorRef deviceRef = startingActors.get(inputClassId); if (null == deviceRef) { final String url = getInputActorUrl(inputClassId); deviceRef = getContext().system().actorFor(url); if (deviceRef.isTerminated()) { final String actId = inputClassId.getIdentifier(); log.debug("Starting new input processing actor with id {} in supervisor '{}'...", actId, getSelf().path().name()); deviceRef = getContext().actorOf(newInputProps(inputClassId), actId); startingActors.put(inputClassId, deviceRef); deviceRef.tell(new StartupRequest(), getSelf()); } else { log.debug("Passing existing device actor..."); } } else { log.debug("Passing existing device actor which is starting now..."); } return deviceRef; }