Search in sources :

Example 6 with ConnectionManager

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

the class DestinationList method closeAttachedConnections.

private void closeAttachedConnections(int reason, String reasonStr) {
    ConnectionManager cmgr = Globals.getConnectionManager();
    ConnectionUID cuid = null;
    Connection con = null;
    synchronized (connections) {
        logger.log(logger.INFO, "Sending good-bye to all assigned connections(" + connections.size() + ") for partition " + this);
        ConnectionUID[] conids = connections.toArray(new ConnectionUID[connections.size()]);
        for (int i = 0; i < conids.length; i++) {
            cuid = conids[i];
            con = cmgr.getConnection(cuid);
            if (con == null) {
                connections.remove(cuid);
                continue;
            }
            con.closeConnection(true, reason, reasonStr);
            connections.remove(cuid);
        }
    }
}
Also used : ConnectionManager(com.sun.messaging.jmq.jmsserver.service.ConnectionManager) Connection(com.sun.messaging.jmq.jmsserver.service.Connection) IMQBasicConnection(com.sun.messaging.jmq.jmsserver.service.imq.IMQBasicConnection) ConnectionUID(com.sun.messaging.jmq.jmsserver.service.ConnectionUID)

Example 7 with ConnectionManager

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

the class ConnectionUtil method getConsumerIDs.

public static List getConsumerIDs(long cxnId) {
    ConnectionManager cm = Globals.getConnectionManager();
    IMQConnection cxn = null;
    List consumerIDs;
    cxn = (IMQConnection) cm.getConnection(new ConnectionUID(cxnId));
    consumerIDs = cxn.getConsumersIDs();
    return (consumerIDs);
}
Also used : ConnectionManager(com.sun.messaging.jmq.jmsserver.service.ConnectionManager) IMQConnection(com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection) List(java.util.List) ArrayList(java.util.ArrayList) ConnectionUID(com.sun.messaging.jmq.jmsserver.service.ConnectionUID)

Example 8 with ConnectionManager

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

the class ConnectionUtil method getConnectionInfo.

/**
 * Returns the ConnectionInfo for the passed connection ID.
 */
public static ConnectionInfo getConnectionInfo(long id) {
    ConnectionManager cm = Globals.getConnectionManager();
    ConnectionInfo cxnInfo = null;
    IMQConnection cxn = null;
    cxn = (IMQConnection) cm.getConnection(new ConnectionUID(id));
    if (cxn == null) {
        return (null);
    }
    cxnInfo = cxn.getConnectionInfo();
    return (cxnInfo);
}
Also used : ConnectionManager(com.sun.messaging.jmq.jmsserver.service.ConnectionManager) IMQConnection(com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection) ConnectionUID(com.sun.messaging.jmq.jmsserver.service.ConnectionUID) ConnectionInfo(com.sun.messaging.jmq.util.admin.ConnectionInfo)

Example 9 with ConnectionManager

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

the class ConnectionUtil method getConnectionInfoList.

/**
 * Returns a List of ConnectionInfo for the given service or all services if the passed service is null.
 */
public static List getConnectionInfoList(String service) {
    ConnectionManager cm = Globals.getConnectionManager();
    List connections, connectionInfoList = new ArrayList();
    IMQConnection cxn;
    ConnectionInfo cxnInfo;
    try {
        Service s = null;
        if (service != null) {
            s = Globals.getServiceManager().getService(service);
            /*
                 * If service object is null, service may not exist or is inactive
                 */
            if (s == null) {
                return (connectionInfoList);
            }
        }
        connections = cm.getConnectionList(s);
    } catch (Exception e) {
        BrokerResources rb = Globals.getBrokerResources();
        Logger logger = Globals.getLogger();
        logger.log(Logger.WARNING, rb.getString(rb.W_JMX_FAILED_TO_OBTAIN_CONNECTION_LIST), e);
        return (connectionInfoList);
    }
    if (connections.size() == 0) {
        return (connectionInfoList);
    }
    Iterator iter = connections.iterator();
    while (iter.hasNext()) {
        cxn = (IMQConnection) iter.next();
        cxnInfo = cxn.getConnectionInfo();
        connectionInfoList.add(cxnInfo);
    }
    return (connectionInfoList);
}
Also used : ConnectionManager(com.sun.messaging.jmq.jmsserver.service.ConnectionManager) IMQConnection(com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Service(com.sun.messaging.jmq.jmsserver.service.Service) List(java.util.List) ArrayList(java.util.ArrayList) ConnectionInfo(com.sun.messaging.jmq.util.admin.ConnectionInfo) Logger(com.sun.messaging.jmq.util.log.Logger) BrokerResources(com.sun.messaging.jmq.jmsserver.resources.BrokerResources)

Example 10 with ConnectionManager

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

the class GetServicesHandler method getServiceInfo.

public static ServiceInfo getServiceInfo(String name) {
    ServiceManager sm = Globals.getServiceManager();
    ConnectionManager cm = Globals.getConnectionManager();
    MetricManager mm = Globals.getMetricManager();
    /*
         * XXX REVISIT dipol 10/17/00 we should probably put this logic into the ServiceManager so knowledge of property names
         * is encapsulated there.
         */
    String proto = props.getProperty(SERVICE_PREFIX + name + ".protocoltype");
    // Fill in admin service info object
    ServiceInfo si = new com.sun.messaging.jmq.util.admin.ServiceInfo();
    si.name = name;
    si.protocol = proto;
    // strange kludge here ...
    // if protocol is tcp or tls, it defaults to 0
    int default_value = -1;
    if (si.protocol != null) {
        if (si.protocol.equals("tcp") || si.protocol.equals("tls")) {
            default_value = 0;
        }
    }
    si.port = props.getIntProperty(SERVICE_PREFIX + name + "." + proto + ".port", default_value);
    if (si.port == 0) {
        si.dynamicPort = true;
    } else {
        si.dynamicPort = false;
    }
    si.minThreads = props.getIntProperty(SERVICE_PREFIX + name + ".min_threads");
    si.maxThreads = props.getIntProperty(SERVICE_PREFIX + name + ".max_threads");
    si.type = sm.getServiceType(name);
    Service service = sm.getService(name);
    if (service != null) {
        si.nConnections = cm.getNumConnections(service);
        si.state = service.getState();
        if (service instanceof IMQService) {
            IMQService ss = (IMQService) service;
            si.currentThreads = ss.getActiveThreadpool();
            si.minThreads = ss.getMinThreadpool();
            si.maxThreads = ss.getMaxThreadpool();
            // port number that is acutally being used
            if (si.port == 0 && ss.getProtocol() != null) {
                si.port = ss.getProtocol().getLocalPort();
            }
        }
        if (mm != null) {
            si.metrics = mm.getMetricCounters(name);
        } else {
            si.metrics = null;
        }
    } else {
        // Service is not intitialized
        si.state = ServiceState.UNKNOWN;
    }
    return si;
}
Also used : ServiceInfo(com.sun.messaging.jmq.util.admin.ServiceInfo) MetricManager(com.sun.messaging.jmq.jmsserver.service.MetricManager) ConnectionManager(com.sun.messaging.jmq.jmsserver.service.ConnectionManager) ServiceManager(com.sun.messaging.jmq.jmsserver.service.ServiceManager) IMQService(com.sun.messaging.jmq.jmsserver.service.imq.IMQService) Service(com.sun.messaging.jmq.jmsserver.service.Service) IMQService(com.sun.messaging.jmq.jmsserver.service.imq.IMQService)

Aggregations

ConnectionManager (com.sun.messaging.jmq.jmsserver.service.ConnectionManager)12 ConnectionUID (com.sun.messaging.jmq.jmsserver.service.ConnectionUID)9 IMQConnection (com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection)8 List (java.util.List)5 Service (com.sun.messaging.jmq.jmsserver.service.Service)4 ConnectionInfo (com.sun.messaging.jmq.util.admin.ConnectionInfo)4 ArrayList (java.util.ArrayList)4 BrokerResources (com.sun.messaging.jmq.jmsserver.resources.BrokerResources)2 IMQBasicConnection (com.sun.messaging.jmq.jmsserver.service.imq.IMQBasicConnection)2 Logger (com.sun.messaging.jmq.util.log.Logger)2 Iterator (java.util.Iterator)2 HAMonitorService (com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService)1 Connection (com.sun.messaging.jmq.jmsserver.service.Connection)1 MetricManager (com.sun.messaging.jmq.jmsserver.service.MetricManager)1 ServiceManager (com.sun.messaging.jmq.jmsserver.service.ServiceManager)1 IMQService (com.sun.messaging.jmq.jmsserver.service.imq.IMQService)1 ServiceInfo (com.sun.messaging.jmq.util.admin.ServiceInfo)1 Vector (java.util.Vector)1