public AgentIdentifier getAgentIdentifier() { return agent.getIdentifier(); } }
public DefaultGoPublisher(GoArtifactsManipulator manipulator, JobIdentifier jobIdentifier, BuildRepositoryRemote remoteBuildRepository, AgentRuntimeInfo agentRuntimeInfo, String consoleLogCharset) { this.manipulator = manipulator; this.jobIdentifier = jobIdentifier; this.agentIdentifier = agentRuntimeInfo.getIdentifier(); this.remoteBuildRepository = remoteBuildRepository; this.agentRuntimeInfo = agentRuntimeInfo; this.consoleLogCharset = consoleLogCharset; init(); }
public void agentReportedCompletion(AgentRuntimeInfo agentRuntimeInfo, JobIdentifier jobIdentifier, long reportCompletionStartTime, long reportCompletionEndTime) { performanceLogger.log("WORK-COMPLETED {} {} {} {}", agentRuntimeInfo.getIdentifier().getUuid(), jobIdentifier, reportCompletionStartTime, reportCompletionEndTime); }
public Work getWork(AgentRuntimeInfo runtimeInfo) { AgentIdentifier agent = runtimeInfo.getIdentifier(); synchronized (agentMutex(agent)) { Work work = assignments.get(agent); if (work == null) { assignments.put(agent, NO_WORK); idleAgentsTopic.post(new IdleAgentMessage(runtimeInfo)); return NO_WORK; } if (work instanceof NoWork) { return work; } return assignments.remove(agent); } }
public void retrievedWorkForAgent(AgentRuntimeInfo agentRuntimeInfo, Work work, long retrieveWorkStartTime, long retrieveWorkEndTime) { if (work == null || !(work instanceof BuildWork)) { performanceLogger.log("WORK-NOWORK {} {} {}", agentRuntimeInfo.getIdentifier().getUuid(), retrieveWorkStartTime, retrieveWorkEndTime); return; } BuildWork buildWork = (BuildWork) work; performanceLogger.log("WORK-RETRIEVED {} {} {} {}", agentRuntimeInfo.getIdentifier().getUuid(), buildWork.identifierForLogging(), retrieveWorkStartTime, retrieveWorkEndTime); }
public Work getWork(AgentRuntimeInfo runtimeInfo) { String className = SystemEnvironment.getProperty("WORKCREATOR", DefaultWorkCreator.class.getCanonicalName()); Class<? extends WorkCreator> aClass = null; try { aClass = (Class<? extends WorkCreator>) Class.forName(className); return aClass.getDeclaredConstructor().newInstance().work(runtimeInfo.getIdentifier()); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
private ElasticAgentRuntimeInfo(AgentRuntimeInfo runtimeInfo, String elasticAgentId, String elasticPluginId) { this(runtimeInfo.getIdentifier(), runtimeInfo.getRuntimeStatus(), runtimeInfo.getLocation(), runtimeInfo.getCookie(), elasticAgentId, elasticPluginId); this.setOperatingSystem(runtimeInfo.getOperatingSystem()); this.setUsableSpace(runtimeInfo.getUsableSpace()); }
@Test public void encodeAndDecodePingMessage() { AgentRuntimeInfo info = new AgentRuntimeInfo(new AgentIdentifier("hostName", "ipAddress", "uuid"), null, null, null, false); byte[] msg = MessageEncoding.encodeMessage(new Message(Action.ping, MessageEncoding.encodeData(info))); Message decoded = MessageEncoding.decodeMessage(new ByteArrayInputStream(msg)); AgentRuntimeInfo decodedInfo = MessageEncoding.decodeData(decoded.getData(), AgentRuntimeInfo.class); assertThat(decodedInfo.getIdentifier(), is(info.getIdentifier())); }
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); }
AgentRuntimeInfo info = MessageEncoding.decodeData(msg.getData(), AgentRuntimeInfo.class); if (!sessionIds.containsKey(agent)) { LOGGER.info("{} is connected with websocket {}", info.getIdentifier(), agent); sessionIds.put(agent, info.getUUId()); this.agentSessions.put(info.getUUId(), agent); String cookie = agentCookie.get(agent); if (cookie == null) { cookie = buildRepositoryRemote.getCookie(info.getIdentifier(), info.getLocation()); agentCookie.put(agent, cookie);
BuildSession build = new BuildSession( buildSettings.getBuildId(), getAgentRuntimeInfo().getIdentifier(), buildStateReporter, buildConsole,