use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class BrokerDestPropsDialog method doOK.
@Override
public void doOK() {
BrokerAdminEvent bae = new BrokerAdminEvent(this, BrokerAdminEvent.UPDATE_DEST);
DestinationInfo destInfo = getUpdateDestinationInfo();
bae.setDestinationInfo(destInfo);
bae.setOKAction(true);
fireAdminEventDispatched(bae);
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class BrokerDestPropsDialog method getUpdateDestinationInfo.
private DestinationInfo getUpdateDestinationInfo() {
int activeConsumers = -1;
int failoverConsumers = -1;
int maxProducers = -1;
long mesgSizeLimitValue = -1;
int mesgLimitValue = -1;
long maxSizePerMsgValue = -1;
boolean useDMQ;
int limitBehavior;
DestinationInfo updateDestInfo = new DestinationInfo();
if (DestType.isQueue(destInfo.type)) {
/*
* Max Active Consumers
*/
if (activeConsumerSF.isSpecialValueSet()) {
activeConsumers = UNLIMITED_VALUE_NEG1;
} else {
activeConsumers = Integer.parseInt(activeConsumerIF.getText());
}
if (activeConsumers != destInfo.maxActiveConsumers) {
updateDestInfo.setMaxActiveConsumers(activeConsumers);
}
/*
* Max Backup Consumers
*/
if (failoverConsumerSF.isSpecialValueSet()) {
failoverConsumers = UNLIMITED_VALUE_NEG1;
} else {
failoverConsumers = Integer.parseInt(failoverConsumerIF.getText());
}
if (failoverConsumers != destInfo.maxFailoverConsumers) {
updateDestInfo.setMaxFailoverConsumers(failoverConsumers);
}
}
/*
* Max Producers
*/
if (maxProducerSF.isSpecialValueSet()) {
maxProducers = UNLIMITED_VALUE_NEG1;
} else {
maxProducers = Integer.parseInt(maxProducerIF.getText());
}
if (maxProducers != destInfo.maxProducers) {
updateDestInfo.setMaxProducers(maxProducers);
}
/*
* Max Total Message Bytes
*/
if (mesgSizeLimitSF.isSpecialValueSet()) {
mesgSizeLimitValue = UNLIMITED_VALUE_NEG1;
} else {
mesgSizeLimitValue = mesgSizeLimitBF.getValue();
}
if (mesgSizeLimitValue != destInfo.maxMessageBytes) {
updateDestInfo.setMaxMessageBytes(mesgSizeLimitValue);
}
/*
* Max Number of Messages
*/
if (mesgLimitSF.isSpecialValueSet()) {
mesgLimitValue = UNLIMITED_VALUE_NEG1;
} else {
mesgLimitValue = Integer.parseInt(mesgLimitIF.getText());
}
if (mesgLimitValue != destInfo.maxMessages) {
updateDestInfo.setMaxMessages(mesgLimitValue);
}
/*
* Max Bytes per Messages
*/
if (maxSizePerMsgSF.isSpecialValueSet()) {
maxSizePerMsgValue = UNLIMITED_VALUE_NEG1;
} else {
maxSizePerMsgValue = maxSizePerMsgBF.getValue();
}
if (maxSizePerMsgValue != destInfo.maxMessageSize) {
updateDestInfo.setMaxMessageSize(maxSizePerMsgValue);
}
/*
* Limit behavior
*/
limitBehavior = getLimitBehavValue((String) limitBehaviorCb.getSelectedItem());
if (limitBehavior != destInfo.destLimitBehavior) {
updateDestInfo.setLimitBehavior(limitBehavior);
}
/*
* Use DMQ
*/
useDMQ = useDMQCkb.isSelected();
if (useDMQ != destInfo.useDMQ()) {
updateDestInfo.setUseDMQ(useDMQ);
}
return (updateDestInfo);
}
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 CmdRunner method listDests.
private void listDests(BrokerCmdProperties brokerCmdProps, Vector dests, int listType) {
BrokerCmdPrinter bcp = setupListDestTitle(listType);
String[] row = new String[12];
Enumeration thisEnum = dests.elements();
while (thisEnum.hasMoreElements()) {
DestinationInfo dInfo = (DestinationInfo) thisEnum.nextElement();
int j = 0, numMsgs;
long totalMsgSize;
float avgMsgSize = 0;
String destType;
if (MessageType.JMQ_ADMIN_DEST.equals(dInfo.name) || MessageType.JMQ_BRIDGE_ADMIN_DEST.equals(dInfo.name))
continue;
if (DestType.isInternal(dInfo.fulltype))
continue;
// differentiate it.
if (DestType.isTemporary(dInfo.type)) {
if (brokerCmdProps.showTempDestModeSet()) {
destType = BrokerAdminUtil.getDestinationType(dInfo.type) + " (" + ar.getString(ar.I_TEMPORARY) + ")";
} else {
continue;
}
} else {
destType = BrokerAdminUtil.getDestinationType(dInfo.type);
}
if ((listType == LIST_TOPIC) && !DestType.isTopic(dInfo.type)) {
continue;
}
if ((listType == LIST_QUEUE) && !DestType.isQueue(dInfo.type)) {
continue;
}
/*
* get total msgs, calculate average size
*/
numMsgs = dInfo.nMessages - dInfo.nTxnMessages;
totalMsgSize = dInfo.nMessageBytes;
if (numMsgs > 0) {
avgMsgSize = (float) totalMsgSize / (float) numMsgs;
}
row[j++] = dInfo.name;
row[j++] = destType;
// row[j++] = DestState.toString(dInfo.destState);
row[j++] = BrokerAdminUtil.getDestinationState(dInfo.destState);
row[j++] = Integer.toString(dInfo.nProducers);
if (listType != LIST_QUEUE) {
if (DestType.isTopic(dInfo.type)) {
/*
* For topics, show number of producer wildcards, if any.
*/
Hashtable h = dInfo.producerWildcards;
row[j++] = Integer.toString(getWildcardCount(h));
} else {
/*
* Wildcards not applicable for queues.
*/
row[j++] = "-";
}
}
/*
* Use cases: list dst -t t -> show total consumers -> show total wildcard consumers list dst -t q -> show active/backup
* consumers list dst -> show total consumers -> show total wildcard consumers for topics -> show "-" for queues
*/
if (DestType.isTopic(dInfo.type)) {
row[j++] = Integer.toString(dInfo.nConsumers);
/*
* For topics, show number of producer wildcards, if any.
*/
Hashtable h = dInfo.consumerWildcards;
row[j++] = Integer.toString(getWildcardCount(h));
} else {
if (listType == LIST_QUEUE) {
row[j++] = Integer.toString(dInfo.naConsumers);
row[j++] = Integer.toString(dInfo.nfConsumers);
} else {
row[j++] = Integer.toString(dInfo.naConsumers + dInfo.nfConsumers);
/*
* Wildcards not applicable for queues.
*/
row[j++] = "-";
}
}
row[j++] = Integer.toString(numMsgs);
row[j++] = Integer.toString(dInfo.nRemoteMessages);
row[j++] = Integer.toString(dInfo.nUnackMessages);
row[j++] = Integer.toString(dInfo.nInDelayMessages);
row[j++] = Float.toString(avgMsgSize);
bcp.add(row);
}
// Fix for bug 4495379: jmqcmd: when create queue and topic
// with same name only one is listed
// Use name+type as the key when listing.
bcp.setKeyCriteria(new int[] { 0, 1 });
bcp.println();
}
use of com.sun.messaging.jmq.util.admin.DestinationInfo in project openmq by eclipse-ee4j.
the class CmdRunner method isDestTypeTopic.
// Check to see if the dest type is topic.
private void isDestTypeTopic(BrokerAdmin broker, String destName) throws BrokerAdminException {
// Query the destination first to make sure it is topic.
// First get all the destinations and check each destination's type
// until we find the one.
// We have to do this because 'query dst' requires both the name
// and type of the destination.
broker.sendGetDestinationsMessage(null, -1);
Vector dests = broker.receiveGetDestinationsReplyMessage();
boolean found = false;
int i = 0;
while ((!found) && (i < dests.size())) {
DestinationInfo dInfo = (DestinationInfo) dests.elementAt(i);
if ((destName.equals(dInfo.name)) && (DestType.isTopic(dInfo.type)))
found = true;
i++;
}
if (!found) {
throw new BrokerAdminException(BrokerAdminException.INVALID_OPERATION);
}
}
Aggregations