Search in sources :

Example 1 with BuildRepositoryRemote

use of com.thoughtworks.go.remote.BuildRepositoryRemote in project gocd by gocd.

the class AgentHTTPClientController method retrieveWork.

void retrieveWork() {
    final BuildRepositoryRemote client = remote();
    AgentIdentifier agentIdentifier = agentIdentifier();
    LOG.debug("[Agent Loop] {} is checking for work from Go", agentIdentifier);
    Work work;
    try {
        getAgentRuntimeInfo().idle();
        work = client.getWork(getAgentRuntimeInfo());
        if (!(work instanceof NoWork)) {
            LOG.debug("[Agent Loop] Got work from server: [{}]", work.description());
        }
        runner = new JobRunner();
        final AgentWorkContext agentWorkContext = new AgentWorkContext(agentIdentifier, client, manipulator, getAgentRuntimeInfo(), packageRepositoryExtension, scmExtension, taskExtension, artifactExtension, pluginRequestProcessorRegistry);
        runner.run(work, agentWorkContext);
    } catch (UnregisteredAgentException e) {
        LOG.warn("[Agent Loop] Invalid agent certificate with fingerprint {}. Registering with server on next iteration.", e.getUuid());
        sslInfrastructureService.invalidateAgentCertificate();
    } finally {
        getAgentRuntimeInfo().idle();
    }
}
Also used : UnregisteredAgentException(com.thoughtworks.go.domain.exception.UnregisteredAgentException) BuildRepositoryRemote(com.thoughtworks.go.remote.BuildRepositoryRemote) Work(com.thoughtworks.go.remote.work.Work) NoWork(com.thoughtworks.go.remote.work.NoWork) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) AgentWorkContext(com.thoughtworks.go.remote.work.AgentWorkContext) NoWork(com.thoughtworks.go.remote.work.NoWork)

Example 2 with BuildRepositoryRemote

use of com.thoughtworks.go.remote.BuildRepositoryRemote in project gocd by gocd.

the class AgentHTTPClientController method ping.

@Override
public void ping() {
    final BuildRepositoryRemote client = remote();
    try {
        if (sslInfrastructureService.isRegistered()) {
            AgentIdentifier agent = agentIdentifier();
            LOG.trace("{} is pinging server [{}]", agent, client);
            getAgentRuntimeInfo().refreshUsableSpace();
            agentInstruction = client.ping(getAgentRuntimeInfo());
            pingSuccess();
            LOG.trace("{} pinged server [{}]", agent, client);
        }
    } catch (Throwable e) {
        LOG.error("Error occurred when agent tried to ping server: ", e);
    }
}
Also used : BuildRepositoryRemote(com.thoughtworks.go.remote.BuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier)

Aggregations

AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)2 BuildRepositoryRemote (com.thoughtworks.go.remote.BuildRepositoryRemote)2 UnregisteredAgentException (com.thoughtworks.go.domain.exception.UnregisteredAgentException)1 AgentWorkContext (com.thoughtworks.go.remote.work.AgentWorkContext)1 NoWork (com.thoughtworks.go.remote.work.NoWork)1 Work (com.thoughtworks.go.remote.work.Work)1