Search in sources :

Example 6 with Message

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));
}
Also used : Message(com.thoughtworks.go.websocket.Message) Username(com.thoughtworks.go.server.domain.Username)

Example 7 with Message

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());
}
Also used : Message(com.thoughtworks.go.websocket.Message) BuildWork(com.thoughtworks.go.remote.work.BuildWork)

Example 8 with Message

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);
}
Also used : Message(com.thoughtworks.go.websocket.Message)

Example 9 with Message

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);
}
Also used : Message(com.thoughtworks.go.websocket.Message) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier)

Example 10 with Message

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);
            }
        }
    });
}
Also used : Message(com.thoughtworks.go.websocket.Message)

Aggregations

Message (com.thoughtworks.go.websocket.Message)17 BuildWork (com.thoughtworks.go.remote.work.BuildWork)4 AgentConfig (com.thoughtworks.go.config.AgentConfig)2 JobInstance (com.thoughtworks.go.domain.JobInstance)2 JobPlan (com.thoughtworks.go.domain.JobPlan)2 Username (com.thoughtworks.go.server.domain.Username)2 AgentStub (com.thoughtworks.go.server.websocket.AgentStub)2 Report (com.thoughtworks.go.websocket.Report)2 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)1 Work (com.thoughtworks.go.remote.work.Work)1 Agent (com.thoughtworks.go.server.websocket.Agent)1 ConsoleTransmission (com.thoughtworks.go.websocket.ConsoleTransmission)1 Map (java.util.Map)1 Test (org.junit.Test)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)1