use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceMother method missing.
public static AgentInstance missing() {
AgentConfig agentConfig = new AgentConfig("1234", "localhost", "192.168.0.1");
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment());
AgentRuntimeInfo newRuntimeInfo = AgentRuntimeInfo.initialState(agentConfig);
newRuntimeInfo.setStatus(AgentStatus.Missing);
instance.update(newRuntimeInfo);
return instance;
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceMother method building.
public static AgentInstance building(String buildLocator, SystemEnvironment systemEnvironment) {
AgentConfig buildingAgentConfig = new AgentConfig("uuid3", "CCeDev01", "10.18.5.1", new Resources("java"));
AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(buildingAgentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false);
agentRuntimeInfo.busy(new AgentBuildingInfo("pipeline", buildLocator));
AgentInstance building = AgentInstance.createFromConfig(buildingAgentConfig, systemEnvironment);
building.update(agentRuntimeInfo);
return building;
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceMother method pending.
public static AgentInstance pending(SystemEnvironment systemEnvironment) {
AgentRuntimeInfo runtimeInfo = AgentRuntimeInfo.fromServer(new AgentConfig("uuid4", "CCeDev03", "10.18.5.3", new Resources(new Resource("db"), new Resource("web"))), false, "/var/lib", 0L, "linux", false);
AgentInstance pending = AgentInstance.createFromLiveAgent(runtimeInfo, systemEnvironment);
pending.pending();
pending.update(runtimeInfo);
pending.pending();
return pending;
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentInstanceMother method lostContact.
public static AgentInstance lostContact(String buildLocator) {
AgentConfig agentConfig = new AgentConfig("1234", "localhost", "192.168.0.1");
AgentInstance instance = AgentInstance.createFromConfig(agentConfig, new SystemEnvironment());
AgentRuntimeInfo newRuntimeInfo = AgentRuntimeInfo.initialState(agentConfig);
newRuntimeInfo.setStatus(AgentStatus.LostContact);
newRuntimeInfo.setUsableSpace(1000L);
newRuntimeInfo.setBuildingInfo(new AgentBuildingInfo("buildInfo", buildLocator));
instance.update(newRuntimeInfo);
return instance;
}
use of com.thoughtworks.go.server.service.AgentRuntimeInfo in project gocd by gocd.
the class AgentRemoteHandler method processWithoutAcknowledgement.
public void processWithoutAcknowledgement(Agent agent, Message msg) throws Exception {
switch(msg.getAction()) {
case ping:
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);
}
if (info.getCookie() == null) {
String cookie = agentCookie.get(agent);
if (cookie == null) {
cookie = buildRepositoryRemote.getCookie(info.getIdentifier(), info.getLocation());
agentCookie.put(agent, cookie);
}
info.setCookie(cookie);
agent.send(new Message(Action.setCookie, MessageEncoding.encodeData(cookie)));
}
AgentInstruction instruction = this.buildRepositoryRemote.ping(info);
if (instruction.isShouldCancelJob()) {
agent.send(new Message(Action.cancelBuild));
}
break;
case reportCurrentStatus:
Report report = MessageEncoding.decodeData(msg.getData(), Report.class);
buildRepositoryRemote.reportCurrentStatus(report.getAgentRuntimeInfo(), findJobIdentifier(report), report.getJobState());
break;
case reportCompleting:
report = MessageEncoding.decodeData(msg.getData(), Report.class);
buildRepositoryRemote.reportCompleting(report.getAgentRuntimeInfo(), findJobIdentifier(report), report.getResult());
break;
case reportCompleted:
report = MessageEncoding.decodeData(msg.getData(), Report.class);
buildRepositoryRemote.reportCompleted(report.getAgentRuntimeInfo(), findJobIdentifier(report), report.getResult());
break;
case consoleOut:
ConsoleTransmission consoleTransmission = MessageEncoding.decodeData(msg.getData(), ConsoleTransmission.class);
File consoleLogFile = consoleService.consoleLogFile(findJobIdentifier(consoleTransmission));
consoleService.updateConsoleLog(consoleLogFile, consoleTransmission.getLineAsStream());
break;
default:
throw new RuntimeException("Unknown action: " + msg.getAction());
}
}
Aggregations