use of com.sun.messaging.jmq.jmsserver.core.DestinationUID 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.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.
the class DebugHandler method getDebugInfo.
public Hashtable getDebugInfo(String arg, String target, String targetType, Properties p) throws Exception {
if (arg.equals("cxn")) {
if (target == null) {
return getAllCxnInfo(null);
} else {
ConnectionUID uid = new ConnectionUID(Long.parseLong(target));
return getCxnInfo(uid);
}
} else if (arg.equals("config")) {
return getConfig();
} else if (arg.equals("memory")) {
return getMemory();
} else if (arg.equals("dst")) {
if (target == null) {
return DL.getAllDebugState();
} else {
boolean isQueue = false;
if (targetType == null) {
throw new Exception("topic or queue not " + "specified with -t [t|q]");
} else if (targetType.equals("t")) {
isQueue = false;
} else if (targetType.equals("q")) {
isQueue = true;
} else {
throw new Exception("Unknown -t argument " + targetType + " expected t or q");
}
DestinationUID uid = DestinationUID.getUID(target, isQueue);
return getDestinationInfo(uid);
}
} else if (arg.equals("ses")) {
if (target == null) {
return Session.getAllDebugState();
} else {
SessionUID uid = new SessionUID(Long.parseLong(target));
return getSession(uid);
}
} else if (arg.equals("prd")) {
if (target == null) {
return Producer.getAllDebugState();
} else {
ProducerUID uid = new ProducerUID(Long.parseLong(target));
return getProducerInfo(uid);
}
} else if (arg.equals("con")) {
if (target == null) {
return Consumer.getAllDebugState();
} else {
ConsumerUID uid = new ConsumerUID(Long.parseLong(target));
return getConInfo(uid);
}
} else if (arg.equals("svc")) {
if (target == null) {
logger.log(Logger.INFO, "XXX - target of null " + "not implemented for " + arg);
} else {
return getSvcInfo(target);
}
} else if (arg.equals("db")) {
return getDBInfo();
} else if (arg.equals("trans")) {
if (target == null) {
return getTransactionInfo(null);
} else {
TransactionUID uid = new TransactionUID(Long.parseLong(target));
return getTransactionInfo(uid);
}
} else if (arg.equals("pool")) {
if (target == null) {
logger.log(Logger.INFO, "XXX - target of null " + "not implemented for " + arg);
} else {
return getThreadPoolInfo(target);
}
} else if (arg.equals("threads")) {
return SupportUtil.getAllStackTracesAsMap();
} else if (arg.equals("cls")) {
return getClusterInfo();
} else if (arg.equals("bkr")) {
return getBrokerInfo();
} else if (arg.equals("pkt")) {
String full = p.getProperty("full");
boolean fullDump = false;
if (full != null && full.equalsIgnoreCase("True")) {
fullDump = true;
}
return getPktInfo(target, targetType, fullDump);
}
logger.log(Logger.INFO, "Unknown dump arg " + arg);
return null;
}
use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.
the class DebugHandler method getPktInfo.
private Hashtable getPktInfo(String target, String type, boolean full) throws Exception {
Hashtable ht = new Hashtable();
if (type == null || type.length() == 0 || type.equals("bkr")) {
Hashtable dest = new Hashtable();
Iterator[] itrs = DL.getAllDestinations(null);
Iterator itr = itrs[0];
while (itr.hasNext()) {
Destination d = (Destination) itr.next();
dest.put(d.getDestinationUID().toString(), d.getDebugMessages(full));
}
ht.put("Destinations", dest);
// XXX LKS 1/8/2004
// add entries for sessions, etc
//
} else if (type.equals("q") || type.equals("t")) {
boolean isQueue = false;
if (type.equals("t")) {
isQueue = false;
} else if (type.equals("q")) {
isQueue = true;
}
DestinationUID uid = DestinationUID.getUID(target, isQueue);
Destination[] ds = DL.getDestination(null, uid);
Destination d = ds[0];
if (d == null) {
throw new Exception("Unknown destination " + uid);
} else {
ht.putAll(d.getDebugMessages(full));
}
} else if (type.equals("con")) {
if (target == null) {
throw new Exception("Please specify consumerUID");
} else {
ConsumerUID uid = new ConsumerUID(Long.parseLong(target));
Consumer c = Consumer.getConsumer(uid);
if (c == null) {
throw new Exception("Unknown consumer " + uid);
} else {
ht.put(uid.toString(), c.getDebugMessages(full));
}
}
} else if (type.equals("cxn")) {
if (target == null) {
throw new Exception("Please specify connectionUID");
}
ConnectionUID uid = new ConnectionUID(Long.parseLong(target));
IMQConnection cxn = (IMQConnection) Globals.getConnectionManager().getConnection(uid);
if (cxn == null) {
throw new Exception("Can not find connection " + uid);
}
ht.put(target, cxn.getDebugMessages(full));
} else if (type.equals("ses")) {
ht.put("Dump acks ", target);
if (target == null) {
throw new Exception("Please specify SessionUID");
}
SessionUID uid = new SessionUID(Long.parseLong(target));
Session sess = Session.getSession(uid);
if (sess == null) {
throw new Exception("Can not find session " + uid);
}
ht.put(target, sess.getDebugMessages(full));
} else {
ht.put("Error", "Unknown pkt type " + type);
}
return ht;
}
use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.
the class TransactionListLoader method handleSentMessages.
static void handleSentMessages(TransactionList transactionList, TransactionWork txnWork) throws BrokerException {
for (int i = 0; i < txnWork.numSentMessages(); i++) {
TransactionWorkMessage msg = txnWork.getSentMessages().get(i);
Packet packet = msg.getMessage();
DestinationUID duid = msg.getDestUID();
logger.log(Logger.DEBUG, " handleSentMessages: duid= " + duid);
PacketReference pr = PacketReference.createReference(transactionList.getPartitionedStore(), packet, duid, null);
Destination[] ds = Globals.getDestinationList().getDestination(transactionList.getPartitionedStore(), duid);
Destination d = ds[0];
if (d == null) {
// Lets recreate it here.
try {
int type = (duid.isQueue() ? DestType.DEST_TYPE_QUEUE : DestType.DEST_TYPE_TOPIC);
ds = Globals.getDestinationList().getDestination(transactionList.getPartitionedStore(), duid.getName(), type, true, true);
d = ds[0];
} catch (IOException e) {
throw new BrokerException("Could not recreate destination " + duid, e);
}
}
// check it is loaded
d.load();
logger.log(Logger.DEBUG, " loadTransactions: processing prepared sent message " + packet.getMessageID());
// queue message
d.queueMessage(pr, true);
// store (should not really be persisted as we are using txnLog)
// pr.store();
// add message to transaction
transactionList.addMessage(pr.getTransactionID(), pr.getSysMessageID(), true);
}
}
use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.
the class TxnConverter method deleteSentMessagesFromStore.
void deleteSentMessagesFromStore(TransactionWork txnWork) throws BrokerException {
// now delete any sent messages from store ( they are stored in txn
// log or prepared msg store)
Iterator<TransactionWorkMessage> sent = txnWork.getSentMessages().iterator();
while (sent.hasNext()) {
TransactionWorkMessage twm = sent.next();
DestinationUID duid = twm.getDestUID();
SysMessageID mid = twm.getMessage().getSysMessageID();
try {
((PartitionedStore) store).removeMessage(duid, mid, true);
} catch (IOException e) {
String msg = "Could not remove transacted sent message during txn conversion";
logger.logStack(Logger.ERROR, msg, e);
}
}
}
Aggregations