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);
}
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;
}
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);
}
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);
}
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;
}
Aggregations