Search in sources :

Example 1 with ConnectionInfo

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

the class GetConsumersHandler method getConnectionInfo.

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 2 with ConnectionInfo

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

the class GetDurablesHandler 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);
    }
    String destination = (String) cmd_props.get(MessageType.JMQ_DESTINATION);
    // Send reply
    Packet reply = new Packet(con.useDirectBuffers());
    reply.setPacketType(PacketType.OBJECT_MESSAGE);
    int status = Status.OK;
    Vector v = null;
    String err = null;
    try {
        DestinationUID duid = null;
        if (destination != null) {
            duid = DestinationUID.getUID(destination, false);
        }
        Set s = Subscription.getAllSubscriptions(duid);
        v = new Vector();
        Iterator itr = s.iterator();
        while (itr.hasNext()) {
            Subscription sub = (Subscription) itr.next();
            DurableInfo di = new DurableInfo();
            di.isDurable = sub.isDurable();
            di.isShared = sub.getShared();
            di.isJMSShared = sub.getJMSShared();
            if (di.isDurable) {
                di.name = sub.getDurableName();
            } else if (di.isJMSShared) {
                di.name = sub.getNDSubscriptionName();
            }
            di.clientID = sub.getClientID();
            di.isActive = sub.isActive();
            di.uidString = String.valueOf(sub.getConsumerUID().longValue());
            List children = sub.getChildConsumers();
            di.activeCount = children.size();
            di.activeConsumers = new LinkedHashMap<>();
            Iterator itr1 = children.iterator();
            while (itr1.hasNext()) {
                Consumer c = (Consumer) itr1.next();
                ConsumerInfo cinfo = new ConsumerInfo();
                cinfo.connection = new ConnectionInfo();
                cinfo.connection.uuid = c.getConsumerUID().getConnectionUID().longValue();
                cinfo.uidString = String.valueOf(c.getConsumerUID().longValue());
                ConsumerUID uid = c.getStoredConsumerUID();
                if (uid != null) {
                    cinfo.subuidString = String.valueOf(uid.longValue());
                }
                BrokerAddress addr = c.getConsumerUID().getBrokerAddress();
                if (addr != null) {
                    cinfo.brokerAddressShortString = addr.getMQAddress().getHostAddressNPort() + (addr.getBrokerID() == null ? "" : "[" + addr.getBrokerID() + "]");
                }
                di.activeConsumers.put(cinfo.uidString, cinfo);
            }
            di.nMessages = sub.numInProcessMsgs();
            di.consumer = new ConsumerInfo();
            // Ok, I'm not setting id because it really should be an int, maybe later
            di.consumer.destination = sub.getDestinationUID().getName();
            di.consumer.type = DestType.DEST_TYPE_TOPIC;
            di.consumer.selector = sub.getSelectorStr();
            // not bothering with the connection this time either
            di.consumer.connection = null;
            v.add(di);
        }
    } catch (BrokerException ex) {
        err = ex.getMessage();
        status = ex.getStatusCode();
    }
    setProperties(reply, MessageType.GET_DURABLES_REPLY, status, err);
    setBodyObject(reply, v);
    parent.sendReply(con, cmd_msg, reply);
    return true;
}
Also used : Set(java.util.Set) ConsumerInfo(com.sun.messaging.jmq.util.admin.ConsumerInfo) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) BrokerAddress(com.sun.messaging.jmq.jmsserver.core.BrokerAddress) DurableInfo(com.sun.messaging.jmq.util.admin.DurableInfo) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) Consumer(com.sun.messaging.jmq.jmsserver.core.Consumer) Iterator(java.util.Iterator) List(java.util.List) ConnectionInfo(com.sun.messaging.jmq.util.admin.ConnectionInfo) Subscription(com.sun.messaging.jmq.jmsserver.core.Subscription) Vector(java.util.Vector)

Example 3 with ConnectionInfo

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

the class GetConsumersHandler method getHost.

private static String getHost(ConsumerUID cid) {
    ConnectionUID cxnId = getConnectionUID(cid);
    if (cxnId == null) {
        return (null);
    }
    ConnectionInfo cxnInfo = getConnectionInfo(cxnId.longValue());
    if (cxnInfo == null) {
        return (null);
    }
    String host = null;
    if (cxnInfo.remoteIP != null) {
        host = String.valueOf(IPAddress.rawIPToString(cxnInfo.remoteIP, true, true));
    }
    return (host);
}
Also used : ConnectionUID(com.sun.messaging.jmq.jmsserver.service.ConnectionUID) ConnectionInfo(com.sun.messaging.jmq.util.admin.ConnectionInfo)

Example 4 with ConnectionInfo

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

the class GetConsumersHandler method getUser.

private static String getUser(ConsumerUID cid) {
    ConnectionUID cxnId = getConnectionUID(cid);
    if (cxnId == null) {
        return (null);
    }
    ConnectionInfo cxnInfo = 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)

Example 5 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)

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