Search in sources :

Example 1 with Statistic

use of javax.management.j2ee.statistics.Statistic in project Payara by payara.

the class GenericStatsImpl method getStatisticsOneByOne.

private Statistic[] getStatisticsOneByOne() {
    final Iterator iter = getters.keySet().iterator();
    final Statistic[] stats = new Statistic[getters.keySet().size()];
    int i = 0;
    while (iter.hasNext()) {
        final String sn = (String) iter.next();
        stats[i++] = this.getStatistic(sn);
    }
    assert (stats.length == i);
    return (stats);
}
Also used : Statistic(javax.management.j2ee.statistics.Statistic) Iterator(java.util.Iterator)

Example 2 with Statistic

use of javax.management.j2ee.statistics.Statistic in project activemq by apache.

the class StatsImpl method reset.

public void reset() {
    Statistic[] stats = getStatistics();
    int size = stats.length;
    for (int i = 0; i < size; i++) {
        Statistic stat = stats[i];
        if (stat instanceof Resettable) {
            Resettable r = (Resettable) stat;
            r.reset();
        }
    }
}
Also used : Statistic(javax.management.j2ee.statistics.Statistic)

Example 3 with Statistic

use of javax.management.j2ee.statistics.Statistic in project Payara by payara.

the class StatsImpl method statToString.

public String statToString() {
    StringBuilder sbuf = new StringBuilder();
    Statistic[] stats = getStatistics();
    int sz = stats.length;
    for (int i = 0; i < sz; i++) {
        if (stats[i] instanceof CountStatistic) {
            CountStatistic stat = (CountStatistic) stats[i];
            sbuf.append(stat.getName()).append("=").append(stat.getCount()).append("; ");
        } else if (stats[i] instanceof BoundedRangeStatistic) {
            BoundedRangeStatistic stat = (BoundedRangeStatistic) stats[i];
            sbuf.append(stat.getName()).append("=").append(stat.getCurrent()).append("; ");
        } else {
            sbuf.append(stats[i].getName()).append("=?");
        }
    }
    return sbuf.toString();
}
Also used : CountStatistic(javax.management.j2ee.statistics.CountStatistic) BoundedRangeStatistic(javax.management.j2ee.statistics.BoundedRangeStatistic) Statistic(javax.management.j2ee.statistics.Statistic) CountStatistic(javax.management.j2ee.statistics.CountStatistic) BoundedRangeStatistic(javax.management.j2ee.statistics.BoundedRangeStatistic)

Example 4 with Statistic

use of javax.management.j2ee.statistics.Statistic in project newrelic-java-agent by newrelic.

the class J2EEStatsAttributeTest method addJmxValueJdbcTest.

@Test
public void addJmxValueJdbcTest() throws MalformedObjectNameException {
    JDBCStats count = new JDBCStats() {

        @Override
        public Statistic[] getStatistics() {
            return new Statistic[0];
        }

        @Override
        public String[] getStatisticNames() {
            return null;
        }

        @Override
        public Statistic getStatistic(String statisticName) {
            return null;
        }

        @Override
        public JDBCConnectionStats[] getConnections() {
            return new JDBCConnectionStats[0];
        }

        @Override
        public JDBCConnectionPoolStats[] getConnectionPools() {
            return new JDBCConnectionPoolStats[] { new TestJdbcConnectionPool() };
        }
    };
    Attribute att = new Attribute("stats", count);
    J2EEStatsAttributeProcessor processor = new J2EEStatsAttributeProcessor();
    StatsEngine engine = new StatsEngineImpl();
    processor.process(engine, new ObjectInstance("tezt:type=1", "test"), att, "JMX/Test", new HashMap<String, Float>());
    // check count stats
    Assert.assertEquals(77, engine.getStats("JMX/Test/Create").getTotal(), .001);
    Assert.assertEquals(1, engine.getStats("JMX/Test/Create").getCallCount(), .001);
    Assert.assertEquals(9, engine.getStats("JMX/Test/Close").getTotal(), .001);
    Assert.assertEquals(1, engine.getStats("JMX/Test/Close").getCallCount(), .001);
    // check time stats
    Assert.assertEquals(12, engine.getResponseTimeStats("JMX/Test/WaitTime").getMaxCallTime(), .001);
    Assert.assertEquals(8, engine.getResponseTimeStats("JMX/Test/WaitTime").getMinCallTime(), .001);
    Assert.assertEquals(2, engine.getResponseTimeStats("JMX/Test/WaitTime").getCallCount(), .001);
    Assert.assertEquals(6, engine.getResponseTimeStats("JMX/Test/UserTime").getMaxCallTime(), .001);
    Assert.assertEquals(4, engine.getResponseTimeStats("JMX/Test/UserTime").getMinCallTime(), .001);
    Assert.assertEquals(2, engine.getResponseTimeStats("JMX/Test/UserTime").getCallCount(), .001);
}
Also used : StatsEngineImpl(com.newrelic.agent.stats.StatsEngineImpl) Attribute(javax.management.Attribute) JDBCConnectionStats(javax.management.j2ee.statistics.JDBCConnectionStats) ObjectInstance(javax.management.ObjectInstance) JDBCStats(javax.management.j2ee.statistics.JDBCStats) StatsEngine(com.newrelic.agent.stats.StatsEngine) CountStatistic(javax.management.j2ee.statistics.CountStatistic) RangeStatistic(javax.management.j2ee.statistics.RangeStatistic) TimeStatistic(javax.management.j2ee.statistics.TimeStatistic) BoundedRangeStatistic(javax.management.j2ee.statistics.BoundedRangeStatistic) BoundaryStatistic(javax.management.j2ee.statistics.BoundaryStatistic) Statistic(javax.management.j2ee.statistics.Statistic) JDBCConnectionPoolStats(javax.management.j2ee.statistics.JDBCConnectionPoolStats) Test(org.junit.Test)

Example 5 with Statistic

use of javax.management.j2ee.statistics.Statistic in project newrelic-java-agent by newrelic.

the class J2EEStatsAttributeTest method addJcaValueJdbcTest.

@Test
public void addJcaValueJdbcTest() throws MalformedObjectNameException {
    JCAStats count = new JCAStats() {

        @Override
        public JCAConnectionStats[] getConnections() {
            return new JCAConnectionStats[0];
        }

        @Override
        public JCAConnectionPoolStats[] getConnectionPools() {
            return new JCAConnectionPoolStats[] { new TestJcaConnectionPool() };
        }

        @Override
        public Statistic getStatistic(String statisticName) {
            return null;
        }

        @Override
        public String[] getStatisticNames() {
            return null;
        }

        @Override
        public Statistic[] getStatistics() {
            return new Statistic[0];
        }
    };
    Attribute att = new Attribute("stats", count);
    J2EEStatsAttributeProcessor processor = new J2EEStatsAttributeProcessor();
    StatsEngine engine = new StatsEngineImpl();
    processor.process(engine, new ObjectInstance("tezt:type=2", "test"), att, "JMX/Test", new HashMap<String, Float>());
    // check count stats
    Assert.assertEquals(6, engine.getStats("JMX/Test/Create").getTotal(), .001);
    Assert.assertEquals(1, engine.getStats("JMX/Test/Create").getCallCount(), .001);
    Assert.assertEquals(99, engine.getStats("JMX/Test/Closed").getTotal(), .001);
    Assert.assertEquals(1, engine.getStats("JMX/Test/Closed").getCallCount(), .001);
    // check time stats
    Assert.assertEquals(10, engine.getResponseTimeStats("JMX/Test/Wait").getMaxCallTime(), .001);
    Assert.assertEquals(5, engine.getResponseTimeStats("JMX/Test/Wait").getMinCallTime(), .001);
    Assert.assertEquals(2, engine.getResponseTimeStats("JMX/Test/Wait").getCallCount(), .001);
    Assert.assertEquals(6, engine.getResponseTimeStats("JMX/Test/User").getMaxCallTime(), .001);
    Assert.assertEquals(4, engine.getResponseTimeStats("JMX/Test/User").getMinCallTime(), .001);
    Assert.assertEquals(2, engine.getResponseTimeStats("JMX/Test/User").getCallCount(), .001);
}
Also used : StatsEngineImpl(com.newrelic.agent.stats.StatsEngineImpl) Attribute(javax.management.Attribute) ObjectInstance(javax.management.ObjectInstance) JCAConnectionStats(javax.management.j2ee.statistics.JCAConnectionStats) StatsEngine(com.newrelic.agent.stats.StatsEngine) CountStatistic(javax.management.j2ee.statistics.CountStatistic) RangeStatistic(javax.management.j2ee.statistics.RangeStatistic) TimeStatistic(javax.management.j2ee.statistics.TimeStatistic) BoundedRangeStatistic(javax.management.j2ee.statistics.BoundedRangeStatistic) BoundaryStatistic(javax.management.j2ee.statistics.BoundaryStatistic) Statistic(javax.management.j2ee.statistics.Statistic) JCAStats(javax.management.j2ee.statistics.JCAStats) JCAConnectionPoolStats(javax.management.j2ee.statistics.JCAConnectionPoolStats) Test(org.junit.Test)

Aggregations

Statistic (javax.management.j2ee.statistics.Statistic)5 BoundedRangeStatistic (javax.management.j2ee.statistics.BoundedRangeStatistic)3 CountStatistic (javax.management.j2ee.statistics.CountStatistic)3 StatsEngine (com.newrelic.agent.stats.StatsEngine)2 StatsEngineImpl (com.newrelic.agent.stats.StatsEngineImpl)2 Attribute (javax.management.Attribute)2 ObjectInstance (javax.management.ObjectInstance)2 BoundaryStatistic (javax.management.j2ee.statistics.BoundaryStatistic)2 RangeStatistic (javax.management.j2ee.statistics.RangeStatistic)2 TimeStatistic (javax.management.j2ee.statistics.TimeStatistic)2 Test (org.junit.Test)2 Iterator (java.util.Iterator)1 JCAConnectionPoolStats (javax.management.j2ee.statistics.JCAConnectionPoolStats)1 JCAConnectionStats (javax.management.j2ee.statistics.JCAConnectionStats)1 JCAStats (javax.management.j2ee.statistics.JCAStats)1 JDBCConnectionPoolStats (javax.management.j2ee.statistics.JDBCConnectionPoolStats)1 JDBCConnectionStats (javax.management.j2ee.statistics.JDBCConnectionStats)1 JDBCStats (javax.management.j2ee.statistics.JDBCStats)1