Search in sources :

Example 11 with ConnectionInfo

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

the class ServiceUtil method getConsumerIDs.

public static List getConsumerIDs(String service) {
    List consumerIDs = new ArrayList(), connections = ConnectionUtil.getConnectionInfoList(service);
    if ((connections == null) || (connections.size() == 0)) {
        return (consumerIDs);
    }
    Iterator itr = connections.iterator();
    while (itr.hasNext()) {
        ConnectionInfo cxnInfo = (ConnectionInfo) itr.next();
        long cxnID = cxnInfo.uuid;
        List oneCxnConsumerIDs = ConnectionUtil.getConsumerIDs(cxnID);
        consumerIDs.addAll(oneCxnConsumerIDs);
    }
    return (consumerIDs);
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ConnectionInfo(com.sun.messaging.jmq.util.admin.ConnectionInfo)

Example 12 with ConnectionInfo

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

the class IMQConnection method getConnectionInfo.

public ConnectionInfo getConnectionInfo() {
    if (coninfo == null) {
        coninfo = new ConnectionInfo();
        coninfo.id = (conId == null ? empty : conId.toString().getBytes());
        coninfo.remoteIP = remoteIP;
        coninfo.service = service.getName();
    }
    coninfo.user = null;
    Principal principal = null;
    try {
        if ((principal = getAuthenticatedName()) != null) {
            coninfo.user = principal.getName();
        }
    } catch (BrokerException e) {
        logger.log(Logger.DEBUG, "Exception getting authentication name " + conId);
        coninfo.user = e.getMessage();
    }
    coninfo.uuid = this.conId.longValue();
    coninfo.metrics = (MetricCounters) counters.clone();
    coninfo.clientID = (String) getClientData(CLIENT_ID);
    coninfo.nproducers = producers.size();
    if ((coninfo.userAgent = (String) getClientData(USER_AGENT)) == null) {
        coninfo.userAgent = "";
    }
    int cnt = 0;
    synchronized (sessions) {
        Iterator itr = sessions.values().iterator();
        while (itr.hasNext()) {
            cnt += ((Session) itr.next()).getConsumerCnt();
        }
    }
    coninfo.nconsumers = cnt;
    return coninfo;
}
Also used : BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) ConnectionInfo(com.sun.messaging.jmq.util.admin.ConnectionInfo) Principal(java.security.Principal)

Example 13 with ConnectionInfo

use of com.sun.messaging.jmq.util.admin.ConnectionInfo 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 14 with ConnectionInfo

use of com.sun.messaging.jmq.util.admin.ConnectionInfo 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 15 with ConnectionInfo

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

the class ConsumerUtil method getUser.

private static String getUser(ConsumerUID cid) {
    ConnectionUID cxnId = getConnectionUID(cid);
    if (cxnId == null) {
        return (null);
    }
    ConnectionInfo cxnInfo = ConnectionUtil.getConnectionInfo(cxnId.longValue());
    if (cxnInfo == null) {
        return (null);
    }
    return (cxnInfo.user);
}
Also used : ConnectionUID(com.sun.messaging.jmq.jmsserver.service.ConnectionUID) ConnectionInfo(com.sun.messaging.jmq.util.admin.ConnectionInfo)

Aggregations

ConnectionInfo (com.sun.messaging.jmq.util.admin.ConnectionInfo)20 Iterator (java.util.Iterator)10 List (java.util.List)10 ConnectionUID (com.sun.messaging.jmq.jmsserver.service.ConnectionUID)9 ConnectionManager (com.sun.messaging.jmq.jmsserver.service.ConnectionManager)4 IMQConnection (com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection)4 ArrayList (java.util.ArrayList)3 MBeanException (javax.management.MBeanException)3 ObjectName (javax.management.ObjectName)3 Producer (com.sun.messaging.jmq.jmsserver.core.Producer)2 Service (com.sun.messaging.jmq.jmsserver.service.Service)2 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)2 Vector (java.util.Vector)2 BrokerAddress (com.sun.messaging.jmq.jmsserver.core.BrokerAddress)1 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)1 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)1 DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)1 Subscription (com.sun.messaging.jmq.jmsserver.core.Subscription)1 BrokerResources (com.sun.messaging.jmq.jmsserver.resources.BrokerResources)1 ConsumerInfo (com.sun.messaging.jmq.util.admin.ConsumerInfo)1