Search in sources :

Example 6 with MQAddress

use of com.sun.messaging.jmq.io.MQAddress in project openmq by eclipse-ee4j.

the class ClusterManagerImpl method parseBrokerList.

@Override
public LinkedHashSet parseBrokerList(String values) throws MalformedURLException, UnknownHostException {
    // we want to pull out dups .. so we use a hashmap
    // with host:port as a key
    HashMap tmpMap = new LinkedHashMap();
    // OK, parse properties
    StringTokenizer st = new StringTokenizer(values, ",");
    // Parse the given broker address list.
    while (st.hasMoreTokens()) {
        String s = st.nextToken();
        MQAddress address = BrokerMQAddress.createAddress(s);
        tmpMap.put(address.toString(), address);
    }
    return new LinkedHashSet(tmpMap.values());
}
Also used : MQAddress(com.sun.messaging.jmq.io.MQAddress) BrokerMQAddress(com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress)

Example 7 with MQAddress

use of com.sun.messaging.jmq.io.MQAddress in project openmq by eclipse-ee4j.

the class ClusterManagerImpl method brokerListChanged.

/**
 * Handles reparsing the broker list if it changes.
 *
 * @throws BrokerException if something goes wrong during parsing
 */
protected void brokerListChanged() throws BrokerException {
    // OK .. get the new broker list
    LinkedHashSet s = null;
    try {
        s = parseBrokerList();
        setBrokerNextToMe(s);
        if (DEBUG) {
            logger.log(Logger.INFO, "ClusterManagerImpl.parseBrokerList:" + s);
        }
    } catch (Exception ex) {
        logger.logStack(Logger.ERROR, BrokerResources.E_INTERNAL_BROKER_ERROR, "bad address in brokerListChanged ", ex);
        s = new LinkedHashSet();
    }
    Iterator itr = s.iterator();
    while (itr.hasNext()) {
        MQAddress addr = (MQAddress) itr.next();
        if (lookupBrokerID(addr) == null) {
            addBroker(addr, false, true, null);
        }
    }
    // OK, we need to clean up the allBroker's list
    List oldBrokers = new ArrayList();
    synchronized (allBrokers) {
        itr = allBrokers.values().iterator();
        while (itr.hasNext()) {
            ClusteredBroker cb = (ClusteredBroker) itr.next();
            ((ClusteredBrokerImpl) cb).setConfigBroker(true);
            MQAddress addr = cb.getBrokerURL();
            if (s.contains(addr)) {
                s.remove(addr);
                continue;
            } else if (!cb.isLocalBroker()) {
                oldBrokers.add(cb);
                itr.remove();
            }
        }
    }
    // send out remove notifications
    itr = oldBrokers.iterator();
    while (itr.hasNext()) {
        ClusteredBroker cb = (ClusteredBroker) itr.next();
        brokerChanged(ClusterReason.REMOVED, cb.getBrokerName(), cb, null, cb.getBrokerSessionUID(), null);
        itr.remove();
    }
    // now add any remaining brokers
    itr = s.iterator();
    while (itr.hasNext()) {
        addBroker((MQAddress) itr.next(), false, true, null);
    }
}
Also used : MQAddress(com.sun.messaging.jmq.io.MQAddress) BrokerMQAddress(com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress) DestinationList(com.sun.messaging.jmq.jmsserver.core.DestinationList) MalformedURLException(java.net.MalformedURLException) UnknownHostException(java.net.UnknownHostException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Example 8 with MQAddress

use of com.sun.messaging.jmq.io.MQAddress in project openmq by eclipse-ee4j.

the class ClusterManagerImpl method masterBrokerChanged.

/**
 * Handles changing the name of the master broker.
 *
 * @param mbroker the brokerid associated with the master broker
 * @throws BrokerException if something goes wrong
 */
protected void masterBrokerChanged(String mbroker) throws BrokerException {
    // handle master broker
    ClusteredBroker oldMaster = getMasterBroker();
    masterBroker = null;
    if (mbroker != null) {
        // ok, see if we exist
        MQAddress addr = null;
        try {
            addr = BrokerMQAddress.createAddress(mbroker);
        } catch (Exception ex) {
            logger.log(Logger.ERROR, BrokerResources.W_BAD_MB, mbroker, ex);
        }
        masterBroker = lookupBrokerID(addr);
        if (masterBroker == null) {
            // wasnt in list, add it
            masterBroker = addBroker(addr, false, true, null);
        }
    }
    ClusteredBroker newMaster = getMasterBroker();
    brokerChanged(ClusterReason.MASTER_BROKER_CHANGED, null, oldMaster, newMaster, null, null);
}
Also used : MQAddress(com.sun.messaging.jmq.io.MQAddress) BrokerMQAddress(com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress) MalformedURLException(java.net.MalformedURLException) UnknownHostException(java.net.UnknownHostException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Example 9 with MQAddress

use of com.sun.messaging.jmq.io.MQAddress in project openmq by eclipse-ee4j.

the class ClusterManagerImpl method setBrokerNextToMe.

private void setBrokerNextToMe(LinkedHashSet list) {
    synchronized (brokerNextToMeLock) {
        Iterator itr = list.iterator();
        MQAddress addr = null, next = null;
        boolean foundlocal = false;
        int i = 0;
        while (itr.hasNext()) {
            addr = (MQAddress) itr.next();
            if (i == 0) {
                if (!addr.equals(getMQAddress())) {
                    next = addr;
                }
            }
            if (foundlocal) {
                next = addr;
                break;
            }
            if (addr.equals(getMQAddress())) {
                foundlocal = true;
            }
        }
        brokerNextToMe = next;
    }
}
Also used : MQAddress(com.sun.messaging.jmq.io.MQAddress) BrokerMQAddress(com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress)

Example 10 with MQAddress

use of com.sun.messaging.jmq.io.MQAddress in project openmq by eclipse-ee4j.

the class ClusteredBrokerImpl method setBrokerURL.

/**
 * sets the URL to the portmapper of this broker.
 *
 * @param address the URL of this broker
 * @throws UnsupportedOperationException if this change can not be made on this broker
 */
@Override
public void setBrokerURL(MQAddress address) throws Exception {
    MQAddress oldaddress = this.address;
    this.address = address;
    parent.brokerChanged(ClusterReason.ADDRESS_CHANGED, this.getBrokerName(), oldaddress, this.address, null, null);
}
Also used : MQAddress(com.sun.messaging.jmq.io.MQAddress)

Aggregations

MQAddress (com.sun.messaging.jmq.io.MQAddress)22 BrokerMQAddress (com.sun.messaging.jmq.jmsserver.core.BrokerMQAddress)16 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)11 MalformedURLException (java.net.MalformedURLException)4 UnknownHostException (java.net.UnknownHostException)3 MBeanException (javax.management.MBeanException)3 CompositeData (javax.management.openmbean.CompositeData)3 PropertyUpdateException (com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException)2 UID (com.sun.messaging.jmq.util.UID)2 Logger (com.sun.messaging.jmq.util.log.Logger)2 Packet (com.sun.messaging.jmq.io.Packet)1 ClusterManager (com.sun.messaging.jmq.jmsserver.cluster.api.ClusterManager)1 DestinationList (com.sun.messaging.jmq.jmsserver.core.DestinationList)1 TakeoverLockException (com.sun.messaging.jmq.jmsserver.persist.api.TakeoverLockException)1 LockFile (com.sun.messaging.jmq.jmsserver.util.LockFile)1 StoreBeingTakenOverException (com.sun.messaging.jmq.jmsserver.util.StoreBeingTakenOverException)1 PUService (com.sun.messaging.portunif.PUService)1 Properties (java.util.Properties)1 Set (java.util.Set)1 OpenDataException (javax.management.openmbean.OpenDataException)1