|
|
|
@ -15,6 +15,7 @@ import org.springframework.http.MediaType;
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
|
|
|
import org.springframework.scheduling.support.CronTrigger;
|
|
|
|
import org.springframework.scheduling.support.CronTrigger;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.web.client.ResourceAccessException;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
@ -49,10 +50,11 @@ public class StatusCheckerSchedulerService {
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
String url = "http://" + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/command";
|
|
|
|
String url = "http://" + knownAgent.getHostName() + ":" + knownAgent.getListenPort() + "/command";
|
|
|
|
log.debug("StatusChecker to {} send a message UUID {}", knownAgent.getHostName(), messageUuid);
|
|
|
|
log.debug("StatusChecker to {} send a message UUID {}", knownAgent.getHostName(), messageUuid);
|
|
|
|
String response = restTemplate.postForObject(url, bodyEntity, String.class);
|
|
|
|
String response = "";
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
AckDto ackDto = null;
|
|
|
|
AckDto ackDto = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
response = restTemplate.postForObject(url, bodyEntity, String.class);
|
|
|
|
ackDto = objectMapper.readValue(response, new TypeReference<AckDto>() {});
|
|
|
|
ackDto = objectMapper.readValue(response, new TypeReference<AckDto>() {});
|
|
|
|
log.debug("StatusChecker received ack from {} ack: {}", knownAgent.getHostName(), ackDto);
|
|
|
|
log.debug("StatusChecker received ack from {} ack: {}", knownAgent.getHostName(), ackDto);
|
|
|
|
if(AckDto.ResultType.PROCESS_SUCCESS == ackDto.getResult()) {
|
|
|
|
if(AckDto.ResultType.PROCESS_SUCCESS == ackDto.getResult()) {
|
|
|
|
@ -65,10 +67,15 @@ public class StatusCheckerSchedulerService {
|
|
|
|
this.agentConfigReader.setKnownAgentStatus(knownAgent.getHostId(), "DOWN");
|
|
|
|
this.agentConfigReader.setKnownAgentStatus(knownAgent.getHostId(), "DOWN");
|
|
|
|
log.debug("known agent {} {} is DOWN", knownAgent.getHostId(), knownAgent.getHostName());
|
|
|
|
log.debug("known agent {} {} is DOWN", knownAgent.getHostId(), knownAgent.getHostName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (JsonProcessingException e) {
|
|
|
|
this.agentConfigReader.setKnownAgentStatus(knownAgent.getHostId(), "DOWN");
|
|
|
|
this.agentConfigReader.setKnownAgentStatus(knownAgent.getHostId(), "DOWN");
|
|
|
|
log.debug("known agent {} {} alive message is not valid then set DOWN", knownAgent.getHostId(), knownAgent.getHostName());
|
|
|
|
log.debug("known agent {} {} alive message is not valid then set DOWN", knownAgent.getHostId(), knownAgent.getHostName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (ResourceAccessException e) {
|
|
|
|
|
|
|
|
this.agentConfigReader.setKnownAgentStatus(knownAgent.getHostId(), "DOWN");
|
|
|
|
|
|
|
|
log.debug("known agent {} {} connection timeout", knownAgent.getHostId(), knownAgent.getHostName());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|