use of com.newrelic.agent.jmx.create.JmxGet in project newrelic-java-agent by newrelic.
the class JmxServiceStartTest method testStartConfig.
@Test
public void testStartConfig() {
JmxService jmxService = ServiceFactory.getJmxService();
List<JmxGet> configurations = jmxService.getConfigurations();
JavaLangJmxMetrics metrics = new JavaLangJmxMetrics();
int extCountInJmxYml = 3;
Assert.assertEquals(configurations.toString(), configurations.size(), metrics.getFrameworkMetrics().size() + extCountInJmxYml);
// verify two of the java lang object names are present
boolean isObjectNameIndex0 = false;
boolean isObjectNameIndex1 = false;
for (JmxGet current : configurations) {
if (metrics.getFrameworkMetrics().get(0).getObjectNameString().equals(current.getObjectNameString())) {
isObjectNameIndex0 = true;
} else if (metrics.getFrameworkMetrics().get(1).getObjectNameString().equals(current.getObjectNameString())) {
isObjectNameIndex1 = true;
}
}
Assert.assertTrue("Some of the java lang metrics are missing from the start up.", isObjectNameIndex0);
Assert.assertTrue("Some of the java lang metrics are missing from the start up.", isObjectNameIndex1);
}
use of com.newrelic.agent.jmx.create.JmxGet in project newrelic-java-agent by newrelic.
the class JmxServiceTest method testAddingToConfig.
@Test
public void testAddingToConfig() {
JmxService jmxService = ServiceFactory.getJmxService();
List<JmxGet> configurations = jmxService.getConfigurations();
int startupsize = configurations.size();
TomcatJmxValues tomcat = new TomcatJmxValues();
ResinJmxValues resin = new ResinJmxValues();
jmxService.addJmxFrameworkValues(tomcat);
jmxService.addJmxFrameworkValues(resin);
String appName = ServiceFactory.getConfigService().getDefaultAgentConfig().getApplicationName();
StatsEngine statsEngine = new StatsEngineImpl();
jmxService.beforeHarvest(appName, statsEngine);
int expectedSize = startupsize + tomcat.getFrameworkMetrics().size() + resin.getFrameworkMetrics().size();
Assert.assertEquals("Failed on initial check: " + configurations.toString(), expectedSize, configurations.size());
GlassfishJmxValues glassfish = new GlassfishJmxValues();
jmxService.addJmxFrameworkValues(glassfish);
jmxService.beforeHarvest(appName, statsEngine);
int newExpectedSize = expectedSize + glassfish.getFrameworkMetrics().size();
Assert.assertEquals("Failed on second check: " + configurations.toString(), newExpectedSize, configurations.size());
JettyJmxMetrics jetty = new JettyJmxMetrics();
jmxService.addJmxFrameworkValues(jetty);
jmxService.beforeHarvest(appName, statsEngine);
int thirdExpectedSize = newExpectedSize + jetty.getFrameworkMetrics().size();
Assert.assertEquals("Failed on third check: " + configurations.toString(), thirdExpectedSize, configurations.size());
}
use of com.newrelic.agent.jmx.create.JmxGet in project newrelic-java-agent by newrelic.
the class JmxServiceTest method testEachExtensionAddedOnlyOnce.
@Test
public void testEachExtensionAddedOnlyOnce() {
JmxService jmxService = ServiceFactory.getJmxService();
List<JmxGet> configs = jmxService.getConfigurations();
Assert.assertTrue(configs.size() > 0);
// this checks to see if we have already seen the object name
// really we should check attributes too, but this should be good enough
// I just want to make sure the same extension is not loaded more than once
Set<String> alreadySeen = new HashSet<>();
for (JmxGet current : configs) {
Assert.assertTrue("It looks like an extension file was loaded more than once.", !alreadySeen.contains(current.getObjectNameString()));
alreadySeen.add(current.getObjectNameString());
}
}
use of com.newrelic.agent.jmx.create.JmxGet in project newrelic-java-agent by newrelic.
the class JmxService method process.
private void process(StatsEngine statsEngine) {
Collection<MBeanServer> srvrList = getServers();
addNewFrameworks();
runThroughAndRemoveInvokes(srvrList);
for (JmxGet object : jmxGets) {
process(statsEngine, srvrList, object);
}
}
Aggregations