- private Logger log = LoggerFactory
- .getLogger(RoutingTableImpl.class);
-
- private IClusterGlobalServices clusterGlobalServices = null;
- private RoutingTableImpl routingTableInstance = null;
- private ConcurrentMap routingTableCache = null;
- private List<RouteChangeListener> routeChangeListeners = new ArrayList<RouteChangeListener>();
- private ServiceRegistration cacheAwareRegistration = null;
-
- public RoutingTableImpl() {
- }
-
- @Override
- public void addRoute(I routeId, R route) throws RoutingTableException {
- throw new UnsupportedOperationException(" Not implemented yet!");
- }
-
- @Override
- public void addGlobalRoute(I routeId, R route) throws RoutingTableException, SystemException {
- Preconditions.checkNotNull(routeId, "addGlobalRoute: routeId cannot be null!");
- Preconditions.checkNotNull(route, "addGlobalRoute: route cannot be null!");
- try {
-
- Set<R> existingRoute = null;
- // ok does the global route is already registered ?
- if ((existingRoute = getRoutes(routeId)) == null) {
-
- if(log.isDebugEnabled()){
- log.debug("addGlobalRoute: adding a new route with id"+ routeId + " and value = "+route);
- }
- // lets start a transaction
- clusterGlobalServices.tbegin();
- Set<R> routes = new HashSet<R>();
- routes.add(route);
- routingTableCache.put(routeId, routes);
- clusterGlobalServices.tcommit();
- } else {
- throw new DuplicateRouteException(" There is already existing route " + existingRoute);
- }
-
- } catch (NotSupportedException e) {
- throw new RoutingTableException("Transaction error - while trying to create route id=" + routeId + "with route" + route, e);
- } catch (HeuristicRollbackException e) {
- throw new RoutingTableException("Transaction error - while trying to create route id=" + routeId + "with route" + route, e);
- } catch (RollbackException e) {
- throw new RoutingTableException("Transaction error - while trying to create route id=" + routeId + "with route" + route, e);
- } catch (HeuristicMixedException e) {
- throw new RoutingTableException("Transaction error - while trying to create route id=" + routeId + "with route" + route, e);
- } catch (javax.transaction.SystemException e){
- throw new SystemException ( "System error occurred - while trying to create with value",e);
+ private Logger log = LoggerFactory.getLogger(RoutingTableImpl.class);
+
+ private IClusterGlobalServices clusterGlobalServices = null;
+ private RoutingTableImpl routingTableInstance = null;
+ private ConcurrentMap routingTableCache = null;
+ private Set<RouteChangeListener> routeChangeListeners = Collections
+ .synchronizedSet(new HashSet<RouteChangeListener>());
+
+ public RoutingTableImpl() {