protected String getActorPathName(ActorRef actorRef) { return actorRef.path().name(); }
private void processEndpointDeregistration(TopicUnsubscriptionMessage message) { String endpointKey = message.getOriginator().path().name(); if (endpointSessions.remove(endpointKey) != null) { LOG.debug("Removed subsctioption for endpoint {}", endpointKey); } else { LOG.warn("Failed to remove subscription for endpoint {} from topic", endpointKey); } }
/** * Process termination. * * @param message the message */ private void processTermination(Terminated message) { ActorRef terminated = message.actor(); if (terminated instanceof LocalActorRef) { LocalActorRef localActor = (LocalActorRef) terminated; String name = localActor.path().name(); if (endpointSessions.remove(name) != null) { LOG.debug("removed: {}", localActor); } } else { LOG.warn("remove commands for remote actors are not supported yet!"); } }
/** * Process termination. * * @param message the message */ private void processTermination(Terminated message) { ActorRef terminated = message.actor(); if (terminated instanceof LocalActorRef) { LocalActorRef localActor = (LocalActorRef) terminated; String name = localActor.path().name(); if (applications.remove(name) != null) { LOG.debug("[{}] removed application: {}", tenantId, localActor); } else if (localUsers.remove(name) != null) { LOG.debug("[{}] removed local user: {}", tenantId, localActor); } else if (globalUsers.remove(name) != null) { LOG.debug("[{}] removed global user: {}", tenantId, localActor); } } else { LOG.warn("remove commands for remote actors are not supported yet!"); } }
if (terminated instanceof LocalActorRef) { LocalActorRef localActor = (LocalActorRef) terminated; String name = localActor.path().name(); EndpointObjectHash endpointHash = endpointActorMap.remove(name); if (endpointHash != null) {
private ActorRef getOrCreateLogActor(String name) { ActorRef logActor = logsSessions.get(name); if (logActor == null) { logActor = context().actorOf( Props.create(new ApplicationLogActor.ActorCreator(context, appToken)) .withDispatcher(LOG_DISPATCHER_NAME) ); context().watch(logActor); logsSessions.put(logActor.path().name(), logActor); } return logActor; }
private ActorRef getOrCreateUserVerifierActor(String name) { ActorRef userVerifierActor = userVerifierSessions.get(name); if (userVerifierActor == null) { userVerifierActor = context() .actorOf( Props.create(new ApplicationUserVerifierActor.ActorCreator(context, appToken)) .withDispatcher(VERIFIER_DISPATCHER_NAME) ); context().watch(userVerifierActor); userVerifierSessions.put(userVerifierActor.path().name(), userVerifierActor); } return userVerifierActor; }
/** * Process endpoint registration. * * @param message the message */ private void processEndpointRegistration(TopicSubscriptionMessage message) { ActorRef endpointActor = message.getOriginator(); Integer seqNum = message.getSeqNumber(); SortedMap<Integer, NotificationDto> pendingNotificationMap = notificationCache.tailMap( seqNum, false); Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); List<NotificationDto> pendingNotifications = filterMap( pendingNotificationMap, message.getSystemNfSchemaVersion(), message.getUserNfSchemaVersion(), calendar); if (!pendingNotifications.isEmpty()) { LOG.debug("Detected new messages during endpoint subscription!"); NotificationMessage notificationMessage = NotificationMessage.fromNotifications( pendingNotifications); endpointActor.tell(notificationMessage, self()); } else { LOG.debug("No new messages detected. Subscribing endpoint actor to topic actor"); String endpointKey = message.getOriginator().path().name(); ActorInfo actorInfo = new ActorInfo( endpointActor, message.getSystemNfSchemaVersion(), message.getUserNfSchemaVersion()); if (endpointSessions.put(endpointKey, actorInfo) != null) { LOG.warn("Detected duplication of registration message: {}", message); } context().watch(endpointActor); } }
@Override public String toString() { return "Greet{" + "name='" + name + '\'' + ", sendTo=" + sendTo.path().name() + '}'; } }
private void stopCommandConsumers() { consumerByNamePrefix.forEach((namePrefix, child) -> { final String actorName = child.path().name(); if (actorName.startsWith(AmqpConsumerActor.ACTOR_NAME_PREFIX)) { stopChildActor(child); } }); consumerByNamePrefix.clear(); }
private static EntityId decodeEntityId(final ActorRef self) { final String name = self.path().name(); try { final String typeWithPath = URLDecoder.decode(name, StandardCharsets.UTF_8.name()); return EntityId.readFrom(typeWithPath); } catch (final UnsupportedEncodingException e) { throw new IllegalStateException("Unsupported encoding", e); } } }
private void stopCommandConsumers() { consumerByNamePrefix.forEach((namePrefix, child) -> { final String actorName = child.path().name(); if (actorName.startsWith(AmqpConsumerActor.ACTOR_NAME_PREFIX)) { stopChildActor(child); } }); consumerByNamePrefix.clear(); }
@Override public String persistenceId() { try { return String.join(persistenceIdPrefix, URLDecoder.decode(self().path().name(), StandardCharsets.UTF_8.name())); } catch (UnsupportedEncodingException e) { log.error("encoding issue with the persistence id "); return String.join(persistenceIdPrefix, self().path().name()); } }
/** * @param message * @param self * @param sender */ private void onStartObserve(Observing message, ActorRef self, ActorRef sender) { String senderPath = sender.path().name(); sender.tell(new GetCallInfo(), self); callMap.put(senderPath, sender); callsUpToNow.incrementAndGet(); }
public MeteringBehavior(UntypedActor actor){ Preconditions.checkArgument(actor != null, "actor must not be null"); this.meteredActor = actor; String actorName = actor.getSelf().path().name(); init(actorName); }
public MeteringBehavior(final UntypedActor actor) { Preconditions.checkArgument(actor != null, "actor must not be null"); this.meteredActor = actor; String actorName = actor.getSelf().path().name(); init(actorName); }
@OnReceive public void processStartupReply(final StartupReply reply) { log.debug("Successful startup notification in {}: {}", getSelf().path().name(), JSON.pretty(reply)); if (!startingActors.containsKey(reply.workerMetadata)) { throw new IllegalStateException("Request to remove non-existing actor: " + reply.workerMetadata); } startingActors.remove(reply.workerMetadata); }
/** * * @param actor whose behaviour needs to be metered */ public MeteringBehavior(AbstractUntypedActorWithMetering actor){ Preconditions.checkArgument(actor != null, "actor must not be null"); this.meteredActor = actor; String actorName = actor.getActorNameOverride() != null ? actor.getActorNameOverride() : actor.getSelf().path().name(); init(actorName); }
/** * Constructs an instance. * * @param actor whose behaviour needs to be metered */ public MeteringBehavior(final AbstractUntypedActorWithMetering actor) { Preconditions.checkArgument(actor != null, "actor must not be null"); this.meteredActor = actor; String actorName = actor.getActorNameOverride() != null ? actor.getActorNameOverride() : actor.getSelf().path().name(); init(actorName); }
@Override public String persistenceId() { return getSelf().path().parent() + "-" + getSelf().path().name(); }