use of com.thoughtworks.go.websocket.Message in project gocd by gocd.
the class BuildAssignmentServiceIntegrationTest method shouldCallForReregisterIfAgentInstanceIsNotRegistered.
@Test
public void shouldCallForReregisterIfAgentInstanceIsNotRegistered() throws Exception {
AgentConfig agentConfig = AgentMother.remoteAgent();
fixture.createPipelineWithFirstStageScheduled();
AgentRuntimeInfo info = AgentRuntimeInfo.fromServer(agentConfig, true, "location", 1000000l, "OS", false);
agentService.requestRegistration(new Username("bob"), info);
assertThat(agentService.findAgent(info.getUUId()).isRegistered(), is(false));
info.setCookie("cookie");
agentRemoteHandler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
buildAssignmentService.onTimer();
assertThat(agent.messages.size(), is(1));
assertThat(agent.messages.get(0).getAction(), is(Action.reregister));
}
use of com.thoughtworks.go.websocket.Message in project gocd by gocd.
the class BuildAssignmentServiceIntegrationTest method shouldAssignMatchedJobToAgentsRegisteredInAgentRemoteHandler.
@Test
public void shouldAssignMatchedJobToAgentsRegisteredInAgentRemoteHandler() throws Exception {
AgentConfig agentConfig = AgentMother.remoteAgent();
configHelper.addAgent(agentConfig);
fixture.createPipelineWithFirstStageScheduled();
AgentRuntimeInfo info = AgentRuntimeInfo.fromServer(agentConfig, true, "location", 1000000l, "OS", false);
info.setCookie("cookie");
agentRemoteHandler.process(agent, new Message(Action.ping, MessageEncoding.encodeData(info)));
AgentInstance agent = agentService.findAgent(agentConfig.getUuid());
assertFalse(agent.isBuilding());
buildAssignmentService.onTimer();
assertThat(this.agent.messages.size(), is(1));
assertThat(MessageEncoding.decodeWork(this.agent.messages.get(0).getData()), instanceOf(BuildWork.class));
assertTrue(agent.isBuilding());
}
use of com.thoughtworks.go.websocket.Message in project gocd by gocd.
the class AgentRemoteSocket method onMessage.
@OnWebSocketMessage
public void onMessage(InputStream input) throws Exception {
Message msg = MessageEncoding.decodeMessage(input);
LOGGER.debug("{} message: {}", sessionName(), msg);
handler.process(this, msg);
}
use of com.thoughtworks.go.websocket.Message in project gocd by gocd.
the class AgentWebSocketClientController method updateServerAgentRuntimeInfo.
private void updateServerAgentRuntimeInfo() {
AgentIdentifier agent = agentIdentifier();
LOG.trace("{} is pinging server [{}]", agent, server);
getAgentRuntimeInfo().refreshUsableSpace();
webSocketSessionHandler.sendAndWaitForAcknowledgement(new Message(Action.ping, MessageEncoding.encodeData(getAgentRuntimeInfo())));
LOG.trace("{} pinged server [{}]", agent, server);
}
use of com.thoughtworks.go.websocket.Message in project gocd by gocd.
the class AgentWebSocketClientController method onMessage.
@OnWebSocketMessage
public void onMessage(InputStream raw) {
final Message msg = MessageEncoding.decodeMessage(raw);
LOG.debug("{} message: {}", webSocketSessionHandler.getSessionName(), msg);
executor.execute(new Runnable() {
@Override
public void run() {
try {
process(msg);
} catch (InterruptedException e) {
LOG.error("Process message[" + msg + "] is interruptted.", e);
} catch (RuntimeException e) {
LOG.error("Unexpected error while processing message[" + msg + "]: " + e.getMessage(), e);
}
}
});
}
Aggregations