use of com.thoughtworks.go.server.domain.ElasticAgentMetadata in project gocd by gocd.
the class ElasticAgentPluginService method heartbeat.
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()) {
elasticAgentsOfMissingPlugins.remove(descriptor.id());
List<ClusterProfile> clusterProfiles = clusterProfilesService.getPluginProfiles().findByPluginId(descriptor.id());
boolean secretsResolved = resolveSecrets(descriptor.id(), clusterProfiles);
if (!secretsResolved)
continue;
serverPingQueue.post(new ServerPingMessage(descriptor.id(), clusterProfiles), pingMessageTimeToLive);
serverHealthService.removeByScope(scope(descriptor.id()));
}
if (!elasticAgentsOfMissingPlugins.isEmpty()) {
for (String pluginId : elasticAgentsOfMissingPlugins.keySet()) {
Collection<String> uuids = elasticAgentsOfMissingPlugins.get(pluginId).stream().map(ElasticAgentMetadata::uuid).collect(toList());
String description = 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, general(scope(pluginId))));
LOGGER.warn(description);
}
}
}
Aggregations