Search in sources :

Example 1 with MetricManager

use of com.sun.messaging.jmq.jmsserver.service.MetricManager in project openmq by eclipse-ee4j.

the class IMQDirectConnection method destroyConnection.

/**
 * destroy the connection to the client clearing out messages, etc
 */
@Override
public void destroyConnection(boolean force, int reason, String reasonstr) {
    int oldstate = 0;
    boolean destroyOK = false;
    try {
        synchronized (this) {
            oldstate = state;
            if (state >= Connection.STATE_DESTROYING) {
                return;
            }
            if (state < Connection.STATE_CLOSED) {
                closeConnection(force, reason, reasonstr);
            }
            setConnectionState(Connection.STATE_DESTROYING);
        }
        Globals.getConnectionManager().removeConnection(getConnectionUID(), force, reason, reasonstr);
        if (accessController.isAuthenticated()) {
            authenticator.logout();
        }
        // The connection is going away. Deposit our metric totals
        // with the metric manager
        MetricManager mm = Globals.getMetricManager();
        if (mm != null) {
            mm.depositTotals(service.getName(), counters);
        }
        // Clear, just in case we are called twice
        counters.reset();
        /*
             * synchronized (timerLock) {
             *
             * if (stateWatcher != null) { try { stateWatcher.cancel(); } catch (IllegalStateException ex) {
             * logger.log(Logger.DEBUG,"Error destroying "+ " connection " + this + " to state " + state, ex); } stateWatcher =
             * null; } }
             */
        logConnectionInfo(true, reasonstr);
        setConnectionState(Connection.STATE_DESTROYED);
        destroyOK = true;
        wakeup();
    } finally {
        if (!destroyOK && reason != GoodbyeReason.SHUTDOWN_BKR && (Globals.getMemManager() == null || Globals.getMemManager().getCurrentLevel() > 0)) {
            state = oldstate;
            if (destroyRecurse < 2) {
                destroyRecurse++;
                destroyConnection(force, reason, reasonstr);
            }
        }
        // free the lock
        Globals.getClusterBroadcast().connectionClosed(getConnectionUID(), isAdminConnection());
    }
}
Also used : MetricManager(com.sun.messaging.jmq.jmsserver.service.MetricManager)

Example 2 with MetricManager

use of com.sun.messaging.jmq.jmsserver.service.MetricManager in project openmq by eclipse-ee4j.

the class JVMMonitor method getMonitorData.

@Override
protected Hashtable getMonitorData() {
    Hashtable mapMessage = new Hashtable();
    MetricManager mm = Globals.getMetricManager();
    MetricData md = mm.getMetrics();
    mapMessage.put("freeMemory", Long.valueOf(md.freeMemory));
    mapMessage.put("maxMemory", Long.valueOf(Runtime.getRuntime().maxMemory()));
    mapMessage.put("totalMemory", Long.valueOf(md.totalMemory));
    return mapMessage;
}
Also used : MetricManager(com.sun.messaging.jmq.jmsserver.service.MetricManager) MetricData(com.sun.messaging.jmq.util.MetricData)

Example 3 with MetricManager

use of com.sun.messaging.jmq.jmsserver.service.MetricManager in project openmq by eclipse-ee4j.

the class ServiceManagerConfig method getMinThreads.

public Integer getMinThreads() {
    MetricManager mm = Globals.getMetricManager();
    MetricCounters mc = mm.getMetricCounters(null);
    return (Integer.valueOf(mc.threadsLowWater));
}
Also used : MetricManager(com.sun.messaging.jmq.jmsserver.service.MetricManager) MetricCounters(com.sun.messaging.jmq.util.MetricCounters)

Example 4 with MetricManager

use of com.sun.messaging.jmq.jmsserver.service.MetricManager in project openmq by eclipse-ee4j.

the class ServiceManagerConfig method getMaxThreads.

public Integer getMaxThreads() {
    MetricManager mm = Globals.getMetricManager();
    MetricCounters mc = mm.getMetricCounters(null);
    return (Integer.valueOf(mc.threadsHighWater));
}
Also used : MetricManager(com.sun.messaging.jmq.jmsserver.service.MetricManager) MetricCounters(com.sun.messaging.jmq.util.MetricCounters)

Example 5 with MetricManager

use of com.sun.messaging.jmq.jmsserver.service.MetricManager in project openmq by eclipse-ee4j.

the class GetMetricsHandler method handle.

/**
 * Handle the incomming administration message.
 *
 * @param con The Connection the message came in on.
 * @param cmd_msg The administration message
 * @param cmd_props The properties from the administration message
 */
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
    if (DEBUG) {
        logger.log(Logger.DEBUG, this.getClass().getName() + ": " + cmd_props);
    }
    int status = Status.OK;
    String errMsg = null;
    String service = (String) cmd_props.get(MessageType.JMQ_SERVICE_NAME);
    String destination = (String) cmd_props.get(MessageType.JMQ_DESTINATION);
    Integer type = (Integer) cmd_props.get(MessageType.JMQ_DEST_TYPE);
    Object replyobj = null;
    String msgtype = null;
    if (destination != null) {
        try {
            Destination[] ds = DL.getDestination(null, destination, DestType.isQueue((type == null ? 0 : type.intValue())));
            // PART
            Destination d = ds[0];
            if (d == null) {
                status = Status.NOT_FOUND;
                int mytype = (type == null ? 0 : type.intValue());
                errMsg = rb.getString(rb.E_NO_SUCH_DESTINATION, getDestinationType(mytype), destination);
            } else {
                replyobj = d.getMetrics();
            }
        } catch (Exception ex) {
            int mytype = (type == null ? 0 : type.intValue());
            errMsg = rb.getString(rb.E_NO_SUCH_DESTINATION, getDestinationType(mytype), destination);
            status = Status.ERROR;
            // log the error
            logger.logStack(Logger.ERROR, rb.E_INTERNAL_BROKER_ERROR, this.getClass().getName() + ": failed to get destination (" + DestType.toString(mytype) + ":" + destination + ")", ex);
        }
        msgtype = "DESTINATION";
    } else {
        ServiceManager sm = Globals.getServiceManager();
        MetricManager mm = Globals.getMetricManager();
        MetricCounters mc = null;
        if (service != null && sm.getServiceType(service) == ServiceType.UNKNOWN) {
            status = Status.NOT_FOUND;
            errMsg = rb.getString(rb.X_NO_SUCH_SERVICE, service);
        } else {
            // If service is null getMetricCounters() will get counters
            // for all services
            mc = mm.getMetricCounters(service);
            if (service != null) {
                msgtype = "SERVICE";
            }
            replyobj = mc;
        }
    }
    // Send reply
    Packet reply = new Packet(con.useDirectBuffers());
    reply.setPacketType(PacketType.OBJECT_MESSAGE);
    Hashtable pr = new Hashtable();
    if (msgtype != null) {
        pr.put(MessageType.JMQ_BODY_TYPE, msgtype);
    }
    setProperties(reply, MessageType.GET_METRICS_REPLY, status, errMsg, pr);
    if (replyobj != null) {
        setBodyObject(reply, replyobj);
    }
    parent.sendReply(con, cmd_msg, reply);
    return true;
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) MetricManager(com.sun.messaging.jmq.jmsserver.service.MetricManager) ServiceManager(com.sun.messaging.jmq.jmsserver.service.ServiceManager) MetricCounters(com.sun.messaging.jmq.util.MetricCounters) Hashtable(java.util.Hashtable)

Aggregations

MetricManager (com.sun.messaging.jmq.jmsserver.service.MetricManager)9 MetricCounters (com.sun.messaging.jmq.util.MetricCounters)4 ServiceManager (com.sun.messaging.jmq.jmsserver.service.ServiceManager)2 IMQService (com.sun.messaging.jmq.jmsserver.service.imq.IMQService)2 MetricData (com.sun.messaging.jmq.util.MetricData)2 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)1 Agent (com.sun.messaging.jmq.jmsserver.management.agent.Agent)1 ConnectionManager (com.sun.messaging.jmq.jmsserver.service.ConnectionManager)1 Service (com.sun.messaging.jmq.jmsserver.service.Service)1 ServiceInfo (com.sun.messaging.jmq.util.admin.ServiceInfo)1 Hashtable (java.util.Hashtable)1