use of com.thoughtworks.go.remote.work.Work in project gocd by gocd.
the class JobAssignmentTest method shouldAssignJobToLocalAgentEvenReachedLimit.
@Test
public void shouldAssignJobToLocalAgentEvenReachedLimit() throws UnknownHostException {
AgentInstance local = setupLocalAgent();
AgentInstance remote = setupRemoteAgent();
fixture.createPipelineWithFirstStageScheduled();
assignmentService.onTimer();
assignmentService.assignWorkToAgent(remote);
Work work = assignmentService.assignWorkToAgent(local);
assertThat(work, instanceOf(BuildWork.class));
}
use of com.thoughtworks.go.remote.work.Work in project gocd by gocd.
the class JobAssignmentTest method shouldNotAssignJobToRemoteAgentIfReachedLimit.
@Test
public void shouldNotAssignJobToRemoteAgentIfReachedLimit() throws UnknownHostException {
AgentInstance local = setupLocalAgent();
AgentInstance remote = setupRemoteAgent();
AgentInstance remote2 = setupRemoteAgent();
fixture.createPipelineWithFirstStageScheduled();
assignmentService.onConfigChange(null);
assignmentService.assignWorkToAgent(local);
assignmentService.assignWorkToAgent(remote);
Work work = assignmentService.assignWorkToAgent(remote2);
assertThat(work, instanceOf(NoWork.class));
}
use of com.thoughtworks.go.remote.work.Work in project gocd by gocd.
the class WorkAssignments method getWork.
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);
}
}
use of com.thoughtworks.go.remote.work.Work in project gocd by gocd.
the class WorkAssignments method onMessage.
public void onMessage(WorkAssignedMessage message) {
AgentIdentifier agentIdentifier = message.getAgent();
Work work = message.getWork();
if (work instanceof NoWork) {
synchronized (agentMutex(agentIdentifier)) {
assignments.remove(agentIdentifier);
}
} else {
synchronized (agentMutex(agentIdentifier)) {
assignments.replace(agentIdentifier, NO_WORK, work);
}
}
}
use of com.thoughtworks.go.remote.work.Work in project gocd by gocd.
the class BuildRepositoryMessageProducer method getWork.
public Work getWork(AgentRuntimeInfo runtimeInfo) {
long startTime = System.currentTimeMillis();
Work work = workAssignments.getWork(runtimeInfo);
workAssignmentPerformanceLogger.retrievedWorkForAgent(runtimeInfo, work, startTime, System.currentTimeMillis());
return work;
}
Aggregations