public void cancel(EnvironmentVariableContext environmentVariableContext, AgentRuntimeInfo agentruntimeInfo) { agentruntimeInfo.idle(); } }
public void cancel(EnvironmentVariableContext environmentVariableContext, AgentRuntimeInfo agentruntimeInfo) { agentruntimeInfo.idle(); }
public void doWork(EnvironmentVariableContext environmentVariableContext, AgentWorkContext agentWorkContext) { agentWorkContext.getAgentRuntimeInfo().idle(); }
public void doWork(EnvironmentVariableContext environmentVariableContext, AgentWorkContext agentWorkContext) { agentWorkContext.getAgentRuntimeInfo().idle(); }
void retrieveWork() { AgentIdentifier agentIdentifier = agentIdentifier(); LOG.debug("[Agent Loop] {} is checking for work from Go", agentIdentifier); Work work; try { getAgentRuntimeInfo().idle(); work = server.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, server, 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(); } }
private AgentRuntimeInfo idleRuntimeInfo() { AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false); agentRuntimeInfo.idle(); return agentRuntimeInfo; }
public void syncConfig(AgentConfig agentConfig) { this.agentConfig = agentConfig; if (agentConfig.isElastic()) { agentRuntimeInfo = ElasticAgentRuntimeInfo.fromServer(agentRuntimeInfo, agentConfig.getElasticAgentId(), agentConfig.getElasticPluginId()); } if (agentRuntimeInfo.getRuntimeStatus() == AgentRuntimeStatus.Unknown) { agentRuntimeInfo.idle(); } updateConfigStatus(agentConfig.isDisabled() ? AgentConfigStatus.Disabled : AgentConfigStatus.Enabled); }
public static AgentInstance createFromLiveAgent(AgentRuntimeInfo agentRuntimeInfo, SystemEnvironment systemEnvironment, AgentStatusChangeListener agentStatusChangeListener) { AgentConfig config = agentRuntimeInfo.agent(); AgentType type = config.isFromLocalHost() ? AgentType.LOCAL : AgentType.REMOTE; AgentInstance instance; if (systemEnvironment.isAutoRegisterLocalAgentEnabled() && config.isFromLocalHost()) { instance = new AgentInstance(config, type, systemEnvironment, agentStatusChangeListener); instance.agentConfigStatus = AgentConfigStatus.Enabled; instance.agentRuntimeInfo.idle(); instance.update(agentRuntimeInfo); return instance; } else { instance = new AgentInstance(config, type, systemEnvironment, agentStatusChangeListener); instance.update(agentRuntimeInfo); } return instance; }
public static AgentInstance idleWith(String uuid, String hostname, String ipAddress, String location, long space, String os, List<String> resources) { AgentConfig agentConfig = new AgentConfig(uuid, hostname, ipAddress); agentConfig.setResourceConfigs(new ResourceConfigs(resources.stream().map(ResourceConfig::new).collect(Collectors.toList()))); AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(agentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, location, "cookie", false); agentRuntimeInfo.idle(); agentRuntimeInfo.setUsableSpace(space); agentRuntimeInfo.setOperatingSystem(os); AgentInstance agentInstance = AgentInstance.createFromLiveAgent(agentRuntimeInfo, new SystemEnvironment(), mock(AgentStatusChangeListener.class)); agentInstance.idle(); agentInstance.update(agentRuntimeInfo); agentInstance.syncConfig(agentConfig); return agentInstance; }
@Test public void shouldUpdateAgentBackToIdleAfterCancelledTaskFinishes() throws Exception { AgentInstance cancelled = AgentInstanceMother.cancelled(); AgentRuntimeInfo fromAgent = new AgentRuntimeInfo(cancelled.agentConfig().getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false); fromAgent.idle(); cancelled.update(fromAgent); assertThat(cancelled.getStatus(), is(AgentStatus.Idle)); }
public static AgentInstance idle(final Date lastHeardAt, final String hostname, SystemEnvironment systemEnvironment) { AgentConfig idleAgentConfig = new AgentConfig("uuid2", hostname, "10.18.5.1"); AgentRuntimeInfo agentRuntimeInfo = new AgentRuntimeInfo(idleAgentConfig.getAgentIdentifier(), AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false); agentRuntimeInfo.setLocation("/var/lib/foo"); agentRuntimeInfo.idle(); agentRuntimeInfo.setUsableSpace(10 * 1024l); AgentInstance agentInstance = AgentInstance.createFromLiveAgent(agentRuntimeInfo, systemEnvironment, mock(AgentStatusChangeListener.class)); agentInstance.idle(); agentInstance.update(agentRuntimeInfo); ReflectionUtil.setField(agentInstance, "lastHeardTime", lastHeardAt); return agentInstance; }
taskExtension, artifactExtension, pluginRequestProcessorRegistry)); } finally { getAgentRuntimeInfo().idle(); updateServerAgentRuntimeInfo();