Search in sources :

Example 11 with MetricCounters

use of com.sun.messaging.jmq.util.MetricCounters in project openmq by eclipse-ee4j.

the class MetricManager method depositTotals.

/**
 * Used by connections that are going away to deposit their totals, so they won't be lost.
 */
public synchronized void depositTotals(String service, MetricCounters counters) {
    MetricCounters mc = (MetricCounters) deadTotalsByService.get(service);
    if (mc == null) {
        mc = new MetricCounters();
        deadTotalsByService.put(service, mc);
    }
    mc.update(counters);
}
Also used : MetricCounters(com.sun.messaging.jmq.util.MetricCounters)

Example 12 with MetricCounters

use of com.sun.messaging.jmq.util.MetricCounters in project openmq by eclipse-ee4j.

the class MetricManager method getMetricCounters.

/**
 * Get the metric counters for the specified service. If serviceName is null then do it for all services
 */
public synchronized MetricCounters getMetricCounters(String serviceName) {
    ConnectionManager cm = Globals.getConnectionManager();
    MetricCounters totals = new MetricCounters();
    // Add counters for connections that no longer exist
    if (serviceName == null) {
        // Sum values for all services
        Enumeration e;
        for (e = deadTotalsByService.elements(); e.hasMoreElements(); ) {
            totals.update((MetricCounters) e.nextElement());
        }
    } else {
        // Sum values for just the specified service
        MetricCounters deadTotals = (MetricCounters) deadTotalsByService.get(serviceName);
        if (deadTotals != null) {
            totals.update((MetricCounters) deadTotalsByService.get(serviceName));
        }
    }
    // Sum totals for all active connections for this service
    // We synchronize since connections may be comming and going
    int n = 0;
    synchronized (cm) {
        Collection connections = cm.values();
        Iterator itr = connections.iterator();
        while (itr.hasNext()) {
            Connection con = (Connection) itr.next();
            Service svc = con.getService();
            // See if connection belongs to the service
            if (serviceName == null || serviceName.equals(svc.getName())) {
                if (con instanceof IMQConnection) {
                    totals.update(((IMQConnection) con).getMetricCounters());
                } else {
                // XXX handle other counters
                }
                n++;
            }
        }
    }
    // Get thread information
    ServiceManager sm = Globals.getServiceManager();
    Service svc = null;
    Iterator iter = null;
    if (serviceName == null) {
        Set s = sm.getAllActiveServices();
        if (s != null) {
            iter = s.iterator();
        }
    } else {
        Vector v = new Vector(1);
        v.add(serviceName);
        iter = v.iterator();
    }
    while (iter != null && iter.hasNext()) {
        svc = sm.getService((String) iter.next());
        if (svc instanceof IMQService) {
            totals.threadsActive += ((IMQService) svc).getActiveThreadpool();
            totals.threadsHighWater += ((IMQService) svc).getMaxThreadpool();
            totals.threadsLowWater += ((IMQService) svc).getMinThreadpool();
        }
    }
    Runtime rt = Runtime.getRuntime();
    totals.totalMemory = rt.totalMemory();
    totals.freeMemory = rt.freeMemory();
    totals.nConnections = n;
    totals.timeStamp = System.currentTimeMillis();
    return totals;
}
Also used : MetricCounters(com.sun.messaging.jmq.util.MetricCounters) IMQConnection(com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection) IMQService(com.sun.messaging.jmq.jmsserver.service.imq.IMQService) IMQService(com.sun.messaging.jmq.jmsserver.service.imq.IMQService) IMQConnection(com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection)

Example 13 with MetricCounters

use of com.sun.messaging.jmq.util.MetricCounters in project openmq by eclipse-ee4j.

the class MetricManager method getMetrics.

/**
 * Gather performance data for all connections in a broker, compute dervied numbers, and return in one convenience class
 */
public synchronized MetricData getMetrics() {
    MetricData md = new MetricData();
    Runtime rt = Runtime.getRuntime();
    long currentTime = System.currentTimeMillis();
    // long elapsedSecs = (currentTime - lastSampleTime) / 1000;
    float elapsedSecs = (currentTime - lastSampleTime) / (float) 1000;
    MetricCounters totals = getMetricCounters(null);
    // Copy values into MetricData
    md.timestamp = currentTime;
    md.totalMemory = rt.totalMemory();
    md.freeMemory = rt.freeMemory();
    md.nConnections = totals.nConnections;
    // Totals are straight copies
    md.setTotals(totals);
    // Rates must be computed
    md.rates.messagesIn = (long) ((totals.messagesIn - lastSample.messagesIn) / elapsedSecs);
    md.rates.messageBytesIn = (long) ((totals.messageBytesIn - lastSample.messageBytesIn) / elapsedSecs);
    md.rates.packetsIn = (long) ((totals.packetsIn - lastSample.packetsIn) / elapsedSecs);
    md.rates.packetBytesIn = (long) ((totals.packetBytesIn - lastSample.packetBytesIn) / elapsedSecs);
    md.rates.messagesOut = (long) ((totals.messagesOut - lastSample.messagesOut) / elapsedSecs);
    md.rates.messageBytesOut = (long) ((totals.messageBytesOut - lastSample.messageBytesOut) / elapsedSecs);
    md.rates.packetsOut = (long) ((totals.packetsOut - lastSample.packetsOut) / elapsedSecs);
    md.rates.packetBytesOut = (long) ((totals.packetBytesOut - lastSample.packetBytesOut) / elapsedSecs);
    lastSampleTime = currentTime;
    lastSample = totals;
    return md;
}
Also used : MetricCounters(com.sun.messaging.jmq.util.MetricCounters) MetricData(com.sun.messaging.jmq.util.MetricData)

Example 14 with MetricCounters

use of com.sun.messaging.jmq.util.MetricCounters in project openmq by eclipse-ee4j.

the class ServiceManagerMonitor method getMetricsForAllServices.

private MetricCounters getMetricsForAllServices() {
    MetricManager mm = Globals.getMetricManager();
    MetricCounters mc = null;
    mc = mm.getMetricCounters(null);
    return (mc);
}
Also used : MetricManager(com.sun.messaging.jmq.jmsserver.service.MetricManager) MetricCounters(com.sun.messaging.jmq.util.MetricCounters)

Example 15 with MetricCounters

use of com.sun.messaging.jmq.util.MetricCounters in project openmq by eclipse-ee4j.

the class ServiceMonitor method getPktBytesOut.

public Long getPktBytesOut() {
    ServiceInfo si = ServiceUtil.getServiceInfo(service);
    MetricCounters metrics = si.metrics;
    if (metrics != null) {
        return (Long.valueOf(metrics.packetBytesOut));
    } else {
        return (Long.valueOf(-1));
    }
}
Also used : ServiceInfo(com.sun.messaging.jmq.util.admin.ServiceInfo) MetricCounters(com.sun.messaging.jmq.util.MetricCounters)

Aggregations

MetricCounters (com.sun.messaging.jmq.util.MetricCounters)18 ServiceInfo (com.sun.messaging.jmq.util.admin.ServiceInfo)9 MetricManager (com.sun.messaging.jmq.jmsserver.service.MetricManager)4 BrokerAdmin (com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin)1 BrokerAdminException (com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException)1 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)1 ServiceManager (com.sun.messaging.jmq.jmsserver.service.ServiceManager)1 IMQConnection (com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection)1 IMQService (com.sun.messaging.jmq.jmsserver.service.imq.IMQService)1 DestMetricsCounters (com.sun.messaging.jmq.util.DestMetricsCounters)1 MetricData (com.sun.messaging.jmq.util.MetricData)1 SizeString (com.sun.messaging.jmq.util.SizeString)1 Hashtable (java.util.Hashtable)1