/** * Verify the actor path of self agrees with what is advertised in ditto-services-models-concierge. * * @param self ActorRef of this actor. */ private static void sanityCheck(final ActorRef self) { final String selfPath = self.path().toStringWithoutAddress(); if (!Objects.equals(DISPATCHER_ACTOR_PATH, selfPath)) { final String message = String.format("Path of <%s> is <%s>, which does not agree with the advertised path <%s>", ACTOR_NAME, selfPath, DISPATCHER_ACTOR_PATH); throw new IllegalStateException(message); } }
private void init(String actorName){ actorQualifiedName = new StringBuilder(meteredActor.getSelf().path().parent().toStringWithoutAddress()). append("/").append(actorName).toString(); final String msgProcessingTime = MetricRegistry.name(actorQualifiedName, MSG_PROCESSING_RATE); msgProcessingTimer = METRICREGISTRY.timer(msgProcessingTime); }
private ShardStatisticsWrapper getShardStatistics(final Map<String, ShardStatisticsWrapper> shardStatisticsMap, final String shardRegion) { ShardStatisticsWrapper shardStatistics = shardStatisticsMap.get(shardRegion); if (shardStatistics == null) { if (getSender().path().toStringWithoutAddress().contains(SR_SEARCH_UPDATER)) { shardStatistics = shardStatisticsMap.get(SR_SEARCH_UPDATER); } else if (getSender().path().toStringWithoutAddress().contains(SR_CONCIERGE)) { shardStatistics = shardStatisticsMap.get(SR_CONCIERGE); } else if (getSender().path().toStringWithoutAddress().contains(SR_POLICY)) { shardStatistics = shardStatisticsMap.get(SR_POLICY); } else if (getSender().path().toStringWithoutAddress().contains(SR_THING)) { shardStatistics = shardStatisticsMap.get(SR_THING); } } return shardStatistics; }
private boolean isExecutePiggybackCommandToPubSubMediator(final DevOpsCommand<?> command) { if (command instanceof ExecutePiggybackCommand) { final ExecutePiggybackCommand executePiggyback = (ExecutePiggybackCommand) command; return Objects.equals(executePiggyback.getTargetActorSelection(), pubSubMediator.path().toStringWithoutAddress()); } else { return false; } }
private void init(final String actorName) { actorQualifiedName = meteredActor.getSelf().path().parent().toStringWithoutAddress() + "/" + actorName; final String msgProcessingTime = MetricRegistry.name(actorQualifiedName, MSG_PROCESSING_RATE); msgProcessingTimer = metricRegistry.timer(msgProcessingTime); }
private void monitorQueueSize(scala.Option<ActorRef> owner, final MeteredMessageQueue monitoredQueue) { if (owner.isEmpty()) { return; //there's no actor to monitor } String actorName = owner.get().path().toStringWithoutAddress(); String metricName = MetricRegistry.name(actorName, QUEUE_SIZE); if (registry.getMetrics().containsKey(metricName)) { return; //already registered } Gauge<Integer> queueSize = getQueueSizeGuage(monitoredQueue); registerQueueSizeMetric(metricName, queueSize); }
static <T extends Metric> void registerMetric(final scala.Option<ActorRef> owner, final String metricName, final T metric) { if (owner.isEmpty()) { // there's no actor to monitor return; } String actorName = owner.get().path().toStringWithoutAddress(); String fullName = MetricRegistry.name(actorName, metricName); MetricRegistry registry = MetricsReporter.getInstance(MeteringBehavior.DOMAIN).getMetricsRegistry(); if (registry.getMetrics().containsKey(fullName)) { // already registered return; } try { registry.register(fullName, metric); } catch (IllegalArgumentException e) { // already registered - shouldn't happen here since we check above... LOG.debug("Unable to register '{}' in metrics registry: {}", e); } }
private void addPeer(final Address address) { if (!clusterMembers.contains(address)) { clusterMembers.add(address); } peers.computeIfAbsent(address, input -> getContext().system() .actorSelection(input.toString() + getSelf().path().toStringWithoutAddress())); }
/** * process member up event for cluster * * @param member * the member of cluster * @return always true,currently not false */ public boolean clusterMemberUp(Member member) { if (isLocalAddress(member.address())) { return true; } String path = member.address() + communicator.path().toStringWithoutAddress(); ActorSelection remoteActorSelection = actorSystem.actorSelection(path); if (remoteActorSelection != null) { remoteActors.add(remoteActorSelection); LOG.info("Added remote actor selection for " + path + ", remote actor number becomes " + remoteActors.size()); } else { LOG.error("Failed to get actor selection for " + path); } return true; }
private void updateActorListFromCluster() { List<String> actorList = new ArrayList<String>(); ActorSelection remoteActorSelection = null; scala.collection.immutable.List<Address> seedNodeList = cluster.settings().SeedNodes().toList(); for (Address address : JavaConversions.seqAsJavaList(seedNodeList)) { if (isLocalAddress(address)) { continue; } actorList.add(address.toString()); } for (String path : actorList) { if (!isLocalActor(path)) { path = path + communicator.path().toStringWithoutAddress(); remoteActorSelection = actorSystem.actorSelection(path); if (remoteActorSelection != null) { remoteActors.add(remoteActorSelection); } else { LOG.error("Failed to get actor selection for " + path); } } } }
/** * process member down event for cluster * * @param member * the member of cluster * @return always true,currently not false */ public boolean clusterMemberDown(Member member) { if (isLocalAddress(member.address())) { return true; } for (ActorSelection actorSelection : remoteActors) { LOG.info("clusterMemberDown: actorSelection is " + actorSelection.pathString() + ",member is " + member.address()); if (actorSelection.pathString().contains(member.address().toString())) { remoteActors.remove(actorSelection); String actorPath = member.address() + communicator.path().toStringWithoutAddress(); // remove all remote channels related with the specified cluster // member deviceTable.removeAll(actorPath); LOG.info("Succed to remove the remote actor when Member(" + member.address() + ") is down or unreachable."); return true; } } LOG.info("Failed to remove the remote actor when Member(" + member.address() + ") is down or unreachable."); return false; }
/** * Gets bucket versions from bucket store and sends to the supplied address * * @param remoteActorSystemAddress remote gossiper to send to */ void getLocalStatusAndSendTo(Address remoteActorSystemAddress){ //Get local status from bucket store and send to remote Future<Object> futureReply = Patterns.ask(getContext().parent(), new GetBucketVersions(), config.getAskDuration()); //Find gossiper on remote system ActorSelection remoteRef = getContext().system().actorSelection( remoteActorSystemAddress.toString() + getSelf().path().toStringWithoutAddress()); if(log.isTraceEnabled()) { log.trace("Sending bucket versions to [{}]", remoteRef); } futureReply.map(getMapperToSendLocalStatus(remoteRef), getContext().dispatcher()); }