use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class CmdRunner method runQuery.
private int runQuery(BrokerCmdProperties brokerCmdProps) {
BrokerAdmin broker;
broker = init();
// Check for the target argument.
// Valid values are dst and svc.
String commandArg = brokerCmdProps.getCommandArg();
if (CMDARG_DESTINATION.equals(commandArg)) {
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_DST_FAIL));
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
String destName = brokerCmdProps.getTargetName();
int destTypeMask = getDestTypeMask(brokerCmdProps);
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_DST));
printDestinationInfo();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
connectToBroker(broker);
broker.sendGetDestinationsMessage(destName, destTypeMask);
Vector dest = broker.receiveGetDestinationsReplyMessage();
if ((dest != null) && (dest.size() == 1)) {
Enumeration thisEnum = dest.elements();
DestinationInfo dInfo = (DestinationInfo) thisEnum.nextElement();
BrokerCmdPrinter bcp = new BrokerCmdPrinter(2, 4);
String[] row = new String[2];
bcp.setSortNeeded(false);
/*
* Basic info - name/type/state etc.
*/
row[0] = ar.getString(ar.I_JMQCMD_DST_NAME);
row[1] = dInfo.name;
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_TYPE);
row[1] = BrokerAdminUtil.getDestinationType(dInfo.type);
// If the destination is temporary, indicate so.
if (DestType.isTemporary(dInfo.type))
row[1] = row[1] + " (" + ar.getString(ar.I_TEMPORARY) + ")";
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_STATE);
// row[1] = DestState.toString(dInfo.destState);
row[1] = BrokerAdminUtil.getDestinationState(dInfo.destState);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_CREATED_ADMIN);
if (dInfo.autocreated) {
row[1] = Boolean.FALSE.toString();
} else {
row[1] = Boolean.TRUE.toString();
}
bcp.add(row);
row[0] = "";
row[1] = "";
bcp.add(row);
/*
* 'Current' numbers
*/
row[0] = ar.getString(ar.I_JMQCMD_DST_CUR_MSG);
row[1] = "";
bcp.add(row);
String indent = " ";
row[0] = indent + ar.getString(ar.I_JMQCMD_DST_ACTUAL);
row[1] = Integer.toString(dInfo.nMessages - dInfo.nTxnMessages);
bcp.add(row);
row[0] = indent + ar.getString(ar.I_JMQCMD_DST_REMOTE);
row[1] = Integer.toString(dInfo.nRemoteMessages);
bcp.add(row);
row[0] = indent + ar.getString(ar.I_JMQCMD_DST_INDELAY);
row[1] = Integer.toString(dInfo.nInDelayMessages);
bcp.add(row);
row[0] = indent + ar.getString(ar.I_JMQCMD_DST_HELD_IN_TXN);
row[1] = Integer.toString(dInfo.nTxnMessages);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_CUR_MSG_BYTES);
row[1] = "";
bcp.add(row);
row[0] = indent + ar.getString(ar.I_JMQCMD_DST_ACTUAL);
row[1] = Long.toString(dInfo.nMessageBytes - dInfo.nTxnMessageBytes);
bcp.add(row);
row[0] = indent + ar.getString(ar.I_JMQCMD_DST_REMOTE);
row[1] = Long.toString(dInfo.nRemoteMessageBytes);
bcp.add(row);
row[0] = indent + ar.getString(ar.I_JMQCMD_DST_INDELAY);
row[1] = Long.toString(dInfo.nInDelayMessageBytes);
bcp.add(row);
row[0] = indent + ar.getString(ar.I_JMQCMD_DST_HELD_IN_TXN);
row[1] = Long.toString(dInfo.nTxnMessageBytes);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_CUR_PRODUCERS);
row[1] = Integer.toString(dInfo.nProducers);
bcp.add(row);
if (DestType.isQueue(destTypeMask)) {
row[0] = ar.getString(ar.I_JMQCMD_DST_CUR_ACTIVE_CONS);
row[1] = Integer.toString(dInfo.naConsumers);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_CUR_FAILOVER_CONS);
row[1] = Integer.toString(dInfo.nfConsumers);
bcp.add(row);
} else {
Hashtable h = dInfo.producerWildcards;
row[0] = ar.getString(ar.I_JMQCMD_DST_CUR_NUM_PRODUCERS_WILDCARD);
row[1] = Integer.toString(getWildcardCount(h));
bcp.add(row);
/*
* The code below will print something like:
*
* foo.bar.* (2) bar.* (1)
*/
Enumeration keys;
if (h != null) {
keys = h.keys();
while (keys.hasMoreElements()) {
String wildcard = (String) keys.nextElement();
Integer val = (Integer) h.get(wildcard);
row[0] = indent + wildcard + " (" + val + ")";
row[1] = "";
bcp.add(row);
}
}
row[0] = ar.getString(ar.I_JMQCMD_DST_CUR_CONS);
row[1] = Integer.toString(dInfo.nConsumers);
bcp.add(row);
h = dInfo.consumerWildcards;
row[0] = ar.getString(ar.I_JMQCMD_DST_CUR_NUM_CONSUMERS_WILDCARD);
row[1] = Integer.toString(getWildcardCount(h));
bcp.add(row);
if (h != null) {
keys = h.keys();
while (keys.hasMoreElements()) {
String wildcard = (String) keys.nextElement();
Integer val = (Integer) h.get(wildcard);
row[0] = indent + wildcard + " (" + val + ")";
row[1] = "";
bcp.add(row);
}
}
}
row[0] = "";
row[1] = "";
bcp.add(row);
/*
* 'Current' numbers
*/
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_MSG_ALLOW);
row[1] = checkAndPrintUnlimitedInt(dInfo.maxMessages, zeroNegOneInt);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_MSG_BYTES_ALLOW);
row[1] = checkAndPrintUnlimitedLong(dInfo.maxMessageBytes, zeroNegOneLong);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_BYTES_PER_MSG_ALLOW);
row[1] = String.valueOf(dInfo.maxMessageSize);
row[1] = checkAndPrintUnlimitedLong(dInfo.maxMessageSize, zeroNegOneLong);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_PRODUCERS);
row[1] = checkAndPrintUnlimitedInt(dInfo.maxProducers, -1);
bcp.add(row);
if (DestType.isQueue(destTypeMask)) {
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_ACTIVE_CONSUMER_COUNT);
row[1] = checkAndPrintUnlimitedInt(dInfo.maxActiveConsumers, -1);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_FAILOVER_CONSUMER_COUNT);
row[1] = checkAndPrintUnlimitedInt(dInfo.maxFailoverConsumers, -1);
bcp.add(row);
}
row[0] = "";
row[1] = "";
bcp.add(row);
/*
* Other misc props
*/
row[0] = ar.getString(ar.I_JMQCMD_DST_LIMIT_BEHAVIOUR);
row[1] = DestLimitBehavior.getString(dInfo.destLimitBehavior);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_CONS_FLOW_LIMIT);
row[1] = checkAndPrintUnlimitedInt(dInfo.maxPrefetch, -1);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_IS_LOCAL_DEST);
if (dInfo.isDestinationLocal()) {
row[1] = Boolean.TRUE.toString();
} else {
row[1] = Boolean.FALSE.toString();
}
bcp.add(row);
if (DestType.isQueue(destTypeMask)) {
row[0] = ar.getString(ar.I_JMQCMD_DST_LOCAL_DELIVERY_PREF);
if (dInfo.destCDP == ClusterDeliveryPolicy.LOCAL_PREFERRED) {
row[1] = Boolean.TRUE.toString();
} else {
row[1] = Boolean.FALSE.toString();
}
bcp.add(row);
}
row[0] = ar.getString(ar.I_JMQCMD_DST_USE_DMQ);
if (dInfo.useDMQ()) {
row[1] = Boolean.TRUE.toString();
} else {
row[1] = Boolean.FALSE.toString();
}
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_VALIDATE_XML_SCHEMA_ENABLED);
if (dInfo.validateXMLSchemaEnabled()) {
row[1] = Boolean.TRUE.toString();
} else {
row[1] = Boolean.FALSE.toString();
}
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_XML_SCHEMA_URI_LIST);
row[1] = dInfo.XMLSchemaUriList;
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_RELOAD_XML_SCHEMA_ON_FAILURE);
if (dInfo.reloadXMLSchemaOnFailure()) {
row[1] = Boolean.TRUE.toString();
} else {
row[1] = Boolean.FALSE.toString();
}
bcp.add(row);
bcp.println();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_DST_SUC));
} else {
// Should not get here, since if something went wrong we should get
// a BrokerAdminException
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_INCORRECT_DATA_RET));
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_DST_FAIL));
return (1);
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_DST_FAIL));
return (1);
}
} else if (CMDARG_SERVICE.equals(commandArg)) {
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_SVC_FAIL));
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
String svcName = brokerCmdProps.getTargetName();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_SVC));
printServiceInfo();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
connectToBroker(broker);
broker.sendGetServicesMessage(svcName);
Vector svc = broker.receiveGetServicesReplyMessage();
if ((svc != null) && (svc.size() == 1)) {
Enumeration thisEnum = svc.elements();
ServiceInfo sInfo = (ServiceInfo) thisEnum.nextElement();
BrokerCmdPrinter bcp = new BrokerCmdPrinter(2, 4);
String[] row = new String[2];
bcp.setSortNeeded(false);
/*
* Basic info - name/port/state
*/
row[0] = ar.getString(ar.I_JMQCMD_SVC_NAME);
row[1] = sInfo.name;
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_SVC_STATE);
// row[1] = ServiceState.getString(sInfo.state);
row[1] = BrokerAdminUtil.getServiceState(sInfo.state);
bcp.add(row);
// It is NOT applicable if it is set to -1
if (sInfo.port != -1) {
row[0] = ar.getString(ar.I_JMQCMD_SVC_PORT);
// dynamically generated or statically declared
if (sInfo.dynamicPort) {
switch(sInfo.state) {
case ServiceState.UNKNOWN:
row[1] = ar.getString(ar.I_DYNAMIC);
break;
default:
row[1] = Integer.toString(sInfo.port) + " (" + ar.getString(ar.I_DYNAMIC) + ")";
}
} else {
row[1] = Integer.toString(sInfo.port) + " (" + ar.getString(ar.I_STATIC) + ")";
}
bcp.add(row);
}
row[0] = "";
row[1] = "";
bcp.add(row);
/*
* 'Curent' numbers
*/
row[0] = ar.getString(ar.I_JMQCMD_SVC_CUR_THREADS);
row[1] = Integer.toString(sInfo.currentThreads);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_SVC_NUM_CXN);
row[1] = Integer.toString(sInfo.nConnections);
bcp.add(row);
row[0] = "";
row[1] = "";
bcp.add(row);
/*
* Min/Max numbers
*/
row[0] = ar.getString(ar.I_JMQCMD_SVC_MIN_THREADS);
row[1] = Integer.toString(sInfo.minThreads);
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_SVC_MAX_THREADS);
row[1] = Integer.toString(sInfo.maxThreads);
bcp.add(row);
bcp.println();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_SVC_SUC));
} else {
// Should not get here, since if something went wrong we should get
// a BrokerAdminException
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_INCORRECT_DATA_RET));
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_SVC_FAIL));
return (1);
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_SVC_FAIL));
return (1);
}
} else if (CMDARG_BROKER.equals(commandArg)) {
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_BKR_FAIL));
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_BKR));
printBrokerInfo(broker);
try {
connectToBroker(broker);
broker.sendGetBrokerPropsMessage();
Properties bkrProps = broker.receiveGetBrokerPropsReplyMessage();
if (bkrProps == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_BKR_FAIL));
return (1);
}
if (brokerCmdProps.adminDebugModeSet()) {
printAllBrokerAttrs(bkrProps);
} else {
printDisplayableBrokerAttrs(bkrProps);
}
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_BKR_SUC));
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_BKR_FAIL));
return (1);
}
} else if (CMDARG_TRANSACTION.equals(commandArg)) {
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_TXN_FAIL));
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
String tidStr = brokerCmdProps.getTargetName();
Long tid = null;
try {
tid = Long.valueOf(tidStr);
} catch (NumberFormatException nfe) {
Globals.stdErrPrintln(ar.getString(ar.E_INVALID_TXN_ID, tidStr));
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_TXN_FAIL));
return (1);
}
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_TXN));
printTransactionInfo();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
connectToBroker(broker);
broker.sendGetTxnsMessage(tid, brokerCmdProps.showPartitionModeSet());
Vector txns = broker.receiveGetTxnsReplyMessage();
if ((txns != null) && (txns.size() == 1)) {
Enumeration thisEnum = txns.elements();
Hashtable txnInfo = (Hashtable) thisEnum.nextElement();
if (brokerCmdProps.debugModeSet()) {
printAllTxnAttrs(txnInfo);
} else {
printDisplayableTxnAttrs(txnInfo);
}
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_TXN_SUC));
} else {
// Should not get here, since if something went wrong we should get
// a BrokerAdminException
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_INCORRECT_DATA_RET));
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_TXN_FAIL));
return (1);
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_TXN_FAIL));
return (1);
}
} else if (CMDARG_CONNECTION.equals(commandArg)) {
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_CXN_FAIL));
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
String cxnIdStr = brokerCmdProps.getTargetName();
Long cxnId = null;
try {
cxnId = Long.valueOf(cxnIdStr);
} catch (NumberFormatException nfe) {
Globals.stdErrPrintln(ar.getString(ar.E_INVALID_CXN_ID, cxnIdStr));
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_CXN_FAIL));
return (1);
}
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_CXN));
printConnectionInfo();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
connectToBroker(broker);
broker.sendGetConnectionsMessage(null, cxnId);
Vector cxnList = broker.receiveGetConnectionsReplyMessage();
if ((cxnList != null) && (cxnList.size() == 1)) {
Enumeration thisEnum = cxnList.elements();
Hashtable cxnInfo = (Hashtable) thisEnum.nextElement();
if (brokerCmdProps.debugModeSet()) {
printAllCxnAttrs(cxnInfo);
} else {
printDisplayableCxnAttrs(cxnInfo);
}
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_CXN_SUC));
} else {
// Should not get here, since if something went wrong we should get
// a BrokerAdminException
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_INCORRECT_DATA_RET));
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_CXN_FAIL));
return (1);
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_CXN_FAIL));
return (1);
}
} else if (CMDARG_MSG.equals(commandArg)) {
if (broker == null) {
/*
* Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_MSG_FAIL));
*/
Globals.stdErrPrintln("Querying message failed.");
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
String destName = brokerCmdProps.getTargetName();
int destTypeMask = getDestTypeMask(brokerCmdProps);
String msgID = brokerCmdProps.getMsgID();
/*
* Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_MSG));
*/
Globals.stdOutPrintln("Querying message:");
printMessageInfo();
Globals.stdOutPrintln("In the destination");
printDestinationInfo();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
connectToBroker(broker);
broker.sendGetMessagesMessage(destName, destTypeMask, true, msgID, null, null);
Vector msgList = broker.receiveGetMessagesReplyMessage();
if ((msgList != null) && (msgList.size() == 1)) {
HashMap oneMsg = (HashMap) msgList.get(0);
printDisplayableMsgAttrs(oneMsg);
/*
* Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_MSG_SUC));
*/
Globals.stdOutPrintln("Successfully queried message.");
} else {
/*
* Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_LIST_MSG_NONE));
*/
Globals.stdErrPrintln("There are no messages.");
Globals.stdOutPrintln("");
/*
* Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_QUERY_MSG_SUC));
*/
Globals.stdOutPrintln("Successfully queried message.");
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
/*
* Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_QUERY_MSG_FAIL));
*/
Globals.stdErrPrintln("Querying message failed.");
return (1);
}
}
if (broker.isConnected()) {
broker.close();
}
return (0);
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class CmdRunner method runGetAttr.
private int runGetAttr(BrokerCmdProperties brokerCmdProps, List result) {
BrokerAdmin broker;
int retValue = 1;
broker = init();
try {
// Check for the target argument.
// Valid value are dst, svc, and bkr.
String commandArg = brokerCmdProps.getCommandArg();
if (CMDARG_DESTINATION.equals(commandArg)) {
if (broker == null) {
Globals.stdOutPrintln("Problems connecting to the broker.");
retValue = 1;
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
String destName = brokerCmdProps.getTargetName();
int destTypeMask = getDestTypeMask(brokerCmdProps);
String attrName = brokerCmdProps.getSingleTargetAttr();
try {
connectToBroker(broker);
broker.sendGetDestinationsMessage(destName, destTypeMask);
Vector dest = broker.receiveGetDestinationsReplyMessage();
if ((dest != null) && (dest.size() == 1)) {
Enumeration thisEnum = dest.elements();
DestinationInfo dInfo = (DestinationInfo) thisEnum.nextElement();
if (PROP_NAME_OPTION_MAX_MESG_BYTE.equals(attrName)) {
Globals.stdOutPrintln(Long.toString(dInfo.maxMessageBytes));
retValue = 0;
} else if (PROP_NAME_OPTION_MAX_MESG.equals(attrName)) {
Globals.stdOutPrintln(Integer.toString(dInfo.maxMessages));
retValue = 0;
} else if (PROP_NAME_OPTION_MAX_PER_MESG_SIZE.equals(attrName)) {
Globals.stdOutPrintln(Long.toString(dInfo.maxMessageSize));
retValue = 0;
} else if (PROP_NAME_OPTION_CUR_MESG_BYTE.equals(attrName)) {
Globals.stdOutPrintln(Long.toString(dInfo.nMessageBytes));
retValue = 0;
} else if (PROP_NAME_OPTION_CUR_MESG.equals(attrName)) {
String val = Integer.toString(dInfo.nMessages);
Globals.stdOutPrintln(val);
if (result != null) {
result.add(val);
}
retValue = 0;
} else if (PROP_NAME_OPTION_CUR_UNACK_MESG.equals(attrName)) {
String val = Integer.toString(dInfo.nUnackMessages);
Globals.stdOutPrintln(val);
if (result != null) {
result.add(val);
}
retValue = 0;
} else if (PROP_NAME_OPTION_CUR_PRODUCERS.equals(attrName)) {
Globals.stdOutPrintln(Integer.toString(dInfo.nProducers));
retValue = 0;
} else if (PROP_NAME_MAX_FAILOVER_CONSUMER_COUNT.equals(attrName)) {
Globals.stdOutPrintln(Integer.toString(dInfo.maxFailoverConsumers));
retValue = 0;
} else if (PROP_NAME_MAX_ACTIVE_CONSUMER_COUNT.equals(attrName)) {
Globals.stdOutPrintln(Integer.toString(dInfo.maxActiveConsumers));
retValue = 0;
} else if (PROP_NAME_IS_LOCAL_DEST.equals(attrName)) {
if (dInfo.isDestinationLocal()) {
Globals.stdOutPrintln(Boolean.TRUE.toString());
} else {
Globals.stdOutPrintln(Boolean.FALSE.toString());
}
retValue = 0;
} else if (PROP_NAME_LIMIT_BEHAVIOUR.equals(attrName)) {
Globals.stdOutPrintln(DestLimitBehavior.getString(dInfo.destLimitBehavior));
retValue = 0;
} else if (PROP_NAME_LOCAL_DELIVERY_PREF.equals(attrName)) {
int cdp = dInfo.destCDP;
if (cdp == ClusterDeliveryPolicy.LOCAL_PREFERRED) {
Globals.stdOutPrintln(Boolean.TRUE.toString());
} else {
Globals.stdOutPrintln(Boolean.FALSE.toString());
}
retValue = 0;
} else if (PROP_NAME_CONSUMER_FLOW_LIMIT.equals(attrName)) {
Globals.stdOutPrintln(Integer.toString(dInfo.maxPrefetch));
retValue = 0;
} else if (PROP_NAME_MAX_PRODUCERS.equals(attrName)) {
Globals.stdOutPrintln(Integer.toString(dInfo.maxProducers));
retValue = 0;
} else if (PROP_NAME_OPTION_CUR_A_CONSUMERS.equals(attrName)) {
String val = null;
if (DestType.isQueue(destTypeMask)) {
val = Integer.toString(dInfo.naConsumers);
Globals.stdOutPrintln(val);
} else {
val = Integer.toString(dInfo.nConsumers);
Globals.stdOutPrintln(val);
}
if (result != null) {
result.add(val);
}
retValue = 0;
} else if (PROP_NAME_OPTION_CUR_B_CONSUMERS.equals(attrName)) {
Globals.stdOutPrintln(Integer.toString(dInfo.nfConsumers));
retValue = 0;
} else if (PROP_NAME_USE_DMQ.equals(attrName)) {
Globals.stdOutPrintln(Boolean.toString(dInfo.useDMQ()));
retValue = 0;
} else if (PROP_NAME_VALIDATE_XML_SCHEMA_ENABLED.equals(attrName)) {
Globals.stdOutPrintln(Boolean.toString(dInfo.validateXMLSchemaEnabled()));
retValue = 0;
} else if (PROP_NAME_XML_SCHEMA_URI_LIST.equals(attrName)) {
Globals.stdOutPrintln(dInfo.XMLSchemaUriList);
retValue = 0;
} else if (PROP_NAME_RELOAD_XML_SCHEMA_ON_FAILURE.equals(attrName)) {
Globals.stdOutPrintln(Boolean.toString(dInfo.reloadXMLSchemaOnFailure()));
retValue = 0;
} else {
// Should not get here since we check for valid attribute
// names in BrokerCmd.checkGetAttr().
Globals.stdErrPrintln(attrName + " is not recognized.");
retValue = 1;
return (1);
}
} else {
Globals.stdErrPrintln("Problems retrieving the destination info.");
retValue = 1;
return (1);
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
retValue = 1;
return (1);
}
return (retValue);
} else if (CMDARG_SERVICE.equals(commandArg)) {
if (broker == null) {
Globals.stdOutPrintln("Problems connecting to the broker.");
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
String svcName = brokerCmdProps.getTargetName();
String attrName = brokerCmdProps.getSingleTargetAttr();
try {
connectToBroker(broker);
broker.sendGetServicesMessage(svcName);
Vector svc = broker.receiveGetServicesReplyMessage();
if ((svc != null) && (svc.size() == 1)) {
Enumeration thisEnum = svc.elements();
ServiceInfo sInfo = (ServiceInfo) thisEnum.nextElement();
if (BrokerCmdOptions.PROP_NAME_SVC_PORT.equals(attrName)) {
Globals.stdOutPrintln(Integer.toString(sInfo.port));
retValue = 0;
} else if (BrokerCmdOptions.PROP_NAME_SVC_MIN_THREADS.equals(attrName)) {
Globals.stdOutPrintln(Integer.toString(sInfo.minThreads));
retValue = 0;
} else if (BrokerCmdOptions.PROP_NAME_SVC_MAX_THREADS.equals(attrName)) {
Globals.stdOutPrintln(Integer.toString(sInfo.maxThreads));
retValue = 0;
} else {
// Should not get here since we check for valid attribute
// names in BrokerCmd.checkGetAttr().
Globals.stdOutPrintln(attrName + " is not recognized.");
retValue = 1;
return (1);
}
} else {
Globals.stdOutPrintln("Problems retrieving the service info.");
retValue = 1;
return (1);
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
retValue = 1;
return (1);
}
return (retValue);
} else if (CMDARG_BROKER.equals(commandArg)) {
if (broker == null) {
Globals.stdOutPrintln("Problems connecting to the broker.");
retValue = 1;
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
String attrName = brokerCmdProps.getSingleTargetAttr();
try {
connectToBroker(broker);
broker.sendGetBrokerPropsMessage();
Properties bkrProps = broker.receiveGetBrokerPropsReplyMessage();
if (bkrProps == null) {
Globals.stdOutPrintln("Problems retrieving the broker info.");
retValue = 1;
return (1);
}
String value;
value = bkrProps.getProperty(attrName, "");
Globals.stdOutPrintln(value);
retValue = 0;
/*
* if (PROP_NAME_BKR_PRIMARY_PORT.equals(attrName)) { value = bkrProps.getProperty(PROP_NAME_BKR_PRIMARY_PORT, "");
* Globals.stdOutPrintln(value); retValue = 0;
*
* } else if (PROP_NAME_BKR_AUTOCREATE_TOPIC.equals(attrName)) { value =
* bkrProps.getProperty(PROP_NAME_BKR_AUTOCREATE_TOPIC, ""); Globals.stdOutPrintln(value); retValue = 0;
*
* } else if (PROP_NAME_BKR_AUTOCREATE_QUEUE.equals(attrName)) { value =
* bkrProps.getProperty(PROP_NAME_BKR_AUTOCREATE_QUEUE, ""); Globals.stdOutPrintln(value); retValue = 0;
*
* } else if (PROP_NAME_BKR_MAX_MSG.equals(attrName)) { value = bkrProps.getProperty(PROP_NAME_BKR_MAX_MSG, "");
* Globals.stdOutPrintln(value); retValue = 0;
*
* } else if (PROP_NAME_BKR_MAX_TTL_MSG_BYTES.equals(attrName)) { value =
* bkrProps.getProperty(PROP_NAME_BKR_MAX_TTL_MSG_BYTES, ""); Globals.stdOutPrintln(value); retValue = 0;
*
* } else if (PROP_NAME_BKR_MAX_MSG_BYTES.equals(attrName)) { value = bkrProps.getProperty(PROP_NAME_BKR_MAX_MSG_BYTES,
* ""); Globals.stdOutPrintln(value); retValue = 0;
*
* } else if (PROP_NAME_BKR_CUR_MSG.equals(attrName)) { value = bkrProps.getProperty(PROP_NAME_BKR_CUR_MSG, "");
* Globals.stdOutPrintln(value); retValue = 0;
*
* } else if (PROP_NAME_BKR_CUR_TTL_MSG_BYTES.equals(attrName)) { value =
* bkrProps.getProperty(PROP_NAME_BKR_CUR_TTL_MSG_BYTES, ""); Globals.stdOutPrintln(value); retValue = 0;
*
* } else { // Should not get here since we check for valid attribute // names in BrokerCmd.checkGetAttr().
* Globals.stdOutPrintln(attrName + " is not recognized."); retValue = 1; return (1); }
*/
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
retValue = 1;
return (1);
}
} else if (CMDARG_DURABLE.equals(commandArg)) {
String destName = brokerCmdProps.getDestName();
String subName = brokerCmdProps.getTargetName();
String clientID = brokerCmdProps.getClientID();
String attrName = brokerCmdProps.getSingleTargetAttr();
if (!BrokerCmdOptions.PROP_NAME_OPTION_CUR_A_CONSUMERS.equals(attrName)) {
return 1;
}
if (broker == null) {
Globals.stdOutPrintln("Problems connecting to the broker.");
retValue = 1;
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force) {
broker = promptForAuthentication(broker);
}
try {
connectToBroker(broker);
if (destName != null) {
isDestTypeTopic(broker, destName);
}
broker.sendGetDurablesMessage(destName, null);
Vector durs = broker.receiveGetDurablesReplyMessage();
retValue = 1;
Enumeration thisEnum = durs.elements();
while (thisEnum.hasMoreElements()) {
DurableInfo dinfo = (DurableInfo) thisEnum.nextElement();
if (subName != null) {
if (dinfo.name.equals(subName)) {
String val = null;
if (clientID != null && clientID.equals(dinfo.clientID)) {
val = Integer.toString(dinfo.activeCount);
Globals.stdOutPrintln(val);
} else {
val = Integer.toString(dinfo.activeCount);
Globals.stdOutPrintln(val);
}
if (result != null) {
result.add(val);
}
return 0;
}
} else if (destName != null && dinfo.consumer != null && destName.equals(dinfo.consumer.destination)) {
if (clientID != null && clientID.equals(dinfo.clientID)) {
Globals.stdOutPrintln(Integer.toString(dinfo.activeCount));
return 0;
} else {
Globals.stdOutPrintln(Integer.toString(dinfo.activeCount));
return 0;
}
}
}
Globals.stdErrPrintln("Subscription not found.");
return 1;
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
return (1);
}
} else if (CMDARG_TRANSACTION.equals(commandArg)) {
String attrName = brokerCmdProps.getSingleTargetAttr();
if (broker == null) {
Globals.stdOutPrintln("Problems connecting to the broker.");
retValue = 1;
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force) {
broker = promptForAuthentication(broker);
}
try {
connectToBroker(broker);
broker.sendGetTxnsMessage(brokerCmdProps.showPartitionModeSet());
Vector txns = broker.receiveGetTxnsReplyMessage();
if (txns == null) {
throw new BrokerAdminException(BrokerAdminException.REPLY_NOT_RECEIVED);
}
if (BrokerCmdOptions.PROP_NAME_OPTION_CUR_TXNS.equals(attrName)) {
String val = String.valueOf(txns.size());
Globals.stdOutPrintln(val);
if (result != null) {
result.add(val);
}
retValue = 0;
} else if (BrokerCmdOptions.PROP_NAME_OPTION_ALL_TXNS.equals(attrName)) {
Globals.stdOutPrintln(txns.toString());
if (result != null) {
result.addAll(txns);
}
retValue = 0;
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
return (1);
}
}
return (retValue);
} finally {
if (broker != null) {
if (retValue == 1) {
broker.forceClose();
} else {
broker.close();
}
}
}
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class JMSAdminImpl method createProviderDestination.
/**
* Create a physical Destination within the JMS Provider using the provided properties to define provider specific
* attributes. Destination is not automatically bound into JNDI namespace.
*
* @param destinationType QUEUE or TOPIC
* @param properties creation properties.
* @exception JMSException thrown if Queue could not be created.
*/
@Override
public void createProviderDestination(String destinationName, int destinationType, java.util.Map properties) throws JMSException {
ObjectMessage requestMesg = null;
Message replyMesg = null;
// Create DestinationInfo.
DestinationInfo di = new DestinationInfo();
di.setName(destinationName);
// REVISIT:
// We only check for queueDeliveryPolicy in the properties
// hard-coded string; left here because we are not sure
// if we are going to expose this attribute yet
String qPolicy = null;
/*
* Early initialization to be used in error messages
*/
int typeMask = this.getDestTypeMask(destinationType, null);
if (properties != null) {
if (properties.containsKey("queueDeliveryPolicy")) {
qPolicy = (String) properties.get("queueDeliveryPolicy");
typeMask = this.getDestTypeMask(destinationType, qPolicy);
}
if (properties.containsKey(BrokerCmdOptions.PROP_NAME_MAX_ACTIVE_CONSUMER_COUNT)) {
Object tmp = null;
String val = null;
tmp = properties.get(BrokerCmdOptions.PROP_NAME_MAX_ACTIVE_CONSUMER_COUNT);
if (tmp != null) {
if (!(tmp instanceof String)) {
JMSException jmse;
jmse = new JMSException(ar.getString(ar.E_SPI_DEST_CREATION_FAILED, DestType.toString(typeMask), destinationName) + "\n" + ar.getString(ar.E_SPI_ATTR_TYPE_NOT_STRING, BrokerCmdOptions.PROP_NAME_MAX_ACTIVE_CONSUMER_COUNT));
throw jmse;
}
val = (String) tmp;
try {
di.setMaxActiveConsumers(Integer.parseInt(val));
} catch (Exception e) {
JMSException jmse;
jmse = new JMSException(ar.getString(ar.E_SPI_DEST_CREATION_FAILED, DestType.toString(typeMask), destinationName) + "\n" + ar.getString(ar.E_INVALID_INTEGER_VALUE, val, BrokerCmdOptions.PROP_NAME_MAX_ACTIVE_CONSUMER_COUNT));
throw (jmse);
}
}
}
}
di.setType(typeMask);
requestMesg = session.createObjectMessage();
requestMesg.setJMSReplyTo(replyQueue);
requestMesg.setIntProperty(MessageType.JMQ_MESSAGE_TYPE, MessageType.CREATE_DESTINATION);
requestMesg.setObject(di);
sender.send(requestMesg);
replyMesg = receiver.receive(timeout);
replyMesg.acknowledge();
checkReplyTypeStatus(replyMesg, MessageType.CREATE_DESTINATION_REPLY);
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class DestinationManagerConfig method create.
public void create(String type, String name, AttributeList attrs) throws MBeanException {
DestinationInfo info = DestinationUtil.getDestinationInfoFromAttrs(type, name, attrs);
try {
DestinationUtil.checkCreateDestinationAttrs(type, attrs);
DestinationUtil.createDestination(info);
} catch (BrokerException e) {
handleOperationException(DestinationOperations.CREATE, e);
}
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class DestinationUtil method getDestinationInfoFromAttrs.
public static DestinationInfo getDestinationInfoFromAttrs(String type, String destName, AttributeList attrs) {
DestinationInfo info = new DestinationInfo();
info.setName(destName);
if (type.equals(DestinationType.QUEUE)) {
info.setType(DestType.DEST_TYPE_QUEUE);
} else if (type.equals(DestinationType.TOPIC)) {
info.setType(DestType.DEST_TYPE_TOPIC);
}
if (attrs == null) {
return (info);
}
for (Iterator i = attrs.iterator(); i.hasNext(); ) {
Attribute attr = (Attribute) i.next();
String name = attr.getName();
Object value = attr.getValue();
if (name.equals(DestinationAttributes.CONSUMER_FLOW_LIMIT)) {
info.setPrefetch(((Long) value).intValue());
}
if (name.equals(DestinationAttributes.LOCAL_ONLY)) {
info.setScope(((Boolean) value).booleanValue());
}
if (name.equals(DestinationAttributes.LIMIT_BEHAVIOR)) {
info.setLimitBehavior(toInternalDestLimitBehavior((String) value));
}
if (name.equals(DestinationAttributes.LOCAL_DELIVERY_PREFERRED)) {
int cdp;
if (((Boolean) value).booleanValue()) {
cdp = ClusterDeliveryPolicy.LOCAL_PREFERRED;
} else {
cdp = ClusterDeliveryPolicy.DISTRIBUTED;
}
info.setClusterDeliveryPolicy(cdp);
}
if (name.equals(DestinationAttributes.MAX_BYTES_PER_MSG)) {
info.setMaxMessageSize(((Long) value).longValue());
}
if (name.equals(DestinationAttributes.MAX_NUM_ACTIVE_CONSUMERS)) {
info.setMaxActiveConsumers(((Integer) value).intValue());
}
if (name.equals(DestinationAttributes.MAX_NUM_BACKUP_CONSUMERS)) {
info.setMaxFailoverConsumers(((Integer) value).intValue());
}
if (name.equals(DestinationAttributes.MAX_NUM_MSGS)) {
info.setMaxMessages(((Long) value).intValue());
}
if (name.equals(DestinationAttributes.MAX_NUM_PRODUCERS)) {
info.setMaxProducers(((Integer) value).intValue());
}
if (name.equals(DestinationAttributes.MAX_TOTAL_MSG_BYTES)) {
info.setMaxMessageBytes(((Long) value).longValue());
}
if (name.equals(DestinationAttributes.USE_DMQ)) {
info.setUseDMQ(((Boolean) value).booleanValue());
}
}
return (info);
}
Aggregations