use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class CmdRunner method runDestroyAll.
private int runDestroyAll(BrokerCmdProperties brokerCmdProps) {
BrokerAdmin broker;
String input = null;
String yes, yesShort, no, noShort;
int ret_code = 0;
yes = ar.getString(ar.Q_RESPONSE_YES);
yesShort = ar.getString(ar.Q_RESPONSE_YES_SHORT);
no = ar.getString(ar.Q_RESPONSE_NO);
noShort = ar.getString(ar.Q_RESPONSE_NO_SHORT);
String commandArg = brokerCmdProps.getCommandArg();
boolean force = brokerCmdProps.forceModeSet();
broker = init();
if (CMDARG_DESTINATION.equals(commandArg)) {
if (broker == null) {
Globals.stdErrPrintln("Destroying all the destinations failed");
return (1);
}
if (!force)
broker = promptForAuthentication(broker);
Globals.stdOutPrintln("Destroying all the destinations");
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
connectToBroker(broker);
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln("Destroying all the destinations failed");
return (1);
}
if (!force) {
input = CommonCmdRunnerUtil.getUserInput("Are you sure you want to destroy all the destinations? (y/n)[n] ", noShort);
Globals.stdOutPrintln("");
}
if (yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input) || force) {
try {
boolean dstsDestroyed = false;
/*
* List all destinations
*/
broker.sendGetDestinationsMessage(null, -1);
Vector dests = broker.receiveGetDestinationsReplyMessage();
if (dests != null) {
Enumeration thisEnum = dests.elements();
while (thisEnum.hasMoreElements()) {
DestinationInfo dInfo = (DestinationInfo) thisEnum.nextElement();
String destName;
int destTypeMask;
destName = dInfo.name;
destTypeMask = dInfo.type;
if (MessageType.JMQ_ADMIN_DEST.equals(destName) || MessageType.JMQ_BRIDGE_ADMIN_DEST.equals(destName) || DestType.isInternal(dInfo.fulltype) || DestType.isTemporary(dInfo.type) || DestType.isDMQ(dInfo.type)) {
Globals.stdOutPrintln("Skipping destination: " + destName);
continue;
}
try {
broker.sendDestroyDestinationMessage(destName, destTypeMask);
broker.receiveDestroyDestinationReplyMessage();
if (DestType.isQueue(destTypeMask)) {
Globals.stdOutPrintln("Successfully destroyed queue " + destName);
} else {
Globals.stdOutPrintln("Successfully destroyed topic " + destName);
}
dstsDestroyed = true;
} catch (BrokerAdminException destroyEx) {
handleBrokerAdminException(destroyEx);
if (DestType.isQueue(destTypeMask)) {
Globals.stdOutPrintln("Destroy failed for queue " + destName);
} else {
Globals.stdOutPrintln("Destroy failed for topic " + destName);
}
ret_code = 1;
}
}
}
if (!dstsDestroyed) {
Globals.stdOutPrintln("No destinations destroyed.");
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln("Destroying all the destinations failed");
return (1);
}
} else if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
Globals.stdOutPrintln("The destinations were not destroyed.");
return (0);
} else {
Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
Globals.stdOutPrintln("");
Globals.stdOutPrintln("The destinations were not destroyed.");
return (1);
}
}
broker.close();
return (ret_code);
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class CmdRunner method getDestinationInfoFromAttrs.
private DestinationInfo getDestinationInfoFromAttrs(Properties destAttrs) {
DestinationInfo di = new DestinationInfo();
for (Enumeration e = destAttrs.propertyNames(); e.hasMoreElements(); ) {
String propName = (String) e.nextElement(), value = destAttrs.getProperty(propName);
SizeString ss;
int intValue = 0;
long longValue = 0;
boolean valueOK = true;
/*
* maxTotalMsgBytes
*/
if (propName.equals(PROP_NAME_OPTION_MAX_MESG_BYTE)) {
try {
ss = new SizeString(value);
longValue = ss.getBytes();
} catch (NumberFormatException nfe) {
valueOK = false;
}
if (valueOK) {
di.setMaxMessageBytes(longValue);
}
continue;
}
/*
* maxNumMsgs
*/
if (propName.equals(PROP_NAME_OPTION_MAX_MESG)) {
try {
intValue = Integer.parseInt(value);
} catch (NumberFormatException nfe) {
valueOK = false;
}
if (valueOK) {
di.setMaxMessages(intValue);
}
continue;
}
/*
* maxBytesPerMsg
*/
if (propName.equals(PROP_NAME_OPTION_MAX_PER_MESG_SIZE)) {
try {
ss = new SizeString(value);
longValue = ss.getBytes();
} catch (NumberFormatException nfe) {
valueOK = false;
}
if (valueOK) {
di.setMaxMessageSize(longValue);
}
continue;
}
/*
* maxFailoverConsumerCount
*/
if (propName.equals(PROP_NAME_MAX_FAILOVER_CONSUMER_COUNT)) {
try {
di.setMaxFailoverConsumers(Integer.parseInt(value));
} catch (NumberFormatException nfe) {
}
}
/*
* maxNumBackupConsumers
*/
if (propName.equals(PROP_NAME_MAX_ACTIVE_CONSUMER_COUNT)) {
try {
di.setMaxActiveConsumers(Integer.parseInt(value));
} catch (NumberFormatException nfe) {
}
}
/*
* isLocalDestination
*/
if (propName.equals(PROP_NAME_IS_LOCAL_DEST)) {
di.setScope(Boolean.parseBoolean(value));
}
/*
* limitBehaviour
*/
if (propName.equals(PROP_NAME_LIMIT_BEHAVIOUR)) {
di.setLimitBehavior(getLimitBehavValue(value));
}
/*
* localDeliveryPreferred
*/
if (propName.equals(PROP_NAME_LOCAL_DELIVERY_PREF)) {
di.setClusterDeliveryPolicy(getClusterDeliveryPolicy(value));
}
/*
* maxPrefetchCount
*/
if (propName.equals(PROP_NAME_CONSUMER_FLOW_LIMIT)) {
try {
di.setPrefetch(Integer.parseInt(value));
} catch (NumberFormatException nfe) {
}
}
/*
* maxProducerCount
*/
if (propName.equals(PROP_NAME_MAX_PRODUCERS)) {
try {
di.setMaxProducers(Integer.parseInt(value));
} catch (NumberFormatException nfe) {
}
}
/*
* useDMQ
*/
if (propName.equals(PROP_NAME_USE_DMQ)) {
di.setUseDMQ(Boolean.parseBoolean(value));
}
if (propName.equals(PROP_NAME_VALIDATE_XML_SCHEMA_ENABLED)) {
di.setValidateXMLSchemaEnabled(Boolean.parseBoolean(value));
}
if (propName.equals(PROP_NAME_XML_SCHEMA_URI_LIST)) {
di.setXMLSchemaUriList(value);
}
if (propName.equals(PROP_NAME_RELOAD_XML_SCHEMA_ON_FAILURE)) {
di.setReloadXMLSchemaOnFailure(Boolean.parseBoolean(value));
}
}
return (di);
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class CmdRunner method runUpdate.
private int runUpdate(BrokerCmdProperties brokerCmdProps) {
BrokerAdmin broker;
Properties targetAttrs;
String input = null;
String yes, yesShort, no, noShort;
yes = ar.getString(ar.Q_RESPONSE_YES);
yesShort = ar.getString(ar.Q_RESPONSE_YES_SHORT);
no = ar.getString(ar.Q_RESPONSE_NO);
noShort = ar.getString(ar.Q_RESPONSE_NO_SHORT);
broker = init();
String commandArg = brokerCmdProps.getCommandArg();
boolean force = brokerCmdProps.forceModeSet();
if (CMDARG_BROKER.equals(commandArg)) {
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_UPDATE_BKR_FAIL));
return (1);
}
if (!force)
broker = promptForAuthentication(broker);
targetAttrs = brokerCmdProps.getTargetAttrs();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_BKR));
Globals.stdOutPrintln("");
printAttrs(targetAttrs);
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
if (!force) {
input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_UPDATE_BKR_OK), noShort);
Globals.stdOutPrintln("");
if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_BKR_NOOP));
return (0);
} else if (!(yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input))) {
Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
Globals.stdOutPrintln("");
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_BKR_NOOP));
return (1);
}
}
try {
connectToBroker(broker);
broker.sendUpdateBrokerPropsMessage(targetAttrs);
broker.receiveUpdateBrokerPropsReplyMessage();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_BKR_SUC));
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_UPDATE_BKR_FAIL));
return (1);
}
} else if (CMDARG_SERVICE.equals(commandArg)) {
ServiceInfo si;
String svcName;
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_UPDATE_SVC_FAIL));
return (1);
}
if (!force)
broker = promptForAuthentication(broker);
targetAttrs = brokerCmdProps.getTargetAttrs();
svcName = brokerCmdProps.getTargetName();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_SVC, svcName));
Globals.stdOutPrintln("");
printAttrs(targetAttrs);
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
si = getServiceInfoFromAttrs(targetAttrs);
si.setName(svcName);
/*
* Get the svcPort value.
*/
// int svcType = -1;
int svcPort = -1;
Vector svc = null;
try {
connectToBroker(broker);
broker.sendGetServicesMessage(svcName);
svc = broker.receiveGetServicesReplyMessage();
if ((svc != null) && (svc.size() == 1)) {
Enumeration thisEnum = svc.elements();
ServiceInfo sInfo = (ServiceInfo) thisEnum.nextElement();
// svcType = sInfo.type;
svcPort = sInfo.port;
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_UPDATE_SVC_FAIL));
return (1);
}
if (!force) {
/*
* Rollback the fix for bug 4432483: jmqcmd, jmqadmin: setting admin max threads = 0 is allowed & hangs. Now this check
* is done by the broker. if ((si.isModified(ServiceInfo.MAX_THREADS)) && (si.maxThreads == 0)) {
* Globals.stdErrPrintln(ar.getString(ar.W_SET_MAX_THREAD_ZERO, svcName)); }
*/
input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_UPDATE_SVC_OK), noShort);
Globals.stdOutPrintln("");
if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_SVC_NOOP));
return (0);
} else if (!(yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input))) {
Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
Globals.stdOutPrintln("");
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_SVC_NOOP));
return (1);
}
}
// If the port is -1, it is not used, so disallow the update.
if ((si.isModified(ServiceInfo.PORT)) && (svcPort == -1)) {
Globals.stdErrPrintln(ar.getString(ar.E_PORT_NOT_ALLOWED_TO_CHANGE, svcName));
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_UPDATE_SVC_FAIL));
return (1);
}
try {
broker.sendUpdateServiceMessage(si);
broker.receiveUpdateServiceReplyMessage();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_SVC_SUC));
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_UPDATE_SVC_FAIL));
return (1);
}
} else if (CMDARG_DESTINATION.equals(commandArg)) {
DestinationInfo di;
String destName;
int destTypeMask;
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_UPDATE_DEST_FAIL));
return (1);
}
if (!force)
broker = promptForAuthentication(broker);
targetAttrs = brokerCmdProps.getTargetAttrs();
destTypeMask = getDestTypeMask(brokerCmdProps);
destName = brokerCmdProps.getTargetName();
if (DestType.isQueue(destTypeMask)) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_DEST_Q, destName));
} else {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_DEST_T, destName));
}
Globals.stdOutPrintln("");
printAttrs(targetAttrs);
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
if (!force) {
if (updatingDestXMLSchema(targetAttrs)) {
Object[] args = new Object[3];
args[0] = PROP_NAME_VALIDATE_XML_SCHEMA_ENABLED;
args[1] = PROP_NAME_XML_SCHEMA_URI_LIST;
args[2] = PROP_NAME_RELOAD_XML_SCHEMA_ON_FAILURE;
input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_UPDATE_DEST_XML_SCHEMA_OK, args), noShort);
} else {
input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_UPDATE_DEST_OK), noShort);
}
Globals.stdOutPrintln("");
if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_DEST_NOOP));
return (0);
} else if (!(yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input))) {
Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
Globals.stdOutPrintln("");
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_DEST_NOOP));
return (1);
}
}
try {
di = getDestinationInfoFromAttrs(targetAttrs);
di.setType(destTypeMask);
di.setName(destName);
connectToBroker(broker);
broker.sendUpdateDestinationMessage(di);
broker.receiveUpdateDestinationReplyMessage();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_UPDATE_DEST_SUC));
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_UPDATE_DEST_FAIL));
return (1);
}
}
broker.close();
return (0);
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class BrokerAdminHandler method refreshBrokerDestList.
private void refreshBrokerDestList(Vector dests, BrokerDestListCObj bDestlCObj) {
BrokerCObj bCObj = bDestlCObj.getBrokerCObj();
// if the new destinations is NOT null.
if (dests != null) {
bDestlCObj.removeAllChildren();
BrokerDestCObj bDestCObj;
int i = 0;
Enumeration e = dests.elements();
while (e.hasMoreElements()) {
DestinationInfo dInfo = (DestinationInfo) e.nextElement();
if ((!DestType.isTemporary(dInfo.type)) && (!MessageType.JMQ_ADMIN_DEST.equals(dInfo.name)) && (!MessageType.JMQ_BRIDGE_ADMIN_DEST.equals(dInfo.name)) && (!DestType.isInternal(dInfo.fulltype))) {
bDestCObj = new BrokerDestCObj(bCObj, dInfo);
bDestlCObj.insert(bDestCObj, i++);
}
}
}
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class BrokerAdminHandler method doResumeDest.
private void doResumeDest(BrokerDestCObj bDestCObj) {
BrokerAdmin ba = bDestCObj.getBrokerAdmin();
DestinationInfo destInfo = bDestCObj.getDestinationInfo();
int result = JOptionPane.showConfirmDialog(app.getFrame(), acr.getString(acr.Q_DEST_RESUME, destInfo.name, ba.getKey()), acr.getString(acr.I_RESUME_DEST), JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.NO_OPTION) {
return;
}
/*
* Broker may take more time to complete the task than the specified timeout value. This value is used when refreshing
* the console in such cases.
*/
if (!ba.isBusy()) {
ba.setAssociatedObj(bDestCObj);
}
if (resumeDest(ba, destInfo.name, destInfo.type)) {
destInfo = queryDestinationInfo(ba, destInfo.name, destInfo.type);
if (destInfo != null) {
bDestCObj.setDestinationInfo(destInfo);
app.getInspector().selectedObjectUpdated();
}
// Update menu items, buttons.
controller.setActions(bDestCObj);
}
}
Aggregations