use of com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAClusteredBroker in project openmq by eclipse-ee4j.
the class JDBCHABrokerInfoMap method get.
/**
* Retrieves the HAClusteredBroker associated with the passed in broker id. If the id is not found in the hashtable, the
* database will be checked.
*
* @param key the brokerid to lookup
* @param update update against store
* @return the HAClusteredBroker object (or null if one can't be found)
*/
@Override
public Object get(Object key, boolean update) {
Object o = super.get(key);
if (o == null || update) {
try {
HABrokerInfo m = Globals.getStore().getBrokerInfo((String) key);
if (m != null && o == null) {
HAClusteredBroker cb = new HAClusteredBrokerImpl((String) key, m, parent);
put(key, cb);
parent.brokerChanged(ClusterReason.ADDED, cb.getBrokerName(), null, cb, cb.getBrokerSessionUID(), null);
o = cb;
}
if (m != null && update) {
((HAClusteredBrokerImpl) o).update(m);
}
} catch (BrokerException ex) {
Globals.getLogger().logStack(Logger.WARNING, "Exception while creating broker entry " + key, ex);
}
}
return o;
}
use of com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAClusteredBroker in project openmq by eclipse-ee4j.
the class SFSHABrokerInfoMap method updateHAMapForState.
private void updateHAMapForState(BrokerState state) throws BrokerException {
Map map = null;
if (state == null) {
map = Globals.getStore().getAllBrokerInfos();
} else {
map = Globals.getStore().getAllBrokerInfoByState(state);
}
Iterator itr = map.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry entry = (Map.Entry) itr.next();
String key = (String) entry.getKey();
HABrokerInfo bi = (HABrokerInfo) entry.getValue();
HAClusteredBrokerImpl impl = (HAClusteredBrokerImpl) get(key);
if (impl == null) {
HAClusteredBroker cb = new SFSHAClusteredBrokerImpl(bi.getId(), bi, parent);
put(key, cb);
parent.brokerChanged(ClusterReason.ADDED, cb.getBrokerName(), null, cb, cb.getBrokerSessionUID(), null);
} else {
impl.update(bi);
}
}
if (state == null) {
itr = entrySet().iterator();
while (itr.hasNext()) {
Map.Entry entry = (Map.Entry) itr.next();
String key = (String) entry.getKey();
if (!map.containsKey(key)) {
itr.remove();
HAClusteredBrokerImpl impl = (HAClusteredBrokerImpl) entry.getValue();
parent.brokerChanged(ClusterReason.REMOVED, impl.getBrokerName(), impl, null, impl.getBrokerSessionUID(), null);
}
}
}
}
Aggregations