Search in sources :

Example 16 with Destination

use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.

the class DestinationUtil method resumeAllDestinations.

public static void resumeAllDestinations() {
    Iterator[] itrs = Globals.getDestinationList().getAllDestinations(null);
    // PART
    Iterator itr = itrs[0];
    while (itr.hasNext()) {
        Destination d = (Destination) itr.next();
        if (d.isPaused()) {
            d.resumeDestination();
        }
    }
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) Iterator(java.util.Iterator)

Example 17 with Destination

use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.

the class DestinationUtil method compactAllDestinations.

public static void compactAllDestinations() throws BrokerException {
    Iterator[] itrs = Globals.getDestinationList().getAllDestinations(null);
    // PART
    Iterator itr = itrs[0];
    boolean docompact = true;
    String errMsg = null;
    BrokerResources rb = Globals.getBrokerResources();
    while (itr.hasNext()) {
        // make sure all are paused
        Destination d = (Destination) itr.next();
        /*
             * Skip internal, admin, or temp destinations. Skipping temp destinations may need to be revisited.
             */
        if (d.isInternal() || d.isAdmin() || d.isTemporary()) {
            continue;
        }
        if (!d.isPaused()) {
            docompact = false;
            String msg = rb.getString(rb.E_SOME_DESTINATIONS_NOT_PAUSED);
            errMsg = rb.getString(rb.X_COMPACT_DSTS_EXCEPTION, msg);
            throw (new BrokerException(errMsg));
        }
    }
    if (docompact) {
        itrs = Globals.getDestinationList().getAllDestinations(null);
        itr = itrs[0];
        while (itr.hasNext()) {
            Destination d = (Destination) itr.next();
            /*
                 * Skip internal, admin, or temp destinations. Skipping temp destinations may need to be revisited.
                 */
            if (d.isInternal() || d.isAdmin() || d.isTemporary()) {
                continue;
            }
            d.compact();
        }
    }
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) Iterator(java.util.Iterator) SizeString(com.sun.messaging.jmq.util.SizeString) BrokerResources(com.sun.messaging.jmq.jmsserver.resources.BrokerResources)

Example 18 with Destination

use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.

the class ConsumerUtil method getDestinationNames.

private static String[] getDestinationNames(ConsumerUID cid) {
    Consumer con = Consumer.getConsumer(cid);
    String[] ret = null;
    if (con == null) {
        return (null);
    }
    ArrayList<String> al = new ArrayList<>();
    Set dests = con.getUniqueDestinations();
    if (dests == null) {
        return null;
    }
    Iterator itr = dests.iterator();
    while (itr.hasNext()) {
        Destination dest = (Destination) itr.next();
        al.add(dest.getDestinationName());
    }
    if (al.size() > 0) {
        ret = new String[al.size()];
        ret = al.toArray(ret);
    }
    return (ret);
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) HashSet(java.util.HashSet) Set(java.util.Set) Consumer(com.sun.messaging.jmq.jmsserver.core.Consumer) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 19 with Destination

use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.

the class ConsumerUtil method getDestination.

public static Destination getDestination(ConsumerUID cid) {
    Consumer con = Consumer.getConsumer(cid);
    Destination d = null;
    if (con != null) {
        d = con.getFirstDestination();
    }
    return (d);
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) Consumer(com.sun.messaging.jmq.jmsserver.core.Consumer)

Example 20 with Destination

use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.

the class Agent method loadAllMBeans.

private void loadAllMBeans() throws MalformedObjectNameException, ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException {
    ObjectName objName;
    /*
         * Create 'one-only' MBeans in MQ as defined in 'oneOnlyMBeans' table.
         */
    for (int i = 0; i < oneOnlyMBeans.length; ++i) {
        ObjectName mbeanName = new ObjectName(oneOnlyMBeans[i][1]);
        String mbeanClassName = mbeansPkgName + "." + oneOnlyMBeans[i][0];
        Object mbean = null;
        try {
            mbean = Class.forName(mbeanClassName).getDeclaredConstructor().newInstance();
            agentRegisterMBean(mbean, mbeanName);
        } catch (Exception e) {
            String name;
            if (mbean instanceof MQMBeanReadOnly) {
                MQMBeanReadOnly mqmb = (MQMBeanReadOnly) mbean;
                name = mqmb.getMBeanName();
            } else {
                name = mbeanName.toString();
            }
            logger.log(Logger.WARNING, rb.getString(rb.W_JMX_REGISTER_MBEAN_EXCEPTION, name), e);
        }
    }
    bkrMon = new BrokerMonitor();
    objName = new ObjectName(MQObjectName.BROKER_MONITOR_MBEAN_NAME);
    agentRegisterMBean(bkrMon, objName);
    svcMgrMon = new ServiceManagerMonitor();
    objName = new ObjectName(MQObjectName.SERVICE_MANAGER_MONITOR_MBEAN_NAME);
    agentRegisterMBean(svcMgrMon, objName);
    dstMgrMon = new DestinationManagerMonitor();
    objName = new ObjectName(MQObjectName.DESTINATION_MANAGER_MONITOR_MBEAN_NAME);
    agentRegisterMBean(dstMgrMon, objName);
    cxnMgrMon = new ConnectionManagerMonitor();
    objName = new ObjectName(MQObjectName.CONNECTION_MANAGER_MONITOR_MBEAN_NAME);
    agentRegisterMBean(cxnMgrMon, objName);
    conMgrMon = new ConsumerManagerMonitor();
    objName = new ObjectName(MQObjectName.CONSUMER_MANAGER_MONITOR_MBEAN_NAME);
    agentRegisterMBean(conMgrMon, objName);
    prdMgrMon = new ProducerManagerMonitor();
    objName = new ObjectName(MQObjectName.PRODUCER_MANAGER_MONITOR_MBEAN_NAME);
    agentRegisterMBean(prdMgrMon, objName);
    txnMgrMon = new TransactionManagerMonitor();
    objName = new ObjectName(MQObjectName.TRANSACTION_MANAGER_MONITOR_MBEAN_NAME);
    agentRegisterMBean(txnMgrMon, objName);
    clsMon = new ClusterMonitor();
    objName = new ObjectName(MQObjectName.CLUSTER_MONITOR_MBEAN_NAME);
    agentRegisterMBean(clsMon, objName);
    logMon = new LogMonitor();
    objName = new ObjectName(MQObjectName.LOG_MONITOR_MBEAN_NAME);
    agentRegisterMBean(logMon, objName);
    if (msgMBeansEnabled()) {
        msgMgrMon = new MessageManagerMonitor();
        objName = new ObjectName(MESSAGE_MANAGER_MONITOR_MBEAN_NAME);
        agentRegisterMBean(msgMgrMon, objName);
        msgMgrCon = new MessageManagerConfig();
        objName = new ObjectName(MESSAGE_MANAGER_CONFIG_MBEAN_NAME);
        agentRegisterMBean(msgMgrCon, objName);
    }
    /*
         * Create DestinationMonitor MBeans
         */
    List dests = DestinationUtil.getVisibleDestinations();
    if (dests.size() != 0) {
        for (int i = 0; i < dests.size(); i++) {
            Destination d = (Destination) dests.get(i);
            registerDestination(d);
        }
    }
    /*
         * Create ServiceMonitor MBeans
         */
    List svcs = ServiceUtil.getVisibleServiceNames();
    Iterator iter = svcs.iterator();
    while (iter.hasNext()) {
        String service = (String) iter.next();
        registerService(service);
    }
    /*
         * Create MLet MBean if broker is imq.jmx.mlet.enabled is set
         */
    if (mletEnabled()) {
        try {
            ObjectName mletName = new ObjectName(MQMLET_MBEAN_NAME);
            mqMLet = new MLet();
            agentRegisterMBean(mqMLet, mletName);
            logger.log(Logger.INFO, "MLET: Registering MLet MBean");
        } catch (Exception e) {
            String name = "MQMLet";
            logger.log(Logger.WARNING, rb.getString(rb.W_JMX_REGISTER_MBEAN_EXCEPTION, name), e);
        }
        if (mqMLet != null) {
            String url = getMLetFileURL();
            if ((url != null) && (!url.equals(""))) {
                try {
                    logger.log(Logger.INFO, "MLET: Loading MBeans from MLet file: " + url);
                    Set loadedMBeans = mqMLet.getMBeansFromURL(url);
                    if (loadedMBeans != null) {
                        Iterator mb = loadedMBeans.iterator();
                        while (mb.hasNext()) {
                            Object obj = mb.next();
                            if (obj instanceof ObjectInstance) {
                                ObjectInstance objInst = (ObjectInstance) obj;
                                logger.log(Logger.INFO, "MLET: Loaded MBean [objectname=" + objInst.getObjectName().toString() + ", class=" + objInst.getClassName() + "]");
                            } else if (obj instanceof Throwable) {
                                Throwable thr = (Throwable) obj;
                                logger.log(Logger.WARNING, "MLET: Failed to load MBean: " + thr);
                            } else {
                                logger.log(Logger.WARNING, "MLET: Unknown object type returned by MLet MBean creation: " + obj);
                            }
                        }
                    }
                } catch (Exception e) {
                    logger.log(Logger.WARNING, "Exception caught while loading MBeans via MQMLet", e);
                }
            }
        }
    }
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) Set(java.util.Set) MLet(javax.management.loading.MLet) MalformedURLException(java.net.MalformedURLException) RemoteException(java.rmi.RemoteException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) Iterator(java.util.Iterator) List(java.util.List)

Aggregations

Destination (com.sun.messaging.jmq.jmsserver.core.Destination)76 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)39 Iterator (java.util.Iterator)29 DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)25 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)25 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)20 SelectorFormatException (com.sun.messaging.jmq.util.selector.SelectorFormatException)18 HashMap (java.util.HashMap)18 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)17 IOException (java.io.IOException)16 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)15 ArrayList (java.util.ArrayList)12 List (java.util.List)11 Packet (com.sun.messaging.jmq.io.Packet)9 AckEntryNotFoundException (com.sun.messaging.jmq.jmsserver.util.AckEntryNotFoundException)9 Map (java.util.Map)9 DestinationList (com.sun.messaging.jmq.jmsserver.core.DestinationList)8 SizeString (com.sun.messaging.jmq.util.SizeString)8 PartitionedStore (com.sun.messaging.jmq.jmsserver.persist.api.PartitionedStore)7 ConsumerAlreadyAddedException (com.sun.messaging.jmq.jmsserver.util.ConsumerAlreadyAddedException)7