You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/11/26 15:13:28 UTC

svn commit: r1413634 - in /karaf/cellar/branches/cellar-2.2.x: bundle/src/main/java/org/apache/karaf/cellar/bundle/ config/src/main/java/org/apache/karaf/cellar/config/ features/src/main/java/org/apache/karaf/cellar/features/

Author: jbonofre
Date: Mon Nov 26 14:13:26 2012
New Revision: 1413634

URL: http://svn.apache.org/viewvc?rev=1413634&view=rev
Log:
[KARAF-2033] Local listeners now check if sync is enable

Modified:
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
    karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
    karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
    karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
    karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
    karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
    karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
    karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java?rev=1413634&r1=1413633&r2=1413634&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java Mon Nov 26 14:13:26 2012
@@ -14,11 +14,15 @@
 package org.apache.karaf.cellar.bundle;
 
 import org.apache.karaf.cellar.core.CellarSupport;
+import org.apache.karaf.cellar.core.Configurations;
+import org.apache.karaf.cellar.core.Group;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
+import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 
+import java.io.IOException;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Properties;
@@ -127,6 +131,24 @@ public class BundleSupport extends Cella
         }
     }
 
+    public Boolean isSyncEnabled(Group group) {
+        Boolean result = Boolean.FALSE;
+        String groupName = group.getName();
+
+        try {
+            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
+            Dictionary<String, String> properties = configuration.getProperties();
+            if (properties != null) {
+                String propertyKey = groupName + Configurations.SEPARATOR + Constants.CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
+                String propertyValue = properties.get(propertyKey);
+                result = Boolean.parseBoolean(propertyValue);
+            }
+        } catch (IOException e) {
+            LOGGER.error("CELLAR BUNDLE: failed to check if sync is enabled", e);
+        }
+        return result;
+    }
+
     /**
      * Returns the {@link BundleContext}.
      *

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java?rev=1413634&r1=1413633&r2=1413634&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java Mon Nov 26 14:13:26 2012
@@ -24,13 +24,9 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleReference;
-import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -176,24 +172,6 @@ public class BundleSynchronizer extends 
         }
     }
 
-    public Boolean isSyncEnabled(Group group) {
-        Boolean result = Boolean.FALSE;
-        String groupName = group.getName();
-
-        try {
-            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
-            Dictionary<String, String> properties = configuration.getProperties();
-            if (properties != null) {
-                String propertyKey = groupName + Configurations.SEPARATOR + Constants.CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
-                String propertyValue = properties.get(propertyKey);
-                result = Boolean.parseBoolean(propertyValue);
-            }
-        } catch (IOException e) {
-            LOGGER.error("CELLAR BUNDLE: failed to check if sync is enabled", e);
-        }
-        return result;
-    }
-
     public EventProducer getEventProducer() {
         return eventProducer;
     }

Modified: karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java?rev=1413634&r1=1413633&r2=1413634&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java Mon Nov 26 14:13:26 2012
@@ -15,7 +15,6 @@ package org.apache.karaf.cellar.bundle;
 
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
-import org.apache.karaf.cellar.core.Node;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
@@ -24,7 +23,6 @@ import org.osgi.framework.BundleListener
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -59,41 +57,46 @@ public class LocalBundleListener extends
             if (groups != null && !groups.isEmpty()) {
                 for (Group group : groups) {
 
-                    String name = (String) event.getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME);
-                    String symbolicName = event.getBundle().getSymbolicName();
-                    String version = event.getBundle().getVersion().toString();
-                    String bundleLocation = event.getBundle().getLocation();
-                    int type = event.getType();
-                    if (isAllowed(group, Constants.CATEGORY, bundleLocation, EventType.OUTBOUND)) {
-
-                        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
-                        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-
-                        try {
-                            // update the cluster map
-                            Map<String, BundleState> bundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + group.getName());
-                            if (type == BundleEvent.UNINSTALLED) {
-                                bundles.remove(symbolicName + "/" + version);
-                            } else {
-                                BundleState state = bundles.get(symbolicName + "/" + version);
-                                if (state == null) {
-                                    state = new BundleState();
+                    if (isSyncEnabled(group)) {
+
+                        String name = (String) event.getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME);
+                        String symbolicName = event.getBundle().getSymbolicName();
+                        String version = event.getBundle().getVersion().toString();
+                        String bundleLocation = event.getBundle().getLocation();
+                        int type = event.getType();
+                        if (isAllowed(group, Constants.CATEGORY, bundleLocation, EventType.OUTBOUND)) {
+
+                            ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+                            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+
+                            try {
+                                // update the cluster map
+                                Map<String, BundleState> bundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + group.getName());
+                                if (type == BundleEvent.UNINSTALLED) {
+                                    bundles.remove(symbolicName + "/" + version);
+                                } else {
+                                    BundleState state = bundles.get(symbolicName + "/" + version);
+                                    if (state == null) {
+                                        state = new BundleState();
+                                    }
+                                    state.setName(name);
+                                    state.setStatus(type);
+                                    state.setLocation(bundleLocation);
+                                    bundles.put(symbolicName + "/" + version, state);
                                 }
-                                state.setName(name);
-                                state.setStatus(type);
-                                state.setLocation(bundleLocation);
-                                bundles.put(symbolicName + "/" + version, state);
-                            }
 
-                            // broadcast the cluster event
-                            RemoteBundleEvent remoteBundleEvent = new RemoteBundleEvent(symbolicName, version, bundleLocation, type);
-                            remoteBundleEvent.setSourceGroup(group);
-                            eventProducer.produce(remoteBundleEvent);
-                        } finally {
-                            Thread.currentThread().setContextClassLoader(originalClassLoader);
-                        }
+                                // broadcast the cluster event
+                                RemoteBundleEvent remoteBundleEvent = new RemoteBundleEvent(symbolicName, version, bundleLocation, type);
+                                remoteBundleEvent.setSourceGroup(group);
+                                eventProducer.produce(remoteBundleEvent);
+                            } finally {
+                                Thread.currentThread().setContextClassLoader(originalClassLoader);
+                            }
 
-                    } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED OUTBOUND", bundleLocation);
+                        } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED OUTBOUND", bundleLocation);
+                    } else {
+                        LOGGER.info("CELLAR BUNDLE: sync is disabled for cluster group " + group.getName());
+                    }
                 }
             }
         }

Modified: karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java?rev=1413634&r1=1413633&r2=1413634&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java Mon Nov 26 14:13:26 2012
@@ -14,6 +14,8 @@
 package org.apache.karaf.cellar.config;
 
 import org.apache.karaf.cellar.core.CellarSupport;
+import org.apache.karaf.cellar.core.Configurations;
+import org.apache.karaf.cellar.core.Group;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 
@@ -201,4 +203,21 @@ public class ConfigurationSupport extend
         this.storage = storage;
     }
 
+    public Boolean isSyncEnabled(Group group) {
+        Boolean result = Boolean.FALSE;
+        String groupName = group.getName();
+        try {
+            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
+            Dictionary<String, String> properties = configuration.getProperties();
+            if (properties != null) {
+                String propertyKey = groupName + Configurations.SEPARATOR + Constants.CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
+                String propertyValue = properties.get(propertyKey);
+                result = Boolean.parseBoolean(propertyValue);
+            }
+        } catch (IOException e) {
+            LOGGER.error("CELLAR CONFIG: failed to check if sync is enabled", e);
+        }
+        return result;
+    }
+
 }

Modified: karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java?rev=1413634&r1=1413633&r2=1413634&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java Mon Nov 26 14:13:26 2012
@@ -26,8 +26,6 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
@@ -155,23 +153,6 @@ public class ConfigurationSynchronizer e
         }
     }
 
-    public Boolean isSyncEnabled(Group group) {
-        Boolean result = Boolean.FALSE;
-        String groupName = group.getName();
-        try {
-            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
-            Dictionary<String, String> properties = configuration.getProperties();
-            if (properties != null) {
-                String propertyKey = groupName + Configurations.SEPARATOR + Constants.CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
-                String propertyValue = properties.get(propertyKey);
-                result = Boolean.parseBoolean(propertyValue);
-            }
-        } catch (IOException e) {
-            LOGGER.error("CELLAR CONFIG: failed to check if sync is enabled", e);
-        }
-        return result;
-    }
-
     public EventProducer getEventProducer() {
         return eventProducer;
     }

Modified: karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java?rev=1413634&r1=1413633&r2=1413634&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java Mon Nov 26 14:13:26 2012
@@ -15,18 +15,15 @@ package org.apache.karaf.cellar.config;
 
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
-import org.apache.karaf.cellar.core.Node;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
-import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationEvent;
 import org.osgi.service.cm.ConfigurationListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
 import java.util.Dictionary;
 import java.util.Map;
 import java.util.Properties;
@@ -72,42 +69,48 @@ public class LocalConfigurationListener 
 
         if (groups != null && !groups.isEmpty()) {
             for (Group group : groups) {
-                // check if the pid is allowed for outbound.
-                if (isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
 
-                    // update the distributed map if needed
-                    Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + group.getName());
+                if (isSyncEnabled(group)) {
 
-                    // broadcast the cluster event
-                    try {
-                        if (event.getType() == ConfigurationEvent.CM_DELETED) {
-                            // update the distributed map
-                            distributedConfigurations.remove(pid);
-                            // broadcast the cluster event
-                            RemoteConfigurationEvent remoteConfigurationEvent = new RemoteConfigurationEvent(pid);
-                            remoteConfigurationEvent.setType(ConfigurationEvent.CM_DELETED);
-                            remoteConfigurationEvent.setSourceNode(clusterManager.getNode());
-                            remoteConfigurationEvent.setSourceGroup(group);
-                            eventProducer.produce(remoteConfigurationEvent);
-                        } else {
-                            localDictionary = filter(localDictionary);
+                    // check if the pid is allowed for outbound.
+                    if (isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
 
-                            Properties distributedDictionary = distributedConfigurations.get(pid);
+                        // update the distributed map if needed
+                        Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + group.getName());
 
-                            if (!equals(localDictionary, distributedDictionary)) {
+                        // broadcast the cluster event
+                        try {
+                            if (event.getType() == ConfigurationEvent.CM_DELETED) {
                                 // update the distributed map
-                                distributedConfigurations.put(pid, dictionaryToProperties(localDictionary));
+                                distributedConfigurations.remove(pid);
                                 // broadcast the cluster event
                                 RemoteConfigurationEvent remoteConfigurationEvent = new RemoteConfigurationEvent(pid);
-                                remoteConfigurationEvent.setSourceGroup(group);
+                                remoteConfigurationEvent.setType(ConfigurationEvent.CM_DELETED);
                                 remoteConfigurationEvent.setSourceNode(clusterManager.getNode());
+                                remoteConfigurationEvent.setSourceGroup(group);
                                 eventProducer.produce(remoteConfigurationEvent);
+                            } else {
+                                localDictionary = filter(localDictionary);
+
+                                Properties distributedDictionary = distributedConfigurations.get(pid);
+
+                                if (!equals(localDictionary, distributedDictionary)) {
+                                    // update the distributed map
+                                    distributedConfigurations.put(pid, dictionaryToProperties(localDictionary));
+                                    // broadcast the cluster event
+                                    RemoteConfigurationEvent remoteConfigurationEvent = new RemoteConfigurationEvent(pid);
+                                    remoteConfigurationEvent.setSourceGroup(group);
+                                    remoteConfigurationEvent.setSourceNode(clusterManager.getNode());
+                                    eventProducer.produce(remoteConfigurationEvent);
+                                }
                             }
+                        } catch (Exception e) {
+                            LOGGER.error("CELLAR CONFIG: failed to push configuration with PID {} to the distributed map", pid, e);
                         }
-                    } catch (Exception e) {
-                        LOGGER.error("CELLAR CONFIG: failed to push configuration with PID {} to the distributed map", pid, e);
-                    }
-                } else LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked as BLOCKED OUTBOUND", pid);
+                    } else LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked as BLOCKED OUTBOUND", pid);
+                } else {
+                    LOGGER.info("CELLAR CONFIG: sync is disabled for cluster group " + group.getName());
+                }
             }
         }
     }

Modified: karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java?rev=1413634&r1=1413633&r2=1413634&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java Mon Nov 26 14:13:26 2012
@@ -20,10 +20,13 @@ import org.apache.karaf.cellar.core.even
 import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService;
 import org.apache.karaf.features.Repository;
+import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
 import java.net.URI;
+import java.util.Dictionary;
 import java.util.List;
 import java.util.Map;
 
@@ -146,6 +149,25 @@ public class FeaturesSupport extends Cel
             repositories.remove(uri.toString());
         }
     }
+
+    public Boolean isSyncEnabled(Group group) {
+        Boolean result = Boolean.FALSE;
+        String groupName = group.getName();
+
+        try {
+            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
+            Dictionary<String, String> properties = configuration.getProperties();
+            if (properties != null) {
+                String propertyKey = groupName + Configurations.SEPARATOR + Constants.FEATURES_CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
+                String propertyValue = properties.get(propertyKey);
+                result = Boolean.parseBoolean(propertyValue);
+            }
+        } catch (IOException e) {
+            LOGGER.warn("CELLAR FEATURES: error while checking if sync is enabled", e);
+        }
+        return result;
+    }
+
     public FeaturesService getFeaturesService() {
         return featuresService;
     }

Modified: karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java?rev=1413634&r1=1413633&r2=1413634&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java Mon Nov 26 14:13:26 2012
@@ -17,19 +17,15 @@ import org.apache.karaf.cellar.core.Clus
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
 import org.apache.karaf.cellar.core.Synchronizer;
-import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
 import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService;
 import org.apache.karaf.features.Repository;
-import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URI;
-import java.util.Dictionary;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -171,24 +167,6 @@ public class FeaturesSynchronizer extend
         }
     }
 
-    public Boolean isSyncEnabled(Group group) {
-        Boolean result = Boolean.FALSE;
-        String groupName = group.getName();
-
-        try {
-            Configuration configuration = configurationAdmin.getConfiguration(Configurations.GROUP);
-            Dictionary<String, String> properties = configuration.getProperties();
-            if (properties != null) {
-                String propertyKey = groupName + Configurations.SEPARATOR + Constants.FEATURES_CATEGORY + Configurations.SEPARATOR + Configurations.SYNC;
-                String propertyValue = properties.get(propertyKey);
-                result = Boolean.parseBoolean(propertyValue);
-            }
-        } catch (IOException e) {
-            LOGGER.warn("CELLAR FEATURES: error while checking if sync is enabled", e);
-        }
-        return result;
-    }
-
     public ClusterManager getCollectionManager() {
         return clusterManager;
     }

Modified: karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java?rev=1413634&r1=1413633&r2=1413634&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java Mon Nov 26 14:13:26 2012
@@ -15,7 +15,6 @@ package org.apache.karaf.cellar.features
 
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
-import org.apache.karaf.cellar.core.Node;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 import org.apache.karaf.cellar.core.event.EventType;
@@ -25,7 +24,6 @@ import org.apache.karaf.features.Reposit
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -67,25 +65,30 @@ public class LocalFeaturesListener exten
             if (groups != null && !groups.isEmpty()) {
                 for (Group group : groups) {
 
-                    Feature feature = event.getFeature();
-                    String name = feature.getName();
-                    String version = feature.getVersion();
-
-                    if (isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND)) {
-                        FeatureEvent.EventType type = event.getType();
-
-                        // update the distributed map
-                        if (FeatureEvent.EventType.FeatureInstalled.equals(event.getType())) {
-                            pushFeature(event.getFeature(), group, true);
-                        } else {
-                            pushFeature(event.getFeature(), group, false);
-                        }
+                    if (isSyncEnabled(group)) {
+
+                        Feature feature = event.getFeature();
+                        String name = feature.getName();
+                        String version = feature.getVersion();
+
+                        if (isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND)) {
+                            FeatureEvent.EventType type = event.getType();
+
+                            // update the distributed map
+                            if (FeatureEvent.EventType.FeatureInstalled.equals(event.getType())) {
+                                pushFeature(event.getFeature(), group, true);
+                            } else {
+                                pushFeature(event.getFeature(), group, false);
+                            }
 
-                        // broadcast the cluster event
-                        RemoteFeaturesEvent featureEvent = new RemoteFeaturesEvent(name, version, type);
-                        featureEvent.setSourceGroup(group);
-                        eventProducer.produce(featureEvent);
-                    } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED OUTBOUND", name);
+                            // broadcast the cluster event
+                            RemoteFeaturesEvent featureEvent = new RemoteFeaturesEvent(name, version, type);
+                            featureEvent.setSourceGroup(group);
+                            eventProducer.produce(featureEvent);
+                        } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED OUTBOUND", name);
+                    } else {
+                        LOGGER.info("CELLAR FEATURES: sync is disabled for cluster group " + group.getName());
+                    }
                 }
             }
         }
@@ -112,49 +115,55 @@ public class LocalFeaturesListener exten
 
                 if (groups != null && !groups.isEmpty()) {
                     for (Group group : groups) {
-                        RemoteRepositoryEvent repositoryEvent = new RemoteRepositoryEvent(event.getRepository().getURI().toString(), event.getType());
-                        repositoryEvent.setSourceGroup(group);
-                        RepositoryEvent.EventType type = event.getType();
-
-                        // update the distributed map
-                        if (RepositoryEvent.EventType.RepositoryAdded.equals(type)) {
-                            pushRepository(event.getRepository(), group);
-                            // update the feature map
-                            Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName());
-                            try {
-                                for (Feature feature : event.getRepository().getFeatures()) {
-                                    // check the feature in the distributed map
-                                    FeatureInfo featureInfo = null;
-                                    for (FeatureInfo distributedFeature : distributedFeatures.keySet()) {
-                                        if (distributedFeature.getName().equals(feature.getName()) && distributedFeature.getVersion().equals(feature.getVersion())) {
-                                            featureInfo = distributedFeature;
-                                            break;
+
+                        if (isSyncEnabled(group)) {
+
+                            RemoteRepositoryEvent repositoryEvent = new RemoteRepositoryEvent(event.getRepository().getURI().toString(), event.getType());
+                            repositoryEvent.setSourceGroup(group);
+                            RepositoryEvent.EventType type = event.getType();
+
+                            // update the distributed map
+                            if (RepositoryEvent.EventType.RepositoryAdded.equals(type)) {
+                                pushRepository(event.getRepository(), group);
+                                // update the feature map
+                                Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName());
+                                try {
+                                    for (Feature feature : event.getRepository().getFeatures()) {
+                                        // check the feature in the distributed map
+                                        FeatureInfo featureInfo = null;
+                                        for (FeatureInfo distributedFeature : distributedFeatures.keySet()) {
+                                            if (distributedFeature.getName().equals(feature.getName()) && distributedFeature.getVersion().equals(feature.getVersion())) {
+                                                featureInfo = distributedFeature;
+                                                break;
+                                            }
+                                        }
+                                        if (featureInfo == null) {
+                                            featureInfo = new FeatureInfo(feature.getName(), feature.getVersion());
+                                            distributedFeatures.put(featureInfo, false);
                                         }
                                     }
-                                    if (featureInfo == null) {
-                                        featureInfo = new FeatureInfo(feature.getName(), feature.getVersion());
-                                        distributedFeatures.put(featureInfo, false);
+                                } catch (Exception e) {
+                                    LOGGER.warn("CELLAR FEATURES: can't update the distributed features map", e);
+                                }
+                            } else {
+                                removeRepository(event.getRepository(), group);
+                                // update the feature map
+                                Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName());
+                                try {
+                                    for (Feature feature : event.getRepository().getFeatures()) {
+                                        FeatureInfo info = new FeatureInfo(feature.getName(), feature.getVersion());
+                                        distributedFeatures.remove(info);
                                     }
+                                } catch (Exception e) {
+                                    LOGGER.warn("CELLAR FEATURES: can't update the distributed features map", e);
                                 }
-                            } catch (Exception e) {
-                                LOGGER.warn("CELLAR FEATURES: can't update the distributed features map", e);
                             }
+
+                            // broadcast the cluster event
+                            eventProducer.produce(repositoryEvent);
                         } else {
-                            removeRepository(event.getRepository(), group);
-                            // update the feature map
-                            Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName());
-                            try {
-                                for (Feature feature : event.getRepository().getFeatures()) {
-                                    FeatureInfo info = new FeatureInfo(feature.getName(), feature.getVersion());
-                                    distributedFeatures.remove(info);
-                                }
-                            } catch (Exception e) {
-                                LOGGER.warn("CELLAR FEATURES: can't update the distributed features map", e);
-                            }
+                            LOGGER.info("CELLAR FEATURES: sync is disabled for cluster group " + group.getName());
                         }
-
-                        // broadcast the cluster event
-                        eventProducer.produce(repositoryEvent);
                     }
                 }
             }