public void updateAfterRemovedSession(SessionSubscriptionInfo info) { synchronized (this.updateCache) { Set<String> destinationsToRemove = new HashSet<>(); this.updateCache.forEach((destination, sessionMap) -> { if (sessionMap.remove(info.getSessionId()) != null) { if (sessionMap.isEmpty()) { destinationsToRemove.add(destination); } else { this.accessCache.put(destination, sessionMap.deepCopy()); } } }); for (String destination : destinationsToRemove) { this.updateCache.remove(destination); this.accessCache.remove(destination); } } }
public void updateAfterRemovedSubscription(String sessionId, String subsId) { synchronized (this.updateCache) { Set<String> destinationsToRemove = new HashSet<>(); this.updateCache.forEach((destination, sessionMap) -> { List<String> subscriptions = sessionMap.get(sessionId); if (subscriptions != null) { subscriptions.remove(subsId); if (subscriptions.isEmpty()) { sessionMap.remove(sessionId); } if (sessionMap.isEmpty()) { destinationsToRemove.add(destination); } else { this.accessCache.put(destination, sessionMap.deepCopy()); } } }); for (String destination : destinationsToRemove) { this.updateCache.remove(destination); this.accessCache.remove(destination); } } }
public LinkedMultiValueMap<String, String> getSubscriptions(String destination, Message<?> message) { LinkedMultiValueMap<String, String> result = this.accessCache.get(destination); if (result == null) { synchronized (this.updateCache) { result = new LinkedMultiValueMap<>(); for (SessionSubscriptionInfo info : subscriptionRegistry.getAllSubscriptions()) { for (String destinationPattern : info.getDestinations()) { if (getPathMatcher().match(destinationPattern, destination)) { for (Subscription sub : info.getSubscriptions(destinationPattern)) { result.add(info.sessionId, sub.getId()); } } } } if (!result.isEmpty()) { this.updateCache.put(destination, result.deepCopy()); this.accessCache.put(destination, result); } } } return result; }
public void heartbeat() { LinkedMultiValueMap<String, ElasticAgentMetadata> elasticAgentsOfMissingPlugins = agentService.allElasticAgents(); // pingMessage TTL is set lesser than elasticPluginHeartBeatInterval to ensure there aren't multiple ping request for the same plugin long pingMessageTimeToLive = elasticPluginHeartBeatInterval - 10000L; for (PluginDescriptor descriptor : elasticAgentPluginRegistry.getPlugins()) { serverPingQueue.post(new ServerPingMessage(descriptor.id()), pingMessageTimeToLive); elasticAgentsOfMissingPlugins.remove(descriptor.id()); serverHealthService.removeByScope(scope(descriptor.id())); } if (!elasticAgentsOfMissingPlugins.isEmpty()) { for (String pluginId : elasticAgentsOfMissingPlugins.keySet()) { Collection<String> uuids = elasticAgentsOfMissingPlugins.get(pluginId).stream().map(ElasticAgentMetadata::uuid).collect(Collectors.toList()); String description = String.format("Elastic agent plugin with identifier %s has gone missing, but left behind %s agent(s) with UUIDs %s.", pluginId, elasticAgentsOfMissingPlugins.get(pluginId).size(), uuids); serverHealthService.update(ServerHealthState.warning("Elastic agents with no matching plugins", description, HealthStateType.general(scope(pluginId)))); LOGGER.warn(description); } } }
public void updateAfterRemovedSession(SessionSubscriptionInfo info) { synchronized (this.updateCache) { Set<String> destinationsToRemove = new HashSet<>(); this.updateCache.forEach((destination, sessionMap) -> { if (sessionMap.remove(info.getSessionId()) != null) { if (sessionMap.isEmpty()) { destinationsToRemove.add(destination); } else { this.accessCache.put(destination, sessionMap.deepCopy()); } } }); for (String destination : destinationsToRemove) { this.updateCache.remove(destination); this.accessCache.remove(destination); } } }
public void updateAfterRemovedSubscription(String sessionId, String subsId) { synchronized (this.updateCache) { Set<String> destinationsToRemove = new HashSet<>(); this.updateCache.forEach((destination, sessionMap) -> { List<String> subscriptions = sessionMap.get(sessionId); if (subscriptions != null) { subscriptions.remove(subsId); if (subscriptions.isEmpty()) { sessionMap.remove(sessionId); } if (sessionMap.isEmpty()) { destinationsToRemove.add(destination); } else { this.accessCache.put(destination, sessionMap.deepCopy()); } } }); for (String destination : destinationsToRemove) { this.updateCache.remove(destination); this.accessCache.remove(destination); } } }
public LinkedMultiValueMap<String, String> getSubscriptions(String destination, Message<?> message) { LinkedMultiValueMap<String, String> result = this.accessCache.get(destination); if (result == null) { synchronized (this.updateCache) { result = new LinkedMultiValueMap<>(); for (SessionSubscriptionInfo info : subscriptionRegistry.getAllSubscriptions()) { for (String destinationPattern : info.getDestinations()) { if (getPathMatcher().match(destinationPattern, destination)) { for (Subscription sub : info.getSubscriptions(destinationPattern)) { result.add(info.sessionId, sub.getId()); } } } } if (!result.isEmpty()) { this.updateCache.put(destination, result.deepCopy()); this.accessCache.put(destination, result); } } } return result; }
public void updateAfterRemovedSession(SessionSubscriptionInfo info) { synchronized (this.updateCache) { Set<String> destinationsToRemove = new HashSet<>(); this.updateCache.forEach((destination, sessionMap) -> { if (sessionMap.remove(info.getSessionId()) != null) { if (sessionMap.isEmpty()) { destinationsToRemove.add(destination); } else { this.accessCache.put(destination, sessionMap.deepCopy()); } } }); for (String destination : destinationsToRemove) { this.updateCache.remove(destination); this.accessCache.remove(destination); } } }
public void updateAfterRemovedSession(SessionSubscriptionInfo info) { synchronized (this.updateCache) { Set<String> destinationsToRemove = new HashSet<>(); this.updateCache.forEach((destination, sessionMap) -> { if (sessionMap.remove(info.getSessionId()) != null) { if (sessionMap.isEmpty()) { destinationsToRemove.add(destination); } else { this.accessCache.put(destination, sessionMap.deepCopy()); } } }); for (String destination : destinationsToRemove) { this.updateCache.remove(destination); this.accessCache.remove(destination); } } }
public void updateAfterRemovedSubscription(String sessionId, String subsId) { synchronized (this.updateCache) { Set<String> destinationsToRemove = new HashSet<>(); this.updateCache.forEach((destination, sessionMap) -> { List<String> subscriptions = sessionMap.get(sessionId); if (subscriptions != null) { subscriptions.remove(subsId); if (subscriptions.isEmpty()) { sessionMap.remove(sessionId); } if (sessionMap.isEmpty()) { destinationsToRemove.add(destination); } else { this.accessCache.put(destination, sessionMap.deepCopy()); } } }); for (String destination : destinationsToRemove) { this.updateCache.remove(destination); this.accessCache.remove(destination); } } }
public void updateAfterRemovedSubscription(String sessionId, String subsId) { synchronized (this.updateCache) { Set<String> destinationsToRemove = new HashSet<>(); this.updateCache.forEach((destination, sessionMap) -> { List<String> subscriptions = sessionMap.get(sessionId); if (subscriptions != null) { subscriptions.remove(subsId); if (subscriptions.isEmpty()) { sessionMap.remove(sessionId); } if (sessionMap.isEmpty()) { destinationsToRemove.add(destination); } else { this.accessCache.put(destination, sessionMap.deepCopy()); } } }); for (String destination : destinationsToRemove) { this.updateCache.remove(destination); this.accessCache.remove(destination); } } }
public LinkedMultiValueMap<String, String> getSubscriptions(String destination, Message<?> message) { LinkedMultiValueMap<String, String> result = this.accessCache.get(destination); if (result == null) { synchronized (this.updateCache) { result = new LinkedMultiValueMap<>(); for (SessionSubscriptionInfo info : subscriptionRegistry.getAllSubscriptions()) { for (String destinationPattern : info.getDestinations()) { if (getPathMatcher().match(destinationPattern, destination)) { for (Subscription sub : info.getSubscriptions(destinationPattern)) { result.add(info.sessionId, sub.getId()); } } } } if (!result.isEmpty()) { this.updateCache.put(destination, result.deepCopy()); this.accessCache.put(destination, result); } } } return result; }
public LinkedMultiValueMap<String, String> getSubscriptions(String destination, Message<?> message) { LinkedMultiValueMap<String, String> result = this.accessCache.get(destination); if (result == null) { synchronized (this.updateCache) { result = new LinkedMultiValueMap<>(); for (SessionSubscriptionInfo info : subscriptionRegistry.getAllSubscriptions()) { for (String destinationPattern : info.getDestinations()) { if (getPathMatcher().match(destinationPattern, destination)) { for (Subscription sub : info.getSubscriptions(destinationPattern)) { result.add(info.sessionId, sub.getId()); } } } } if (!result.isEmpty()) { this.updateCache.put(destination, result.deepCopy()); this.accessCache.put(destination, result); } } } return result; }