public void reportCompleted(final AgentRuntimeInfo agentRuntimeInfo, final JobIdentifier jobIdentifier, final JobResult result) { final JobState state = JobState.Completed; handleFailuresDuringReporting(agentRuntimeInfo, jobIdentifier, "status and result", String.format("%s, %s", state, result), () -> { //TODO: may be i don't belong here, ping already updates agent runtime info agentService.updateRuntimeInfo(agentRuntimeInfo); buildRepositoryService.completing(jobIdentifier, result, agentRuntimeInfo.getUUId()); buildRepositoryService.updateStatusFromAgent(jobIdentifier, state, agentRuntimeInfo.getUUId()); jobStatusTopic.post(new JobStatusMessage(jobIdentifier, state, agentRuntimeInfo.getUUId())); }); }
public String agentInfoDebugString() { return format("Agent [%s, %s, %s, %s]", getHostName(), getIpAdress(), getUUId(), cookie); }
public void updateAgentRuntimeInfo(AgentRuntimeInfo info) { AgentInstance instance = this.findAgentAndRefreshStatus(info.getUUId()); instance.update(info); }
public void reportCurrentStatus(final AgentRuntimeInfo agentRuntimeInfo, final JobIdentifier jobIdentifier, final JobState state) { handleFailuresDuringReporting(agentRuntimeInfo, jobIdentifier, "status", state.toString(), () -> { //TODO: may be i don't belong here, ping already updates agent runtime info agentService.updateRuntimeInfo(agentRuntimeInfo); buildRepositoryService.updateStatusFromAgent(jobIdentifier, state, agentRuntimeInfo.getUUId()); jobStatusTopic.post(new JobStatusMessage(jobIdentifier, state, agentRuntimeInfo.getUUId())); }); }
public AgentInstruction ping(AgentRuntimeInfo info) { LOGGER.trace("{} ping received.", info); try { agentService.updateRuntimeInfo(info); return new AgentInstruction(agentService.findAgentAndRefreshStatus(info.getUUId()).isCancelled()); } catch (AgentWithDuplicateUUIDException agentException) { throw wrappedException(agentException); } catch (Exception e) { LOGGER.error("Error occurred in {} ping.", info, e); throw wrappedException(e); } }
public AgentConfig agent() { return new AgentConfig(getUUId(), identifier.getHostName(), identifier.getIpAddress()); }
public void reportCompleting(final AgentRuntimeInfo agentRuntimeInfo, final JobIdentifier jobIdentifier, final JobResult result) { handleFailuresDuringReporting(agentRuntimeInfo, jobIdentifier, "result", result.toString(), () -> { //TODO: may be i don't belong here, ping already updates agent runtime info agentService.updateRuntimeInfo(agentRuntimeInfo); buildRepositoryService.completing(jobIdentifier, result, agentRuntimeInfo.getUUId()); }); }
public void updateRuntimeInfo(AgentRuntimeInfo info) { if (!info.hasCookie()) { LOGGER.warn("Agent [{}] has no cookie set", info.agentInfoDebugString()); throw new AgentNoCookieSetException(format("Agent [%s] has no cookie set", info.agentInfoDebugString())); } if (info.hasDuplicateCookie(agentDao.cookieFor(info.getIdentifier()))) { LOGGER.warn("Found agent [{}] with duplicate uuid. Please check the agent installation.", info.agentInfoDebugString()); serverHealthService.update( ServerHealthState.warning(format("[%s] has duplicate unique identifier which conflicts with [%s]", info.agentInfoForDisplay(), findAgentAndRefreshStatus(info.getUUId()).agentInfoForDisplay()), "Please check the agent installation. Click <a href='" + docsUrl("/faq/agent_guid_issue.html") + "' target='_blank'>here</a> for more info.", HealthStateType.duplicateAgent(HealthStateScope.forAgent(info.getCookie())), Timeout.THIRTY_SECONDS)); throw new AgentWithDuplicateUUIDException(format("Agent [%s] has invalid cookie", info.agentInfoDebugString())); } AgentInstance agentInstance = findAgentAndRefreshStatus(info.getUUId()); if (agentInstance.isIpChangeRequired(info.getIpAdress())) { AgentConfig agentConfig = agentInstance.agentConfig(); Username userName = agentUsername(info.getUUId(), info.getIpAdress(), agentConfig.getHostNameForDisplay()); LOGGER.warn("Agent with UUID [{}] changed IP Address from [{}] to [{}]", info.getUUId(), agentConfig.getIpAddress(), info.getIpAdress()); agentConfigService.updateAgentIpByUuid(agentConfig.getUuid(), info.getIpAdress(), userName); } agentInstances.updateAgentRuntimeInfo(info); }
public AgentInstance register(AgentRuntimeInfo info) { AgentInstance agentInstance = findAgentAndRefreshStatus(info.getUUId()); if (!agentInstance.isRegistered()) { if(isMaxPendingAgentsLimitReached()) { throw new MaxPendingAgentsLimitReachedException(systemEnvironment.get(SystemEnvironment.MAX_PENDING_AGENTS_ALLOWED)); } agentInstance = AgentInstance.createFromLiveAgent(info, systemEnvironment, agentStatusChangeListener); this.add(agentInstance); } agentInstance.update(info); return agentInstance; }