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());
}
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);
}
}
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);
}
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;
}
}
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);
}
Aggregations