private Configuration getLiveResourceConfiguration(Resource resource, boolean pingAgentFirst, boolean fromStructured) {
Configuration liveConfig = null;
try {
Agent agent = resource.getAgent();
AgentClient agentClient = this.agentManager.getAgentClient(agent);
boolean agentPingedSuccessfully = false;
// Getting live configuration is mostly for the UI's benefit - as such, do not hang
// for a long time in the event the agent is down or can't be reached. Let's make the UI
// responsive even in the case of an agent down by pinging it quickly to verify the agent is up.
if (pingAgentFirst) {
agentPingedSuccessfully = agentClient.pingService(5000L);
}
if (!pingAgentFirst || agentPingedSuccessfully) {
liveConfig = agentClient.getConfigurationAgentService().loadResourceConfiguration(resource.getId());
if (liveConfig == null) {
// This should really never occur - the PC should never return a null, always at least an empty config.
LOG.debug("ConfigurationAgentService.loadResourceConfiguration() returned a null Configuration.");
liveConfig = new Configuration();
}