Repository: karaf-cellar
Updated Branches:
  refs/heads/master 01422f1be -> f734e334f


[KARAF-3981] Beginning of the refactoring of the synchronizer with new policies 
and better behaviors


Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/f734e334
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/f734e334
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/f734e334

Branch: refs/heads/master
Commit: f734e334f92f710896fa0662dcb83a35b0a8b58b
Parents: 01422f1
Author: Jean-Baptiste Onofré <[email protected]>
Authored: Fri Sep 11 18:20:27 2015 +0200
Committer: Jean-Baptiste Onofré <[email protected]>
Committed: Fri Sep 11 18:20:27 2015 +0200

----------------------------------------------------------------------
 .../karaf/cellar/bundle/BundleEventHandler.java |  44 +++---
 .../karaf/cellar/bundle/BundleSupport.java      |  20 +++
 .../karaf/cellar/bundle/BundleSynchronizer.java | 134 ++++++++++++-------
 .../cellar/bundle/LocalBundleListener.java      |  11 +-
 .../cellar/bundle/internal/osgi/Activator.java  |   1 +
 .../internal/CellarBundleMBeanImpl.java         |  53 +++-----
 .../karaf/cellar/bundle/shell/BlockCommand.java |   2 +-
 .../bundle/shell/BundleCommandSupport.java      |  25 ++--
 .../bundle/shell/InstallBundleCommand.java      |  14 +-
 .../cellar/bundle/shell/ListBundleCommand.java  |  19 ++-
 .../cellar/bundle/shell/StartBundleCommand.java |   8 +-
 .../cellar/bundle/shell/StopBundleCommand.java  |   8 +-
 .../bundle/shell/UninstallBundleCommand.java    |   6 +-
 .../karaf/cellar/hazelcast/QueueProducer.java   |   4 +-
 .../karaf/cellar/hazelcast/TopicProducer.java   |   4 +-
 15 files changed, 196 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
index 43a8c51..4b2700b 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
@@ -20,7 +20,7 @@ import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventHandler;
 import org.apache.karaf.cellar.core.event.EventType;
 import org.apache.karaf.features.Feature;
-import org.osgi.framework.BundleEvent;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
@@ -38,7 +38,7 @@ public class BundleEventHandler extends BundleSupport 
implements EventHandler<Cl
     public static final String SWITCH_ID = 
"org.apache.karaf.cellar.bundle.handler";
 
     private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
-    
+
     /**
      * Handle received bundle cluster events.
      *
@@ -52,7 +52,7 @@ public class BundleEventHandler extends BundleSupport 
implements EventHandler<Cl
             LOGGER.debug("CELLAR BUNDLE: {} switch is OFF, cluster event is 
not handled", SWITCH_ID);
             return;
         }
-        
+
         if (groupManager == null) {
                //in rare cases for example right after installation this 
happens!
                LOGGER.error("CELLAR BUNDLE: retrieved event {} while 
groupManager is not available yet!", event);
@@ -66,33 +66,39 @@ public class BundleEventHandler extends BundleSupport 
implements EventHandler<Cl
         }
 
         try {
+            // check if it's not a "local" event
+            if (event.getSourceNode() != null && 
event.getSourceNode().getId().equalsIgnoreCase(clusterManager.getNode().getId()))
 {
+                LOGGER.debug("CELLAR BUNDLE: cluster event is local (coming 
from local synchronizer or listener)");
+                return;
+            }
             // check if the pid is marked as local.
             if (isAllowed(event.getSourceGroup(), Constants.CATEGORY, 
event.getLocation(), EventType.INBOUND)) {
-               // check the features first
-               List<Feature> matchingFeatures = 
retrieveFeature(event.getLocation());
-               for (Feature feature : matchingFeatures) {
-                                       if (!isAllowed(event.getSourceGroup(), 
"features", feature.getName(), EventType.INBOUND)) {
-                                               LOGGER.trace("CELLAR BUNDLE: 
bundle {} is contained in feature {} marked BLOCKED INBOUND for cluster group 
{}", event.getLocation(), feature.getName(), event.getSourceGroup().getName());
-                                               return;
-                                       }
-                               }
-                if (event.getType() == BundleEvent.INSTALLED) {
+                // check the features first
+                List<Feature> matchingFeatures = 
retrieveFeature(event.getLocation());
+                for (Feature feature : matchingFeatures) {
+                    if (!isAllowed(event.getSourceGroup(), "features", 
feature.getName(), EventType.INBOUND)) {
+                        LOGGER.trace("CELLAR BUNDLE: bundle {} is contained in 
feature {} marked BLOCKED INBOUND for cluster group {}", event.getLocation(), 
feature.getName(), event.getSourceGroup().getName());
+                        return;
+                    }
+                }
+                if (event.getType() == Bundle.INSTALLED) {
                     installBundleFromLocation(event.getLocation());
                     LOGGER.debug("CELLAR BUNDLE: installing {}/{}", 
event.getSymbolicName(), event.getVersion());
-                } else if (event.getType() == BundleEvent.UNINSTALLED) {
+                } else if (event.getType() == Bundle.UNINSTALLED) {
                     uninstallBundle(event.getSymbolicName(), 
event.getVersion());
                     LOGGER.debug("CELLAR BUNDLE: uninstalling {}/{}", 
event.getSymbolicName(), event.getVersion());
-                } else if (event.getType() == BundleEvent.STARTED) {
+                } else if (event.getType() == Bundle.ACTIVE) {
+                    if (!isInstalled(event.getLocation())) {
+                        installBundleFromLocation(event.getLocation());
+                    }
                     startBundle(event.getSymbolicName(), event.getVersion());
                     LOGGER.debug("CELLAR BUNDLE: starting {}/{}", 
event.getSymbolicName(), event.getVersion());
-                } else if (event.getType() == BundleEvent.STOPPED) {
+                } else if (event.getType() == Bundle.RESOLVED) {
                     stopBundle(event.getSymbolicName(), event.getVersion());
                     LOGGER.debug("CELLAR BUNDLE: stopping {}/{}", 
event.getSymbolicName(), event.getVersion());
-                } else if (event.getType() == BundleEvent.UPDATED) {
-                    updateBundle(event.getSymbolicName(), event.getVersion());
-                    LOGGER.debug("CELLAR BUNDLE: updating {}/{}", 
event.getSymbolicName(), event.getVersion());
                 }
-            } else LOGGER.trace("CELLAR BUNDLE: bundle {} is marked BLOCKED 
INBOUND for cluster group {}", event.getSymbolicName(), 
event.getSourceGroup().getName());
+            } else
+                LOGGER.trace("CELLAR BUNDLE: bundle {} is marked BLOCKED 
INBOUND for cluster group {}", event.getSymbolicName(), 
event.getSourceGroup().getName());
         } catch (BundleException e) {
             LOGGER.error("CELLAR BUNDLE: failed to install bundle {}/{}.", new 
Object[]{event.getSymbolicName(), event.getVersion()}, e);
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
index da649cc..b2509f7 100644
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
@@ -42,6 +42,26 @@ public class BundleSupport extends CellarSupport {
         getBundleContext().installBundle(location);
     }
 
+    public boolean isInstalled(String location) {
+        Bundle[] bundles = getBundleContext().getBundles();
+        for (Bundle bundle : bundles) {
+            if (bundle.getLocation().equals(location)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean isStarted(String location) {
+        Bundle[] bundles = getBundleContext().getBundles();
+        for (Bundle bundle : bundles) {
+            if (bundle.getLocation().equals(location) && (bundle.getState() == 
Bundle.ACTIVE)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * Locally uninstall a bundle.
      *

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
index d97a958..e8124de 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
@@ -16,12 +16,10 @@ 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.Synchronizer;
-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.Bundle;
 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;
@@ -41,6 +39,12 @@ public class BundleSynchronizer extends BundleSupport 
implements Synchronizer {
 
     private static final transient Logger LOGGER = 
LoggerFactory.getLogger(BundleSynchronizer.class);
 
+    private EventProducer eventProducer;
+
+    public void setEventProducer(EventProducer eventProducer) {
+        this.eventProducer = eventProducer;
+    }
+
     public void init() {
         if (groupManager == null)
             return;
@@ -64,19 +68,32 @@ public class BundleSynchronizer extends BundleSupport 
implements Synchronizer {
     @Override
     public void sync(Group group) {
         String policy = getSyncPolicy(group);
-        if (policy != null && policy.equalsIgnoreCase("cluster")) {
-            LOGGER.debug("CELLAR BUNDLE: sync policy is set as 'cluster' for 
cluster group " + group.getName());
-            if (clusterManager.listNodesByGroup(group).size() == 1 && 
clusterManager.listNodesByGroup(group).contains(clusterManager.getNode())) {
-                LOGGER.debug("CELLAR BUNDLE: node is the first and only member 
of the group, pushing state");
-                push(group);
-            } else {
-                LOGGER.debug("CELLAR BUNDLE: pulling state");
-                pull(group);
-            }
+        if (policy == null) {
+            LOGGER.warn("CELLAR BUNDLE: sync policy is not defined for cluster 
group " + group.getName());
         }
-        if (policy != null && policy.equalsIgnoreCase("node")) {
-            LOGGER.debug("CELLAR BUNDLE: sync policy is set as 'node' for 
cluster group " + group.getName());
+        if (policy.equalsIgnoreCase("cluster")) {
+            LOGGER.debug("CELLAR BUNDLE: sync policy set as 'cluster' for 
cluster group " + group.getName());
+            LOGGER.debug("CELLAR BUNDLE: updating node from the cluster (pull 
first)");
+            pull(group);
+            LOGGER.debug("CELLAR BUNDLE: updating cluster from the local node 
(push after)");
             push(group);
+        } else if (policy.equalsIgnoreCase("node")) {
+            LOGGER.debug("CELLAR BUNDLE: sync policy set as 'node' for cluster 
group " + group.getName());
+            LOGGER.debug("CELLAR BUNDLE: updating cluster from the local node 
(push first)");
+            push(group);
+            LOGGER.debug("CELLAR BUNDLE: updating node from the cluster (pull 
after)");
+            pull(group);
+        } else if (policy.equalsIgnoreCase("clusterOnly")) {
+            LOGGER.debug("CELLAR BUNDLE: sync policy set as 'clusterOnly' for 
cluster group " + group.getName());
+            LOGGER.debug("CELLAR BUNDLE: updating node from the cluster (pull 
only)");
+            pull(group);
+        } else if (policy.equalsIgnoreCase("nodeOnly")) {
+            LOGGER.debug("CELLAR BUNDLE: sync policy set as 'nodeOnly' for 
cluster group " + group.getName());
+            LOGGER.debug("CELLAR BUNDLE: updating cluster from the local node 
(push only)");
+            push(group);
+        } else {
+            LOGGER.debug("CELLAR BUNDLE: sync policy set as 'disabled' for 
cluster group " + group.getName());
+            LOGGER.debug("CELLAR BUNDLE: no sync");
         }
     }
 
@@ -108,11 +125,24 @@ public class BundleSynchronizer extends BundleSupport 
implements Synchronizer {
                             String bundleLocation = state.getLocation();
                             if (isAllowed(group, Constants.CATEGORY, 
bundleLocation, EventType.INBOUND)) {
                                 try {
-                                    if (state.getStatus() == 
BundleEvent.INSTALLED) {
-                                        
installBundleFromLocation(state.getLocation());
-                                    } else if (state.getStatus() == 
BundleEvent.STARTED) {
-                                        
installBundleFromLocation(state.getLocation());
-                                        startBundle(symbolicName, version);
+                                    if (state.getStatus() == Bundle.INSTALLED) 
{
+                                        if (!isInstalled(state.getLocation())) 
{
+                                            LOGGER.debug("CELLAR BUNDLE: 
installing bundle located {}", state.getLocation());
+                                            
installBundleFromLocation(state.getLocation());
+                                        } else {
+                                            LOGGER.debug("CELLAR BUNDLE: 
bundle located {} already installed on node", state.getLocation());
+                                        }
+                                    } else if (state.getStatus() == 
Bundle.ACTIVE) {
+                                        if (!isInstalled(state.getLocation())) 
{
+                                            LOGGER.debug("CELLAR BUNDLE: 
installing bundle located {}", state.getLocation());
+                                            
installBundleFromLocation(state.getLocation());
+                                        }
+                                        if (!isStarted(state.getLocation())) {
+                                            LOGGER.debug("CELLAR BUNDLE: 
starting bundle {}/{}", symbolicName, version);
+                                            startBundle(symbolicName, version);
+                                        } else {
+                                            LOGGER.debug("CELLAR BUNDLE: 
bundle located {} already started on node", state.getLocation());
+                                        }
                                     }
                                 } catch (BundleException e) {
                                     LOGGER.error("CELLAR BUNDLE: failed to 
pull bundle {}", id, e);
@@ -150,43 +180,49 @@ public class BundleSynchronizer extends BundleSupport 
implements Synchronizer {
                 for (Bundle bundle : bundles) {
                     long bundleId = bundle.getBundleId();
                     String symbolicName = bundle.getSymbolicName();
-                    String version = bundle.getVersion().toString();
+                    String version = 
bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION);
                     String bundleLocation = bundle.getLocation();
                     int status = bundle.getState();
                     String id = symbolicName + "/" + version;
 
                     // check if the pid is marked as local.
                     if (isAllowed(group, Constants.CATEGORY, bundleLocation, 
EventType.OUTBOUND)) {
-
-                        BundleState bundleState = new BundleState();
-                        // get the bundle name or location.
-                        String name = (String) 
bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME);
-                        // if there is no name, then default to symbolic name.
-                        name = (name == null) ? symbolicName : name;
-                        // if there is no symbolic name, resort to location.
-                        name = (name == null) ? bundle.getLocation() : name;
-                        bundleState.setId(bundleId);
-                        bundleState.setName(name);
-                        bundleState.setSymbolicName(symbolicName);
-                        bundleState.setVersion(version);
-                        bundleState.setLocation(bundleLocation);
-
-                        if (status == Bundle.ACTIVE)
-                            status = BundleEvent.STARTED;
-                        if (status == Bundle.INSTALLED)
-                            status = BundleEvent.INSTALLED;
-                        if (status == Bundle.RESOLVED)
-                            status = BundleEvent.RESOLVED;
-                        if (status == Bundle.STARTING)
-                            status = BundleEvent.STARTING;
-                        if (status == Bundle.UNINSTALLED)
-                            status = BundleEvent.UNINSTALLED;
-                        if (status == Bundle.STOPPING)
-                            status = BundleEvent.STARTED;
-
-                        bundleState.setStatus(status);
-
-                        clusterBundles.put(id, bundleState);
+                        if (!clusterBundles.containsKey(id)) {
+                            LOGGER.debug("CELLAR BUNDLE: deploying bundle {} 
on the cluster", id);
+                            BundleState bundleState = new BundleState();
+                            // get the bundle name or location.
+                            String name = (String) 
bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME);
+                            // if there is no name, then default to symbolic 
name.
+                            name = (name == null) ? symbolicName : name;
+                            // if there is no symbolic name, resort to 
location.
+                            name = (name == null) ? bundle.getLocation() : 
name;
+                            bundleState.setId(bundleId);
+                            bundleState.setName(name);
+                            bundleState.setSymbolicName(symbolicName);
+                            bundleState.setVersion(version);
+                            bundleState.setLocation(bundleLocation);
+                            bundleState.setStatus(status);
+                            // update cluster state
+                            clusterBundles.put(id, bundleState);
+                            // send cluster event
+                            ClusterBundleEvent clusterEvent = new 
ClusterBundleEvent(symbolicName, version, bundleLocation, status);
+                            clusterEvent.setSourceGroup(group);
+                            
clusterEvent.setSourceNode(clusterManager.getNode());
+                            eventProducer.produce(clusterEvent);
+                        } else {
+                            BundleState bundleState = clusterBundles.get(id);
+                            if (bundleState.getStatus() != status) {
+                                LOGGER.debug("CELLAR BUNDLE: updating bundle 
{} on the cluster", id);
+                                // update cluster state
+                                bundleState.setStatus(status);
+                                clusterBundles.put(id, bundleState);
+                                // send cluster event
+                                ClusterBundleEvent clusterEvent = new 
ClusterBundleEvent(symbolicName, version, bundleLocation, status);
+                                clusterEvent.setSourceGroup(group);
+                                
clusterEvent.setSourceNode(clusterManager.getNode());
+                                eventProducer.produce(clusterEvent);
+                            }
+                        }
 
                     } else LOGGER.trace("CELLAR BUNDLE: bundle {} is marked 
BLOCKED OUTBOUND for cluster group {}", bundleLocation, groupName);
                 }

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
index 39c2f56..c418c60 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
@@ -55,7 +55,7 @@ public class LocalBundleListener extends BundleSupport 
implements SynchronousBun
         }
 
         if (!isEnabled()) {
-            LOGGER.debug("CELLAR BUNDLE: local listener is disabled");
+            LOGGER.trace("CELLAR BUNDLE: local listener is disabled");
             return;
         }
 
@@ -89,7 +89,7 @@ public class LocalBundleListener extends BundleSupport 
implements SynchronousBun
                     String symbolicName = event.getBundle().getSymbolicName();
                     String version = 
event.getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION);
                     String bundleLocation = event.getBundle().getLocation();
-                    int type = event.getType();
+                    int status = event.getBundle().getState();
 
                     if (isAllowed(group, Constants.CATEGORY, bundleLocation, 
EventType.OUTBOUND)) {
 
@@ -99,7 +99,7 @@ public class LocalBundleListener extends BundleSupport 
implements SynchronousBun
                         try {
                             // update bundles in the cluster group
                             Map<String, BundleState> clusterBundles = 
clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + 
group.getName());
-                            if (type == BundleEvent.UNINSTALLED) {
+                            if (event.getType() == BundleEvent.UNINSTALLED) {
                                 clusterBundles.remove(symbolicName + "/" + 
version);
                             } else {
                                 BundleState state = 
clusterBundles.get(symbolicName + "/" + version);
@@ -110,7 +110,7 @@ public class LocalBundleListener extends BundleSupport 
implements SynchronousBun
                                 state.setName(name);
                                 state.setVersion(version);
                                 state.setSymbolicName(symbolicName);
-                                state.setStatus(type);
+                                state.setStatus(status);
                                 state.setLocation(bundleLocation);
                                 clusterBundles.put(symbolicName + "/" + 
version, state);
                             }
@@ -125,8 +125,9 @@ public class LocalBundleListener extends BundleSupport 
implements SynchronousBun
                                        }
                             
                             // broadcast the cluster event
-                            ClusterBundleEvent clusterBundleEvent = new 
ClusterBundleEvent(symbolicName, version, bundleLocation, type);
+                            ClusterBundleEvent clusterBundleEvent = new 
ClusterBundleEvent(symbolicName, version, bundleLocation, status);
                             clusterBundleEvent.setSourceGroup(group);
+                            
clusterBundleEvent.setSourceNode(clusterManager.getNode());
                             eventProducer.produce(clusterBundleEvent);
                         } catch (Exception e) {
                                LOGGER.error("CELLAR BUNDLE: failed to create 
bundle event", e);

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java
 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java
index c0d681d..d9559e5 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java
@@ -103,6 +103,7 @@ public class Activator extends BaseActivator {
         synchronizer.setGroupManager(groupManager);
         synchronizer.setClusterManager(clusterManager);
         synchronizer.setBundleContext(bundleContext);
+        synchronizer.setEventProducer(eventProducer);
         synchronizer.init();
         props = new Hashtable();
         props.put("resource", "bundle");

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java
 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java
index 231aa73..f4ccc63 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java
@@ -16,16 +16,13 @@ package org.apache.karaf.cellar.bundle.management.internal;
 import org.apache.karaf.cellar.bundle.BundleState;
 import org.apache.karaf.cellar.bundle.ClusterBundleEvent;
 import org.apache.karaf.cellar.bundle.Constants;
-import org.apache.karaf.cellar.bundle.shell.BundleCommandSupport;
 import org.apache.karaf.cellar.core.*;
-import org.apache.karaf.cellar.core.control.ManageGroupAction;
 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.apache.karaf.cellar.bundle.management.CellarBundleMBean;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
 import org.osgi.service.cm.ConfigurationAdmin;
 
 import javax.management.NotCompliantMBeanException;
@@ -149,9 +146,9 @@ public class CellarBundleMBeanImpl extends StandardMBean 
implements CellarBundle
             state.setId(clusterBundles.size());
             state.setLocation(location);
             if (start) {
-                state.setStatus(BundleEvent.STARTED);
+                state.setStatus(Bundle.ACTIVE);
             } else {
-                state.setStatus(BundleEvent.INSTALLED);
+                state.setStatus(Bundle.INSTALLED);
             }
             clusterBundles.put(symbolicName + "/" + version, state);
         } finally {
@@ -159,10 +156,10 @@ public class CellarBundleMBeanImpl extends StandardMBean 
implements CellarBundle
         }
 
         // broadcast the event
-        ClusterBundleEvent event = new ClusterBundleEvent(symbolicName, 
version, location, BundleEvent.INSTALLED);
+        ClusterBundleEvent event = new ClusterBundleEvent(symbolicName, 
version, location, Bundle.INSTALLED);
         event.setSourceGroup(group);
         if (start) {
-            event = new ClusterBundleEvent(symbolicName, version, location, 
BundleEvent.STARTED);
+            event = new ClusterBundleEvent(symbolicName, version, location, 
Bundle.ACTIVE);
             event.setSourceGroup(group);
         }
         eventProducer.produce(event);
@@ -212,7 +209,7 @@ public class CellarBundleMBeanImpl extends StandardMBean 
implements CellarBundle
 
                 // broadcast the cluster event
                 String[] split = bundle.split("/");
-                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, BundleEvent.UNINSTALLED);
+                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, Bundle.UNINSTALLED);
                 event.setSourceGroup(group);
                 eventProducer.produce(event);
             }
@@ -263,12 +260,12 @@ public class CellarBundleMBeanImpl extends StandardMBean 
implements CellarBundle
                 }
 
                 // update the cluster state
-                state.setStatus(BundleEvent.STARTED);
+                state.setStatus(Bundle.ACTIVE);
                 clusterBundles.put(bundle, state);
 
                 // broadcast the cluster event
                 String[] split = bundle.split("/");
-                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, BundleEvent.STARTED);
+                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, Bundle.ACTIVE);
                 event.setSourceGroup(group);
                 eventProducer.produce(event);
             }
@@ -316,12 +313,12 @@ public class CellarBundleMBeanImpl extends StandardMBean 
implements CellarBundle
                 }
 
                 // update the cluster state
-                state.setStatus(BundleEvent.STOPPED);
+                state.setStatus(Bundle.RESOLVED);
                 clusterBundles.put(bundle, state);
 
                 // broadcast the cluster event
                 String[] split = bundle.split("/");
-                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, BundleEvent.STOPPED);
+                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, Bundle.RESOLVED);
                 event.setSourceGroup(group);
                 eventProducer.produce(event);
             }
@@ -396,25 +393,22 @@ public class CellarBundleMBeanImpl extends StandardMBean 
implements CellarBundle
             for (ExtendedBundleState bundle : bundles) {
                 String status;
                 switch (bundle.getStatus()) {
-                    case BundleEvent.INSTALLED:
+                    case Bundle.INSTALLED:
                         status = "Installed";
                         break;
-                    case BundleEvent.RESOLVED:
+                    case Bundle.RESOLVED:
                         status = "Resolved";
                         break;
-                    case BundleEvent.STARTED:
+                    case Bundle.ACTIVE:
                         status = "Active";
                         break;
-                    case BundleEvent.STARTING:
+                    case Bundle.STARTING:
                         status = "Starting";
                         break;
-                    case BundleEvent.STOPPED:
-                        status = "Resolved";
-                        break;
-                    case BundleEvent.STOPPING:
+                    case Bundle.STOPPING:
                         status = "Stopping";
                         break;
-                    case BundleEvent.UNINSTALLED:
+                    case Bundle.UNINSTALLED:
                         status = "Uninstalled";
                         break;
                     default:
@@ -604,23 +598,10 @@ public class CellarBundleMBeanImpl extends StandardMBean 
implements CellarBundle
                 name = (name == null) ? bundle.getLocation() : name;
                 extendedState.setId(bundle.getBundleId());
                 extendedState.setName(name);
-                
extendedState.setVersion(bundle.getHeaders().get("Bundle-Version").toString());
+                
extendedState.setVersion(bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION));
                 extendedState.setSymbolicName(bundle.getSymbolicName());
                 extendedState.setLocation(bundle.getLocation());
-                int status = bundle.getState();
-                if (status == Bundle.ACTIVE)
-                    status = BundleEvent.STARTED;
-                if (status == Bundle.INSTALLED)
-                    status = BundleEvent.INSTALLED;
-                if (status == Bundle.RESOLVED)
-                    status = BundleEvent.RESOLVED;
-                if (status == Bundle.STARTING)
-                    status = BundleEvent.STARTING;
-                if (status == Bundle.UNINSTALLED)
-                    status = BundleEvent.UNINSTALLED;
-                if (status == Bundle.STOPPING)
-                    status = BundleEvent.STARTED;
-                extendedState.setStatus(status);
+                extendedState.setStatus(bundle.getState());
                 extendedState.setCluster(false);
                 extendedState.setLocal(true);
                 bundles.put(key, extendedState);

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BlockCommand.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BlockCommand.java 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BlockCommand.java
index 199a13c..f655c87 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BlockCommand.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BlockCommand.java
@@ -54,7 +54,7 @@ public class BlockCommand extends BundleCommandSupport {
         
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
 
         try {
-            Map<String, ExtendedBundleState> bundles = gatherBundles();
+            Map<String, ExtendedBundleState> bundles = gatherBundles(false);
             List<String> selectedBundles = selector(bundles);
             for (String selectedBundle : selectedBundles) {
                 patterns.add(bundles.get(selectedBundle).getLocation());

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java
 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java
index 6937307..06182ac 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java
@@ -15,6 +15,7 @@ package org.apache.karaf.cellar.bundle.shell;
 
 import org.apache.karaf.cellar.bundle.BundleState;
 import org.apache.karaf.cellar.bundle.Constants;
+import org.apache.karaf.cellar.bundle.shell.completers.AllBundlesNameCompleter;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
 import org.apache.karaf.cellar.core.shell.completer.AllGroupsCompleter;
@@ -23,7 +24,6 @@ import org.apache.karaf.shell.api.action.Completion;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -39,6 +39,7 @@ public abstract class BundleCommandSupport extends 
CellarCommandSupport {
     String groupName;
 
     @Argument(index = 1, name = "ids", description = "The list of bundle 
(identified by IDs or name or name/version) separated by whitespaces", required 
= false, multiValued = true)
+    @Completion(AllBundlesNameCompleter.class)
     List<String> ids;
 
     @Reference
@@ -166,7 +167,7 @@ public abstract class BundleCommandSupport extends 
CellarCommandSupport {
         }
     }
 
-    protected Map<String, ExtendedBundleState> gatherBundles() {
+    protected Map<String, ExtendedBundleState> gatherBundles(boolean 
clusterOnly) {
         Map<String, ExtendedBundleState> bundles = new HashMap<String, 
ExtendedBundleState>();
 
         // retrieve bundles from the cluster
@@ -185,6 +186,9 @@ public abstract class BundleCommandSupport extends 
CellarCommandSupport {
             bundles.put(key, extendedState);
         }
 
+        if (clusterOnly)
+            return bundles;
+
         // retrieve local bundles
         for (Bundle bundle : bundleContext.getBundles()) {
             String version = (String) 
bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION);
@@ -203,22 +207,9 @@ public abstract class BundleCommandSupport extends 
CellarCommandSupport {
                 name = (name == null) ? bundle.getLocation() : name;
                 extendedState.setId(bundle.getBundleId());
                 extendedState.setName(name);
-                
extendedState.setVersion(bundle.getHeaders().get("Bundle-Version").toString());
+                
extendedState.setVersion(bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION));
                 extendedState.setLocation(bundle.getLocation());
-                int status = bundle.getState();
-                if (status == Bundle.ACTIVE)
-                    status = BundleEvent.STARTED;
-                if (status == Bundle.INSTALLED)
-                    status = BundleEvent.INSTALLED;
-                if (status == Bundle.RESOLVED)
-                    status = BundleEvent.RESOLVED;
-                if (status == Bundle.STARTING)
-                    status = BundleEvent.STARTING;
-                if (status == Bundle.UNINSTALLED)
-                    status = BundleEvent.UNINSTALLED;
-                if (status == Bundle.STOPPING)
-                    status = BundleEvent.STARTED;
-                extendedState.setStatus(status);
+                extendedState.setStatus(bundle.getState());
                 extendedState.setCluster(false);
                 extendedState.setLocal(true);
                 bundles.put(key, extendedState);

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java
 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java
index eee3cf9..a347ae5 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java
@@ -30,7 +30,7 @@ import org.apache.karaf.shell.api.action.Completion;
 import org.apache.karaf.shell.api.action.Option;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.osgi.framework.BundleEvent;
+import org.osgi.framework.Bundle;
 
 import java.net.URL;
 import java.util.List;
@@ -110,9 +110,9 @@ public class InstallBundleCommand extends 
CellarCommandSupport {
                     state.setId(clusterBundles.size());
                     state.setLocation(url);
                     if (start) {
-                        state.setStatus(BundleEvent.STARTED);
+                        state.setStatus(Bundle.ACTIVE);
                     } else {
-                        state.setStatus(BundleEvent.INSTALLED);
+                        state.setStatus(Bundle.INSTALLED);
                     }
                     clusterBundles.put(symbolicName + "/" + version, state);
                 } finally {
@@ -120,10 +120,12 @@ public class InstallBundleCommand extends 
CellarCommandSupport {
                 }
 
                 // broadcast the cluster event
-                ClusterBundleEvent event = new 
ClusterBundleEvent(symbolicName, version, url, BundleEvent.INSTALLED);
-                event.setSourceGroup(group);
+                ClusterBundleEvent event;
                 if (start) {
-                    event = new ClusterBundleEvent(symbolicName, version, url, 
BundleEvent.STARTED);
+                    event = new ClusterBundleEvent(symbolicName, version, url, 
Bundle.ACTIVE);
+                    event.setSourceGroup(group);
+                } else {
+                    event = new ClusterBundleEvent(symbolicName, version, url, 
Bundle.INSTALLED);
                     event.setSourceGroup(group);
                 }
                 eventProducer.produce(event);

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java
 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java
index b935dd1..34a6484 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java
@@ -22,7 +22,7 @@ import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.Option;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.apache.karaf.shell.support.table.ShellTable;
-import org.osgi.framework.BundleEvent;
+import org.osgi.framework.Bundle;
 
 import java.util.*;
 
@@ -63,7 +63,7 @@ public class ListBundleCommand extends BundleCommandSupport {
         
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
 
         try {
-            Map<String, ExtendedBundleState> allBundles = gatherBundles();
+            Map<String, ExtendedBundleState> allBundles = gatherBundles(false);
             if (allBundles != null && !allBundles.isEmpty()) {
                 System.out.println(String.format("Bundles in cluster group " + 
groupName));
 
@@ -87,25 +87,22 @@ public class ListBundleCommand extends BundleCommandSupport 
{
                 for (ExtendedBundleState bundle : bundles) {
                     String status;
                     switch (bundle.getStatus()) {
-                        case BundleEvent.INSTALLED:
+                        case Bundle.INSTALLED:
                             status = "Installed";
                             break;
-                        case BundleEvent.RESOLVED:
+                        case Bundle.RESOLVED:
                             status = "Resolved";
                             break;
-                        case BundleEvent.STARTED:
+                        case Bundle.ACTIVE:
                             status = "Active";
                             break;
-                        case BundleEvent.STARTING:
+                        case Bundle.STARTING:
                             status = "Starting";
                             break;
-                        case BundleEvent.STOPPED:
-                            status = "Resolved";
-                            break;
-                        case BundleEvent.STOPPING:
+                        case Bundle.STOPPING:
                             status = "Stopping";
                             break;
-                        case BundleEvent.UNINSTALLED:
+                        case Bundle.UNINSTALLED:
                             status = "Uninstalled";
                             break;
                         default:

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java
 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java
index c1e773f..eba376d 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java
@@ -25,7 +25,7 @@ import org.apache.karaf.cellar.core.event.EventType;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.osgi.framework.BundleEvent;
+import org.osgi.framework.Bundle;
 
 import java.util.List;
 import java.util.Map;
@@ -59,7 +59,7 @@ public class StartBundleCommand extends BundleCommandSupport {
         try {
             Map<String, BundleState> clusterBundles = 
clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + 
groupName);
 
-            List<String> bundles = selector(gatherBundles());
+            List<String> bundles = selector(gatherBundles(true));
 
             for (String bundle : bundles) {
                 BundleState state = clusterBundles.get(bundle);
@@ -78,12 +78,12 @@ public class StartBundleCommand extends 
BundleCommandSupport {
                 }
 
                 // update the cluster state
-                state.setStatus(BundleEvent.STARTED);
+                state.setStatus(Bundle.ACTIVE);
                 clusterBundles.put(bundle, state);
 
                 // broadcast the cluster event
                 String[] split = bundle.split("/");
-                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, BundleEvent.STARTED);
+                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, Bundle.ACTIVE);
                 event.setSourceGroup(group);
                 eventProducer.produce(event);
             }

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java
 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java
index 6f5968c..5fd70f8 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java
@@ -25,7 +25,7 @@ import org.apache.karaf.cellar.core.event.EventType;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.osgi.framework.BundleEvent;
+import org.osgi.framework.Bundle;
 
 import java.util.List;
 import java.util.Map;
@@ -59,7 +59,7 @@ public class StopBundleCommand extends BundleCommandSupport {
         try {
             Map<String, BundleState> clusterBundles = 
clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + 
groupName);
 
-            List<String> bundles = selector(gatherBundles());
+            List<String> bundles = selector(gatherBundles(true));
 
             for (String bundle : bundles) {
                 BundleState state = clusterBundles.get(bundle);
@@ -78,12 +78,12 @@ public class StopBundleCommand extends BundleCommandSupport 
{
                 }
 
                 // update the cluster state
-                state.setStatus(BundleEvent.STOPPED);
+                state.setStatus(Bundle.RESOLVED);
                 clusterBundles.put(bundle, state);
 
                 // broadcast the cluster event
                 String[] split = bundle.split("/");
-                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, BundleEvent.STOPPED);
+                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, Bundle.RESOLVED);
                 event.setSourceGroup(group);
                 eventProducer.produce(event);
             }

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java
----------------------------------------------------------------------
diff --git 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java
 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java
index fd9f8d5..a6616f3 100644
--- 
a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java
+++ 
b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java
@@ -25,7 +25,7 @@ import org.apache.karaf.cellar.core.event.EventType;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.osgi.framework.BundleEvent;
+import org.osgi.framework.Bundle;
 
 import java.util.List;
 import java.util.Map;
@@ -59,7 +59,7 @@ public class UninstallBundleCommand extends 
BundleCommandSupport {
         try {
             Map<String, BundleState> clusterBundles = 
clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + 
groupName);
 
-            List<String> bundles = selector(gatherBundles());
+            List<String> bundles = selector(gatherBundles(true));
 
             for (String bundle : bundles) {
                 BundleState state = clusterBundles.get(bundle);
@@ -82,7 +82,7 @@ public class UninstallBundleCommand extends 
BundleCommandSupport {
 
                 // broadcast the cluster event
                 String[] split = bundle.split("/");
-                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, BundleEvent.UNINSTALLED);
+                ClusterBundleEvent event = new ClusterBundleEvent(split[0], 
split[1], location, Bundle.UNINSTALLED);
                 event.setSourceGroup(group);
                 eventProducer.produce(event);
             }

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueProducer.java
----------------------------------------------------------------------
diff --git 
a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueProducer.java 
b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueProducer.java
index 4dcf404..b489444 100644
--- 
a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueProducer.java
+++ 
b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueProducer.java
@@ -31,6 +31,7 @@ import com.hazelcast.core.HazelcastInstance;
 import com.hazelcast.core.IQueue;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.cellar.core.command.Command;
 import org.apache.karaf.cellar.core.command.Result;
 import org.apache.karaf.cellar.core.control.BasicSwitch;
 import org.apache.karaf.cellar.core.control.Switch;
@@ -71,7 +72,8 @@ public class QueueProducer<E extends Event> implements 
EventProducer<E> {
     @Override
     public void produce(E event) {
         if (this.getSwitch().getStatus().equals(SwitchStatus.ON) || 
event.getForce() || event instanceof Result) {
-            event.setSourceNode(node);
+            if (event instanceof Result || event instanceof Command)
+                event.setSourceNode(node);
             try {
                 queue.put(event);
             } catch (InterruptedException e) {

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f734e334/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicProducer.java
----------------------------------------------------------------------
diff --git 
a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicProducer.java 
b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicProducer.java
index 65f20f1..6ea4fc9 100644
--- 
a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicProducer.java
+++ 
b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicProducer.java
@@ -17,6 +17,7 @@ import com.hazelcast.core.HazelcastInstance;
 import com.hazelcast.core.ITopic;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.cellar.core.command.Command;
 import org.apache.karaf.cellar.core.command.Result;
 import org.apache.karaf.cellar.core.control.BasicSwitch;
 import org.apache.karaf.cellar.core.control.Switch;
@@ -57,7 +58,8 @@ public class TopicProducer<E extends Event> implements 
EventProducer<E> {
     @Override
     public void produce(E event) {
         if (this.getSwitch().getStatus().equals(SwitchStatus.ON) || 
event.getForce() || event instanceof Result) {
-            event.setSourceNode(node);
+            if (event instanceof Result || event instanceof Command)
+                event.setSourceNode(node);
             topic.publish(event);
         } else {
             if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {

Reply via email to