private void register(AgentAutoRegistrationProperties agentAutoRegistrationProperties) throws Exception { String hostName = SystemUtil.getLocalhostNameOrRandomNameIfNotFound(); Registration keyEntry = Registration.createNullPrivateKeyEntry(); while (!keyEntry.isValid()) { try { getTokenIfNecessary(); keyEntry = remoteRegistrationRequester.requestRegistration(hostName, agentAutoRegistrationProperties); } catch (Exception e) { LOGGER.error("[Agent Registration] There was a problem registering with the go server.", e); throw e; } if ((!keyEntry.isValid())) { try { LOGGER.debug("[Agent Registration] Retrieved agent key from Go server is not valid."); Thread.sleep(REGISTER_RETRY_INTERVAL); } catch (InterruptedException e) { // Ok } } } LOGGER.info("[Agent Registration] Retrieved registration from Go server."); storeChainIntoAgentStore(keyEntry); agentAutoRegistrationProperties.scrubRegistrationProperties(); }
public AgentController(SslInfrastructureService sslInfrastructureService, SystemEnvironment systemEnvironment, AgentRegistry agentRegistry, PluginManager pluginManager, SubprocessLogger subprocessLogger, AgentUpgradeService agentUpgradeService, AgentHealthHolder agentHealthHolder) { this.sslInfrastructureService = sslInfrastructureService; this.systemEnvironment = systemEnvironment; this.agentRegistry = agentRegistry; this.subprocessLogger = subprocessLogger; this.agentUpgradeService = agentUpgradeService; this.agentHealthHolder = agentHealthHolder; PluginManagerReference.reference().setPluginManager(pluginManager); hostName = SystemUtil.getLocalhostNameOrRandomNameIfNotFound(); ipAddress = SystemUtil.getClientIp(systemEnvironment.getServiceUrl()); }