use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class CreateDestinationHandler 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
*/
@SuppressWarnings("deprecation")
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
DestinationInfo info;
info = (DestinationInfo) getBodyObject(cmd_msg);
if (DEBUG) {
logger.log(Logger.DEBUG, this.getClass().getName() + ": " + "Creating destination: " + cmd_props + ": " + info.toString());
}
Packet reply = new Packet(con.useDirectBuffers());
reply.setPacketType(PacketType.OBJECT_MESSAGE);
int status = Status.OK;
String errMsg = null;
// Default attributes of the destination
int type = DestType.DEST_TYPE_QUEUE | DestType.DEST_FLAVOR_SINGLE;
int maxMessages = -1;
SizeString maxMessageBytes = null;
SizeString maxMessageSize = null;
HAMonitorService hamonitor = Globals.getHAMonitorService();
if (hamonitor != null && hamonitor.inTakeover()) {
status = Status.ERROR;
errMsg = rb.getString(rb.E_CANNOT_PROCEED_TAKEOVER_IN_PROCESS);
logger.log(Logger.ERROR, this.getClass().getName() + ": " + errMsg);
} else if (MemoryGlobals.getMEM_DISALLOW_CREATE_DEST()) {
status = Status.ERROR;
errMsg = rb.W_LOW_MEM_REJECT_DEST;
} else if (info.isModified(DestinationInfo.NAME)) {
if (info.isModified(DestinationInfo.TYPE)) {
type = info.type;
}
if (info.isModified(DestinationInfo.MAX_MESSAGES)) {
maxMessages = info.maxMessages;
}
if (info.isModified(DestinationInfo.MAX_MESSAGE_BYTES)) {
maxMessageBytes = new SizeString();
maxMessageBytes.setBytes(info.maxMessageBytes);
}
if (info.isModified(DestinationInfo.MAX_MESSAGE_SIZE)) {
maxMessageSize = new SizeString();
maxMessageSize.setBytes(info.maxMessageSize);
}
} else {
status = Status.ERROR;
errMsg = rb.X_NO_DEST_NAME_SET;
}
// XXX create destination
if (status == Status.OK) {
if (DestType.destNameIsInternal(info.name)) {
status = Status.ERROR;
errMsg = rb.getKString(rb.X_CANNOT_CREATE_INTERNAL_DEST, info.name, DestType.INTERNAL_DEST_PREFIX);
} else {
if (isValidDestinationName(info.name)) {
try {
DL.createDestination(null, info.name, type);
} catch (Exception ex) {
status = Status.ERROR;
errMsg = rb.getKString(rb.X_CREATE_DEST_EXCEPTION, info.name, getMessageFromException(ex));
if (ex instanceof ConflictException) {
logger.log(Logger.INFO, errMsg, ex);
} else {
logger.logStack(Logger.INFO, errMsg, ex);
}
}
} else {
status = Status.ERROR;
errMsg = rb.getKString(rb.X_DEST_NAME_INVALID, info.name);
}
}
}
if (status == Status.OK) {
try {
Destination[] ds = DL.getDestination(null, info.name, DestType.isQueue(type));
Destination d = ds[0];
d.setCapacity(maxMessages);
d.setByteCapacity(maxMessageBytes);
d.setMaxByteSize(maxMessageSize);
if (info.isModified(info.DEST_SCOPE)) {
int scope = info.destScope;
d.setScope(scope);
}
if (info.isModified(info.DEST_LIMIT)) {
int destlimit = info.destLimitBehavior;
d.setLimitBehavior(destlimit);
}
if (info.isModified(info.DEST_PREFETCH)) {
int prefetch = info.maxPrefetch;
d.setMaxPrefetch(prefetch);
}
if (info.isModified(info.DEST_CDP)) {
int clusterdeliverypolicy = info.destCDP;
d.setClusterDeliveryPolicy(clusterdeliverypolicy);
}
if (info.isModified(info.MAX_ACTIVE_CONSUMERS)) {
int maxcons = info.maxActiveConsumers;
d.setMaxActiveConsumers(maxcons);
}
if (info.isModified(info.MAX_PRODUCERS)) {
int maxp = info.maxProducers;
d.setMaxProducers(maxp);
}
if (info.isModified(info.MAX_FAILOVER_CONSUMERS)) {
int maxcons = info.maxFailoverConsumers;
d.setMaxFailoverConsumers(maxcons);
}
if (info.isModified(info.MAX_SHARED_CONSUMERS)) {
int maxsharedcons = info.maxNumSharedConsumers;
d.setMaxSharedConsumers(maxsharedcons);
}
if (info.isModified(info.SHARE_FLOW_LIMIT)) {
int sflowlimit = info.sharedConsumerFlowLimit;
d.setSharedFlowLimit(sflowlimit);
}
if (info.isModified(info.USE_DMQ)) {
boolean dmq = info.useDMQ;
d.setUseDMQ(dmq);
}
if (info.isModified(info.VALIDATE_XML_SCHEMA_ENABLED)) {
d.setValidateXMLSchemaEnabled(info.validateXMLSchemaEnabled);
}
if (info.isModified(info.XML_SCHEMA_URI_LIST)) {
d.setXMLSchemaUriList(info.XMLSchemaUriList);
}
if (info.isModified(info.RELOAD_XML_SCHEMA_ON_FAILURE)) {
d.setReloadXMLSchemaOnFailure(info.reloadXMLSchemaOnFailure);
}
d.update();
// audit logging for create destination
Globals.getAuditSession().destinationOperation(con.getUserName(), con.remoteHostString(), MQAuditSession.CREATE_DESTINATION, d.isQueue() ? MQAuditSession.QUEUE : MQAuditSession.TOPIC, d.getDestinationName());
} catch (Exception ex) {
// remove the destination
try {
DestinationUID duid = DestinationUID.getUID(info.name, DestType.isQueue(type));
DL.removeDestination(null, duid, false, ex.toString());
} catch (Exception ex1) {
// if we cant destroy .. its ok .. ignore the exception
}
status = Status.ERROR;
errMsg = rb.getString(rb.X_UPDATE_DEST_EXCEPTION, info.name, getMessageFromException(ex));
logger.logStack(Logger.WARNING, errMsg, ex);
}
}
// Send reply
setProperties(reply, MessageType.CREATE_DESTINATION_REPLY, status, errMsg);
parent.sendReply(con, cmd_msg, reply);
return true;
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class BrokerAdminHandler method handleBrokerCmdStatusEvent.
private void handleBrokerCmdStatusEvent(BrokerCmdStatusEvent cse) {
int type = cse.getType(), msgType;
BrokerAdmin ba = cse.getBrokerAdmin();
boolean success = cse.getSuccess();
Exception ex = cse.getLinkedException();
String dstName = cse.getDestinationName(), svcName = cse.getServiceName(), clientID = cse.getClientID(), durName = cse.getDurableName(), bkrName = ba.getKey(), title, msg;
DestinationInfo dstInfo = cse.getDestinationInfo();
ServiceInfo svcInfo = cse.getServiceInfo();
Object refreshObj = ba.getAssociatedObj();
if (type == BrokerCmdStatusEvent.BROKER_BUSY) {
int numRetriesAttempted = cse.getNumRetriesAttempted(), maxNumRetries = cse.getMaxNumRetries();
long retryTimeount = cse.getRetryTimeount();
Object[] args = new Object[3];
args[0] = Integer.toString(numRetriesAttempted);
args[1] = Integer.toString(maxNumRetries);
args[2] = Long.toString(retryTimeount);
/*
* This string is of the form: Broker not responding, retrying [1 of 5 attempts, timeout=20 seconds]
*/
String s = ar.getString(ar.I_JMQCMD_BROKER_BUSY, args);
app.getStatusArea().appendText(s + "\n");
return;
}
/*
* Do not bring up the result dialog for 1. QUERY_SVC 2. QUERY_DST 3. LIST_DUR (for querying destination) 4. QUERY_BKR
*/
if ((type == BrokerCmdStatusEvent.QUERY_SVC) || (type == BrokerCmdStatusEvent.QUERY_DST) || (type == BrokerCmdStatusEvent.LIST_DUR) || (type == BrokerCmdStatusEvent.QUERY_BKR)) {
/*
* We need to refresh the console if 'connect' is successful but 'query broker' is not upon connecting to a broker.
*/
if (refreshObj instanceof BrokerCObj) {
app.getExplorer().nodeChanged((DefaultMutableTreeNode) refreshObj);
controller.setActions((BrokerCObj) refreshObj);
}
return;
}
/*
* Type of dialog depends on success/failure
*/
if (success) {
msgType = JOptionPane.INFORMATION_MESSAGE;
} else {
msgType = JOptionPane.ERROR_MESSAGE;
}
/*
* Dialog title reads: Status received from broker
*/
title = acr.getString(acr.I_STATUS_RECV);
switch(type) {
case BrokerCmdStatusEvent.HELLO:
if (success) {
msg = acr.getString(acr.S_BROKER_CONNECT, bkrName);
if (refreshObj instanceof BrokerCObj) {
BrokerCObj bCObj = (BrokerCObj) refreshObj;
/*
* Connection is considered created when the hello protocol handshake takes place successfully.
*/
ba.setIsConnected(true);
if (refreshBrokerServiceListCObj(bCObj.getBrokerServiceListCObj())) {
if (refreshBrokerDestListCObj(bCObj.getBrokerDestListCObj())) {
app.getExplorer().nodeChanged(bCObj);
app.getInspector().refresh();
controller.setActions(bCObj);
}
}
}
} else {
msg = acr.getString(acr.E_CONNECT_BROKER, bkrName);
}
break;
case BrokerCmdStatusEvent.CREATE_DST:
if (success) {
msg = acr.getString(acr.S_BROKER_DEST_ADD, dstInfo.name, bkrName);
if (refreshObj instanceof BrokerCObj) {
BrokerCObj bCObj = (BrokerCObj) refreshObj;
BrokerDestListCObj bDestlCObj = bCObj.getBrokerDestListCObj();
BrokerDestCObj bDestCObj = new BrokerDestCObj(bCObj, dstInfo);
app.getExplorer().addToParent(bDestlCObj, bDestCObj);
app.getInspector().refresh();
}
} else {
msg = acr.getString(acr.E_ADD_DEST_BROKER, dstInfo.name, bkrName);
}
break;
case BrokerCmdStatusEvent.DESTROY_DST:
if (success) {
msg = acr.getString(acr.S_BROKER_DEST_DELETE, dstName, bkrName);
if (refreshObj instanceof BrokerDestCObj) {
app.getExplorer().removeFromParent((BrokerDestCObj) refreshObj);
app.getInspector().refresh();
}
} else {
msg = acr.getString(acr.E_BROKER_DEST_DELETE, dstName, bkrName);
}
break;
case BrokerCmdStatusEvent.UPDATE_DST:
if (success) {
msg = acr.getString(acr.S_BROKER_UPDATE_DEST, dstInfo.name);
} else {
msg = acr.getString(acr.E_UPDATE_DEST, dstInfo.name);
}
break;
case BrokerCmdStatusEvent.PURGE_DST:
if (success) {
msg = acr.getString(acr.S_BROKER_DEST_PURGE, dstName, bkrName);
} else {
msg = acr.getString(acr.E_BROKER_DEST_PURGE, dstName, bkrName);
}
break;
case BrokerCmdStatusEvent.DESTROY_DUR:
if (success) {
msg = acr.getString(acr.S_BROKER_DESTROY_DUR, BrokerAdminUtil.getDSubLogString(clientID, durName));
if (refreshObj instanceof BrokerDestCObj) {
BrokerDestCObj bDestCObj = (BrokerDestCObj) refreshObj;
refreshBrokerDestCObj(bDestCObj, BrokerAdminEvent.DELETE_DUR);
Vector durables = bDestCObj.getDurables();
if (durables != null) {
brokerDestPropsDialog.refresh(durables);
}
}
} else {
msg = acr.getString(acr.E_BROKER_DESTROY_DUR, BrokerAdminUtil.getDSubLogString(clientID, durName));
}
break;
case BrokerCmdStatusEvent.LIST_DST:
if (success) {
msg = acr.getString(acr.S_BROKER_REFRESH_DESTLIST, bkrName);
Object obj = cse.getReturnedObject();
BrokerDestListCObj bDestlCObj;
if (obj instanceof Vector) {
Vector dests = (Vector) obj;
if (refreshObj instanceof BrokerDestListCObj) {
bDestlCObj = (BrokerDestListCObj) refreshObj;
} else if (refreshObj instanceof BrokerCObj) {
BrokerCObj bCObj = (BrokerCObj) refreshObj;
bDestlCObj = bCObj.getBrokerDestListCObj();
} else {
return;
}
refreshBrokerDestList(dests, bDestlCObj);
app.getInspector().refresh();
}
} else {
msg = acr.getString(acr.E_REFRESH_DESTLIST);
}
break;
case BrokerCmdStatusEvent.PAUSE_SVC:
if (success) {
msg = acr.getString(acr.S_SERVICE_PAUSE, svcName, bkrName);
if (refreshObj instanceof BrokerServiceCObj) {
BrokerServiceCObj bSvcCObj = (BrokerServiceCObj) refreshObj;
if (refreshBrokerServiceCObj(bSvcCObj)) {
app.getInspector().refresh();
controller.setActions(bSvcCObj);
}
}
} else {
msg = acr.getString(acr.E_SERVICE_PAUSE, svcName);
}
break;
case BrokerCmdStatusEvent.RESUME_SVC:
if (success) {
msg = acr.getString(acr.S_SERVICE_RESUME, svcName, bkrName);
if (refreshObj instanceof BrokerServiceCObj) {
BrokerServiceCObj bSvcCObj = (BrokerServiceCObj) refreshObj;
if (refreshBrokerServiceCObj(bSvcCObj)) {
app.getInspector().refresh();
controller.setActions(bSvcCObj);
}
}
} else {
msg = acr.getString(acr.E_SERVICE_RESUME, svcName);
}
break;
case BrokerCmdStatusEvent.UPDATE_SVC:
if (success) {
msg = acr.getString(acr.S_BROKER_UPDATE_SVC, svcInfo.name);
if (refreshObj instanceof BrokerServiceCObj) {
if (refreshBrokerServiceCObj((BrokerServiceCObj) refreshObj)) {
app.getInspector().refresh();
}
}
} else {
msg = acr.getString(acr.E_UPDATE_SERVICE, svcInfo.name);
}
break;
case BrokerCmdStatusEvent.LIST_SVC:
if (success) {
msg = acr.getString(acr.S_BROKER_REFRESH_SVCLIST, bkrName);
Object obj = cse.getReturnedObject();
BrokerServiceListCObj bSvclCObj;
if (obj instanceof Vector) {
Vector svcs = (Vector) obj;
if (refreshObj instanceof BrokerServiceListCObj) {
bSvclCObj = (BrokerServiceListCObj) refreshObj;
} else if (refreshObj instanceof BrokerCObj) {
BrokerCObj bCObj = (BrokerCObj) refreshObj;
bSvclCObj = bCObj.getBrokerServiceListCObj();
} else {
return;
}
refreshBrokerServiceList(svcs, bSvclCObj);
app.getInspector().refresh();
}
} else {
msg = acr.getString(acr.E_REFRESH_SVCLIST);
}
break;
case BrokerCmdStatusEvent.PAUSE_BKR:
if (success) {
msg = acr.getString(acr.S_BROKER_PAUSE, bkrName);
if (refreshObj instanceof BrokerCObj) {
BrokerCObj bCObj = (BrokerCObj) refreshObj;
if (refreshBrokerServiceListCObj(bCObj.getBrokerServiceListCObj())) {
app.getInspector().refresh();
controller.setActions(bCObj);
}
}
} else {
msg = acr.getString(acr.E_BROKER_PAUSE, bkrName);
}
break;
case BrokerCmdStatusEvent.RESUME_BKR:
if (success) {
msg = acr.getString(acr.S_BROKER_RESUME, bkrName);
if (refreshObj instanceof BrokerCObj) {
BrokerCObj bCObj = (BrokerCObj) refreshObj;
if (refreshBrokerServiceListCObj(bCObj.getBrokerServiceListCObj())) {
app.getInspector().refresh();
controller.setActions(bCObj);
}
}
} else {
msg = acr.getString(acr.E_BROKER_RESUME, bkrName);
}
break;
case BrokerCmdStatusEvent.UPDATE_BKR:
if (success) {
msg = acr.getString(acr.S_BROKER_UPDATE, bkrName);
} else {
msg = acr.getString(acr.E_UPDATE_BROKER, bkrName);
}
break;
default:
msg = acr.getString(acr.I_UNKNOWN_STATUS, bkrName);
break;
}
if (!success) {
if (ex instanceof BrokerAdminException) {
msg = msg + "\n" + printBrokerAdminExceptionDetails((BrokerAdminException) ex);
} else {
msg = msg + "\n" + ex;
}
}
JOptionPane.showOptionDialog(app.getFrame(), msg, title, JOptionPane.YES_NO_OPTION, msgType, null, close, close[0]);
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class BrokerAdminHandler method addDestination.
private BrokerDestCObj addDestination(BrokerCObj bCObj, BrokerAdminEvent bae) {
BrokerDestCObj bDestCObj;
DestinationInfo destInfo = createDestination(bae);
BrokerAdmin ba = bCObj.getBrokerAdmin();
/*
* 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(bCObj);
}
String destName = destInfo.name;
try {
ba.sendCreateDestinationMessage(destInfo);
ba.receiveCreateDestinationReplyMessage();
bDestCObj = new BrokerDestCObj(bCObj, destInfo);
app.getStatusArea().appendText(acr.getString(acr.S_BROKER_DEST_ADD, destInfo.name, ba.getKey()));
} catch (BrokerAdminException baex) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_ADD_DEST_BROKER, destName, ba.getKey()) + printBrokerAdminExceptionDetails(baex), acr.getString(acr.I_ADD_BROKER_DEST) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_ADD_DEST_BROKER), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return null;
}
return bDestCObj;
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class BrokerAdminHandler method refreshBrokerDestCObj.
private boolean refreshBrokerDestCObj(BrokerDestCObj bDestCObj, int eventType) {
DestinationInfo oldDestInfo = bDestCObj.getDestinationInfo();
BrokerAdmin ba = bDestCObj.getBrokerAdmin();
/*
* 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);
}
Vector dests = null;
Vector durables = null;
boolean succeed = false;
try {
ba.sendGetDurablesMessage(oldDestInfo.name, null);
/*
* False because users do not need to know whether or not the operation had succeeded after timeout.
*/
durables = ba.receiveGetDurablesReplyMessage(false);
} catch (BrokerAdminException baex) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_RETRIEVE_DUR, oldDestInfo.name) + printBrokerAdminExceptionDetails(baex), acr.getString(acr.I_BROKER_DEST_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_RETRIEVE_DUR), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return false;
}
bDestCObj.setDurables(durables);
succeed = true;
try {
ba.sendGetDestinationsMessage(oldDestInfo.name, oldDestInfo.type);
/*
* False because users do not need to know whether or not the operation had succeeded after timeout.
*/
dests = ba.receiveGetDestinationsReplyMessage(false);
} catch (BrokerAdminException baex) {
/*
* Do not pop up an error message, as another error message will be popped up.
*/
if (eventType == BrokerAdminEvent.DELETE_DUR || eventType == BrokerAdminEvent.UPDATE_DEST) {
return false;
}
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_RETRIEVE_DEST, oldDestInfo.name) + printBrokerAdminExceptionDetails(baex), acr.getString(acr.I_BROKER_DEST_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_RETRIEVE_DEST), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return false;
}
if ((dests != null) && (dests.size() == 1)) {
Enumeration e = dests.elements();
DestinationInfo dInfo = (DestinationInfo) e.nextElement();
if ((!DestType.isTemporary(dInfo.type)) && (!DestType.isInternal(dInfo.fulltype)) && (!MessageType.JMQ_BRIDGE_ADMIN_DEST.equals(dInfo.name)) && (!MessageType.JMQ_ADMIN_DEST.equals(dInfo.name))) {
bDestCObj.setDestinationInfo(dInfo);
}
succeed = true;
}
return succeed;
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class BrokerAdminHandler method doPurgeDestination.
private void doPurgeDestination(BrokerDestCObj bDestCObj) {
BrokerAdmin ba = bDestCObj.getBrokerAdmin();
DestinationInfo destInfo = bDestCObj.getDestinationInfo();
int result = JOptionPane.showConfirmDialog(app.getFrame(), acr.getString(acr.Q_BROKER_PURGE_DEST, destInfo.name, ba.getKey()), acr.getString(acr.I_PURGE_MESSAGES), JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.NO_OPTION) {
return;
}
if (!purgeDestination(ba, destInfo.name, destInfo.type)) {
return;
}
destInfo = queryDestinationInfo(ba, destInfo.name, destInfo.type);
if (destInfo != null) {
bDestCObj.setDestinationInfo(destInfo);
app.getInspector().selectedObjectUpdated();
}
}
Aggregations