From 1ab03e13c23a3771c0ee1cdcd84150ec4d0f3bd1 Mon Sep 17 00:00:00 2001 From: Jerry Duffy <jtduffy@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:43:32 -0500 Subject: [PATCH] Refactor super agent name out of the agent --- .../internal/IntrospectorCoreService.java | 4 +- .../internal/IntrospectorRPMService.java | 2 +- .../main/java/com/newrelic/agent/Agent.java | 8 +- .../java/com/newrelic/agent/IRPMService.java | 2 +- .../java/com/newrelic/agent/MetricNames.java | 2 +- .../java/com/newrelic/agent/RPMService.java | 5 +- ...trolIntegrationHealthFileBasedClient.java} | 16 ++-- .../AgentControlHealthNoOpClientControl.java} | 4 +- ...AgentControlIntegrationClientFactory.java} | 16 ++-- .../AgentControlIntegrationHealthClient.java} | 4 +- .../AgentControlIntegrationService.java} | 28 +++---- .../AgentControlIntegrationUtils.java} | 12 +-- .../AgentHealth.java | 2 +- .../HealthDataChangeListener.java | 2 +- .../HealthDataProducer.java | 2 +- .../circuitbreaker/CircuitBreakerService.java | 12 +-- .../newrelic/agent/config/AgentConfig.java | 2 +- .../agent/config/AgentConfigImpl.java | 12 +-- ...ava => AgentControlIntegrationConfig.java} | 14 ++-- .../AgentControlIntegrationConfigImpl.java | 72 ++++++++++++++++++ ... AgentControlIntegrationHealthConfig.java} | 4 +- .../agent/config/ConfigServiceFactory.java | 10 +-- .../SuperAgentIntegrationConfigImpl.java | 73 ------------------- .../newrelic/agent/core/CoreServiceImpl.java | 6 +- .../agent/service/ServiceManagerImpl.java | 26 +++---- .../agent/transport/DataSenderImpl.java | 28 +++---- .../java/com/newrelic/agent/AgentTest.java | 6 +- .../newrelic/agent/HarvestServiceTest.java | 2 +- .../com/newrelic/agent/MockCoreService.java | 4 +- .../com/newrelic/agent/MockRPMService.java | 2 +- .../AgentControlHealthUnitTestClient.java} | 4 +- ...tControlIntegrationClientFactoryTest.java} | 22 +++--- ...IntegrationHealthFileBasedClientTest.java} | 20 ++--- .../AgentControlIntegrationServiceTest.java} | 52 ++++++------- .../AgentControlIntegrationUtilsTest.java} | 12 ++- .../AgentHealthTest.java | 14 ++-- .../UnitTestHealthDataChangeListener.java | 2 +- ...=> AgentControlIntegrationConfigTest.java} | 22 +++--- 38 files changed, 258 insertions(+), 272 deletions(-) rename newrelic-agent/src/main/java/com/newrelic/agent/{superagent/SuperAgentIntegrationHealthFileBasedClient.java => agentcontrol/AgentControlControlIntegrationHealthFileBasedClient.java} (79%) rename newrelic-agent/src/main/java/com/newrelic/agent/{superagent/SuperAgentHealthNoOpClient.java => agentcontrol/AgentControlHealthNoOpClientControl.java} (66%) rename newrelic-agent/src/main/java/com/newrelic/agent/{superagent/SuperAgentIntegrationClientFactory.java => agentcontrol/AgentControlIntegrationClientFactory.java} (56%) rename newrelic-agent/src/main/java/com/newrelic/agent/{superagent/SuperAgentIntegrationHealthClient.java => agentcontrol/AgentControlIntegrationHealthClient.java} (67%) rename newrelic-agent/src/main/java/com/newrelic/agent/{superagent/SuperAgentIntegrationService.java => agentcontrol/AgentControlIntegrationService.java} (61%) rename newrelic-agent/src/main/java/com/newrelic/agent/{superagent/SuperAgentIntegrationUtils.java => agentcontrol/AgentControlIntegrationUtils.java} (75%) rename newrelic-agent/src/main/java/com/newrelic/agent/{superagent => agentcontrol}/AgentHealth.java (98%) rename newrelic-agent/src/main/java/com/newrelic/agent/{superagent => agentcontrol}/HealthDataChangeListener.java (88%) rename newrelic-agent/src/main/java/com/newrelic/agent/{superagent => agentcontrol}/HealthDataProducer.java (85%) rename newrelic-agent/src/main/java/com/newrelic/agent/config/{SuperAgentIntegrationConfig.java => AgentControlIntegrationConfig.java} (57%) create mode 100644 newrelic-agent/src/main/java/com/newrelic/agent/config/AgentControlIntegrationConfigImpl.java rename newrelic-agent/src/main/java/com/newrelic/agent/config/{SuperAgentIntegrationHealthConfig.java => AgentControlIntegrationHealthConfig.java} (91%) delete mode 100644 newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationConfigImpl.java rename newrelic-agent/src/test/java/com/newrelic/agent/{superagent/SuperAgentHealthUnitTestClient.java => agentcontrol/AgentControlHealthUnitTestClient.java} (76%) rename newrelic-agent/src/test/java/com/newrelic/agent/{superagent/SuperAgentIntegrationClientFactoryTest.java => agentcontrol/AgentControlIntegrationClientFactoryTest.java} (54%) rename newrelic-agent/src/test/java/com/newrelic/agent/{superagent/SuperAgentIntegrationHealthFileBasedClientTest.java => agentcontrol/AgentControlIntegrationHealthFileBasedClientTest.java} (80%) rename newrelic-agent/src/test/java/com/newrelic/agent/{superagent/SuperAgentIntegrationServiceTest.java => agentcontrol/AgentControlIntegrationServiceTest.java} (58%) rename newrelic-agent/src/test/java/com/newrelic/agent/{superagent/SuperAgentIntegrationUtilsTest.java => agentcontrol/AgentControlIntegrationUtilsTest.java} (69%) rename newrelic-agent/src/test/java/com/newrelic/agent/{superagent => agentcontrol}/AgentHealthTest.java (75%) rename newrelic-agent/src/test/java/com/newrelic/agent/{superagent => agentcontrol}/UnitTestHealthDataChangeListener.java (91%) rename newrelic-agent/src/test/java/com/newrelic/agent/config/{SuperAgentIntegrationConfigTest.java => AgentControlIntegrationConfigTest.java} (54%) diff --git a/instrumentation-test/src/main/java/com/newrelic/agent/introspec/internal/IntrospectorCoreService.java b/instrumentation-test/src/main/java/com/newrelic/agent/introspec/internal/IntrospectorCoreService.java index 87c8ece7fc..306df12b35 100644 --- a/instrumentation-test/src/main/java/com/newrelic/agent/introspec/internal/IntrospectorCoreService.java +++ b/instrumentation-test/src/main/java/com/newrelic/agent/introspec/internal/IntrospectorCoreService.java @@ -10,8 +10,8 @@ import com.newrelic.agent.InstrumentationProxy; import com.newrelic.agent.core.CoreService; import com.newrelic.agent.service.AbstractService; -import com.newrelic.agent.superagent.HealthDataChangeListener; -import com.newrelic.agent.superagent.HealthDataProducer; +import com.newrelic.agent.agentcontrol.HealthDataChangeListener; +import com.newrelic.agent.agentcontrol.HealthDataProducer; class IntrospectorCoreService extends AbstractService implements CoreService, HealthDataProducer { private InstrumentationProxy instrumentation = null; diff --git a/instrumentation-test/src/main/java/com/newrelic/agent/introspec/internal/IntrospectorRPMService.java b/instrumentation-test/src/main/java/com/newrelic/agent/introspec/internal/IntrospectorRPMService.java index 7a6d7e74ec..0b6e1278bd 100644 --- a/instrumentation-test/src/main/java/com/newrelic/agent/introspec/internal/IntrospectorRPMService.java +++ b/instrumentation-test/src/main/java/com/newrelic/agent/introspec/internal/IntrospectorRPMService.java @@ -20,7 +20,7 @@ import com.newrelic.agent.service.module.JarData; import com.newrelic.agent.sql.SqlTrace; import com.newrelic.agent.stats.StatsEngine; -import com.newrelic.agent.superagent.HealthDataProducer; +import com.newrelic.agent.agentcontrol.HealthDataProducer; import com.newrelic.agent.trace.TransactionTrace; import com.newrelic.agent.transaction.TransactionNamingScheme; diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/Agent.java b/newrelic-agent/src/main/java/com/newrelic/agent/Agent.java index 52bcf72233..8966df906b 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/Agent.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/Agent.java @@ -25,8 +25,8 @@ import com.newrelic.agent.service.ServiceManagerImpl; import com.newrelic.agent.stats.StatsService; import com.newrelic.agent.stats.StatsWorks; -import com.newrelic.agent.superagent.AgentHealth; -import com.newrelic.agent.superagent.SuperAgentIntegrationUtils; +import com.newrelic.agent.agentcontrol.AgentHealth; +import com.newrelic.agent.agentcontrol.AgentControlIntegrationUtils; import com.newrelic.agent.util.UnwindableInstrumentation; import com.newrelic.agent.util.UnwindableInstrumentationImpl; import com.newrelic.agent.util.asm.ClassStructure; @@ -294,13 +294,13 @@ private static boolean tryToInitializeServiceManager(Instrumentation inst) { AgentConfig agentConfig = serviceManager.getConfigService().getDefaultAgentConfig(); if (isLicenseKeyEmpty(agentConfig.getLicenseKey())) { - SuperAgentIntegrationUtils.reportUnhealthyStatusPriorToServiceStart(agentConfig, AgentHealth.Status.MISSING_LICENSE); + AgentControlIntegrationUtils.reportUnhealthyStatusPriorToServiceStart(agentConfig, AgentHealth.Status.MISSING_LICENSE); LOG.error("license_key is empty in the config. Not starting New Relic Agent."); return false; } if (!serviceManager.getConfigService().getDefaultAgentConfig().isAgentEnabled()) { - SuperAgentIntegrationUtils.reportUnhealthyStatusPriorToServiceStart(agentConfig, AgentHealth.Status.AGENT_DISABLED); + AgentControlIntegrationUtils.reportUnhealthyStatusPriorToServiceStart(agentConfig, AgentHealth.Status.AGENT_DISABLED); LOG.warning("agent_enabled is false in the config. Not starting New Relic Agent."); return false; } diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/IRPMService.java b/newrelic-agent/src/main/java/com/newrelic/agent/IRPMService.java index 27fad1ae16..762009386d 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/IRPMService.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/IRPMService.java @@ -19,7 +19,7 @@ import com.newrelic.agent.service.module.JarData; import com.newrelic.agent.sql.SqlTrace; import com.newrelic.agent.stats.StatsEngine; -import com.newrelic.agent.superagent.HealthDataProducer; +import com.newrelic.agent.agentcontrol.HealthDataProducer; import com.newrelic.agent.trace.TransactionTrace; import com.newrelic.agent.transaction.TransactionNamingScheme; diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/MetricNames.java b/newrelic-agent/src/main/java/com/newrelic/agent/MetricNames.java index 709ec1b68e..fc3e9235bd 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/MetricNames.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/MetricNames.java @@ -511,7 +511,7 @@ public class MetricNames { public static final String SUPPORTABILITY_AI_MONITORING_TOKEN_COUNT_CALLBACK_SET = "Supportability/AiMonitoringTokenCountCallback/Set"; // Super Agent Integration - public static final String SUPPORTABILITY_SUPERAGENT_HEALTH_REPORTING_ENABLED = "Supportability/SuperAgent/Health/enabled"; + public static final String SUPPORTABILITY_AGENT_CONTROL_HEALTH_REPORTING_ENABLED = "Supportability/AgentControl/Health/enabled"; /** * Utility method for adding supportability metrics to APIs diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/RPMService.java b/newrelic-agent/src/main/java/com/newrelic/agent/RPMService.java index 7b8a1a6714..b56cde3d2c 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/RPMService.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/RPMService.java @@ -36,9 +36,7 @@ import com.newrelic.agent.service.module.JarData; import com.newrelic.agent.sql.SqlTrace; import com.newrelic.agent.stats.StatsEngine; -import com.newrelic.agent.superagent.AgentHealth; -import com.newrelic.agent.superagent.HealthDataChangeListener; -import com.newrelic.agent.superagent.HealthDataProducer; +import com.newrelic.agent.agentcontrol.HealthDataProducer; import com.newrelic.agent.trace.TransactionTrace; import com.newrelic.agent.transaction.TransactionNamingScheme; import com.newrelic.agent.transport.ConnectionResponse; @@ -61,7 +59,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationHealthFileBasedClient.java b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlControlIntegrationHealthFileBasedClient.java similarity index 79% rename from newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationHealthFileBasedClient.java rename to newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlControlIntegrationHealthFileBasedClient.java index b7a096b9dc..04c6194ae2 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationHealthFileBasedClient.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlControlIntegrationHealthFileBasedClient.java @@ -4,10 +4,10 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; import com.newrelic.agent.Agent; -import com.newrelic.agent.config.SuperAgentIntegrationConfig; +import com.newrelic.agent.config.AgentControlIntegrationConfig; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; @@ -20,12 +20,12 @@ import java.util.UUID; import java.util.logging.Level; -public class SuperAgentIntegrationHealthFileBasedClient implements SuperAgentIntegrationHealthClient { +public class AgentControlControlIntegrationHealthFileBasedClient implements AgentControlIntegrationHealthClient { private Yaml yamlWriter; private File healthFile = null; private boolean isValid = false; - public SuperAgentIntegrationHealthFileBasedClient(SuperAgentIntegrationConfig config) { + public AgentControlControlIntegrationHealthFileBasedClient(AgentControlIntegrationConfig config) { URI locationFromConfig = config.getHealthDeliveryLocation(); File fileFolder = createHealthFileFolderInstance(locationFromConfig); @@ -49,10 +49,10 @@ public void sendHealthMessage(AgentHealth agentHealth) { fw.close(); if (Agent.LOG.isFinestEnabled() && Agent.isDebugEnabled()) { - Agent.LOG.log(Level.FINEST, "Wrote SA health file: {0}", healthFile.getAbsolutePath()); + Agent.LOG.log(Level.FINEST, "Wrote agent control health file: {0}", healthFile.getAbsolutePath()); } } catch (IOException e) { - Agent.LOG.log(Level.WARNING, "Error writing health message to file: {0}", e.getMessage()); + Agent.LOG.log(Level.WARNING, "Error writing agent control health message to file: {0}", e.getMessage()); } } } @@ -68,7 +68,7 @@ private Map<String, Object> createHeathMessageMap(AgentHealth agentHealth) { healthMap.put("healthy", agentHealth.isHealthy()); healthMap.put("status", agentHealth.getCurrentStatus()); healthMap.put("start_time_unix_nano", agentHealth.getStartTimeNanos()); - healthMap.put("status_time_unix_nano", SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos()); + healthMap.put("status_time_unix_nano", AgentControlIntegrationUtils.getPseudoCurrentTimeNanos()); if (!agentHealth.isHealthy()) { healthMap.put("last_error", agentHealth.getLastError()); } @@ -81,7 +81,7 @@ private File createHealthFileFolderInstance(URI location) { if (location != null) { fileFolder = new File(location); if (!(fileFolder.isDirectory() && fileFolder.canWrite())) { - Agent.LOG.log(Level.WARNING, "superagent.health.delivery_location is not a valid folder. " + + Agent.LOG.log(Level.WARNING, "agent_control.health.delivery_location is not a valid folder. " + "Health messages will not be generated. Configured location: {0} isFolder: {1} canWrite: {2}", fileFolder.getAbsolutePath(), fileFolder.isDirectory(), fileFolder.canWrite()); fileFolder = null; diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentHealthNoOpClient.java b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlHealthNoOpClientControl.java similarity index 66% rename from newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentHealthNoOpClient.java rename to newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlHealthNoOpClientControl.java index acb3b4411f..382c2c6f34 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentHealthNoOpClient.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlHealthNoOpClientControl.java @@ -4,9 +4,9 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; -public class SuperAgentHealthNoOpClient implements SuperAgentIntegrationHealthClient { +public class AgentControlHealthNoOpClientControl implements AgentControlIntegrationHealthClient { @Override public void sendHealthMessage(AgentHealth agentHealth) { diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationClientFactory.java b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationClientFactory.java similarity index 56% rename from newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationClientFactory.java rename to newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationClientFactory.java index e8a8133186..1f99815dab 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationClientFactory.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationClientFactory.java @@ -4,30 +4,30 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; import com.newrelic.agent.Agent; -import com.newrelic.agent.config.SuperAgentIntegrationConfig; +import com.newrelic.agent.config.AgentControlIntegrationConfig; import java.util.logging.Level; -public class SuperAgentIntegrationClientFactory { - private static final SuperAgentIntegrationHealthClient NO_OP_INSTANCE = new SuperAgentHealthNoOpClient(); +public class AgentControlIntegrationClientFactory { + private static final AgentControlIntegrationHealthClient NO_OP_INSTANCE = new AgentControlHealthNoOpClientControl(); public enum HealthClientType { noop, file, } - public static SuperAgentIntegrationHealthClient createHealthClient(SuperAgentIntegrationConfig config) { - SuperAgentIntegrationHealthClient client; + public static AgentControlIntegrationHealthClient createHealthClient(AgentControlIntegrationConfig config) { + AgentControlIntegrationHealthClient client; try { HealthClientType healthClientType = HealthClientType.valueOf(config.getHealthClientType()); - Agent.LOG.log(Level.INFO, "Generating SuperAgent Health Client type: {0}", healthClientType); + Agent.LOG.log(Level.INFO, "Generating Agent Control Health Client type: {0}", healthClientType); switch (healthClientType) { case file: - client = new SuperAgentIntegrationHealthFileBasedClient(config); + client = new AgentControlControlIntegrationHealthFileBasedClient(config); break; default: diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationHealthClient.java b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationHealthClient.java similarity index 67% rename from newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationHealthClient.java rename to newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationHealthClient.java index bb5bdc1148..abaa729834 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationHealthClient.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationHealthClient.java @@ -4,9 +4,9 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; -public interface SuperAgentIntegrationHealthClient { +public interface AgentControlIntegrationHealthClient { void sendHealthMessage(AgentHealth agentHealth); boolean isValid(); diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationService.java b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationService.java similarity index 61% rename from newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationService.java rename to newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationService.java index 4971d4124a..3ffca36c96 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationService.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationService.java @@ -4,7 +4,7 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; import com.newrelic.agent.Agent; import com.newrelic.agent.MetricNames; @@ -18,20 +18,20 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; -public class SuperAgentIntegrationService extends AbstractService implements HealthDataChangeListener { +public class AgentControlIntegrationService extends AbstractService implements HealthDataChangeListener { private final AgentConfig agentConfig; - private final SuperAgentIntegrationHealthClient client; + private final AgentControlIntegrationHealthClient client; private final AgentHealth agentHealth; private ScheduledExecutorService scheduler; - public SuperAgentIntegrationService(SuperAgentIntegrationHealthClient client, AgentConfig agentConfig, + public AgentControlIntegrationService(AgentControlIntegrationHealthClient client, AgentConfig agentConfig, HealthDataProducer... healthProducers) { - super(SuperAgentIntegrationService.class.getSimpleName()); + super(AgentControlIntegrationService.class.getSimpleName()); this.agentConfig = agentConfig; this.client = client; - this.agentHealth = new AgentHealth(SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos()); + this.agentHealth = new AgentHealth(AgentControlIntegrationUtils.getPseudoCurrentTimeNanos()); for (HealthDataProducer healthProducer : healthProducers) { healthProducer.registerHealthDataChangeListener(this); @@ -41,15 +41,15 @@ public SuperAgentIntegrationService(SuperAgentIntegrationHealthClient client, Ag @Override protected void doStart() throws Exception { if (isEnabled()) { - Agent.LOG.log(Level.INFO, "SuperAgentIntegrationService starting: Health file location: {0} Frequency: {1} Scheme: {2}", - agentConfig.getSuperAgentIntegrationConfig().getHealthDeliveryLocation(), - agentConfig.getSuperAgentIntegrationConfig().getHealthReportingFrequency(), - agentConfig.getSuperAgentIntegrationConfig().getHealthClientType()); - NewRelic.getAgent().getMetricAggregator().incrementCounter(MetricNames.SUPPORTABILITY_SUPERAGENT_HEALTH_REPORTING_ENABLED); + Agent.LOG.log(Level.INFO, "AgentControlIntegrationService starting: Health file location: {0} Frequency: {1} Scheme: {2}", + agentConfig.getAgentControlIntegrationConfig().getHealthDeliveryLocation(), + agentConfig.getAgentControlIntegrationConfig().getHealthReportingFrequency(), + agentConfig.getAgentControlIntegrationConfig().getHealthClientType()); + NewRelic.getAgent().getMetricAggregator().incrementCounter(MetricNames.SUPPORTABILITY_AGENT_CONTROL_HEALTH_REPORTING_ENABLED); - int messageSendFrequency = agentConfig.getSuperAgentIntegrationConfig().getHealthReportingFrequency(); //Used for both repeat frequency and initial delay + int messageSendFrequency = agentConfig.getAgentControlIntegrationConfig().getHealthReportingFrequency(); //Used for both repeat frequency and initial delay - this.scheduler = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("New Relic Super Agent Integration Service", true)); + this.scheduler = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("New Relic Agent Control Integration Service", true)); this.scheduler.scheduleWithFixedDelay(() -> client.sendHealthMessage(agentHealth), messageSendFrequency, messageSendFrequency, TimeUnit.SECONDS); } } @@ -65,7 +65,7 @@ protected void doStop() throws Exception { @Override public boolean isEnabled() { - return agentConfig.getSuperAgentIntegrationConfig().isEnabled() && client != null && client.isValid(); + return agentConfig.getAgentControlIntegrationConfig().isEnabled() && client != null && client.isValid(); } @Override diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationUtils.java b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationUtils.java similarity index 75% rename from newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationUtils.java rename to newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationUtils.java index fff9516526..b8d0a35581 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/SuperAgentIntegrationUtils.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationUtils.java @@ -4,14 +4,14 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; import com.newrelic.agent.config.AgentConfig; -import com.newrelic.agent.config.SuperAgentIntegrationConfig; +import com.newrelic.agent.config.AgentControlIntegrationConfig; import java.util.List; -public class SuperAgentIntegrationUtils { +public class AgentControlIntegrationUtils { public static long getPseudoCurrentTimeNanos() { // The message expects the time in nanoseconds. Since this is a practical impossibility on most hardware, // simply get the current ms and multiply. @@ -32,9 +32,9 @@ public static void reportHealthyStatus(List<HealthDataChangeListener> healthData } public static void reportUnhealthyStatusPriorToServiceStart(AgentConfig config, AgentHealth.Status status) { - SuperAgentIntegrationConfig superAgentIntegrationConfig = config.getSuperAgentIntegrationConfig(); - if (superAgentIntegrationConfig.isEnabled()) { - SuperAgentIntegrationHealthClient client = SuperAgentIntegrationClientFactory.createHealthClient(superAgentIntegrationConfig); + AgentControlIntegrationConfig agentControlIntegrationConfig = config.getAgentControlIntegrationConfig(); + if (agentControlIntegrationConfig.isEnabled()) { + AgentControlIntegrationHealthClient client = AgentControlIntegrationClientFactory.createHealthClient(agentControlIntegrationConfig); AgentHealth agentHealth = new AgentHealth(getPseudoCurrentTimeNanos()); agentHealth.setUnhealthyStatus(status); client.sendHealthMessage(agentHealth); diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/AgentHealth.java b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentHealth.java similarity index 98% rename from newrelic-agent/src/main/java/com/newrelic/agent/superagent/AgentHealth.java rename to newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentHealth.java index 8980821ed8..161c264c3a 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/AgentHealth.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/AgentHealth.java @@ -4,7 +4,7 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; public class AgentHealth { public enum Category { diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/HealthDataChangeListener.java b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/HealthDataChangeListener.java similarity index 88% rename from newrelic-agent/src/main/java/com/newrelic/agent/superagent/HealthDataChangeListener.java rename to newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/HealthDataChangeListener.java index d5554bc974..59f261288d 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/HealthDataChangeListener.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/HealthDataChangeListener.java @@ -4,7 +4,7 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; public interface HealthDataChangeListener { void onUnhealthyStatus(AgentHealth.Status newStatus, String... additionalInfo); diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/HealthDataProducer.java b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/HealthDataProducer.java similarity index 85% rename from newrelic-agent/src/main/java/com/newrelic/agent/superagent/HealthDataProducer.java rename to newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/HealthDataProducer.java index a2329cbfa7..4731bfc9dc 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/superagent/HealthDataProducer.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/agentcontrol/HealthDataProducer.java @@ -4,7 +4,7 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; public interface HealthDataProducer { void registerHealthDataChangeListener(HealthDataChangeListener listener); diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/circuitbreaker/CircuitBreakerService.java b/newrelic-agent/src/main/java/com/newrelic/agent/circuitbreaker/CircuitBreakerService.java index f208265da4..aae18f440a 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/circuitbreaker/CircuitBreakerService.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/circuitbreaker/CircuitBreakerService.java @@ -17,10 +17,10 @@ import com.newrelic.agent.service.AbstractService; import com.newrelic.agent.service.ServiceFactory; import com.newrelic.agent.stats.StatsEngine; -import com.newrelic.agent.superagent.AgentHealth; -import com.newrelic.agent.superagent.HealthDataChangeListener; -import com.newrelic.agent.superagent.HealthDataProducer; -import com.newrelic.agent.superagent.SuperAgentIntegrationUtils; +import com.newrelic.agent.agentcontrol.AgentHealth; +import com.newrelic.agent.agentcontrol.HealthDataChangeListener; +import com.newrelic.agent.agentcontrol.HealthDataProducer; +import com.newrelic.agent.agentcontrol.AgentControlIntegrationUtils; import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; @@ -187,7 +187,7 @@ private boolean shouldTrip() { Agent.LOG.log(Level.WARNING, "Circuit breaker tripped at memory {0}% GC CPU time {1}%", percentageFreeMemory, gcCpuTimePercentage); - SuperAgentIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, AgentHealth.Status.GC_CIRCUIT_BREAKER, + AgentControlIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, AgentHealth.Status.GC_CIRCUIT_BREAKER, String.valueOf(percentageFreeMemory), String.valueOf(gcCpuTimePercentage)); return true; @@ -232,7 +232,7 @@ private void trip() { public void reset() { tripped = 0; Agent.LOG.log(Level.FINE, "Circuit breaker reset"); - SuperAgentIntegrationUtils.reportHealthyStatus(healthDataChangeListeners, AgentHealth.Category.CIRCUIT_BREAKER); + AgentControlIntegrationUtils.reportHealthyStatus(healthDataChangeListeners, AgentHealth.Category.CIRCUIT_BREAKER); logWarning.set(true); } diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfig.java b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfig.java index 5aa0eb55ce..d43267ce20 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfig.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfig.java @@ -355,6 +355,6 @@ public interface AgentConfig extends com.newrelic.api.agent.Config, DataSenderCo SlowTransactionsConfig getSlowTransactionsConfig(); - SuperAgentIntegrationConfig getSuperAgentIntegrationConfig(); + AgentControlIntegrationConfig getAgentControlIntegrationConfig(); } diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfigImpl.java b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfigImpl.java index e99795ed01..395f5a4983 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfigImpl.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentConfigImpl.java @@ -271,7 +271,7 @@ public class AgentConfigImpl extends BaseConfig implements AgentConfig { private final SpanEventsConfig spanEventsConfig; private final SqlTraceConfig sqlTraceConfig; private final StripExceptionConfig stripExceptionConfig; - private final SuperAgentIntegrationConfig superAgentIntegrationConfig; + private final AgentControlIntegrationConfig agentControlIntegrationConfig; private final ThreadProfilerConfig threadProfilerConfig; private final TransactionEventsConfig transactionEventsConfig; private final TransactionTracerConfigImpl transactionTracerConfig; @@ -375,7 +375,7 @@ private AgentConfigImpl(Map<String, Object> props) { normalizationRuleConfig = new NormalizationRuleConfig(props); slowTransactionsConfig = initSlowTransactionsConfig(); obfuscateJvmPropsConfig = initObfuscateJvmPropsConfig(); - superAgentIntegrationConfig = initSuperAgentHealthCheckConfig(); + agentControlIntegrationConfig = initAgentControlHealthCheckConfig(); Map<String, Object> flattenedProps = new HashMap<>(); flatten("", props, flattenedProps); @@ -842,8 +842,8 @@ private SlowTransactionsConfig initSlowTransactionsConfig() { return new SlowTransactionsConfigImpl(props); } - private SuperAgentIntegrationConfig initSuperAgentHealthCheckConfig() { - return new SuperAgentIntegrationConfigImpl(nestedProps(SuperAgentIntegrationConfigImpl.ROOT)); + private AgentControlIntegrationConfig initAgentControlHealthCheckConfig() { + return new AgentControlIntegrationConfigImpl(nestedProps(AgentControlIntegrationConfigImpl.ROOT)); } @Override @@ -1068,8 +1068,8 @@ public SlowTransactionsConfig getSlowTransactionsConfig() { } @Override - public SuperAgentIntegrationConfig getSuperAgentIntegrationConfig() { - return superAgentIntegrationConfig; + public AgentControlIntegrationConfig getAgentControlIntegrationConfig() { + return agentControlIntegrationConfig; } private Object findPropertyInMap(String[] property, Map<String, Object> map) { diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationConfig.java b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentControlIntegrationConfig.java similarity index 57% rename from newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationConfig.java rename to newrelic-agent/src/main/java/com/newrelic/agent/config/AgentControlIntegrationConfig.java index dd2a2d8025..13febb591d 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationConfig.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentControlIntegrationConfig.java @@ -8,30 +8,30 @@ import java.net.URI; -public interface SuperAgentIntegrationConfig { +public interface AgentControlIntegrationConfig { /** - * Check if the Super Agent integration service is enabled + * Check if the Agent Control integration service is enabled * - * @return <code>true</code> if the Super Agent Health Check service is enabled, else <code>false</code>. + * @return <code>true</code> if the Agent Control Health Check service is enabled, else <code>false</code>. */ boolean isEnabled(); /** - * Get the domain socket listener address + * Get the health reporting location information * - * @return the domain socket address for the health check + * @return the location info for the health check */ URI getHealthDeliveryLocation(); /** - * Return the frequency of the health messages sent to the Super Agent, in seconds + * Return the frequency of the health messages reported to Agent Control, in seconds * * @return the health check frequency, in seconds */ int getHealthReportingFrequency(); /** - * Return the fleet id assigned by the super agent + * Return the fleet id assigned by Agent Control * * @return the fleet id, if available */ diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentControlIntegrationConfigImpl.java b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentControlIntegrationConfigImpl.java new file mode 100644 index 0000000000..6e0eff73f1 --- /dev/null +++ b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentControlIntegrationConfigImpl.java @@ -0,0 +1,72 @@ +/* + * + * * Copyright 2024 New Relic Corporation. All rights reserved. + * * SPDX-License-Identifier: Apache-2.0 + * + */ +package com.newrelic.agent.config; + +import com.newrelic.agent.Agent; +import org.apache.commons.lang3.StringUtils; + +import java.net.URI; +import java.util.Collections; +import java.util.Map; +import java.util.logging.Level; + +public class AgentControlIntegrationConfigImpl extends BaseConfig implements AgentControlIntegrationConfig { + public static final String ROOT = "agent_control"; + public static final String SYSTEM_PROPERTY_ROOT = "newrelic.config.agent_control."; + public static final String FLEET_ID = "fleet_id"; + + private final String fleetId; + + private final AgentControlIntegrationHealthConfig agentControlIntegrationHealthConfig; + + public AgentControlIntegrationConfigImpl(Map<String, Object> configProps) { + super(configProps, SYSTEM_PROPERTY_ROOT); + agentControlIntegrationHealthConfig = createHealthConfig(); + String tmpFleetId = getProperty(FLEET_ID); + + if (StringUtils.isNotEmpty(tmpFleetId) && agentControlIntegrationHealthConfig.getHealthDeliveryLocation() == null) { + Agent.LOG.log(Level.WARNING, "Configured Super Agent health delivery location is not a valid URI; " + + "Agent Control integration service will not be started"); + fleetId = null; + } else { + fleetId = tmpFleetId; + } + } + + private AgentControlIntegrationHealthConfig createHealthConfig() { + Map<String, Object> healthProps = getProperty(AgentControlIntegrationHealthConfig.ROOT, Collections.emptyMap()); + AgentControlIntegrationHealthConfig agentControlIntegrationHealthConfig; + + agentControlIntegrationHealthConfig = new AgentControlIntegrationHealthConfig(healthProps, SYSTEM_PROPERTY_ROOT); + return agentControlIntegrationHealthConfig; + } + + @Override + public boolean isEnabled() { + return fleetId != null; + } + + @Override + public URI getHealthDeliveryLocation() { + return agentControlIntegrationHealthConfig == null ? null : agentControlIntegrationHealthConfig.getHealthDeliveryLocation(); + } + + @Override + public int getHealthReportingFrequency() { + return agentControlIntegrationHealthConfig == null ? 0 : agentControlIntegrationHealthConfig.getHealthReportingFrequency(); + } + + @Override + public String getFleetId() { + return fleetId; + } + + @Override + public String getHealthClientType() { + return agentControlIntegrationHealthConfig == null ? null : agentControlIntegrationHealthConfig.getHealthClientType(); + } +} diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationHealthConfig.java b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentControlIntegrationHealthConfig.java similarity index 91% rename from newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationHealthConfig.java rename to newrelic-agent/src/main/java/com/newrelic/agent/config/AgentControlIntegrationHealthConfig.java index 1ac2276cd4..e504a827aa 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationHealthConfig.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentControlIntegrationHealthConfig.java @@ -11,7 +11,7 @@ import java.net.URI; import java.util.Map; -public class SuperAgentIntegrationHealthConfig extends BaseConfig { +public class AgentControlIntegrationHealthConfig extends BaseConfig { public static final String ROOT = "health"; public static final String FREQUENCY = "frequency"; public static final int FREQUENCY_DEFAULT = 5; // In seconds @@ -21,7 +21,7 @@ public class SuperAgentIntegrationHealthConfig extends BaseConfig { private URI deliveryLocation; private String healthClientType; - public SuperAgentIntegrationHealthConfig(Map<String, Object> props, String systemPropertyPrefix) { + public AgentControlIntegrationHealthConfig(Map<String, Object> props, String systemPropertyPrefix) { super(props, systemPropertyPrefix + ROOT + "."); frequency = getProperty(FREQUENCY, FREQUENCY_DEFAULT); diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/config/ConfigServiceFactory.java b/newrelic-agent/src/main/java/com/newrelic/agent/config/ConfigServiceFactory.java index d41f4ee359..bd19bcdc07 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/config/ConfigServiceFactory.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/config/ConfigServiceFactory.java @@ -9,8 +9,8 @@ import com.google.common.annotations.VisibleForTesting; import com.newrelic.agent.ForceDisconnectException; -import com.newrelic.agent.superagent.AgentHealth; -import com.newrelic.agent.superagent.SuperAgentIntegrationUtils; +import com.newrelic.agent.agentcontrol.AgentHealth; +import com.newrelic.agent.agentcontrol.AgentControlIntegrationUtils; import com.newrelic.api.agent.Logger; import java.io.File; @@ -82,15 +82,15 @@ private static File getConfigFile(Logger log) { @VisibleForTesting public static void validateConfig(AgentConfig config, ConfigurationException fileParseException) throws ConfigurationException, ForceDisconnectException { if (fileParseException != null) { - SuperAgentIntegrationUtils.reportUnhealthyStatusPriorToServiceStart(config, AgentHealth.Status.CONFIG_FILE_PARSE_ERROR); + AgentControlIntegrationUtils.reportUnhealthyStatusPriorToServiceStart(config, AgentHealth.Status.CONFIG_FILE_PARSE_ERROR); throw fileParseException; } if (config.getApplicationName() == null) { - SuperAgentIntegrationUtils.reportUnhealthyStatusPriorToServiceStart(config, AgentHealth.Status.MISSING_APP_NAME); + AgentControlIntegrationUtils.reportUnhealthyStatusPriorToServiceStart(config, AgentHealth.Status.MISSING_APP_NAME); throw new ConfigurationException("The agent requires an application name. Check the app_name setting in newrelic.yml"); } if (config.getApplicationNames().size() > 3) { - SuperAgentIntegrationUtils.reportUnhealthyStatusPriorToServiceStart(config, AgentHealth.Status.MAX_APP_NAMES_EXCEEDED); + AgentControlIntegrationUtils.reportUnhealthyStatusPriorToServiceStart(config, AgentHealth.Status.MAX_APP_NAMES_EXCEEDED); throw new ConfigurationException("The agent does not support more than three application names. Check the app_name setting in newrelic.yml"); } if (config.isHighSecurity() && config.laspEnabled()) { diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationConfigImpl.java b/newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationConfigImpl.java deleted file mode 100644 index 274d871158..0000000000 --- a/newrelic-agent/src/main/java/com/newrelic/agent/config/SuperAgentIntegrationConfigImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * Copyright 2024 New Relic Corporation. All rights reserved. - * * SPDX-License-Identifier: Apache-2.0 - * - */ -package com.newrelic.agent.config; - -import com.newrelic.agent.Agent; -import org.apache.commons.lang3.StringUtils; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collections; -import java.util.Map; -import java.util.logging.Level; - -public class SuperAgentIntegrationConfigImpl extends BaseConfig implements SuperAgentIntegrationConfig { - public static final String ROOT = "superagent"; - public static final String SYSTEM_PROPERTY_ROOT = "newrelic.config.superagent."; - public static final String FLEET_ID = "fleet_id"; - - private final String fleetId; - - private final SuperAgentIntegrationHealthConfig superAgentIntegrationHealthConfig; - - public SuperAgentIntegrationConfigImpl(Map<String, Object> configProps) { - super(configProps, SYSTEM_PROPERTY_ROOT); - superAgentIntegrationHealthConfig = createHealthConfig(); - String tmpFleetId = getProperty(FLEET_ID); - - if (StringUtils.isNotEmpty(tmpFleetId) && superAgentIntegrationHealthConfig.getHealthDeliveryLocation() == null) { - Agent.LOG.log(Level.WARNING, "Configured Super Agent health delivery location is not a valid URI; " + - "SuperAgent integration service will not be started"); - fleetId = null; - } else { - fleetId = tmpFleetId; - } - } - - private SuperAgentIntegrationHealthConfig createHealthConfig() { - Map<String, Object> healthProps = getProperty(SuperAgentIntegrationHealthConfig.ROOT, Collections.emptyMap()); - SuperAgentIntegrationHealthConfig superAgentIntegrationHealthConfig; - - superAgentIntegrationHealthConfig = new SuperAgentIntegrationHealthConfig(healthProps, SYSTEM_PROPERTY_ROOT); - return superAgentIntegrationHealthConfig; - } - - @Override - public boolean isEnabled() { - return fleetId != null; - } - - @Override - public URI getHealthDeliveryLocation() { - return superAgentIntegrationHealthConfig == null ? null : superAgentIntegrationHealthConfig.getHealthDeliveryLocation(); - } - - @Override - public int getHealthReportingFrequency() { - return superAgentIntegrationHealthConfig == null ? 0 : superAgentIntegrationHealthConfig.getHealthReportingFrequency(); - } - - @Override - public String getFleetId() { - return fleetId; - } - - @Override - public String getHealthClientType() { - return superAgentIntegrationHealthConfig == null ? null : superAgentIntegrationHealthConfig.getHealthClientType(); - } -} diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/core/CoreServiceImpl.java b/newrelic-agent/src/main/java/com/newrelic/agent/core/CoreServiceImpl.java index ba858227f3..d75bb1a92f 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/core/CoreServiceImpl.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/core/CoreServiceImpl.java @@ -20,10 +20,8 @@ import com.newrelic.agent.service.AbstractService; import com.newrelic.agent.service.ServiceFactory; import com.newrelic.agent.stats.StatsService; -import com.newrelic.agent.superagent.AgentHealth; -import com.newrelic.agent.superagent.HealthDataChangeListener; -import com.newrelic.agent.superagent.HealthDataProducer; -import com.newrelic.agent.superagent.SuperAgentIntegrationUtils; +import com.newrelic.agent.agentcontrol.HealthDataChangeListener; +import com.newrelic.agent.agentcontrol.HealthDataProducer; import com.newrelic.api.agent.NewRelicApiImplementation; import java.lang.instrument.Instrumentation; diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/service/ServiceManagerImpl.java b/newrelic-agent/src/main/java/com/newrelic/agent/service/ServiceManagerImpl.java index 392ff6a546..fec0b26833 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/service/ServiceManagerImpl.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/service/ServiceManagerImpl.java @@ -79,10 +79,10 @@ import com.newrelic.agent.stats.StatsService; import com.newrelic.agent.stats.StatsServiceImpl; import com.newrelic.agent.stats.StatsWork; -import com.newrelic.agent.superagent.HealthDataProducer; -import com.newrelic.agent.superagent.SuperAgentIntegrationClientFactory; -import com.newrelic.agent.superagent.SuperAgentIntegrationHealthClient; -import com.newrelic.agent.superagent.SuperAgentIntegrationService; +import com.newrelic.agent.agentcontrol.HealthDataProducer; +import com.newrelic.agent.agentcontrol.AgentControlIntegrationClientFactory; +import com.newrelic.agent.agentcontrol.AgentControlIntegrationHealthClient; +import com.newrelic.agent.agentcontrol.AgentControlIntegrationService; import com.newrelic.agent.trace.TransactionTraceService; import com.newrelic.agent.tracing.DistributedTraceService; import com.newrelic.agent.tracing.DistributedTraceServiceImpl; @@ -156,7 +156,7 @@ public class ServiceManagerImpl extends AbstractService implements ServiceManage private volatile SourceLanguageService sourceLanguageService; private volatile ExpirationService expirationService; private volatile SlowTransactionService slowTransactionService; - private volatile SuperAgentIntegrationService superAgentIntegrationService; + private volatile AgentControlIntegrationService agentControlIntegrationService; public ServiceManagerImpl(CoreService coreService, ConfigService configService) { super(ServiceManagerImpl.class.getSimpleName()); @@ -289,7 +289,7 @@ protected synchronized void doStart() throws Exception { slowTransactionService = new SlowTransactionService(config); - superAgentIntegrationService = buildSuperAgentIntegrationService(config); + agentControlIntegrationService = buildAgentControlIntegrationService(config); asyncTxService.start(); threadService.start(); @@ -324,7 +324,7 @@ protected synchronized void doStart() throws Exception { distributedTraceService.start(); spanEventsService.start(); slowTransactionService.start(); - superAgentIntegrationService.start(); + agentControlIntegrationService.start(); startServices(); @@ -355,12 +355,12 @@ private InfiniteTracing buildInfiniteTracing(ConfigService configService) { return InfiniteTracing.initialize(infiniteTracingConfig, NewRelic.getAgent().getMetricAggregator()); } - private SuperAgentIntegrationService buildSuperAgentIntegrationService(AgentConfig config) { + private AgentControlIntegrationService buildAgentControlIntegrationService(AgentConfig config) { ArrayList<HealthDataProducer> healthDataProducers = new ArrayList<>(); - SuperAgentIntegrationHealthClient healthClient = null; + AgentControlIntegrationHealthClient healthClient = null; - if (config.getSuperAgentIntegrationConfig() != null && StringUtils.isNotEmpty(config.getSuperAgentIntegrationConfig().getFleetId())) { - healthClient = SuperAgentIntegrationClientFactory.createHealthClient(config.getSuperAgentIntegrationConfig()); + if (config.getAgentControlIntegrationConfig() != null && StringUtils.isNotEmpty(config.getAgentControlIntegrationConfig().getFleetId())) { + healthClient = AgentControlIntegrationClientFactory.createHealthClient(config.getAgentControlIntegrationConfig()); healthDataProducers.add(circuitBreakerService); healthDataProducers.add((HealthDataProducer) coreService); @@ -369,7 +369,7 @@ private SuperAgentIntegrationService buildSuperAgentIntegrationService(AgentConf } } - return new SuperAgentIntegrationService(healthClient, config, + return new AgentControlIntegrationService(healthClient, config, healthDataProducers.toArray(new HealthDataProducer[]{})); } @@ -414,7 +414,7 @@ protected synchronized void doStop() throws Exception { distributedTraceService.stop(); spanEventsService.stop(); slowTransactionService.stop(); - superAgentIntegrationService.stop(); + agentControlIntegrationService.stop(); stopServices(); } diff --git a/newrelic-agent/src/main/java/com/newrelic/agent/transport/DataSenderImpl.java b/newrelic-agent/src/main/java/com/newrelic/agent/transport/DataSenderImpl.java index 76a55ac87e..0efc78e084 100644 --- a/newrelic-agent/src/main/java/com/newrelic/agent/transport/DataSenderImpl.java +++ b/newrelic-agent/src/main/java/com/newrelic/agent/transport/DataSenderImpl.java @@ -31,10 +31,10 @@ import com.newrelic.agent.sql.SqlTrace; import com.newrelic.agent.stats.StatsService; import com.newrelic.agent.stats.StatsWorks; -import com.newrelic.agent.superagent.AgentHealth; -import com.newrelic.agent.superagent.HealthDataChangeListener; -import com.newrelic.agent.superagent.HealthDataProducer; -import com.newrelic.agent.superagent.SuperAgentIntegrationUtils; +import com.newrelic.agent.agentcontrol.AgentHealth; +import com.newrelic.agent.agentcontrol.HealthDataChangeListener; +import com.newrelic.agent.agentcontrol.HealthDataProducer; +import com.newrelic.agent.agentcontrol.AgentControlIntegrationUtils; import com.newrelic.agent.trace.TransactionTrace; import org.json.simple.JSONObject; import org.json.simple.JSONStreamAware; @@ -130,7 +130,7 @@ public class DataSenderImpl implements DataSender, HealthDataProducer { private volatile Map<String, String> requestMetadata; private volatile Map<String, String> metadata; private final List<HealthDataChangeListener> healthDataChangeListeners = new CopyOnWriteArrayList<>(); - private final boolean isSuperAgentEnabled; + private final boolean isAgentControlEnabled; public DataSenderImpl( DataSenderConfig config, @@ -163,7 +163,7 @@ public DataSenderImpl( } this.httpClientWrapper = httpClientWrapper; - this.isSuperAgentEnabled = configService.getDefaultAgentConfig().getSuperAgentIntegrationConfig().isEnabled(); + this.isAgentControlEnabled = configService.getDefaultAgentConfig().getAgentControlIntegrationConfig().isEnabled(); } private void checkAuditMode() { @@ -625,7 +625,7 @@ private ReadResult connectAndSend(String host, String method, String encoding, S recordDataUsageMetrics(method, payloadJsonSent, payloadJsonReceived); - SuperAgentIntegrationUtils.reportHealthyStatus(healthDataChangeListeners, AgentHealth.Category.HARVEST, AgentHealth.Category.CONFIG); + AgentControlIntegrationUtils.reportHealthyStatus(healthDataChangeListeners, AgentHealth.Category.HARVEST, AgentHealth.Category.CONFIG); if (dataSenderListener != null) { dataSenderListener.dataSent(method, encoding, uri, data); @@ -672,7 +672,7 @@ private void throwExceptionFromStatusCode(String method, ReadResult result, byte switch (result.getStatusCode()) { case HttpResponseCode.PROXY_AUTHENTICATION_REQUIRED: // agent receives a 407 response due to a misconfigured proxy (not from NR backend), throw exception - SuperAgentIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, AgentHealth.Status.PROXY_ERROR, + AgentControlIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, AgentHealth.Status.PROXY_ERROR, Integer.toString(result.getStatusCode()), method); final String authField = result.getProxyAuthenticateHeader(); if (authField != null) { @@ -682,30 +682,24 @@ private void throwExceptionFromStatusCode(String method, ReadResult result, byte } case HttpResponseCode.UNAUTHORIZED: // received 401 Unauthorized, throw exception instead of parsing LicenseException from 200 response body - SuperAgentIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, AgentHealth.Status.INVALID_LICENSE); + AgentControlIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, AgentHealth.Status.INVALID_LICENSE); throw new LicenseException(parseExceptionMessage(result.getResponseBody())); case HttpResponseCode.CONFLICT: // received 409 Conflict, throw exception instead of parsing ForceRestartException from 200 response body throw new ForceRestartException(parseExceptionMessage(result.getResponseBody())); case HttpResponseCode.GONE: // received 410 Gone, throw exception instead of parsing ForceDisconnectException from 200 response body - SuperAgentIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, AgentHealth.Status.FORCED_DISCONNECT); + AgentControlIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, AgentHealth.Status.FORCED_DISCONNECT); throw new ForceDisconnectException(parseExceptionMessage(result.getResponseBody())); default: // response is bad (neither 200 nor 202), throw generic HttpError exception - SuperAgentIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, AgentHealth.Status.HTTP_ERROR, + AgentControlIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, AgentHealth.Status.HTTP_ERROR, Integer.toString(result.getStatusCode()), method); logger.log(Level.FINER, "Connection http status code: {0}", result.getStatusCode()); throw HttpError.create(result.getStatusCode(), request.getURL().getHost(), data.length); } } - private void reportUnhealthyStatusToSuperAgent(AgentHealth.Status status, String ... additionalInfo) { - if (isSuperAgentEnabled) { - SuperAgentIntegrationUtils.reportUnhealthyStatus(healthDataChangeListeners, status, additionalInfo); - } - } - private String parseExceptionMessage(String responseBody) { try { JSONParser parser = new JSONParser(); diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/AgentTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/AgentTest.java index 6c332735b0..7535ec599c 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/AgentTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/AgentTest.java @@ -9,7 +9,7 @@ import com.newrelic.agent.config.AgentConfig; import com.newrelic.agent.config.ConfigService; import com.newrelic.agent.config.ConfigServiceFactory; -import com.newrelic.agent.config.SuperAgentIntegrationConfig; +import com.newrelic.agent.config.AgentControlIntegrationConfig; import com.newrelic.agent.logging.AgentLogManager; import com.newrelic.agent.logging.IAgentLogger; import com.newrelic.agent.service.ServiceFactory; @@ -56,7 +56,7 @@ public void test_JRockitMessage() throws NoSuchFieldException, IllegalAccessExce public void test_emptyLicense() { try (MockedStatic<ConfigServiceFactory> csfMock = Mockito.mockStatic(ConfigServiceFactory.class)) { AgentConfig agentConfig = Mockito.mock(AgentConfig.class); - Mockito.when(agentConfig.getSuperAgentIntegrationConfig()).thenReturn(Mockito.mock(SuperAgentIntegrationConfig.class)); + Mockito.when(agentConfig.getAgentControlIntegrationConfig()).thenReturn(Mockito.mock(AgentControlIntegrationConfig.class)); Mockito.when(agentConfig.getLicenseKey()).thenReturn(null); ConfigService configService = Mockito.mock(ConfigService.class); Mockito.when(configService.getDefaultAgentConfig()).thenReturn(agentConfig); @@ -72,7 +72,7 @@ public void test_emptyLicense() { public void test_agentDisabled2() { try (MockedStatic<ConfigServiceFactory> csfMock = Mockito.mockStatic(ConfigServiceFactory.class)) { AgentConfig agentConfig = Mockito.mock(AgentConfig.class); - Mockito.when(agentConfig.getSuperAgentIntegrationConfig()).thenReturn(Mockito.mock(SuperAgentIntegrationConfig.class)); + Mockito.when(agentConfig.getAgentControlIntegrationConfig()).thenReturn(Mockito.mock(AgentControlIntegrationConfig.class)); Mockito.when(agentConfig.getLicenseKey()).thenReturn("licenseKey"); Mockito.when(agentConfig.isAgentEnabled()).thenReturn(false); ConfigService configService = Mockito.mock(ConfigService.class); diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/HarvestServiceTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/HarvestServiceTest.java index f340bf141d..0bc2a4da1e 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/HarvestServiceTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/HarvestServiceTest.java @@ -22,7 +22,7 @@ import com.newrelic.agent.stats.StatsService; import com.newrelic.agent.stats.StatsServiceImpl; import com.newrelic.agent.stats.StatsWork; -import com.newrelic.agent.superagent.HealthDataProducer; +import com.newrelic.agent.agentcontrol.HealthDataProducer; import com.newrelic.api.agent.Logger; import org.junit.After; import org.junit.Assert; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/MockCoreService.java b/newrelic-agent/src/test/java/com/newrelic/agent/MockCoreService.java index e6136c100a..901a9ce3ca 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/MockCoreService.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/MockCoreService.java @@ -14,8 +14,8 @@ import com.newrelic.agent.service.ServiceFactory; import com.newrelic.agent.service.ServiceManager; import com.newrelic.agent.service.ServiceManagerImpl; -import com.newrelic.agent.superagent.HealthDataChangeListener; -import com.newrelic.agent.superagent.HealthDataProducer; +import com.newrelic.agent.agentcontrol.HealthDataChangeListener; +import com.newrelic.agent.agentcontrol.HealthDataProducer; import com.newrelic.api.agent.Logger; import org.mockito.Mockito; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/MockRPMService.java b/newrelic-agent/src/test/java/com/newrelic/agent/MockRPMService.java index 5894f04050..6c4d5e5d4c 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/MockRPMService.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/MockRPMService.java @@ -19,7 +19,7 @@ import com.newrelic.agent.service.analytics.TransactionEvent; import com.newrelic.agent.sql.SqlTrace; import com.newrelic.agent.stats.StatsEngine; -import com.newrelic.agent.superagent.HealthDataProducer; +import com.newrelic.agent.agentcontrol.HealthDataProducer; import com.newrelic.agent.trace.TransactionTrace; import java.util.ArrayList; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentHealthUnitTestClient.java b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlHealthUnitTestClient.java similarity index 76% rename from newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentHealthUnitTestClient.java rename to newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlHealthUnitTestClient.java index 46492b34c1..47dfe8a85b 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentHealthUnitTestClient.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlHealthUnitTestClient.java @@ -4,9 +4,9 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; -public class SuperAgentHealthUnitTestClient implements SuperAgentIntegrationHealthClient { +public class AgentControlHealthUnitTestClient implements AgentControlIntegrationHealthClient { private AgentHealth agentHealth; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationClientFactoryTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationClientFactoryTest.java similarity index 54% rename from newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationClientFactoryTest.java rename to newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationClientFactoryTest.java index 2c280d2243..c68782f902 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationClientFactoryTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationClientFactoryTest.java @@ -4,9 +4,9 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; -import com.newrelic.agent.config.SuperAgentIntegrationConfig; +import com.newrelic.agent.config.AgentControlIntegrationConfig; import org.junit.Before; import org.junit.Test; @@ -17,19 +17,19 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class SuperAgentIntegrationClientFactoryTest { +public class AgentControlIntegrationClientFactoryTest { private final String URI_TEST_STRING = "file://" + System.getProperty("user.dir") + "/health.yml"; - private SuperAgentIntegrationConfig mockConfig; + private AgentControlIntegrationConfig mockConfig; @Before public void setup() { - mockConfig = mock(SuperAgentIntegrationConfig.class); + mockConfig = mock(AgentControlIntegrationConfig.class); } @Test public void createHealthClient_withInvalidType_returnsNoOpClient() { - SuperAgentIntegrationHealthClient client = SuperAgentIntegrationClientFactory.createHealthClient(mockConfig); - assertTrue(client instanceof SuperAgentHealthNoOpClient); + AgentControlIntegrationHealthClient client = AgentControlIntegrationClientFactory.createHealthClient(mockConfig); + assertTrue(client instanceof AgentControlHealthNoOpClientControl); } @Test @@ -37,14 +37,14 @@ public void createHealthClient_withFileType_returnsFileBasedClient() throws URIS URI uri = new URI(URI_TEST_STRING); when(mockConfig.getHealthDeliveryLocation()).thenReturn(uri); when(mockConfig.getHealthClientType()).thenReturn("file"); - SuperAgentIntegrationHealthClient client = SuperAgentIntegrationClientFactory.createHealthClient(mockConfig); - assertTrue(client instanceof SuperAgentIntegrationHealthFileBasedClient); + AgentControlIntegrationHealthClient client = AgentControlIntegrationClientFactory.createHealthClient(mockConfig); + assertTrue(client instanceof AgentControlControlIntegrationHealthFileBasedClient); } @Test public void createHealthClient_withNoOpType_returnsNoOpClient() { when(mockConfig.getHealthClientType()).thenReturn("noop"); - SuperAgentIntegrationHealthClient client = SuperAgentIntegrationClientFactory.createHealthClient(mockConfig); - assertTrue(client instanceof SuperAgentHealthNoOpClient); + AgentControlIntegrationHealthClient client = AgentControlIntegrationClientFactory.createHealthClient(mockConfig); + assertTrue(client instanceof AgentControlHealthNoOpClientControl); } } diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationHealthFileBasedClientTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationHealthFileBasedClientTest.java similarity index 80% rename from newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationHealthFileBasedClientTest.java rename to newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationHealthFileBasedClientTest.java index ba6bd6c13f..b39ef98af6 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationHealthFileBasedClientTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationHealthFileBasedClientTest.java @@ -4,9 +4,9 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; -import com.newrelic.agent.config.SuperAgentIntegrationConfig; +import com.newrelic.agent.config.AgentControlIntegrationConfig; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -28,7 +28,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class SuperAgentIntegrationHealthFileBasedClientTest { +public class AgentControlIntegrationHealthFileBasedClientTest { private static URI HEALTH_FILE_LOCATION = null; static { @@ -39,11 +39,11 @@ public class SuperAgentIntegrationHealthFileBasedClientTest { } } - private SuperAgentIntegrationConfig mockConfig; + private AgentControlIntegrationConfig mockConfig; @Before public void setup() { - mockConfig = mock(SuperAgentIntegrationConfig.class); + mockConfig = mock(AgentControlIntegrationConfig.class); } @After @@ -59,9 +59,9 @@ public void cleanup() { @Test public void sendHealthMessage_withValidConfig_createsHealthFile() throws IOException { when(mockConfig.getHealthDeliveryLocation()).thenReturn(HEALTH_FILE_LOCATION); - SuperAgentIntegrationHealthFileBasedClient client = new SuperAgentIntegrationHealthFileBasedClient(mockConfig); + AgentControlControlIntegrationHealthFileBasedClient client = new AgentControlControlIntegrationHealthFileBasedClient(mockConfig); - long startTime = SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos(); + long startTime = AgentControlIntegrationUtils.getPseudoCurrentTimeNanos(); AgentHealth agentHealth = new AgentHealth(startTime); client.sendHealthMessage(agentHealth); @@ -81,9 +81,9 @@ public void sendHealthMessage_withValidConfig_createsHealthFile() throws IOExcep @Test public void sendHealthMessage_withUnhealthyAgentInstance_createsHealthFileWithLastError() throws IOException { when(mockConfig.getHealthDeliveryLocation()).thenReturn(HEALTH_FILE_LOCATION); - SuperAgentIntegrationHealthFileBasedClient client = new SuperAgentIntegrationHealthFileBasedClient(mockConfig); + AgentControlControlIntegrationHealthFileBasedClient client = new AgentControlControlIntegrationHealthFileBasedClient(mockConfig); - long startTime = SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos(); + long startTime = AgentControlIntegrationUtils.getPseudoCurrentTimeNanos(); AgentHealth agentHealth = new AgentHealth(startTime); agentHealth.setUnhealthyStatus(AgentHealth.Status.INVALID_LICENSE); @@ -104,7 +104,7 @@ public void sendHealthMessage_withUnhealthyAgentInstance_createsHealthFileWithLa @Test public void constructor_withInvalidLocation_setsValidToFalse() throws URISyntaxException { when(mockConfig.getHealthDeliveryLocation()).thenReturn(new URI("file:///foo/bar/zzzzzzzz")); - SuperAgentIntegrationHealthFileBasedClient client = new SuperAgentIntegrationHealthFileBasedClient(mockConfig); + AgentControlControlIntegrationHealthFileBasedClient client = new AgentControlControlIntegrationHealthFileBasedClient(mockConfig); assertFalse(client.isValid()); } diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationServiceTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationServiceTest.java similarity index 58% rename from newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationServiceTest.java rename to newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationServiceTest.java index 071e1ad919..21ec7915c0 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationServiceTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationServiceTest.java @@ -4,12 +4,12 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; import com.newrelic.agent.MockServiceManager; import com.newrelic.agent.RPMServiceManager; import com.newrelic.agent.config.AgentConfig; -import com.newrelic.agent.config.SuperAgentIntegrationConfig; +import com.newrelic.agent.config.AgentControlIntegrationConfig; import com.newrelic.agent.service.ServiceFactory; import org.junit.Before; import org.junit.Test; @@ -21,16 +21,16 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class SuperAgentIntegrationServiceTest { +public class AgentControlIntegrationServiceTest { AgentConfig mockAgentConfig; - SuperAgentIntegrationConfig mockSuperAgentIntegrationConfig; + AgentControlIntegrationConfig mockAgentControlIntegrationConfig; RPMServiceManager mockRPMServiceManager; AgentHealth mockAgentHealth; @Before public void before() { mockAgentConfig = mock(AgentConfig.class); - mockSuperAgentIntegrationConfig = mock(SuperAgentIntegrationConfig.class); + mockAgentControlIntegrationConfig = mock(AgentControlIntegrationConfig.class); mockAgentHealth = mock(AgentHealth.class); mockRPMServiceManager = mock(RPMServiceManager.class); @@ -38,16 +38,16 @@ public void before() { manager.setRPMServiceManager(mockRPMServiceManager); ServiceFactory.setServiceManager(manager); - when(mockAgentConfig.getSuperAgentIntegrationConfig()).thenReturn(mockSuperAgentIntegrationConfig); - when(mockAgentConfig.getSuperAgentIntegrationConfig()).thenReturn(mockSuperAgentIntegrationConfig); + when(mockAgentConfig.getAgentControlIntegrationConfig()).thenReturn(mockAgentControlIntegrationConfig); + when(mockAgentConfig.getAgentControlIntegrationConfig()).thenReturn(mockAgentControlIntegrationConfig); } @Test public void constructor_createsAgentHealth_withHealthyStatus() throws Exception { - when(mockSuperAgentIntegrationConfig.getHealthReportingFrequency()).thenReturn(1); - when(mockSuperAgentIntegrationConfig.isEnabled()).thenReturn(true); - SuperAgentHealthUnitTestClient healthClient = new SuperAgentHealthUnitTestClient(); - SuperAgentIntegrationService service = new SuperAgentIntegrationService(healthClient, mockAgentConfig); + when(mockAgentControlIntegrationConfig.getHealthReportingFrequency()).thenReturn(1); + when(mockAgentControlIntegrationConfig.isEnabled()).thenReturn(true); + AgentControlHealthUnitTestClient healthClient = new AgentControlHealthUnitTestClient(); + AgentControlIntegrationService service = new AgentControlIntegrationService(healthClient, mockAgentConfig); service.doStart(); Thread.sleep(2100); @@ -58,10 +58,10 @@ public void constructor_createsAgentHealth_withHealthyStatus() throws Exception @Test public void onUnhealthyStatus_updatesAgentHealthToUnhealthy() throws Exception { - when(mockSuperAgentIntegrationConfig.getHealthReportingFrequency()).thenReturn(1); - when(mockSuperAgentIntegrationConfig.isEnabled()).thenReturn(true); - SuperAgentHealthUnitTestClient healthClient = new SuperAgentHealthUnitTestClient(); - SuperAgentIntegrationService service = new SuperAgentIntegrationService(healthClient, mockAgentConfig); + when(mockAgentControlIntegrationConfig.getHealthReportingFrequency()).thenReturn(1); + when(mockAgentControlIntegrationConfig.isEnabled()).thenReturn(true); + AgentControlHealthUnitTestClient healthClient = new AgentControlHealthUnitTestClient(); + AgentControlIntegrationService service = new AgentControlIntegrationService(healthClient, mockAgentConfig); service.onUnhealthyStatus(AgentHealth.Status.GC_CIRCUIT_BREAKER, "1", "2"); service.doStart(); Thread.sleep(2100); @@ -74,10 +74,10 @@ public void onUnhealthyStatus_updatesAgentHealthToUnhealthy() throws Exception { @Test public void onHealthyStatus_updatesAgentHealthToHealthy() throws Exception { - when(mockSuperAgentIntegrationConfig.getHealthReportingFrequency()).thenReturn(1); - when(mockSuperAgentIntegrationConfig.isEnabled()).thenReturn(true); - SuperAgentHealthUnitTestClient healthClient = new SuperAgentHealthUnitTestClient(); - SuperAgentIntegrationService service = new SuperAgentIntegrationService(healthClient, mockAgentConfig); + when(mockAgentControlIntegrationConfig.getHealthReportingFrequency()).thenReturn(1); + when(mockAgentControlIntegrationConfig.isEnabled()).thenReturn(true); + AgentControlHealthUnitTestClient healthClient = new AgentControlHealthUnitTestClient(); + AgentControlIntegrationService service = new AgentControlIntegrationService(healthClient, mockAgentConfig); service.onUnhealthyStatus(AgentHealth.Status.GC_CIRCUIT_BREAKER, "1", "2"); service.doStart(); Thread.sleep(2100); @@ -96,10 +96,10 @@ public void onHealthyStatus_updatesAgentHealthToHealthy() throws Exception { @Test public void doStop_writesShutdownHealthStatus() throws Exception { - when(mockSuperAgentIntegrationConfig.getHealthReportingFrequency()).thenReturn(1); - when(mockSuperAgentIntegrationConfig.isEnabled()).thenReturn(true); - SuperAgentHealthUnitTestClient healthClient = new SuperAgentHealthUnitTestClient(); - SuperAgentIntegrationService service = new SuperAgentIntegrationService(healthClient, mockAgentConfig); + when(mockAgentControlIntegrationConfig.getHealthReportingFrequency()).thenReturn(1); + when(mockAgentControlIntegrationConfig.isEnabled()).thenReturn(true); + AgentControlHealthUnitTestClient healthClient = new AgentControlHealthUnitTestClient(); + AgentControlIntegrationService service = new AgentControlIntegrationService(healthClient, mockAgentConfig); service.doStart(); service.doStop(); @@ -111,9 +111,9 @@ public void doStop_writesShutdownHealthStatus() throws Exception { @Test public void doStart_ignoresStartCommand_whenEnabledIsFalse() throws Exception { - when(mockSuperAgentIntegrationConfig.isEnabled()).thenReturn(false); - SuperAgentHealthUnitTestClient healthClient = new SuperAgentHealthUnitTestClient(); - SuperAgentIntegrationService service = new SuperAgentIntegrationService(healthClient, mockAgentConfig); + when(mockAgentControlIntegrationConfig.isEnabled()).thenReturn(false); + AgentControlHealthUnitTestClient healthClient = new AgentControlHealthUnitTestClient(); + AgentControlIntegrationService service = new AgentControlIntegrationService(healthClient, mockAgentConfig); service.doStart(); Thread.sleep(2100); diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationUtilsTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationUtilsTest.java similarity index 69% rename from newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationUtilsTest.java rename to newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationUtilsTest.java index cfca2fa74e..c97b965ad4 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/SuperAgentIntegrationUtilsTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentControlIntegrationUtilsTest.java @@ -4,11 +4,9 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; import com.newrelic.agent.MockServiceManager; -import com.newrelic.agent.config.AgentConfig; -import com.newrelic.agent.config.SuperAgentIntegrationConfig; import com.newrelic.agent.service.ServiceFactory; import org.junit.Before; import org.junit.Test; @@ -19,7 +17,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -public class SuperAgentIntegrationUtilsTest { +public class AgentControlIntegrationUtilsTest { private HealthDataChangeListener mockListener; @Before @@ -33,19 +31,19 @@ public void before() { @Test public void getPseudoCurrentTimeNanos_returnsTimeInNanos() { long testTime = System.currentTimeMillis(); - long time = SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos(); + long time = AgentControlIntegrationUtils.getPseudoCurrentTimeNanos(); assertTrue(time >= testTime * 1000000); } @Test public void reportUnhealthyStatus_updatesHealthListeners() { - SuperAgentIntegrationUtils.reportUnhealthyStatus(Collections.singletonList(mockListener), AgentHealth.Status.GC_CIRCUIT_BREAKER); + AgentControlIntegrationUtils.reportUnhealthyStatus(Collections.singletonList(mockListener), AgentHealth.Status.GC_CIRCUIT_BREAKER); verify(mockListener).onUnhealthyStatus(AgentHealth.Status.GC_CIRCUIT_BREAKER); } @Test public void reportHealthyStatus_updatesHealthListeners() { - SuperAgentIntegrationUtils.reportHealthyStatus(Collections.singletonList(mockListener), AgentHealth.Category.HARVEST); + AgentControlIntegrationUtils.reportHealthyStatus(Collections.singletonList(mockListener), AgentHealth.Category.HARVEST); verify(mockListener).onHealthyStatus(AgentHealth.Category.HARVEST); } } diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/AgentHealthTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentHealthTest.java similarity index 75% rename from newrelic-agent/src/test/java/com/newrelic/agent/superagent/AgentHealthTest.java rename to newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentHealthTest.java index 144166ece6..5bcbcbe8d6 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/AgentHealthTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/AgentHealthTest.java @@ -4,7 +4,7 @@ * * SPDX-License-Identifier: Apache-2.0 * */ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; import org.junit.Test; @@ -16,20 +16,20 @@ public class AgentHealthTest { @Test public void isHealthy_returnsTrue_whenStatusIsHealthy() { // Newly constructed AgentHealth object should be healthy - AgentHealth agentHealth = new AgentHealth(SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos()); + AgentHealth agentHealth = new AgentHealth(AgentControlIntegrationUtils.getPseudoCurrentTimeNanos()); assertTrue(agentHealth.isHealthy()); } @Test public void isHealthy_returnsFalse_whenStatusIsNotHealthy() { - AgentHealth agentHealth = new AgentHealth(SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos()); + AgentHealth agentHealth = new AgentHealth(AgentControlIntegrationUtils.getPseudoCurrentTimeNanos()); agentHealth.setUnhealthyStatus(AgentHealth.Status.INVALID_LICENSE); assertFalse(agentHealth.isHealthy()); } @Test public void classGetters_returnCorrectValues() { - long startTime = SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos(); + long startTime = AgentControlIntegrationUtils.getPseudoCurrentTimeNanos(); AgentHealth agentHealth = new AgentHealth(startTime); agentHealth.setUnhealthyStatus(AgentHealth.Status.INVALID_LICENSE); @@ -40,7 +40,7 @@ public void classGetters_returnCorrectValues() { @Test public void setHealthyStatus_setsStatusToHealthy_whenLastStatusCategoryMatches() { - AgentHealth agentHealth = new AgentHealth(SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos()); + AgentHealth agentHealth = new AgentHealth(AgentControlIntegrationUtils.getPseudoCurrentTimeNanos()); agentHealth.setUnhealthyStatus(AgentHealth.Status.INVALID_LICENSE); agentHealth.setHealthyStatus(AgentHealth.Category.CONFIG); assertTrue(agentHealth.isHealthy()); @@ -48,7 +48,7 @@ public void setHealthyStatus_setsStatusToHealthy_whenLastStatusCategoryMatches() @Test public void setHealthyStatus_ignoresSetStatusToHealthy_whenLastStatusCategoryDoesNotMatch() { - AgentHealth agentHealth = new AgentHealth(SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos()); + AgentHealth agentHealth = new AgentHealth(AgentControlIntegrationUtils.getPseudoCurrentTimeNanos()); agentHealth.setUnhealthyStatus(AgentHealth.Status.INVALID_LICENSE); agentHealth.setHealthyStatus(AgentHealth.Category.HARVEST); assertFalse(agentHealth.isHealthy()); @@ -56,7 +56,7 @@ public void setHealthyStatus_ignoresSetStatusToHealthy_whenLastStatusCategoryDoe @Test public void getDescription_returnsCorrectDescription_whenAdditionalInfoIsProvided() { - AgentHealth agentHealth = new AgentHealth(SuperAgentIntegrationUtils.getPseudoCurrentTimeNanos()); + AgentHealth agentHealth = new AgentHealth(AgentControlIntegrationUtils.getPseudoCurrentTimeNanos()); agentHealth.setUnhealthyStatus(AgentHealth.Status.HTTP_ERROR, "404", "whatever"); assertEquals("HTTP error response code [404] received from New Relic while sending data type [whatever]", agentHealth.getCurrentStatus()); } diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/UnitTestHealthDataChangeListener.java b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/UnitTestHealthDataChangeListener.java similarity index 91% rename from newrelic-agent/src/test/java/com/newrelic/agent/superagent/UnitTestHealthDataChangeListener.java rename to newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/UnitTestHealthDataChangeListener.java index 16b10c6534..97ade9dca5 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/superagent/UnitTestHealthDataChangeListener.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/agentcontrol/UnitTestHealthDataChangeListener.java @@ -1,4 +1,4 @@ -package com.newrelic.agent.superagent; +package com.newrelic.agent.agentcontrol; public class UnitTestHealthDataChangeListener implements HealthDataChangeListener { private AgentHealth.Status lastStatus = null; diff --git a/newrelic-agent/src/test/java/com/newrelic/agent/config/SuperAgentIntegrationConfigTest.java b/newrelic-agent/src/test/java/com/newrelic/agent/config/AgentControlIntegrationConfigTest.java similarity index 54% rename from newrelic-agent/src/test/java/com/newrelic/agent/config/SuperAgentIntegrationConfigTest.java rename to newrelic-agent/src/test/java/com/newrelic/agent/config/AgentControlIntegrationConfigTest.java index 1ed32e45c5..4f1a57dc5e 100644 --- a/newrelic-agent/src/test/java/com/newrelic/agent/config/SuperAgentIntegrationConfigTest.java +++ b/newrelic-agent/src/test/java/com/newrelic/agent/config/AgentControlIntegrationConfigTest.java @@ -14,18 +14,18 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -public class SuperAgentIntegrationConfigTest { +public class AgentControlIntegrationConfigTest { @Test - public void superAgentConfig_withValidProperties_createsValidConfig() { - Map<String, Object> superAgentConfigProps = new HashMap<>(); + public void agentControlConfig_withValidProperties_createsValidConfig() { + Map<String, Object> agentControlConfigProps = new HashMap<>(); Map<String, Object> healthConfigProps = new HashMap<>(); - superAgentConfigProps.put("fleet_id", "12345"); + agentControlConfigProps.put("fleet_id", "12345"); healthConfigProps.put("delivery_location", "file:///foo/bar"); healthConfigProps.put("frequency", 5); - superAgentConfigProps.put("health", healthConfigProps); + agentControlConfigProps.put("health", healthConfigProps); - SuperAgentIntegrationConfig config = new SuperAgentIntegrationConfigImpl(superAgentConfigProps); + AgentControlIntegrationConfig config = new AgentControlIntegrationConfigImpl(agentControlConfigProps); assertEquals("12345", config.getFleetId()); assertEquals(5, config.getHealthReportingFrequency()); assertEquals("file", config.getHealthClientType()); @@ -33,15 +33,15 @@ public void superAgentConfig_withValidProperties_createsValidConfig() { } @Test - public void superAgentConfig_withInvalidLocation_nullsFleetId() { - Map<String, Object> superAgentConfigProps = new HashMap<>(); + public void agentControlConfig_withInvalidLocation_nullsFleetId() { + Map<String, Object> agentControlConfigProps = new HashMap<>(); Map<String, Object> healthConfigProps = new HashMap<>(); - superAgentConfigProps.put("fleet_id", "12345"); + agentControlConfigProps.put("fleet_id", "12345"); healthConfigProps.put("delivery_location", ""); - superAgentConfigProps.put("health", healthConfigProps); + agentControlConfigProps.put("health", healthConfigProps); - SuperAgentIntegrationConfig config = new SuperAgentIntegrationConfigImpl(superAgentConfigProps); + AgentControlIntegrationConfig config = new AgentControlIntegrationConfigImpl(agentControlConfigProps); assertNull(config.getFleetId()); } }