@Override public int compareSubscribers(ActorRef a, ActorRef b) { return a.compareTo(b); }
/** * broad cast message to all managed remote actors,like add channel event * message * * @param message * remote message */ public void broadcastMessage(UscRemoteMessage message) { if (remoteActors.size() == 0) { // normally will not enter here, since cluster member up event will // happen at before updateActorListFromCluster(); } if (remoteActors.size() == 0) { LOG.warn("Failed to send broadcast message to all remote actor, since currently there is no remote actor!Remote actor list is empty!"); // TODO broadcast message for (ActorRef actorRef : deviceTable.getActorRefList()) { if (actorRef.compareTo(communicator) != 0) { actorRef.tell(message, communicator); } } } else { LOG.trace("Start to send broadcast message to " + remoteActors.size() + " remote acotrs."); for (ActorSelection actorSelection : remoteActors) { actorSelection.tell(message, communicator); } } }
/** * add remote channel and communicator which belongs to the controller which * connected with the remote channel * * @param remoteChannel * remote channel * @param communicator * communicator */ public void addMountedDevice(UscRemoteChannelIdentifier remoteChannel, ActorRef communicator) { // since the hash code is different,it can not use UscRouteIdentifier as // a UscRemoteChannelIdentifier UscRemoteChannelIdentifier filteredRemoteChannel = new UscRemoteChannelIdentifier( remoteChannel.getInetAddress(), remoteChannel.getChannelType()); deviceTable.addEntry(filteredRemoteChannel, communicator); if (communicator.compareTo(this.communicator) != 0) { ActorSelection remoteActorSelection = actorSystem.actorSelection(communicator.path()); if (remoteActorSelection != null) { remoteActors.add(remoteActorSelection); } else { LOG.error("Failed to get actor selection for " + communicator.path()); } } }