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 2013/12/18 13:22:36 UTC
[01/50] [abbrv] git commit: [KARAF-2287] FeaturesSynchronizer now
check the local status of a features repository before adding
Updated Branches:
refs/heads/master e4609aa5c -> 0e15a67b2
[KARAF-2287] FeaturesSynchronizer now check the local status of a features repository before adding
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1470849 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/88883672
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/88883672
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/88883672
Branch: refs/heads/master
Commit: 88883672bb257150b9fed15d977f156703ba268a
Parents: 816f1ca
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Apr 23 08:43:57 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Apr 23 08:43:57 2013 +0000
----------------------------------------------------------------------
.../karaf/cellar/features/FeaturesSupport.java | 5 +-
.../cellar/features/FeaturesSynchronizer.java | 70 ++++++++------------
2 files changed, 28 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/88883672/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
index 3f81491..8f9e5e3 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
@@ -37,12 +37,11 @@ public class FeaturesSupport extends CellarSupport {
protected FeaturesService featuresService;
public void init() {
-
+ // nothing to do
}
public void destroy() {
-
-
+ // nothing to do
}
/**
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/88883672/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
index fcc6fb9..70d47f6 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
@@ -40,9 +40,6 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
private static final transient Logger LOGGER = LoggerFactory.getLogger(FeaturesSynchronizer.class);
- /**
- * Initialization method
- */
public void init() {
super.init();
Set<Group> groups = groupManager.listLocalGroups();
@@ -56,31 +53,32 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
}
}
- /**
- * Destruction method
- */
public void destroy() {
super.destroy();
}
/**
- * Pulls the features from the cluster.
+ * Get the features from the cluster group.
+ *
+ * @param group the cluster group.
*/
public void pull(Group group) {
if (group != null) {
String groupName = group.getName();
- List<String> repositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
- Map<FeatureInfo, Boolean> features = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
+ List<String> clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
clusterManager.getList(Constants.FEATURES + Configurations.SEPARATOR + groupName);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- //Retrieve remote feautre URLs.
- if (repositories != null && !repositories.isEmpty()) {
- for (String url : repositories) {
+ // get the features repositories URLs from the cluster group
+ if (clusterRepositories != null && !clusterRepositories.isEmpty()) {
+ for (String url : clusterRepositories) {
try {
- LOGGER.debug("CELLAR FEATURES: adding new repository {}", url);
- featuresService.addRepository(new URI(url));
+ if (!isRepositoryRegisteredLocally(url)) {
+ LOGGER.debug("CELLAR FEATURES: adding new repository {}", url);
+ featuresService.addRepository(new URI(url));
+ }
} catch (MalformedURLException e) {
LOGGER.error("CELLAR FEATURES: failed to add features repository URL {} (malformed)", url, e);
} catch (Exception e) {
@@ -89,13 +87,13 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
}
}
- // retrieve remote feature status
- if (features != null && !features.isEmpty()) {
- for (FeatureInfo info : features.keySet()) {
+ // get the features from the cluster group
+ if (clusterFeatures != null && !clusterFeatures.isEmpty()) {
+ for (FeatureInfo info : clusterFeatures.keySet()) {
String name = info.getName();
- //Check if feature is blocked.
+ // check if feature is blocked
if (isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.INBOUND)) {
- Boolean remotelyInstalled = features.get(info);
+ Boolean remotelyInstalled = clusterFeatures.get(info);
Boolean locallyInstalled = isFeatureInstalledLocally(info.getName(), info.getVersion());
// prevent NPE
@@ -106,21 +104,21 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
locallyInstalled = false;
}
- //If feature needs to be installed locally.
+ // if feature has to be installed locally
if (remotelyInstalled && !locallyInstalled) {
try {
LOGGER.debug("CELLAR FEATURES: installing feature {}/{}", info.getName(), info.getVersion());
featuresService.installFeature(info.getName(), info.getVersion());
} catch (Exception e) {
- LOGGER.error("CELLAR FEATURES: failed to install feature {}/{} ", new Object[]{ info.getName(), info.getVersion() }, e);
+ LOGGER.error("CELLAR FEATURES: failed to install feature {}/{} ", new Object[]{info.getName(), info.getVersion()}, e);
}
- //If feature needs to be localy uninstalled.
+ // if feature has to be uninstalled locally
} else if (!remotelyInstalled && locallyInstalled) {
try {
LOGGER.debug("CELLAR FEATURES: un-installing feature {}/{}", info.getName(), info.getVersion());
featuresService.uninstallFeature(info.getName(), info.getVersion());
} catch (Exception e) {
- LOGGER.error("CELLAR FEATURES: failed to uninstall feature {}/{} ", new Object[]{ info.getName(), info.getVersion() }, e);
+ LOGGER.error("CELLAR FEATURES: failed to uninstall feature {}/{} ", new Object[]{info.getName(), info.getVersion()}, e);
}
}
} else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED INBOUND", name);
@@ -133,14 +131,14 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
}
/**
- * Push features to the cluster.
+ * Push features repositories and features status to the cluster group.
+ *
+ * @param group the cluster group.
*/
public void push(Group group) {
if (group != null) {
String groupName = group.getName();
LOGGER.info("CELLAR FEATURES: Pulling features from group {}.",groupName);
- //List<String> repositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
- Map<FeatureInfo, Boolean> features = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
clusterManager.getList(Constants.FEATURES + Configurations.SEPARATOR + groupName);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
@@ -157,14 +155,14 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
LOGGER.error("CELLAR FEATURES: error listing features", e);
}
- //Process repository list
+ // push features repositories to the cluster group
if (repositoryList != null && repositoryList.length > 0) {
for (Repository repository : repositoryList) {
pushRepository(repository, group);
}
}
- //Process features list
+ // push features to the cluster group
if (featuresList != null && featuresList.length > 0) {
for (Feature feature : featuresList) {
pushFeature(feature, group);
@@ -195,20 +193,4 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
return result;
}
- public ClusterManager getCollectionManager() {
- return clusterManager;
- }
-
- public void setCollectionManager(ClusterManager clusterManager) {
- this.clusterManager = clusterManager;
- }
-
- public FeaturesService getFeaturesService() {
- return featuresService;
- }
-
- public void setFeaturesService(FeaturesService featuresService) {
- this.featuresService = featuresService;
- }
-
}
[38/50] [abbrv] git commit: [KARAF-2354] Rename cellar-event feature
to cellar-eventadmin
Posted by jb...@apache.org.
[KARAF-2354] Rename cellar-event feature to cellar-eventadmin
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1493466 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/124d44e5
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/124d44e5
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/124d44e5
Branch: refs/heads/master
Commit: 124d44e5efe78bf4f2bca15eaa9575d08a2a4e1a
Parents: 03405c5
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Sun Jun 16 07:04:49 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Sun Jun 16 07:04:49 2013 +0000
----------------------------------------------------------------------
assembly/src/main/resources/features.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/124d44e5/assembly/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/features.xml b/assembly/src/main/resources/features.xml
index 94a9989..851ca92 100644
--- a/assembly/src/main/resources/features.xml
+++ b/assembly/src/main/resources/features.xml
@@ -86,7 +86,7 @@
<bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.obr/${project.version}</bundle>
</feature>
- <feature name="cellar-event" description="OSGi events broadcasting in clusters" version="${project.version}" resolver="(obr)">
+ <feature name="cellar-eventadmin" description="OSGi events broadcasting in clusters" version="${project.version}" resolver="(obr)">
<feature>eventadmin</feature>
<feature version="${project.version}">cellar-core</feature>
<bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.event/${project.version}</bundle>
[16/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471549 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/b43a255a
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/b43a255a
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/b43a255a
Branch: refs/heads/master
Commit: b43a255ad91d9db9c80f0583eabd891ed841fbb2
Parents: 33d67d1
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed Apr 24 17:23:48 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed Apr 24 17:23:48 2013 +0000
----------------------------------------------------------------------
.../karaf/cellar/hazelcast/CellarExtender.java | 5 +-
.../karaf/cellar/hazelcast/Constants.java | 2 +-
.../hazelcast/HazelcastBundleListener.java | 3 +
.../hazelcast/HazelcastClusterManager.java | 63 ++++++++------
.../HazelcastEventTransportFactory.java | 6 +-
.../cellar/hazelcast/HazelcastGroupManager.java | 72 ++++++++--------
.../hazelcast/HazelcastInstanceAware.java | 11 +--
.../karaf/cellar/hazelcast/HazelcastNode.java | 14 +---
.../karaf/cellar/hazelcast/QueueConsumer.java | 25 +++---
.../karaf/cellar/hazelcast/QueueProducer.java | 18 ++--
.../karaf/cellar/hazelcast/TopicConsumer.java | 18 ++--
.../karaf/cellar/hazelcast/TopicProducer.java | 16 +---
.../factory/HazelcastConfigurationManager.java | 12 ++-
.../factory/HazelcastServiceFactory.java | 26 +++---
.../hazelcast/merge/CellarMergePolicy.java | 64 ++++++++------
.../resources/OSGI-INF/blueprint/blueprint.xml | 87 +++++++++-----------
.../factory/HazelcastServiceFactoryTest.java | 13 ---
17 files changed, 224 insertions(+), 231 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/CellarExtender.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/CellarExtender.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/CellarExtender.java
index 6f373f2..d417500 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/CellarExtender.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/CellarExtender.java
@@ -11,12 +11,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.karaf.cellar.hazelcast;
import org.apache.karaf.cellar.core.utils.CombinedClassLoader;
import org.osgi.framework.BundleContext;
+/**
+ * Cellar extender.
+ */
public class CellarExtender {
private HazelcastBundleListener hazelcastBundleListener;
@@ -45,4 +47,5 @@ public class CellarExtender {
public void setCombinedClassLoader(CombinedClassLoader combinedClassLoader) {
this.combinedClassLoader = combinedClassLoader;
}
+
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/Constants.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/Constants.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/Constants.java
index 107882a..6279d95 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/Constants.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/Constants.java
@@ -14,7 +14,7 @@
package org.apache.karaf.cellar.hazelcast;
/**
- * Hazelcast constants.
+ * Hazelcast configuration constants.
*/
public class Constants {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastBundleListener.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastBundleListener.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastBundleListener.java
index 1d427c9..63fcbc2 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastBundleListener.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastBundleListener.java
@@ -18,6 +18,9 @@ import org.osgi.framework.*;
import java.util.Dictionary;
+/**
+ * Hazelcast bundle listener.
+ */
public class HazelcastBundleListener implements SynchronousBundleListener {
private BundleContext bundleContext;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastClusterManager.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastClusterManager.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastClusterManager.java
index 6be3739..529aaf6 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastClusterManager.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastClusterManager.java
@@ -29,7 +29,7 @@ import java.util.Map;
import java.util.Set;
/**
- * Hazelcast cluster manager.
+ * Cluster manager implementation powered by Hazelcast.
*/
public class HazelcastClusterManager extends HazelcastInstanceAware implements ClusterManager {
@@ -41,40 +41,44 @@ public class HazelcastClusterManager extends HazelcastInstanceAware implements C
private CombinedClassLoader combinedClassLoader;
/**
- * Returns a named distributed map.
+ * Get a Map in Hazelcast.
*
- * @param mapName
- * @return
+ * @param mapName the Map name.
+ * @return the Map in Hazelcast.
*/
+ @Override
public Map getMap(String mapName) {
return instance.getMap(mapName);
}
/**
- * Returns a named distributed list.
+ * Get a List in Hazelcast.
*
- * @param listName
- * @return
+ * @param listName the List name.
+ * @return the List in Hazelcast.
*/
+ @Override
public List getList(String listName) {
return instance.getList(listName);
}
/**
- * Returns a named distributed set.
- * @param setName
- * @return
+ * Get a Set in Hazelcast.
+ *
+ * @param setName the Set name.
+ * @return the Set in Hazelcast.
*/
+ @Override
public Set getSet(String setName) {
return instance.getSet(setName);
}
-
/**
- * Returns the list of Hazelcast Nodes.
+ * Get the list of Hazelcast nodes.
*
- * @return
+ * @return a Set containing the Hazelcast nodes.
*/
+ @Override
public Set<Node> listNodes() {
Set<Node> nodes = new HashSet<Node>();
@@ -91,14 +95,13 @@ public class HazelcastClusterManager extends HazelcastInstanceAware implements C
return nodes;
}
-
-
/**
- * Returns the {@code Node}s with the corresponding ids.
+ * Get the nodes with given IDs.
*
- * @param ids
- * @return
+ * @param ids a collection of IDs to look for.
+ * @return a Set containing the nodes.
*/
+ @Override
public Set<Node> listNodes(Collection<String> ids) {
Set<Node> nodes = new HashSet<Node>();
if (ids != null && !ids.isEmpty()) {
@@ -119,11 +122,12 @@ public class HazelcastClusterManager extends HazelcastInstanceAware implements C
}
/**
- * Returns the {@code Node} with the corresponding id.
+ * Get a node with a given ID.
*
- * @param id
- * @return
+ * @param id the node ID.
+ * @return the node.
*/
+ @Override
public Node findNodeById(String id) {
if (id != null) {
Cluster cluster = instance.getCluster();
@@ -142,16 +146,23 @@ public class HazelcastClusterManager extends HazelcastInstanceAware implements C
return null;
}
+ /**
+ * List the nodes in a given cluster group.
+ *
+ * @param group the cluster group.
+ * @return a Set with the nodes.
+ */
@Override
public Set<Node> listNodesByGroup(Group group) {
return group.getNodes();
}
/**
- * Generate an id.
+ * Generate an unique ID.
*
- * @return
+ * @return the generated unique ID.
*/
+ @Override
public synchronized String generateId() {
if (idgenerator == null) {
idgenerator = instance.getIdGenerator(GENERATOR_ID);
@@ -159,16 +170,19 @@ public class HazelcastClusterManager extends HazelcastInstanceAware implements C
return String.valueOf(idgenerator.newId());
}
+ @Override
public void start() {
-
+ // nothing to do
}
+ @Override
public void stop() {
if (instance != null && instance.getLifecycleService().isRunning()) {
instance.getLifecycleService().shutdown();
}
}
+ @Override
public void restart() {
if (instance != null && instance.getLifecycleService().isRunning()) {
instance.getLifecycleService().restart();
@@ -190,4 +204,5 @@ public class HazelcastClusterManager extends HazelcastInstanceAware implements C
public void setCombinedClassLoader(CombinedClassLoader combinedClassLoader) {
this.combinedClassLoader = combinedClassLoader;
}
+
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastEventTransportFactory.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastEventTransportFactory.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastEventTransportFactory.java
index 2b3027e..e39ce36 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastEventTransportFactory.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastEventTransportFactory.java
@@ -21,9 +21,9 @@ import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.event.EventTransportFactory;
import org.apache.karaf.cellar.core.utils.CombinedClassLoader;
-import java.util.HashMap;
-import java.util.Map;
-
+/**
+ * An event transport factory powered by Hazelcast.
+ */
public class HazelcastEventTransportFactory extends HazelcastInstanceAware implements EventTransportFactory {
private Dispatcher dispatcher;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastGroupManager.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastGroupManager.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastGroupManager.java
index f3860d3..b781c6a 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastGroupManager.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastGroupManager.java
@@ -42,7 +42,7 @@ import org.osgi.service.cm.ConfigurationListener;
import org.slf4j.Logger;
/**
- * Hazelcast group manager.
+ * A group manager implementation powered by Hazelcast.
* The role of this class is to provide means of creating groups, setting nodes to groups etc.
* Keep in sync the distributed group configuration with the locally persisted.
*/
@@ -89,7 +89,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
}
} catch (IOException e) {
- LOGGER.warn("CELLAR HAZELCAST: can't create group from configuration admin", e);
+ LOGGER.warn("CELLAR HAZELCAST: can't create cluster group from configuration admin", e);
}
try {
// add group membership from configuration
@@ -169,7 +169,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
// store the group list to configuration admin
persist(listGroups());
} catch (Exception e) {
- LOGGER.warn("CELLAR HAZELCAST: can't store group list", e);
+ LOGGER.warn("CELLAR HAZELCAST: can't store cluster group list", e);
}
}
return group;
@@ -189,7 +189,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
// store the group list to configuration admin
persist(listGroups());
} catch (Exception e) {
- LOGGER.warn("CELLAR HAZELCAST: can't store group list", e);
+ LOGGER.warn("CELLAR HAZELCAST: can't store cluster group list", e);
}
}
} finally {
@@ -331,8 +331,9 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
/**
- * Registers a {@link Group}.
- * @param group
+ * Register a cluster {@link Group}.
+ *
+ * @param group the cluster group to register.
*/
@Override
public void registerGroup(Group group) {
@@ -342,7 +343,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
String groupName = group.getName();
createGroup(groupName);
- LOGGER.info("Registering group {}.", groupName);
+ LOGGER.info("CELLAR HAZELCAST: registering cluster group {}.", groupName);
Properties serviceProperties = new Properties();
serviceProperties.put("type", "group");
serviceProperties.put("name", groupName);
@@ -396,7 +397,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
}
} catch (IOException e) {
- LOGGER.error("Error reading group configuration {}", group);
+ LOGGER.error("CELLAR HAZELCAST: error reading cluster group configuration {}", group);
}
// launch the synchronization on the group
@@ -413,7 +414,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
}
} catch (InvalidSyntaxException e) {
- LOGGER.error("Error looking up for Synchronizers", e);
+ LOGGER.error("CELLAR HAZELCAST: failed to look for synchronizers", e);
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
@@ -446,16 +447,17 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
}
+ @Override
public void unRegisterGroup(Group group) {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(combinedClassLoader);
String groupName = group.getName();
- // remove local node from group.
+ // remove local node from cluster group
group.getNodes().remove(getNode());
listGroups().put(groupName, group);
- // unregister group consumers
+ // un-register cluster group consumers
if (consumerRegistrations != null && !consumerRegistrations.isEmpty()) {
ServiceRegistration consumerRegistration = consumerRegistrations.get(groupName);
if (consumerRegistration != null) {
@@ -464,7 +466,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
}
- // unregister group producers
+ // un-register cluster group producers
if (producerRegistrations != null && !producerRegistrations.isEmpty()) {
ServiceRegistration producerRegistration = producerRegistrations.get(groupName);
if (producerRegistration != null) {
@@ -473,14 +475,14 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
}
- // remove Consumers & Producers
+ // remove consumers & producers
groupProducers.remove(groupName);
EventConsumer consumer = groupConsumer.remove(groupName);
if (consumer != null) {
consumer.stop();
}
- // remove group from configuration
+ // remove cluster group from configuration
try {
Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE);
Dictionary<String, Object> properties = configuration.getProperties();
@@ -495,7 +497,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
properties.put(Configurations.GROUPS_KEY, groups);
configuration.update(properties);
} catch (IOException e) {
- LOGGER.error("Error reading group configuration {}", group);
+ LOGGER.error("CELLAR HAZELCAST: failed to read cluster group configuration", e);
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
@@ -503,27 +505,28 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
/**
- * Copies the configuration of a {@link Group}.
+ * Copy the configuration of a cluster {@link Group}.
+ *
* <b>1.</b> Updates configuration admin from Hazelcast using source config.
* <b>2.</b> Creates target configuration both on Hazelcast and configuration admin.
*
- * @param sourceGroupName
- * @param targetGroupName
+ * @param sourceGroupName the source cluster group.
+ * @param targetGroupName the target cluster group.
*/
public void copyGroupConfiguration(String sourceGroupName, String targetGroupName) {
try {
Configuration conf = configurationAdmin.getConfiguration(Configurations.GROUP);
if (conf != null) {
- //Get configuration from config admin.
+ // get configuration from config admin
Dictionary configAdminProperties = conf.getProperties();
if (configAdminProperties == null) {
configAdminProperties = new Properties();
}
- //Get configuration from Hazelcast
+ // get configuration from Hazelcast
Map<String, String> sourceGropConfig = instance.getMap(GROUPS_CONFIG);
- //Update local configuration from cluster.
+ // update local configuration from cluster
for (Map.Entry<String, String> parentEntry : sourceGropConfig.entrySet()) {
configAdminProperties.put(parentEntry.getKey(), parentEntry.getValue());
}
@@ -546,15 +549,15 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
} catch (IOException e) {
- LOGGER.error("Error reading group configuration ", e);
+ LOGGER.error("CELLAR HAZELCAST: failed to read cluster group configuration", e);
}
}
/**
- * Utility method which converts a set to a String.
+ * Util method which converts a Set to a String.
*
- * @param set
- * @return
+ * @param set the Set to convert.
+ * @return the String corresponding to the Set.
*/
protected String convertSetToString(Set<String> set) {
StringBuffer result = new StringBuffer();
@@ -570,10 +573,10 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
/**
- * Utility method which converts String to Set.
+ * Util method which converts a String to a Set.
*
- * @param string
- * @return
+ * @param string the String to convert.
+ * @return the Set corresponding to the String.
*/
protected Set<String> convertStringToSet(String string) {
if (string == null)
@@ -591,7 +594,11 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
return result;
}
-
+ /**
+ * A local configuration listener to update the local Hazelcast instance when the configuration changes.
+ *
+ * @param configurationEvent the local configuration event.
+ */
@Override
public void configurationEvent(ConfigurationEvent configurationEvent) {
String pid = configurationEvent.getPid();
@@ -610,7 +617,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
}
}
} catch (Exception e) {
- LOGGER.warn("Failed to update group configuration");
+ LOGGER.warn("CELLAR HAZELCAST: failed to update cluster group configuration", e);
}
}
}
@@ -642,7 +649,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
*/
@Override
public void entryUpdated(EntryEvent entryEvent) {
- LOGGER.info("Distributed Group configuration has been updated, updating local configuration.");
+ LOGGER.info("CELLAR HAZELCAST: cluster group configuration has been updated, updating local configuration");
try {
Configuration conf = configurationAdmin.getConfiguration(GROUPS);
Dictionary props = conf.getProperties();
@@ -653,7 +660,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
conf.update(props);
}
} catch (Exception ex) {
- LOGGER.warn("Error while updating local group configuration", ex);
+ LOGGER.warn("CELLAR HAZELCAST: failed to update local configuration", ex);
}
}
@@ -667,7 +674,6 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
entryUpdated(entryEvent);
}
-
public HazelcastInstance getInstance() {
return instance;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastInstanceAware.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastInstanceAware.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastInstanceAware.java
index 9fa2efc..87e1288 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastInstanceAware.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastInstanceAware.java
@@ -18,6 +18,9 @@ import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.Member;
import org.apache.karaf.cellar.core.Node;
+/**
+ * Hazelcast instance aware.
+ */
public class HazelcastInstanceAware {
protected HazelcastInstance instance;
@@ -30,10 +33,10 @@ public class HazelcastInstanceAware {
this.instance = null;
}
- /**
- * Returns the node on which the command was run.
+ /**
+ * Return the local node.
*
- * @return
+ * @return the local node.
*/
public Node getNode() {
Cluster cluster = instance.getCluster();
@@ -53,6 +56,4 @@ public class HazelcastInstanceAware {
this.instance = instance;
}
-
-
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastNode.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastNode.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastNode.java
index c1f6a78..eabd20e 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastNode.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastNode.java
@@ -16,7 +16,7 @@ package org.apache.karaf.cellar.hazelcast;
import org.apache.karaf.cellar.core.Node;
/**
- * Hazelcast cluster node.
+ * Cluster node powered by Hazelcast.
*/
public class HazelcastNode implements Node {
@@ -25,12 +25,6 @@ public class HazelcastNode implements Node {
private String host;
private int port;
- /**
- * Constructor
- *
- * @param host
- * @param port
- */
public HazelcastNode(String host, int port) {
StringBuilder builder = new StringBuilder();
this.host = host;
@@ -38,10 +32,12 @@ public class HazelcastNode implements Node {
this.id = builder.append(host).append(":").append(port).toString();
}
+ @Override
public String getId() {
return id;
}
+ @Override
public String getHost() {
return host;
}
@@ -50,6 +46,7 @@ public class HazelcastNode implements Node {
this.host = host;
}
+ @Override
public int getPort() {
return port;
}
@@ -81,9 +78,6 @@ public class HazelcastNode implements Node {
return id != null ? id.hashCode() : 0;
}
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
return "HazelcastNode [id=" + id + ", host=" + host + ", port=" + port
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueConsumer.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueConsumer.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueConsumer.java
index ebae4ab..da601ee 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueConsumer.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueConsumer.java
@@ -36,7 +36,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
- * Consumes messages from the distributed {@code ITopic} and calls the {@code EventDispatcher}.
+ * Consumes cluster events from the Hazelcast {@code IQueue} and calls the {@code EventDispatcher}.
*/
public class QueueConsumer<E extends Event> implements EventConsumer<E>, ItemListener<E>, Runnable {
@@ -57,15 +57,13 @@ public class QueueConsumer<E extends Event> implements EventConsumer<E>, ItemLis
private ConfigurationAdmin configurationAdmin;
public QueueConsumer() {
+ // nothing to do
}
public QueueConsumer(CombinedClassLoader combinedClassLoader) {
this.combinedClassLoader = combinedClassLoader;
}
- /**
- * Initialization method.
- */
public void init() {
if (queue != null) {
queue.addItemListener(this, true);
@@ -76,9 +74,6 @@ public class QueueConsumer<E extends Event> implements EventConsumer<E>, ItemLis
executorService.execute(this);
}
- /**
- * Destruction method.
- */
public void destroy() {
isConsuming = false;
if (queue != null) {
@@ -99,24 +94,25 @@ public class QueueConsumer<E extends Event> implements EventConsumer<E>, ItemLis
try {
e = getQueue().poll(10, TimeUnit.SECONDS);
} catch (InterruptedException e1) {
- LOGGER.warn("Consume task interrupted");
+ LOGGER.warn("CELLAR HAZELCAST: consume task interrupted");
}
if (e != null) {
consume(e);
}
}
} catch (Exception ex) {
- LOGGER.error("Error while consuming from queue", ex);
+ LOGGER.error("CELLAR HAZELCAST: failed to consume from queue", ex);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
}
/**
- * Consumes an event form the topic.
+ * Consume a cluster event.
*
- * @param event
+ * @param event the cluster event.
*/
+ @Override
public void consume(E event) {
if (event != null && (this.getSwitch().getStatus().equals(SwitchStatus.ON) || event.getForce())) {
dispatcher.dispatch(event);
@@ -133,24 +129,24 @@ public class QueueConsumer<E extends Event> implements EventConsumer<E>, ItemLis
executorService.execute(this);
}
-
@Override
public void stop() {
isConsuming = false;
}
+ @Override
public Boolean isConsuming() {
return isConsuming;
}
@Override
public void itemAdded(ItemEvent<E> event) {
-
+ // nothing to do
}
@Override
public void itemRemoved(ItemEvent<E> event) {
-
+ // nothing to do
}
public Dispatcher getDispatcher() {
@@ -177,6 +173,7 @@ public class QueueConsumer<E extends Event> implements EventConsumer<E>, ItemLis
this.queue = queue;
}
+ @Override
public Switch getSwitch() {
// load the switch status from the config
try {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/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 c1c4ced..d196f89 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
@@ -43,7 +43,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Produces {@code Event}s into the distributed {@code ITopic}.
+ * Produces cluster {@code Event}s into the Hazelcast {@code IQueue}.
*/
public class QueueProducer<E extends Event> implements EventProducer<E> {
@@ -58,33 +58,24 @@ public class QueueProducer<E extends Event> implements EventProducer<E> {
private Node node;
private ConfigurationAdmin configurationAdmin;
- /**
- * Initialization method.
- */
public void init() {
if (queue == null) {
queue = instance.getQueue(Constants.QUEUE);
}
}
- /**
- * Destruction method.
- */
public void destroy() {
+ // nothing to do
}
- /**
- * Propagates an event into the distributed {@code ITopic}.
- *
- * @param event
- */
+ @Override
public void produce(E event) {
if (this.getSwitch().getStatus().equals(SwitchStatus.ON) || event.getForce() || event instanceof Result) {
event.setSourceNode(node);
try {
queue.put(event);
} catch (InterruptedException e) {
- LOGGER.error("Queue producer interrupted", e);
+ LOGGER.error("CELLAR HAZELCAST: queue producer interrupted", e);
}
} else {
if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
@@ -93,6 +84,7 @@ public class QueueProducer<E extends Event> implements EventProducer<E> {
}
}
+ @Override
public Switch getSwitch() {
// load the switch status from the config
try {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicConsumer.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicConsumer.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicConsumer.java
index 7d87bf1..ba9ef5e 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicConsumer.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicConsumer.java
@@ -31,7 +31,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Consumes messages from the distributed {@code ITopic} and calls the {@code EventDispatcher}.
+ * Consumes messages from the Hazelcast {@code ITopic} and calls the {@code EventDispatcher}.
*/
public class TopicConsumer<E extends Event> implements EventConsumer<E>, MessageListener<E> {
@@ -49,9 +49,6 @@ public class TopicConsumer<E extends Event> implements EventConsumer<E>, Message
private boolean isConsuming;
- /**
- * Initialization method.
- */
public void init() {
if (topic == null) {
topic = instance.getTopic(Constants.TOPIC);
@@ -59,20 +56,13 @@ public class TopicConsumer<E extends Event> implements EventConsumer<E>, Message
start();
}
- /**
- * Destruction method.
- */
public void destroy() {
stop();
}
- /**
- * Consumes an event form the topic.
- *
- * @param event
- */
+ @Override
public void consume(E event) {
- //Check if event has a specified destination.
+ // check if event has a specified destination.
if ((event.getDestination() == null || event.getDestination().contains(node)) && (this.getSwitch().getStatus().equals(SwitchStatus.ON) || event.getForce())) {
dispatcher.dispatch(event);
} else {
@@ -107,6 +97,7 @@ public class TopicConsumer<E extends Event> implements EventConsumer<E>, Message
return isConsuming;
}
+ @Override
public void onMessage(Message<E> message) {
consume(message.getMessageObject());
}
@@ -135,6 +126,7 @@ public class TopicConsumer<E extends Event> implements EventConsumer<E>, Message
this.topic = topic;
}
+ @Override
public Switch getSwitch() {
// load the switch status from the config
try {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/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 cf1c77a..f39d9c3 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
@@ -29,7 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Produces {@code Event}s into the distributed {@code ITopic}.
+ * Produces cluster {@code Event}s into the distributed {@code ITopic}.
*/
public class TopicProducer<E extends Event> implements EventProducer<E> {
@@ -44,26 +44,17 @@ public class TopicProducer<E extends Event> implements EventProducer<E> {
private Node node;
private ConfigurationAdmin configurationAdmin;
- /**
- * Initialization method.
- */
public void init() {
if (topic == null) {
topic = instance.getTopic(Constants.TOPIC);
}
}
- /**
- * Destruction method.
- */
public void destroy() {
+ // nothing to do
}
- /**
- * Propagates an event into the distributed {@code ITopic}.
- *
- * @param event
- */
+ @Override
public void produce(E event) {
if (this.getSwitch().getStatus().equals(SwitchStatus.ON) || event.getForce() || event instanceof Result) {
event.setSourceNode(node);
@@ -75,6 +66,7 @@ public class TopicProducer<E extends Event> implements EventProducer<E> {
}
}
+ @Override
public Switch getSwitch() {
// load the switch status from the config
try {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
index 9475949..1d7501b 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
@@ -25,6 +25,10 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
+/**
+ * Hazelcast configuration manager.
+ * It loads hazelcast.xml configuration file.
+ */
public class HazelcastConfigurationManager {
private static final transient Logger LOGGER = LoggerFactory.getLogger(HazelcastServiceFactory.class);
@@ -34,9 +38,9 @@ public class HazelcastConfigurationManager {
private Set<String> discoveredMemberSet = new LinkedHashSet<String>();
/**
- * Builds a Hazelcast {@link com.hazelcast.config.Config}
+ * Build a Hazelcast {@link com.hazelcast.config.Config}.
*
- * @return
+ * @return the Hazelcast configuration.
*/
public Config getHazelcastConfig() {
System.setProperty("hazelcast.config", xmlConfigLocation);
@@ -49,9 +53,9 @@ public class HazelcastConfigurationManager {
}
/**
- * Updates Hazelcast Instance.
+ * Update configuration of a Hazelcast instance.
*
- * @param properties
+ * @param properties the updated configuration properties.
*/
public boolean isUpdated(Map properties) {
Boolean updated = Boolean.FALSE;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
index 5cb1341..49c98ad 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
@@ -15,20 +15,16 @@ package org.apache.karaf.cellar.hazelcast.factory;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
-import com.hazelcast.config.Config;
+
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.apache.karaf.cellar.core.utils.CombinedClassLoader;
import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
- * A factory for a Hazelcast Instance, which integration with OSGi Service Registry and Config Admin.
+ * Factory for Hazelcast instance, including integration with OSGi ServiceRegistry and ConfigAdmin.
*/
-public class HazelcastServiceFactory {
-
- private static final transient Logger LOGGER = LoggerFactory.getLogger(HazelcastServiceFactory.class);
+public class HazelcastServiceFactory {
private BundleContext bundleContext;
private CombinedClassLoader combinedClassLoader;
@@ -38,7 +34,6 @@ public class HazelcastServiceFactory {
private CountDownLatch instanceLatch = new CountDownLatch(1);
private HazelcastInstance instance;
-
public void init() {
if (combinedClassLoader != null) {
combinedClassLoader.addBundle(bundleContext.getBundle());
@@ -57,26 +52,26 @@ public class HazelcastServiceFactory {
}
/**
- * Returs a Hazelcast instance from service registry.
+ * Return the local Hazelcast instance.
*
- * @return
+ * @return the Hazelcast instance.
*/
public HazelcastInstance getInstance() throws InterruptedException {
if (instance == null) {
- initializationLatch.await();
- this.instance = buildInstance();
+ initializationLatch.await();
+ this.instance = buildInstance();
instanceLatch.countDown();
}
return instance;
}
/**
- * Builds a {@link HazelcastInstance}
+ * Build a {@link HazelcastInstance}.
*
- * @return
+ * @return the Hazelcast instance.
*/
private HazelcastInstance buildInstance() {
- if(combinedClassLoader != null) {
+ if (combinedClassLoader != null) {
Thread.currentThread().setContextClassLoader(combinedClassLoader);
}
return Hazelcast.newHazelcastInstance(configurationManager.getHazelcastConfig());
@@ -97,4 +92,5 @@ public class HazelcastServiceFactory {
public void setCombinedClassLoader(CombinedClassLoader combinedClassLoader) {
this.combinedClassLoader = combinedClassLoader;
}
+
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java
index b8002fd..4e40b60 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java
@@ -1,3 +1,16 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.karaf.cellar.hazelcast.merge;
import java.util.LinkedHashSet;
@@ -6,25 +19,29 @@ import java.util.List;
import java.util.Set;
import com.hazelcast.core.MapEntry;
import com.hazelcast.merge.MergePolicy;
-import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.MultiNode;
import org.apache.karaf.cellar.core.utils.CellarUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * A Cellar custom Hazelcast merge policy.
+ */
public class CellarMergePolicy implements MergePolicy {
private static final transient Logger LOGGER = LoggerFactory.getLogger(CellarMergePolicy.class);
+
/**
* Returns the value of the entry after the merge
* of entries with the same key. Returning value can be
* You should consider the case where existingEntry is null.
*
- * @param mapName name of the map
- * @param mergingEntry entry merging into the destination cluster
+ * @param mapName name of the map
+ * @param mergingEntry entry merging into the destination cluster
* @param existingEntry existing entry in the destination cluster
* @return final value of the entry. If returns null then no change on the entry.
*/
+ @Override
public Object merge(String mapName, MapEntry mergingEntry, MapEntry existingEntry) {
LOGGER.info("Cellar merge policy triggered merging entry {}, existing entry {}",mergingEntry,existingEntry);
Object mergingDataValue = mergingEntry != null ? mergingEntry.getValue() : null;
@@ -38,7 +55,7 @@ public class CellarMergePolicy implements MergePolicy {
return existingDataValue;
}
- //Merge MultiNodes by merging their members.
+ // merge MultiNodes by merging their members.
else if(MultiNode.class.isAssignableFrom(mergingDataValue.getClass())
&& MultiNode.class.isAssignableFrom(existingDataValue.getClass())) {
@@ -69,23 +86,23 @@ public class CellarMergePolicy implements MergePolicy {
}
/**
- * Merges Sets.
- * @param mergingSet
- * @param existingSet
- * @param <T>
- * @return
+ * Merges sets.
+ *
+ * @param mergingSet the first set to merge.
+ * @param existingSet the second set to merge.
+ * @return a set resulting of the merge of the two others.
*/
public <T> Set<T> merge(Set<T> mergingSet, Set<T> existingSet) {
Set<T> result = new LinkedHashSet<T>();
- //Copy new Set.
+ // copy new Set
if(mergingSet != null && !mergingSet.isEmpty()) {
for(T obj:mergingSet) {
result.add(obj);
}
}
- //Copy existing Set.
+ // copy existing Set
if(existingSet != null && !existingSet.isEmpty()) {
for(T obj:existingSet) {
result.add(obj);
@@ -95,25 +112,24 @@ public class CellarMergePolicy implements MergePolicy {
return result;
}
-
/**
- * Merges Lists.
- * @param mergingList
- * @param existingList
- * @param <T>
- * @return
+ * Merge lists.
+ *
+ * @param mergingList the first list to merge.
+ * @param existingList the second list to merge.
+ * @return a list resulting of the merge of the two others.
*/
public <T> List<T> merge(List<T> mergingList, List<T> existingList) {
List<T> result = new LinkedList<T>();
- //Copy existing List.
+ // copy existing List
if(existingList != null && !existingList.isEmpty()) {
for(T obj:existingList) {
result.add(obj);
}
}
- //Copy new List.
+ // copy new List
if(mergingList != null && !mergingList.isEmpty()) {
for(T obj:mergingList) {
result.add(obj);
@@ -124,10 +140,11 @@ public class CellarMergePolicy implements MergePolicy {
}
/**
- * Merges Strings.
- * @param mergingString
- * @param existingString
- * @return
+ * Merge Strings.
+ *
+ * @param mergingString the first String to merge.
+ * @param existingString the second String to merge.
+ * @return a String resulting of the merge of the two others.
*/
public String merge(String mergingString, String existingString) {
String result = existingString;
@@ -139,4 +156,5 @@ public class CellarMergePolicy implements MergePolicy {
}
return result;
}
+
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 2c4b7ce..77bc51e 100644
--- a/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -14,13 +14,11 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
- xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
+ xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
-
-
- <!-- Hazelcast hazelcast -->
<bean id="hazelcast" class="com.hazelcast.core.Hazelcast" factory-ref="instanceFactory"
factory-method="getInstance" destroy-method="shutdown"/>
+ <service ref="hazelcast" interface="com.hazelcast.core.HazelcastInstance"/>
<bean id="instanceFactory" class="org.apache.karaf.cellar.hazelcast.factory.HazelcastServiceFactory"
init-method="init" destroy-method="destroy">
@@ -36,7 +34,7 @@
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
-
+ <!-- Members Listener -->
<bean id="membershipListener" class="org.apache.karaf.cellar.hazelcast.CellarMembershipListener">
<argument index="0" ref="hazelcast"/>
<property name="synchronizers" ref="synchronizers"/>
@@ -49,8 +47,9 @@
<property name="configurationAdmin" ref="configurationAdmin"/>
<property name="combinedClassLoader" ref="combinedClassLoader"/>
</bean>
+ <service ref="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
- <!-- Group Manager -->
+ <!-- Cluster Group Manager -->
<bean id="groupManager" class="org.apache.karaf.cellar.hazelcast.HazelcastGroupManager" init-method="init" destroy-method="destroy">
<property name="instance" ref="hazelcast"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
@@ -58,30 +57,39 @@
<property name="combinedClassLoader" ref="combinedClassLoader"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
</bean>
+ <service ref="groupManager">
+ <interfaces>
+ <value>org.apache.karaf.cellar.core.GroupManager</value>
+ <value>org.osgi.service.cm.ConfigurationListener</value>
+ </interfaces>
+ </service>
+ <!-- Cluster Event Transport Factory -->
<bean id="eventTransportFactory" class="org.apache.karaf.cellar.hazelcast.HazelcastEventTransportFactory">
<property name="dispatcher" ref="dispatcher"/>
<property name="instance" ref="hazelcast"/>
<property name="combinedClassLoader" ref="combinedClassLoader"/>
</bean>
+ <service ref="eventTransportFactory" interface="org.apache.karaf.cellar.core.event.EventTransportFactory"/>
+ <!-- Cellar Extender -->
<bean id="cellarExtender" class="org.apache.karaf.cellar.hazelcast.CellarExtender" init-method="init" destroy-method="destroy">
<property name="combinedClassLoader" ref="combinedClassLoader"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
</bean>
+ <!-- Bundle Combined ClassLoader -->
<bean id="combinedClassLoader" class="org.apache.karaf.cellar.core.utils.CombinedClassLoader" init-method="init" destroy-method="destroy"/>
-
- <!-- Hazelcast Cluster and Node -->
+ <!-- Local Node -->
<bean id="node" factory-ref="clusterManager" factory-method="getNode"/>
- <!-- The distributed topic -->
+ <!-- Cluster Event Topic -->
<bean id="eventTopic" factory-ref="hazelcast" factory-method="getTopic">
<argument value="org.apache.karaf.cellar.event.topic"/>
</bean>
- <!-- Consumer -->
+ <!-- Cluster Event Consumer -->
<bean id="consumer" class="org.apache.karaf.cellar.hazelcast.TopicConsumer" init-method="init"
destroy-method="destroy">
<property name="instance" ref="hazelcast"/>
@@ -90,108 +98,93 @@
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
- <!-- Producer -->
+ <!-- Cluster Event Producer -->
<bean id="producer" class="org.apache.karaf.cellar.hazelcast.TopicProducer" init-method="init">
<property name="instance" ref="hazelcast"/>
<property name="node" ref="node"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
+ <service ref="producer" interface="org.apache.karaf.cellar.core.event.EventProducer"/>
+ <!-- Execution Context -->
<bean id="executionContext" class="org.apache.karaf.cellar.core.command.ClusteredExecutionContext">
<property name="producer" ref="producer"/>
<property name="commandStore" ref="commandStore"/>
</bean>
+ <service ref="executionContext" interface="org.apache.karaf.cellar.core.command.ExecutionContext"/>
- <!-- Producer Switch Handler -->
+ <!-- Handler For Cluster Producer Switch Command Event -->
<bean id="producerSwitchCommandHandler" class="org.apache.karaf.cellar.core.control.ProducerSwitchCommandHandler">
<property name="producer" ref="producer"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
+ <service ref="producerSwitchCommandHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
+ <!-- Handler For Cluster Producer Switch Result Event -->
<bean id="producerSwitchResultHandler" class="org.apache.karaf.cellar.core.control.ProducerSwitchResultHandler">
<property name="commandStore" ref="commandStore"/>
</bean>
+ <service ref="producerSwitchResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <!-- Consumer Switch Event Handler -->
+ <!-- Handler For Cluster Consumer Switch Command Event -->
<bean id="consumerSwitchCommandHandler" class="org.apache.karaf.cellar.core.control.ConsumerSwitchCommandHandler">
<property name="producer" ref="producer"/>
<property name="consumer" ref="consumer"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
+ <service ref="consumerSwitchCommandHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
+ <!-- Handler For Cluster Consumer Switch Result Event -->
<bean id="consumerSwitchResultHandler" class="org.apache.karaf.cellar.core.control.ConsumerSwitchResultHandler">
<property name="commandStore" ref="commandStore"/>
</bean>
+ <service ref="consumerSwitchResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <!-- Managed Handlers Command Handlers -->
+ <!-- Handler For Cluster Manage Handlers Command Event -->
<bean id="manageHandlersCommandHandler" class="org.apache.karaf.cellar.core.control.ManageHandlersCommandHandler">
<property name="producer" ref="producer"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
+ <service ref="manageHandlersCommandHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
+ <!-- Handler For Cluster Manage Handlers Result Event -->
<bean id="manageHandlersResultHandler" class="org.apache.karaf.cellar.core.control.ManageHandlersResultHandler">
<property name="commandStore" ref="commandStore"/>
</bean>
+ <service ref="manageHandlersResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <!-- Managed Group Command Handlers -->
+ <!-- Handler For Cluster Manager Group Command Event -->
<bean id="manageGroupCommandHandler" class="org.apache.karaf.cellar.core.control.ManageGroupCommandHandler">
<property name="producer" ref="producer"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
</bean>
+ <service ref="manageGroupCommandHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
+ <!-- Handlers For Cluster Manager Group Result Event -->
<bean id="manageGroupResultHandler" class="org.apache.karaf.cellar.core.control.ManageGroupResultHandler">
<property name="commandStore" ref="commandStore"/>
</bean>
+ <service ref="manageGroupResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
<!-- Command Store -->
<bean id="commandStore" class="org.apache.karaf.cellar.core.command.BasicCommandStore"/>
+ <service ref="commandStore" interface="org.apache.karaf.cellar.core.command.CommandStore"/>
-
+ <!-- Cluster Event Dispatcher -->
<bean id="dispatcher" class="org.apache.karaf.cellar.core.event.EventHandlerRegistryDispatcher" init-method="init">
<property name="handlerRegistry" ref="registry"/>
</bean>
-
- <!-- Hazelcast Instance Service-->
- <service ref="hazelcast" interface="com.hazelcast.core.HazelcastInstance"/>
-
- <service ref="producer" interface="org.apache.karaf.cellar.core.event.EventProducer"/>
-
- <service ref="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
- <service ref="eventTransportFactory" interface="org.apache.karaf.cellar.core.event.EventTransportFactory"/>
- <service ref="executionContext" interface="org.apache.karaf.cellar.core.command.ExecutionContext"/>
- <service ref="commandStore" interface="org.apache.karaf.cellar.core.command.CommandStore"/>
-
- <service ref="groupManager">
- <interfaces>
- <value>org.apache.karaf.cellar.core.GroupManager</value>
- <value>org.osgi.service.cm.ConfigurationListener</value>
- </interfaces>
- </service>
-
- <!-- Event Handler Service -->
- <service ref="consumerSwitchCommandHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <service ref="consumerSwitchResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <service ref="producerSwitchCommandHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <service ref="producerSwitchResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <service ref="manageHandlersCommandHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <service ref="manageHandlersResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <service ref="manageGroupCommandHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <service ref="manageGroupResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
-
<reference id="registry" interface="org.apache.karaf.cellar.core.event.EventHandlerRegistry"/>
<reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
<reference-list id="discoveryServices" availability="optional"
interface="org.apache.karaf.cellar.core.discovery.DiscoveryService"/>
-
- <!-- Group Consumer & Producer Serices -->
<reference-list id="groupEventProducers" availability="optional" interface="org.apache.karaf.cellar.core.event.EventProducer"
filter="(type = group)"/>
<reference-list id="groupEventConsumers" availability="optional" interface="org.apache.karaf.cellar.core.event.EventConsumer"
filter="(type = group)"/>
-
<reference-list id="synchronizers" availability="optional" interface="org.apache.karaf.cellar.core.Synchronizer"/>
</blueprint>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/b43a255a/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java b/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java
index 0146b43..9b9ad75 100644
--- a/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java
+++ b/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java
@@ -15,30 +15,17 @@ package org.apache.karaf.cellar.hazelcast.factory;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import java.util.Properties;
-
/**
* Hazelcast service factory test.
*/
@RunWith(JUnit4.class)
public class HazelcastServiceFactoryTest {
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
@Test
public void testDefaultInstance() throws InterruptedException {
HazelcastServiceFactory factory = new HazelcastServiceFactory();
[08/50] [abbrv] Code cleanup
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/utils/CellarUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/utils/CellarUtils.java b/core/src/main/java/org/apache/karaf/cellar/core/utils/CellarUtils.java
index a7f8158..28e57d7 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/utils/CellarUtils.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/utils/CellarUtils.java
@@ -1,3 +1,16 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.karaf.cellar.core.utils;
import java.util.Collection;
@@ -7,6 +20,9 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * Generic Cellar utils class.
+ */
public class CellarUtils {
public static enum MergeType {
@@ -18,11 +34,11 @@ public class CellarUtils {
private static final Pattern mergablePattern = Pattern.compile(MERGABLE_REGEX);
-
/**
- * Returns true if String is mergable.
- * @param s
- * @return
+ * Check if a String is "merge-able".
+ *
+ * @param s the String to check.
+ * @return true if the String is "merge-able", false else.
*/
public static boolean isMergable(String s) {
Matcher matcher = mergablePattern.matcher(s);
@@ -30,10 +46,10 @@ public class CellarUtils {
}
/**
- * Converts a comma delimited String to a Set of Strings.
+ * Convert a comma delimited String to a Set of Strings.
*
- * @param text
- * @return
+ * @param text the String to "split".
+ * @return the set of Strings.
*/
public static Set<String> createSetFromString(String text) {
if(isMergable(text)) {
@@ -56,12 +72,13 @@ public class CellarUtils {
}
/**
- * Creates a comma delimited list of items.
+ * Convert a set of Strings into a global String.
*
- * @param items
- * @return
+ * @param items the set of String.
+ * @param mergeable true if you want to use the MERRGEABLE string format, false else.
+ * @return the global String resulting of the concatenation of the Strings in the Set.
*/
- public static String createStringFromSet(Set<String> items, boolean mergable) {
+ public static String createStringFromSet(Set<String> items, boolean mergeable) {
StringBuilder builder = new StringBuilder();
Iterator<String> iterator = items.iterator();
@@ -71,7 +88,7 @@ public class CellarUtils {
builder.append(",");
}
}
- if (mergable) {
+ if (mergeable) {
return String.format(MERGABLE, builder.toString());
} else {
return builder.toString();
@@ -79,22 +96,22 @@ public class CellarUtils {
}
/**
- * Returns true if both {@link java.util.Collection}s contain exactly the same items (order doesn't matter).
+ * Check if two collections contain the same elements.
*
- * @param col1
- * @param col2
- * @return
+ * @param col1 the first collection.
+ * @param col2 the second collection.
+ * @return true if the two collections
*/
public static boolean collectionEquals(Collection col1, Collection col2) {
return collectionSubset(col1, col2) && collectionSubset(col2, col1);
}
/**
- * Returns true if one {@link Collection} contains all items of the others
+ * Check if the a collection if a subset of another one.
*
- * @param source
- * @param target
- * @return
+ * @param source the source collection.
+ * @param target the target collection.
+ * @return true if source is a subset of the target, false else.
*/
public static boolean collectionSubset(Collection source, Collection target) {
if (source == null && target == null) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/utils/CombinedClassLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/utils/CombinedClassLoader.java b/core/src/main/java/org/apache/karaf/cellar/core/utils/CombinedClassLoader.java
index 8065a77..f31e479 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/utils/CombinedClassLoader.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/utils/CombinedClassLoader.java
@@ -11,13 +11,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.karaf.cellar.core.utils;
import org.osgi.framework.Bundle;
import java.net.URL;
-import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -25,7 +23,7 @@ import java.util.concurrent.ConcurrentMap;
/**
* A class loader which combines multiple bundle class loaders.
* A bundle can add itself for to this class loader, so that the class loader can load classes from the bundle.
- * It is meant to be used together with the extender pattern in order to extends cellars class space.
+ * It is meant to be used together with the extender pattern in order to extends Cellar class space.
*/
public class CombinedClassLoader extends ClassLoader {
@@ -47,7 +45,7 @@ public class CombinedClassLoader extends ClassLoader {
bundles.remove(bundle.getBundleId());
}
-
+ @Override
public Class findClass(String name) throws ClassNotFoundException {
for (Map.Entry<Long, Bundle> entry : bundles.entrySet()) {
try {
@@ -62,8 +60,7 @@ public class CombinedClassLoader extends ClassLoader {
throw new ClassNotFoundException(name);
}
-
-
+ @Override
public URL getResource(String name) {
for (Map.Entry<Long, Bundle> entry : bundles.entrySet()) {
Bundle bundle = entry.getValue();
@@ -76,4 +73,5 @@ public class CombinedClassLoader extends ClassLoader {
}
return null;
}
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index f14da2d..851da4e 100644
--- a/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -14,14 +14,10 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <!-- Registry -->
+ <!-- Handlers Registry -->
<bean id="registry" class="org.apache.karaf.cellar.core.event.EventHandlerServiceRegistry"/>
-
-
- <!-- Service Registrations -->
<service ref="registry" interface="org.apache.karaf.cellar.core.event.EventHandlerRegistry"/>
-
<reference-list id="eventHandlers" interface="org.apache.karaf.cellar.core.event.EventHandler" availability="optional">
<reference-listener bind-method="bind" unbind-method="unbind">
<ref component-id="registry"/>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/test/java/org/apache/karaf/cellar/core/CellarSupportTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/karaf/cellar/core/CellarSupportTest.java b/core/src/test/java/org/apache/karaf/cellar/core/CellarSupportTest.java
index 151118b..f8e7681 100644
--- a/core/src/test/java/org/apache/karaf/cellar/core/CellarSupportTest.java
+++ b/core/src/test/java/org/apache/karaf/cellar/core/CellarSupportTest.java
@@ -78,4 +78,5 @@ public class CellarSupportTest {
result = support.isAllowed(defaultGroup,"config","org.apache.karaf.cellar.instance", EventType.INBOUND);
assertEquals("Instance config should be allowed",expectedResult,result);
}
+
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/test/java/org/apache/karaf/cellar/core/utils/CellarUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/karaf/cellar/core/utils/CellarUtilsTest.java b/core/src/test/java/org/apache/karaf/cellar/core/utils/CellarUtilsTest.java
index 28c97d5..7af5f32 100644
--- a/core/src/test/java/org/apache/karaf/cellar/core/utils/CellarUtilsTest.java
+++ b/core/src/test/java/org/apache/karaf/cellar/core/utils/CellarUtilsTest.java
@@ -1,3 +1,16 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.karaf.cellar.core.utils;
import java.util.ArrayList;
[04/50] [abbrv] git commit: Code cleanup
Posted by jb...@apache.org.
Code cleanup
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1470988 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/913bf55f
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/913bf55f
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/913bf55f
Branch: refs/heads/master
Commit: 913bf55fae8ab7686e62ce0313a34acf4551a839
Parents: 65d177e
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Apr 23 14:53:44 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Apr 23 14:53:44 2013 +0000
----------------------------------------------------------------------
.../apache/karaf/cellar/cloud/Activator.java | 6 ++
.../cellar/cloud/BlobStoreDiscoveryService.java | 59 +++++++++++++-------
.../karaf/cellar/cloud/ServiceContainer.java | 12 ++--
3 files changed, 50 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/913bf55f/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java
----------------------------------------------------------------------
diff --git a/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java b/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java
index c51926a..8c020cb 100644
--- a/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java
+++ b/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java
@@ -20,8 +20,12 @@ import org.osgi.service.cm.ManagedServiceFactory;
import java.util.Hashtable;
+/**
+ * Cloud bundle activator.
+ */
public class Activator implements BundleActivator {
+ @Override
public void start(BundleContext context) throws Exception {
Hashtable<String, Object> properties = new Hashtable<String, Object>();
properties.put(Constants.SERVICE_PID, "org.apache.karaf.cellar.cloud");
@@ -29,7 +33,9 @@ public class Activator implements BundleActivator {
context.registerService(ManagedServiceFactory.class.getName(), blobStoreDiscoveryServiceFactory, properties);
}
+ @Override
public void stop(BundleContext context) throws Exception {
+ // nothing to do
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/913bf55f/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
----------------------------------------------------------------------
diff --git a/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java b/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
index 590ac18..522140d 100644
--- a/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
+++ b/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
@@ -14,7 +14,6 @@
package org.apache.karaf.cellar.cloud;
import org.apache.karaf.cellar.core.discovery.DiscoveryService;
-import org.jclouds.blobstore.BlobMap;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextFactory;
@@ -38,6 +37,9 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+/**
+ * Discovery service that use a cloud blob store.
+ */
public class BlobStoreDiscoveryService implements DiscoveryService {
private static final transient Logger LOGGER = LoggerFactory.getLogger(BlobStoreDiscoveryService.class);
@@ -52,9 +54,6 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
BlobStoreContext context;
private BlobStore blobStore;
- /**
- * Constructor
- */
public BlobStoreDiscoveryService() {
LOGGER.debug("CELLAR CLOUD: blob store discovery service initialized");
}
@@ -83,10 +82,11 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
}
/**
- * Returns a {@link Set} of Ips.
+ * Returns a {@link Set} of IPs.
*
- * @return
+ * @return a set of IPs.
*/
+ @Override
public Set<String> discoverMembers() {
refresh();
@@ -95,7 +95,7 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
ListContainerOptions opt = new ListContainerOptions();
PageSet<? extends StorageMetadata> pageSet = blobStore.list(container, opt);
- LOGGER.debug("CELLAR CLOUD: storage contains a pageset of size {}", pageSet.size());
+ LOGGER.debug("CELLAR CLOUD: storage contains a page set of size {}", pageSet.size());
for (StorageMetadata md : pageSet) {
if (md.getType() != StorageType.BLOB) {
//skip everything that isn't of type BLOB ...
@@ -105,7 +105,7 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
Object obj = readBlob(container, ip);
if (obj == null)
continue;
- //Check if ip hasn't been updated recently.
+ // check if the IP hasn't been updated recently
if (obj instanceof DateTime) {
LOGGER.debug("CELLAR CLOUD: retrieved a DateTime from blog store");
DateTime registeredTime = (DateTime) obj;
@@ -136,6 +136,7 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
/**
* Sign In member to the {@link DiscoveryService}.
*/
+ @Override
public void signIn() {
DateTime now = new DateTime();
createBlob(container, ipAddress, new ServiceContainer(getHostAdress(), getIpAddress(), now));
@@ -144,28 +145,30 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
/**
* Refresh member to the {@link DiscoveryService}.
*/
+ @Override
public void refresh() {
DateTime now = new DateTime();
createBlob(container, ipAddress, new ServiceContainer(getHostAdress(), getIpAddress(), now));
}
/**
- * Sing out member to the {@link DiscoveryService}.
+ * Sign out member to the {@link DiscoveryService}.
*/
+ @Override
public void signOut() {
if (blobStore.blobExists(container, ipAddress)) {
blobStore.removeBlob(container, ipAddress);
} else {
- LOGGER.debug("CELLAR CLOUD: could not find the IP address of the current node in the blob store.");
+ LOGGER.debug("CELLAR CLOUD: could not find the IP address of the current node in the blob store");
}
}
/**
- * Reads from a {@link BlobStore}. It returns an Object.
+ * Reads from a {@link BlobStore}.
*
- * @param container
- * @param blobName
- * @return
+ * @param container the blob store container.
+ * @param blobName the blob store name.
+ * @return the Object read from the blob store.
*/
protected Object readBlob(String container, String blobName) {
Object result = null;
@@ -186,6 +189,7 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
try {
ois.close();
} catch (IOException e) {
+ // nothing to do
}
}
@@ -193,13 +197,20 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
try {
is.close();
} catch (IOException e) {
+ // nothing to do
}
}
}
-
return result;
}
+ /**
+ * Create a blob store.
+ *
+ * @param container the blob store container.
+ * @param name the blob store name.
+ * @param data the blob store data.
+ */
public void createBlob(String container, String name, Object data) {
Blob blob;
if (blobStore != null) {
@@ -227,6 +238,7 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
try {
oos.close();
} catch (IOException e) {
+ // nothing to do
}
}
@@ -234,6 +246,7 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
try {
baos.close();
} catch (IOException e) {
+ // nothing to do
}
}
}
@@ -241,23 +254,29 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
}
/**
- * Get an instance of InetAddress for the local computer
- * and return its string representation.
+ * Get the IP address of the local node.
+ *
+ * @return the IP address of the local node.
*/
protected String getIpAddress() {
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException ex) {
- LOGGER.error("CELLAR CLOUD: can't determine IP address for current node", ex);
+ LOGGER.error("CELLAR CLOUD: can't determine IP address of the local node", ex);
return null;
}
}
-
+
+ /**
+ * Get the hostname of the local node.
+ *
+ * @return the hostname of the local node.
+ */
protected String getHostAdress() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException ex) {
- LOGGER.error("CELLAR CLOUD: unable to determine host address for current node", ex);
+ LOGGER.error("CELLAR CLOUD: unable to determine host name of the node", ex);
return null;
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/913bf55f/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java
----------------------------------------------------------------------
diff --git a/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java b/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java
index ff77148..5e7f012 100644
--- a/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java
+++ b/cloud/src/main/java/org/apache/karaf/cellar/cloud/ServiceContainer.java
@@ -17,13 +17,11 @@ import java.io.Serializable;
import org.joda.time.DateTime;
+/**
+ * A cloud service container.
+ */
public class ServiceContainer implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
private DateTime registeredTime;
private String hostName;
private String hostIp;
@@ -48,12 +46,12 @@ public class ServiceContainer implements Serializable {
public ServiceContainer(String hostName, String hostIp, DateTime registeredTime) {
this(hostName, hostIp, null, registeredTime);
}
-
-
+
public ServiceContainer(String hostName, String hostIp, String hostPort, DateTime registeredTime) {
this.registeredTime = registeredTime;
this.hostName = hostName;
this.hostIp = hostIp;
this.hostPort = hostPort;
}
+
}
[48/50] [abbrv] git commit: [KARAF-2514] Improve Cellar config,
especially around configuration deletion
Posted by jb...@apache.org.
[KARAF-2514] Improve Cellar config, especially around configuration deletion
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1531345 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/5fe65839
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/5fe65839
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/5fe65839
Branch: refs/heads/master
Commit: 5fe65839e4473d72dae4ac03515441a84fe7a5bc
Parents: ef5dec8
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Fri Oct 11 16:23:41 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Fri Oct 11 16:23:41 2013 +0000
----------------------------------------------------------------------
.../config/ClusterConfigurationEvent.java | 6 ++--
.../config/ConfigurationEventHandler.java | 17 +++++-----
.../config/LocalConfigurationListener.java | 34 +++++++++-----------
3 files changed, 27 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/5fe65839/config/src/main/java/org/apache/karaf/cellar/config/ClusterConfigurationEvent.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ClusterConfigurationEvent.java b/config/src/main/java/org/apache/karaf/cellar/config/ClusterConfigurationEvent.java
index d3eb7ee..9c51e44 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/ClusterConfigurationEvent.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ClusterConfigurationEvent.java
@@ -20,17 +20,17 @@ import org.apache.karaf.cellar.core.event.Event;
*/
public class ClusterConfigurationEvent extends Event {
- private int type;
+ private Integer type;
public ClusterConfigurationEvent(String id) {
super(id);
}
- public int getType() {
+ public Integer getType() {
return type;
}
- public void setType(int type) {
+ public void setType(Integer type) {
this.type = type;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/5fe65839/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
index 7cf7211..e1d87ad 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
@@ -72,28 +72,29 @@ public class ConfigurationEventHandler extends ConfigurationSupport implements E
if (isAllowed(event.getSourceGroup(), Constants.CATEGORY, pid, EventType.INBOUND)) {
Properties clusterDictionary = clusterConfigurations.get(pid);
- Configuration conf;
try {
- conf = configurationAdmin.getConfiguration(pid, null);
+ // update the local configuration
+ Configuration[] localConfigurations = configurationAdmin.listConfigurations("(service.pid=" + pid + ")");
if (event.getType() == ConfigurationEvent.CM_DELETED) {
- if (conf.getProperties() != null) {
- // delete the properties
- conf.delete();
+ // delete the configuration
+ if (localConfigurations != null && localConfigurations.length > 0) {
+ localConfigurations[0].delete();
deleteStorage(pid);
}
} else {
if (clusterDictionary != null) {
- Dictionary localDictionary = conf.getProperties();
+ Configuration localConfiguration = configurationAdmin.getConfiguration(pid, null);
+ Dictionary localDictionary = localConfiguration.getProperties();
if (localDictionary == null)
localDictionary = new Properties();
localDictionary = filter(localDictionary);
if (!equals(clusterDictionary, localDictionary)) {
- conf.update((Dictionary) clusterDictionary);
+ localConfiguration.update((Dictionary) clusterDictionary);
persistConfiguration(configurationAdmin, pid, clusterDictionary);
}
}
}
- } catch (IOException ex) {
+ } catch (Exception ex) {
LOGGER.error("CELLAR CONFIG: failed to read cluster configuration", ex);
}
} else LOGGER.debug("CELLAR CONFIG: configuration PID {} is marked BLOCKED INBOUND for cluster group {}", pid, groupName);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/5fe65839/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java b/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
index f35d9fb..83d83aa 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
@@ -52,17 +52,6 @@ public class LocalConfigurationListener extends ConfigurationSupport implements
String pid = event.getPid();
- Dictionary localDictionary = null;
- if (event.getType() != ConfigurationEvent.CM_DELETED) {
- try {
- Configuration conf = configurationAdmin.getConfiguration(pid, null);
- localDictionary = conf.getProperties();
- } catch (Exception e) {
- LOGGER.error("CELLAR CONFIG: can't retrieve configuration with PID {}", pid, e);
- return;
- }
- }
-
Set<Group> groups = groupManager.listLocalGroups();
if (groups != null && !groups.isEmpty()) {
@@ -74,15 +63,22 @@ public class LocalConfigurationListener extends ConfigurationSupport implements
try {
if (event.getType() == ConfigurationEvent.CM_DELETED) {
- // update the configurations in the cluster group
- clusterConfigurations.remove(pid);
- // broadcast the cluster event
- ClusterConfigurationEvent clusterConfigurationEvent = new ClusterConfigurationEvent(pid);
- clusterConfigurationEvent.setType(ConfigurationEvent.CM_DELETED);
- clusterConfigurationEvent.setSourceNode(clusterManager.getNode());
- clusterConfigurationEvent.setSourceGroup(group);
- eventProducer.produce(clusterConfigurationEvent);
+
+ if (clusterConfigurations.containsKey(pid)) {
+ // update the configurations in the cluster group
+ clusterConfigurations.remove(pid);
+ // broadcast the cluster event
+ ClusterConfigurationEvent clusterConfigurationEvent = new ClusterConfigurationEvent(pid);
+ clusterConfigurationEvent.setType(event.getType());
+ clusterConfigurationEvent.setSourceNode(clusterManager.getNode());
+ clusterConfigurationEvent.setSourceGroup(group);
+ eventProducer.produce(clusterConfigurationEvent);
+ }
+
} else {
+
+ Configuration conf = configurationAdmin.getConfiguration(pid, null);
+ Dictionary localDictionary = conf.getProperties();
localDictionary = filter(localDictionary);
Properties distributedDictionary = clusterConfigurations.get(pid);
[12/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471419 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/2184d484
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/2184d484
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/2184d484
Branch: refs/heads/master
Commit: 2184d48476c222ebc370bcc5c57878b4bbb6ea32
Parents: 4574b21
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed Apr 24 13:58:25 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed Apr 24 13:58:25 2013 +0000
----------------------------------------------------------------------
.../apache/karaf/cellar/dosgi/Constants.java | 3 +
.../cellar/dosgi/ExportServiceListener.java | 99 ++++++++++----------
.../cellar/dosgi/ImportServiceListener.java | 31 +++---
.../karaf/cellar/dosgi/RemoteServiceCall.java | 7 +-
.../cellar/dosgi/RemoteServiceCallHandler.java | 26 +++--
.../cellar/dosgi/RemoteServiceFactory.java | 3 +-
.../cellar/dosgi/RemoteServiceFindHook.java | 4 +-
.../dosgi/RemoteServiceInvocationHandler.java | 9 +-
.../karaf/cellar/dosgi/RemoteServiceResult.java | 7 +-
.../dosgi/RemoteServiceResultHandler.java | 7 +-
.../shell/ListDistributedServicesCommand.java | 4 +-
.../resources/OSGI-INF/blueprint/blueprint.xml | 10 +-
.../OSGI-INF/blueprint/shell-dosgi.xml | 2 -
.../cellar/dosgi/EndpointDescriptionTest.java | 4 +-
.../cellar/dosgi/ExportServiceListenerTest.java | 14 +--
15 files changed, 107 insertions(+), 123 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java
index cb87db1..c26b686 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java
@@ -13,6 +13,9 @@
*/
package org.apache.karaf.cellar.dosgi;
+/**
+ * DOSGi Constants.
+ */
public abstract class Constants {
public static final String SEPARATOR = "/";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java
index f12921b..fff299b 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java
@@ -32,7 +32,7 @@ import java.util.Map;
import java.util.Set;
/**
- * Listener for service export.
+ * Listener called when a new service is exported.
*/
public class ExportServiceListener implements ServiceListener {
@@ -42,9 +42,9 @@ public class ExportServiceListener implements ServiceListener {
private EventTransportFactory eventTransportFactory;
private BundleContext bundleContext;
- private Map<String,EndpointDescription> remoteEndpoints;
+ private Map<String, EndpointDescription> remoteEndpoints;
- private final Map<String,EventConsumer> consumers = new HashMap<String,EventConsumer>();
+ private final Map<String, EventConsumer> consumers = new HashMap<String, EventConsumer>();
private Node node;
@@ -53,17 +53,17 @@ public class ExportServiceListener implements ServiceListener {
remoteEndpoints = clusterManager.getMap(Constants.REMOTE_ENDPOINTS);
bundleContext.addServiceListener(this);
- //Lookup for already exported services.
+ // lookup for already exported services
ServiceReference[] references = null;
try {
- String filter = "(" + Constants.EXPORTED_INTERFACES + "=" + Constants.ALL_INTERFACES+")";
+ String filter = "(" + Constants.EXPORTED_INTERFACES + "=" + Constants.ALL_INTERFACES + ")";
references = bundleContext.getServiceReferences((String) null, filter);
- if (references != null) {
- for (ServiceReference reference : references) {
- exportService(reference);
+ if (references != null) {
+ for (ServiceReference reference : references) {
+ exportService(reference);
+ }
}
- }
} catch (InvalidSyntaxException e) {
LOGGER.error("CELLAR DOSGI: error exporting existing remote services", e);
}
@@ -71,35 +71,38 @@ public class ExportServiceListener implements ServiceListener {
public void destroy() {
bundleContext.removeServiceListener(this);
- for(Map.Entry<String,EventConsumer> consumerEntry:consumers.entrySet()) {
- EventConsumer consumer = consumerEntry.getValue();
- consumer.stop();
- }
- consumers.clear();
+ for (Map.Entry<String, EventConsumer> consumerEntry : consumers.entrySet()) {
+ EventConsumer consumer = consumerEntry.getValue();
+ consumer.stop();
+ }
+ consumers.clear();
}
-
+ /**
+ * Callback method called when a service has change.
+ *
+ * @param event the local service change event.
+ */
@Override
public void serviceChanged(ServiceEvent event) {
- if (event != null) {
- switch (event.getType()) {
- case ServiceEvent.REGISTERED:
- exportService(event.getServiceReference());
- break;
- case ServiceEvent.UNREGISTERING:
- unExportService(event.getServiceReference());
- break;
- case ServiceEvent.MODIFIED:
- case ServiceEvent.MODIFIED_ENDMATCH:
- default:
- break;
- }
+ if (event != null) {
+ switch (event.getType()) {
+ case ServiceEvent.REGISTERED:
+ exportService(event.getServiceReference());
+ break;
+ case ServiceEvent.UNREGISTERING:
+ unExportService(event.getServiceReference());
+ break;
+ case ServiceEvent.MODIFIED:
+ case ServiceEvent.MODIFIED_ENDMATCH:
+ default:
+ break;
}
-
+ }
}
/**
- * Registers {@link EventConsumer}s for consuming remote service calls.
+ * Register a cluster event consumer on a local service reference, in order to consume remote service calls.
*
* @param serviceReference The reference of the service to be exported.
*/
@@ -110,14 +113,14 @@ public class ExportServiceListener implements ServiceListener {
String exportedServices = (String) serviceReference.getProperty(Constants.EXPORTED_INTERFACES);
if (exportedServices != null && exportedServices.length() > 0) {
- LOGGER.debug("CELLAR DOSGI: Exporting remote service");
+ LOGGER.debug("CELLAR DOSGI: registering services {} in the cluster", exportedServices);
String[] interfaces = exportedServices.split(Constants.INTERFACE_SEPARATOR);
Object service = bundleContext.getService(serviceReference);
Set<String> exportedInterfaces = getServiceInterfaces(service, interfaces);
for (String iface : exportedInterfaces) {
- //Add endpoint description to the set.
+ // add endpoint description to the set.
Version version = serviceReference.getBundle().getVersion();
String endpointId = iface + Constants.SEPARATOR + version.toString();
@@ -127,17 +130,17 @@ public class ExportServiceListener implements ServiceListener {
endpoint = remoteEndpoints.get(endpointId);
endpoint.getNodes().add(node);
} else {
- endpoint = new EndpointDescription(endpointId,node);
+ endpoint = new EndpointDescription(endpointId, node);
}
remoteEndpoints.put(endpointId, endpoint);
- //Register the endpoint consumer
+ // register the endpoint consumer
EventConsumer consumer = consumers.get(endpointId);
- if(consumer == null) {
+ if (consumer == null) {
consumer = eventTransportFactory.getEventConsumer(Constants.INTERFACE_PREFIX + Constants.SEPARATOR + endpointId, false);
consumers.put(endpointId, consumer);
- } else if(!consumer.isConsuming()) {
+ } else if (!consumer.isConsuming()) {
consumer.start();
}
}
@@ -148,32 +151,32 @@ public class ExportServiceListener implements ServiceListener {
}
/**
- * Removes {@link EventConsumer}s for consuming remote service calls.
+ * Remove the cluster event consumer, and stop to consume remote service calls.
*
- * @param serviceReference
+ * @param serviceReference the service to stop to expose on the cluster.
*/
public void unExportService(ServiceReference serviceReference) {
- ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
String exportedServices = (String) serviceReference.getProperty(Constants.EXPORTED_INTERFACES);
if (exportedServices != null && exportedServices.length() > 0) {
- LOGGER.debug("CELLAR DOSGI: un-exporting remote service");
+ LOGGER.debug("CELLAR DOSGI: un-register service {} from the cluster", exportedServices);
String[] interfaces = exportedServices.split(Constants.INTERFACE_SEPARATOR);
Object service = bundleContext.getService(serviceReference);
Set<String> exportedInterfaces = getServiceInterfaces(service, interfaces);
for (String iface : exportedInterfaces) {
- //Add endpoint description to the set.
+ // add endpoint description to the set.
Version version = serviceReference.getBundle().getVersion();
String endpointId = iface + Constants.SEPARATOR + version.toString();
EndpointDescription endpointDescription = remoteEndpoints.remove(endpointId);
endpointDescription.getNodes().remove(node);
- //If the endpoint is used for export from other nodes too, then put it back.
- if(endpointDescription.getNodes().size() > 0) {
- remoteEndpoints.put(endpointId,endpointDescription);
+ // if the endpoint is used for export from other nodes too, then put it back.
+ if (endpointDescription.getNodes().size() > 0) {
+ remoteEndpoints.put(endpointId, endpointDescription);
}
EventConsumer eventConsumer = consumers.remove(endpointId);
@@ -186,11 +189,11 @@ public class ExportServiceListener implements ServiceListener {
}
/**
- * Returns a Set of interfaces that match the actual exported service interfaces of a service.
+ * Get the interfaces that match the exported service interfaces.
*
- * @param service
- * @param services
- * @return
+ * @param service the service.
+ * @param services the service interfaces.
+ * @return the matched service interface.
*/
public Set<String> getServiceInterfaces(Object service, String[] services) {
Set<String> interfaceList = new LinkedHashSet<String>();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java
index 6a166f3..c37da89 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java
@@ -14,7 +14,6 @@
package org.apache.karaf.cellar.dosgi;
import org.apache.karaf.cellar.core.ClusterManager;
-import org.apache.karaf.cellar.core.Producer;
import org.apache.karaf.cellar.core.command.ClusteredExecutionContext;
import org.apache.karaf.cellar.core.command.CommandStore;
import org.apache.karaf.cellar.core.command.ExecutionContext;
@@ -33,7 +32,6 @@ import java.util.Hashtable;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -79,7 +77,7 @@ public class ImportServiceListener implements ListenerHook, Runnable {
producers.clear();
}
-
+ @Override
public void run() {
for (ListenerInfo listener : pendingListeners) {
checkListener(listener);
@@ -98,9 +96,8 @@ public class ImportServiceListener implements ListenerHook, Runnable {
}
pendingListeners.add(listenerInfo);
- // Make sure we only import remote services
+ // make sure we only import remote services
checkListener(listenerInfo);
-
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
@@ -117,9 +114,9 @@ public class ImportServiceListener implements ListenerHook, Runnable {
continue;
}
- // Make sure we only import remote services
+ // make sure we only import remote services
String filter = "(&" + listenerInfo.getFilter() + "(!(" + Constants.ENDPOINT_FRAMEWORK_UUID + "=" + clusterManager.getNode().getId() + ")))";
- // Iterate through known services and import them if needed
+ // iterate through known services and import them if needed
Set<EndpointDescription> matches = new LinkedHashSet<EndpointDescription>();
for (Map.Entry<String, EndpointDescription> entry : remoteEndpoints.entrySet()) {
EndpointDescription endpointDescription = entry.getValue();
@@ -129,7 +126,7 @@ public class ImportServiceListener implements ListenerHook, Runnable {
}
for (EndpointDescription endpoint : matches) {
- unimportService(endpoint);
+ unImportService(endpoint);
}
pendingListeners.remove(listenerInfo);
@@ -140,15 +137,15 @@ public class ImportServiceListener implements ListenerHook, Runnable {
}
/**
- * Checks if there is a match for the current {@link ListenerInfo}.
+ * Check if there is a match for the current {@link ListenerInfo}.
*
- * @param listenerInfo
+ * @param listenerInfo the listener info.
*/
private void checkListener(ListenerInfo listenerInfo) {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- // Iterate through known services and import them if needed
+ // iterate through known services and import them if needed
Set<EndpointDescription> matches = new LinkedHashSet<EndpointDescription>();
for (Map.Entry<String, EndpointDescription> entry : remoteEndpoints.entrySet()) {
EndpointDescription endpointDescription = entry.getValue();
@@ -166,10 +163,10 @@ public class ImportServiceListener implements ListenerHook, Runnable {
}
/**
- * Imports a remote service to the service registry.
+ * Import a remote service to the service registry.
*
- * @param endpoint
- * @param listenerInfo
+ * @param endpoint the endpoint to import.
+ * @param listenerInfo the associated listener info.
*/
private void importService(EndpointDescription endpoint, ListenerInfo listenerInfo) {
LOGGER.debug("CELLAR DOSGI: importing remote service");
@@ -202,11 +199,11 @@ public class ImportServiceListener implements ListenerHook, Runnable {
}
/**
- * Unregisters an imported service
+ * Un-register an imported service.
*
- * @param endpoint
+ * @param endpoint the endpoint to un-register.
*/
- private void unimportService(EndpointDescription endpoint) {
+ private void unImportService(EndpointDescription endpoint) {
ServiceRegistration registration = registrations.get(endpoint);
registration.unregister();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java
index f337f6b..7ffcba4 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java
@@ -18,7 +18,7 @@ import org.apache.karaf.cellar.core.command.Command;
import java.util.List;
/**
- * Call to a remote service.
+ * Cluster remote service call event.
*/
public class RemoteServiceCall extends Command<RemoteServiceResult> {
@@ -27,11 +27,6 @@ public class RemoteServiceCall extends Command<RemoteServiceResult> {
private String serviceClass;
private List<Object> arguments;
- /**
- * Constructor
- *
- * @param id
- */
public RemoteServiceCall(String id) {
super(id);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
index c29053f..cfe8e27 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
@@ -32,7 +32,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
- * Call handler for remote service.
+ * Handler for cluster remote service call event.
*/
public class RemoteServiceCallHandler extends CellarSupport implements EventHandler<RemoteServiceCall> {
@@ -46,6 +46,11 @@ public class RemoteServiceCallHandler extends CellarSupport implements EventHand
private EventTransportFactory eventTransportFactory;
+ /**
+ * Handle a cluster remote service call event.
+ *
+ * @param event the cluster event to handle.
+ */
@Override
public void handle(RemoteServiceCall event) {
@@ -58,28 +63,22 @@ public class RemoteServiceCallHandler extends CellarSupport implements EventHand
Object targetService = null;
if (event != null) {
-
ServiceReference[] serviceReferences = null;
try {
-
serviceReferences = bundleContext.getServiceReferences(event.getServiceClass(), null);
if (serviceReferences != null && serviceReferences.length > 0) {
targetService = bundleContext.getService(serviceReferences[0]);
bundleContext.ungetService(serviceReferences[0]);
}
-
} catch (InvalidSyntaxException e) {
- LOGGER.error("CELLAR DOSGI: could not lookup service", e);
+ LOGGER.error("CELLAR DOSGI: failed to lookup service", e);
}
if (targetService != null) {
-
Class[] classes = new Class[0];
-
if (event.getArguments() != null && event.getArguments().size() > 0) {
classes = new Class[event.getArguments().size()];
int i = 0;
-
for (Object obj : event.getArguments()) {
classes[i++] = obj.getClass();
}
@@ -111,12 +110,21 @@ public class RemoteServiceCallHandler extends CellarSupport implements EventHand
}
}
-
+ /**
+ * Get the event type that this handler can handle.
+ *
+ * @return the remote service call event type.
+ */
@Override
public Class<RemoteServiceCall> getType() {
return RemoteServiceCall.class;
}
+ /**
+ * Get the handler switch.
+ *
+ * @return the handler switch.
+ */
@Override
public Switch getSwitch() {
// load the switch status from the config
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java
index 51db5c3..11d1321 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java
@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.List;
/**
- * Remote service factory.
+ * Factory for remote service.
*/
public class RemoteServiceFactory implements ServiceFactory {
@@ -54,6 +54,7 @@ public class RemoteServiceFactory implements ServiceFactory {
@Override
public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+ // nothing to do
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java
index 3d2d71c..2584d2b 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java
@@ -19,13 +19,13 @@ import org.osgi.framework.hooks.service.FindHook;
import java.util.Collection;
/**
- * Remote service finder.
+ * Hook for remote service find.
*/
public class RemoteServiceFindHook implements FindHook {
@Override
public void find(BundleContext context, String name, String filter, boolean allServices, Collection references) {
-
+ // nothing to do
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java
index 8f4afe2..fc82ed4 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java
@@ -24,7 +24,7 @@ import java.util.List;
import java.util.Map;
/**
- * Handler for the remote service invocation.
+ * Handler for cluster remote service invocation event.
*/
public class RemoteServiceInvocationHandler implements InvocationHandler {
@@ -33,13 +33,6 @@ public class RemoteServiceInvocationHandler implements InvocationHandler {
private ClusterManager clusterManager;
private ExecutionContext executionContext;
- /**
- * Constructor
- * @param endpointId
- * @param serviceClass
- * @param clusterManager
- * @param executionContext
- */
public RemoteServiceInvocationHandler(String endpointId,String serviceClass, ClusterManager clusterManager, ExecutionContext executionContext) {
this.endpointId = endpointId;
this.serviceClass = serviceClass;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java
index 5c07b37..81bb7f6 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java
@@ -16,17 +16,12 @@ package org.apache.karaf.cellar.dosgi;
import org.apache.karaf.cellar.core.command.Result;
/**
- * Remote service call result.
+ * Cluster remote service result event.
*/
public class RemoteServiceResult extends Result {
private Object result;
- /**
- * Constructor
- *
- * @param id
- */
public RemoteServiceResult(String id) {
super(id);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java
index f5b2a50..334f2ed 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java
@@ -16,10 +16,15 @@ package org.apache.karaf.cellar.dosgi;
import org.apache.karaf.cellar.core.command.ResultHandler;
/**
- * Handler for a remote service result.
+ * Handler for cluster remote service result event.
*/
public class RemoteServiceResultHandler extends ResultHandler<RemoteServiceResult> {
+ /**
+ * Get the event type that this handler is able to handle.
+ *
+ * @return the cluster remote service result event type.
+ */
@Override
public Class<RemoteServiceResult> getType() {
return RemoteServiceResult.class;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
index 975d9d2..7abcadf 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
@@ -22,7 +22,7 @@ import org.apache.karaf.shell.commands.Command;
import java.util.Map;
import java.util.Set;
-@Command(scope = "cluster", name = "service-list", description = "List the cluster distributed services.")
+@Command(scope = "cluster", name = "service-list", description = "List the cluster distributed services")
public class ListDistributedServicesCommand extends CellarCommandSupport {
private static final String LIST_FORMAT = "%-80s %-20s";
@@ -46,7 +46,7 @@ public class ListDistributedServicesCommand extends CellarCommandSupport {
}
} else {
- System.out.println("There are no distributed service");
+ System.out.println("No distributed service");
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 58c699a..51171fc 100644
--- a/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -16,21 +16,22 @@
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<!-- Import Service Listener -->
- <bean id="importListener" class="org.apache.karaf.cellar.dosgi.ImportServiceListener" init-method="init" destroy-method="destroy">
+ <bean id="importServiceListener" class="org.apache.karaf.cellar.dosgi.ImportServiceListener" init-method="init" destroy-method="destroy">
<property name="clusterManager" ref="clusterManager"/>
<property name="commandStore" ref="commandStore"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="eventTransportFactory" ref="eventTransportFactory"/>
</bean>
- <service ref="importListener" interface="org.osgi.framework.hooks.service.ListenerHook"/>
+ <service ref="importServiceListener" interface="org.osgi.framework.hooks.service.ListenerHook"/>
<!-- Export Service Listener -->
- <bean id="exportListener" class="org.apache.karaf.cellar.dosgi.ExportServiceListener" init-method="init" destroy-method="destroy">
+ <bean id="exportServiceListener" class="org.apache.karaf.cellar.dosgi.ExportServiceListener" init-method="init" destroy-method="destroy">
<property name="clusterManager" ref="clusterManager"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="eventTransportFactory" ref="eventTransportFactory"/>
</bean>
+ <!-- Remote Service Call Event Handler -->
<bean id="remoteServiceCallHandler" class="org.apache.karaf.cellar.dosgi.RemoteServiceCallHandler">
<property name="clusterManager" ref="clusterManager"/>
<property name="eventTransportFactory" ref="eventTransportFactory"/>
@@ -43,13 +44,12 @@
</service-properties>
</service>
- <!-- Cluster Event Handler -->
+ <!-- Remote Service Result Event Handler -->
<bean id="remoteServiceResultHandler" class="org.apache.karaf.cellar.dosgi.RemoteServiceResultHandler">
<property name="commandStore" ref="commandStore"/>
</bean>
<service ref="remoteServiceResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <!-- Cluster Core Services -->
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="eventTransportFactory" interface="org.apache.karaf.cellar.core.event.EventTransportFactory"/>
<reference id="commandStore" interface="org.apache.karaf.cellar.core.command.CommandStore"/>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
----------------------------------------------------------------------
diff --git a/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml b/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
index 1de4eb5..4aafd27 100644
--- a/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
+++ b/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
@@ -14,7 +14,6 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
- <!-- Command Bundle -->
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
<command name="cluster/service-list">
<action class="org.apache.karaf.cellar.dosgi.shell.ListDistributedServicesCommand">
@@ -23,5 +22,4 @@
</command>
</command-bundle>
-
</blueprint>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java
----------------------------------------------------------------------
diff --git a/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java b/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java
index f79dfac..c13f52d 100644
--- a/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java
+++ b/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java
@@ -19,13 +19,11 @@ import org.junit.Test;
public class EndpointDescriptionTest {
String objectClass = "org.apache.karaf.cellar.dosgi.Test";
- String frameworkUUID1 = "192.168.1.101:5701";
- String frameworkUUID2 = "192.168.1.102:5702";
String filterPattern = "(&(objectClass=%s))";
@Test
public void testMatches() throws Exception {
- //This is a dummy test for testing the behaviour of matches method.
+ // this is a dummy test for testing the behaviour of matches method
String testEndpointFilter = String.format(filterPattern, objectClass);
String endpointId = objectClass + Constants.SEPARATOR + "1.0.0";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java
----------------------------------------------------------------------
diff --git a/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java b/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java
index e40a010..41849b0 100644
--- a/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java
+++ b/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java
@@ -13,9 +13,7 @@
*/
package org.apache.karaf.cellar.dosgi;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
@@ -26,16 +24,6 @@ public class ExportServiceListenerTest {
private ExportServiceListener listener = new ExportServiceListener();
- @Before
- public void setUp() throws Exception {
-
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
@Test
public void testGetServiceInterfaces() throws Exception {
System.out.println("Test Service interfaces with null service");
@@ -46,7 +34,7 @@ public class ExportServiceListenerTest {
result = listener.getServiceInterfaces(null,new String[] {"*"});
Assert.assertEquals(expectedResult,result);
- System.out.println("Test Service interfaces with ArrayList and wildchard services");
+ System.out.println("Test Service interfaces with ArrayList and wildcard services");
result = listener.getServiceInterfaces(new ArrayList(),new String[] {"*"});
Assert.assertTrue(result.contains("java.util.List"));
[32/50] [abbrv] git commit: Fix bundle synchronizer
Posted by jb...@apache.org.
Fix bundle synchronizer
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1484063 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/a18c0f61
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/a18c0f61
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/a18c0f61
Branch: refs/heads/master
Commit: a18c0f6170a869c52e9c2904041dcd80cdb405e2
Parents: 9020e91
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Sat May 18 06:29:50 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Sat May 18 06:29:50 2013 +0000
----------------------------------------------------------------------
.../java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/a18c0f61/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 100ebd3..6194be9 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
@@ -150,7 +150,6 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
// if there is no symbolic name, resort to location.
name = (name == null) ? bundle.getLocation() : name;
bundleState.setName(name);
- bundleState.setName(bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME));
bundleState.setLocation(bundleLocation);
if (status == Bundle.ACTIVE)
[29/50] [abbrv] git commit: [KARAF-2142] Simplify consumer, handlers,
producer commands code
Posted by jb...@apache.org.
[KARAF-2142] Simplify consumer, handlers, producer commands code
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1483432 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/8a85ea74
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/8a85ea74
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/8a85ea74
Branch: refs/heads/master
Commit: 8a85ea7492fd957a570ecb39b1b41bbc56f357ca
Parents: 4c5d87a
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu May 16 16:11:46 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu May 16 16:11:46 2013 +0000
----------------------------------------------------------------------
.../org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java | 4 +---
.../org/apache/karaf/cellar/shell/handler/HandlersSupport.java | 4 +---
.../org/apache/karaf/cellar/shell/producer/ProducerSupport.java | 4 +---
3 files changed, 3 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/8a85ea74/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
index 17f7cc3..38ecfee 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
@@ -37,9 +37,8 @@ public abstract class ConsumerSupport extends ClusterCommandSupport {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
// looking for nodes and check if exist
- Set<Node> recipientList;
+ Set<Node> recipientList = new HashSet<Node>();
if (nodeIds != null && !nodeIds.isEmpty()) {
- recipientList = new HashSet<Node>();
for (String nodeId : nodeIds) {
Node node = clusterManager.findNodeById(nodeId);
if (node == null) {
@@ -54,7 +53,6 @@ public abstract class ConsumerSupport extends ClusterCommandSupport {
recipientList = clusterManager.listNodes();
} else {
// in case of status change, select only the local node
- recipientList = new HashSet<Node>();
recipientList.add(clusterManager.getNode());
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/8a85ea74/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
index bcbc67c..c4c0271 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
@@ -36,9 +36,8 @@ public abstract class HandlersSupport extends ClusterCommandSupport {
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId());
// looking for nodes and check if exist
- Set<Node> recipientList;
+ Set<Node> recipientList = new HashSet<Node>();
if (nodeIds != null && !nodeIds.isEmpty()) {
- recipientList = new HashSet<Node>();
for (String nodeId : nodeIds) {
Node node = clusterManager.findNodeById(nodeId);
if (node == null) {
@@ -53,7 +52,6 @@ public abstract class HandlersSupport extends ClusterCommandSupport {
recipientList = clusterManager.listNodes();
} else {
// in case of status change, select only the local node
- recipientList = new HashSet<Node>();
recipientList.add(clusterManager.getNode());
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/8a85ea74/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
index 84fd040..602abb7 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
@@ -37,9 +37,8 @@ public abstract class ProducerSupport extends ClusterCommandSupport {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
// looking for nodes and check if exist
- Set<Node> recipientList;
+ Set<Node> recipientList = new HashSet<Node>();
if (nodeIds != null && !nodeIds.isEmpty()) {
- recipientList = new HashSet<Node>();
for (String nodeId : nodeIds) {
Node node = clusterManager.findNodeById(nodeId);
if (node == null) {
@@ -54,7 +53,6 @@ public abstract class ProducerSupport extends ClusterCommandSupport {
recipientList = clusterManager.listNodes();
} else {
// in case of status change, select only the local node
- recipientList = new HashSet<Node>();
recipientList.add(clusterManager.getNode());
}
}
[23/50] [abbrv] git commit: [KARAF-2280] Add org.ops4j.pax.web in
config blacklist by default
Posted by jb...@apache.org.
[KARAF-2280] Add org.ops4j.pax.web in config blacklist by default
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1478268 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/63d3f67f
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/63d3f67f
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/63d3f67f
Branch: refs/heads/master
Commit: 63d3f67f7cf3af2c7cda947c7ca2788715fe7503
Parents: 0aaf4f5
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu May 2 05:19:50 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu May 2 05:19:50 2013 +0000
----------------------------------------------------------------------
assembly/src/main/resources/groups.cfg | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/63d3f67f/assembly/src/main/resources/groups.cfg
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/groups.cfg b/assembly/src/main/resources/groups.cfg
index 68d3c3b..7d4d642 100644
--- a/assembly/src/main/resources/groups.cfg
+++ b/assembly/src/main/resources/groups.cfg
@@ -6,12 +6,14 @@ default.config.blacklist.inbound = org.apache.felix.fileinstall*, \
org.apache.karaf.cellar*, \
org.apache.karaf.management, \
org.apache.karaf.shell, \
- org.ops4j.pax.logging
+ org.ops4j.pax.logging, \
+ org.ops4j.pax.web
default.config.blacklist.outbound = org.apache.felix.fileinstall*, \
org.apache.karaf.cellar*, \
org.apache.karaf.management, \
org.apache.karaf.shell, \
- org.ops4j.pax.logging
+ org.ops4j.pax.logging, \
+ org.ops4j.pax.web
default.config.sync = true
default.features.whitelist.inbound = *
[40/50] [abbrv] git commit: [KARAF-2347] Small improvements on the
Cellar configuration
Posted by jb...@apache.org.
[KARAF-2347] Small improvements on the Cellar configuration
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1496172 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/ffad5337
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/ffad5337
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/ffad5337
Branch: refs/heads/master
Commit: ffad53377078878e9b764d5e31451eb3ebde0312
Parents: 111c15c
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Mon Jun 24 19:32:37 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Mon Jun 24 19:32:37 2013 +0000
----------------------------------------------------------------------
.../cellar/config/ConfigurationSupport.java | 50 ++++++++++----------
1 file changed, 26 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ffad5337/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
index f33d367..a3ee898 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
@@ -42,13 +42,11 @@ public class ConfigurationSupport extends CellarSupport {
*/
public Properties dictionaryToProperties(Dictionary dictionary) {
Properties properties = new Properties();
- if (dictionary != null && dictionary.keys() != null) {
-
+ if (dictionary != null) {
Enumeration keys = dictionary.keys();
while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
+ Object key = keys.nextElement();
if (key != null && dictionary.get(key) != null) {
- String value = (String) dictionary.get(key);
properties.put(key, dictionary.get(key));
}
}
@@ -73,11 +71,14 @@ public class ConfigurationSupport extends CellarSupport {
if (source.isEmpty() && target.isEmpty())
return true;
+ if (source.size() != target.size())
+ return false;
+
Enumeration sourceKeys = source.keys();
while (sourceKeys.hasMoreElements()) {
- String key = (String) sourceKeys.nextElement();
- String sourceValue = String.valueOf(source.get(key));
- String targetValue = String.valueOf(target.get(key));
+ Object key = sourceKeys.nextElement();
+ Object sourceValue = source.get(key);
+ Object targetValue = target.get(key);
if (sourceValue != null && targetValue == null)
return false;
if (sourceValue == null && targetValue != null)
@@ -86,9 +87,6 @@ public class ConfigurationSupport extends CellarSupport {
return false;
}
- if (source.size() != target.size())
- return false;
-
return true;
}
@@ -105,7 +103,7 @@ public class ConfigurationSupport extends CellarSupport {
while (sourceKeys.hasMoreElements()) {
String key = (String) sourceKeys.nextElement();
if (!isExcludedProperty(key)) {
- String value = String.valueOf(dictionary.get(key));
+ Object value = dictionary.get(key);
result.put(key, value);
}
}
@@ -156,31 +154,35 @@ public class ConfigurationSupport extends CellarSupport {
storageFile = new File(new URL((String) val).toURI());
}
} catch (Exception e) {
- throw (IOException) new IOException(e.getMessage()).initCause(e);
+ throw new IOException(e.getMessage(), e);
}
}
+
org.apache.felix.utils.properties.Properties p = new org.apache.felix.utils.properties.Properties(storageFile);
- for (Enumeration keys = props.keys(); keys.hasMoreElements(); ) {
- Object key = keys.nextElement();
+ List<String> propertiesToRemove = new ArrayList<String>();
+ Set<String> set = p.keySet();
+
+ for (String key : set) {
if (!org.osgi.framework.Constants.SERVICE_PID.equals(key)
&& !ConfigurationAdmin.SERVICE_FACTORYPID.equals(key)
&& !FELIX_FILEINSTALL_FILENAME.equals(key)) {
- p.put((String) key, (String) props.get(key));
+ propertiesToRemove.add(key);
}
}
- // remove "removed" properties from the file
- ArrayList<String> propertiesToRemove = new ArrayList<String>();
- for (Object key : p.keySet()) {
- if (props.get(key) == null
- && !org.osgi.framework.Constants.SERVICE_PID.equals(key)
+
+ for (String key : propertiesToRemove) {
+ p.remove(key);
+ }
+
+ for (Enumeration<String> keys = props.keys(); keys.hasMoreElements(); ) {
+ String key = keys.nextElement();
+ if (!org.osgi.framework.Constants.SERVICE_PID.equals(key)
&& !ConfigurationAdmin.SERVICE_FACTORYPID.equals(key)
&& !FELIX_FILEINSTALL_FILENAME.equals(key)) {
- propertiesToRemove.add(key.toString());
+ p.put(key, (String) props.get(key));
}
}
- for (String key : propertiesToRemove) {
- p.remove(key);
- }
+
// save the cfg file
storage.mkdirs();
p.save();
[22/50] [abbrv] git commit: [KARAF-2281] Add Cellar configurations in
blacklist
Posted by jb...@apache.org.
[KARAF-2281] Add Cellar configurations in blacklist
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1478150 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/0aaf4f5d
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/0aaf4f5d
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/0aaf4f5d
Branch: refs/heads/master
Commit: 0aaf4f5de847582203a1f371fe2bdfe9ac7f47c4
Parents: 07228e7
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed May 1 19:19:24 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed May 1 19:19:24 2013 +0000
----------------------------------------------------------------------
assembly/src/main/resources/groups.cfg | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0aaf4f5d/assembly/src/main/resources/groups.cfg
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/groups.cfg b/assembly/src/main/resources/groups.cfg
index 2a4eaf8..68d3c3b 100644
--- a/assembly/src/main/resources/groups.cfg
+++ b/assembly/src/main/resources/groups.cfg
@@ -3,14 +3,12 @@ groups = default
default.config.whitelist.inbound = *
default.config.whitelist.outbound = *
default.config.blacklist.inbound = org.apache.felix.fileinstall*, \
- org.apache.karaf.cellar.groups, \
- org.apache.karaf.cellar.node, \
+ org.apache.karaf.cellar*, \
org.apache.karaf.management, \
org.apache.karaf.shell, \
org.ops4j.pax.logging
default.config.blacklist.outbound = org.apache.felix.fileinstall*, \
- org.apache.karaf.cellar.groups, \
- org.apache.karaf.cellar.node, \
+ org.apache.karaf.cellar*, \
org.apache.karaf.management, \
org.apache.karaf.shell, \
org.ops4j.pax.logging
@@ -30,4 +28,4 @@ default.bundle.blacklist.outbound = none
default.bundle.sync = true
default.obr.urls.sync = true
-default.obr.bundles.sync = true
\ No newline at end of file
+default.obr.bundles.sync = true
[07/50] [abbrv] git commit: Fix config blueprint descriptor
Posted by jb...@apache.org.
Fix config blueprint descriptor
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471048 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/f74a514f
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/f74a514f
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/f74a514f
Branch: refs/heads/master
Commit: f74a514f1b001bf7b96636e0d6d79ae7488c192a
Parents: e08a2e8
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Apr 23 17:12:32 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Apr 23 17:12:32 2013 +0000
----------------------------------------------------------------------
config/src/main/resources/OSGI-INF/blueprint/blueprint.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f74a514f/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 3610f4c..881daf8 100644
--- a/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -35,7 +35,7 @@
<property name="configurationAdmin" ref="configurationAdmin"/>
<property name="eventProducer" ref="eventProducer"/>
</bean>
- <service ref="configurationListener" interface="org.osgi.service.cm.ConfigurationListener"/>
+ <service ref="localListener" interface="org.osgi.service.cm.ConfigurationListener"/>
<!-- Configuration Synchronizer -->
<bean id="synchronizer" class="org.apache.karaf.cellar.config.ConfigurationSynchronizer"
[25/50] [abbrv] git commit: Use new FeaturesService method
Posted by jb...@apache.org.
Use new FeaturesService method
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1482301 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/5c36aa3c
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/5c36aa3c
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/5c36aa3c
Branch: refs/heads/master
Commit: 5c36aa3c6936f1487ad1bd858f85cad892bdea39
Parents: c981561
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue May 14 11:13:32 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue May 14 11:13:32 2013 +0000
----------------------------------------------------------------------
.../org/apache/karaf/cellar/features/FeaturesEventHandler.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/5c36aa3c/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
index 5d4ea54..fc16741 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
@@ -93,7 +93,7 @@ public class FeaturesEventHandler extends FeaturesSupport implements EventHandle
featuresService.installFeature(name, version, options);
} else {
LOGGER.debug("CELLAR FEATURES: installing feature {}", name);
- featuresService.installFeature(name, "0.0.0", options);
+ featuresService.installFeature(name, options);
}
} else if (FeatureEvent.EventType.FeatureUninstalled.equals(type) && isInstalled) {
if (version != null) {
[35/50] [abbrv] git commit: [KARAF-2353] Upgrade to Hazelcast 2.6
Posted by jb...@apache.org.
[KARAF-2353] Upgrade to Hazelcast 2.6
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1489714 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/96aa8175
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/96aa8175
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/96aa8175
Branch: refs/heads/master
Commit: 96aa817520c2a6091804531de8a38d53e6931f47
Parents: 1301802
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed Jun 5 06:10:16 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed Jun 5 06:10:16 2013 +0000
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/96aa8175/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0b7c447..1b35846 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,7 +40,7 @@
<felix.configadmin.version>1.6.0</felix.configadmin.version>
<felix.utils.version>1.2.0</felix.utils.version>
<felix.webconsole.version>4.0.0</felix.webconsole.version>
- <hazelcast.version>2.5</hazelcast.version>
+ <hazelcast.version>2.6</hazelcast.version>
<jclouds.version>1.4.0</jclouds.version>
<joda-time.version>2.1</joda-time.version>
<junit.version>4.10</junit.version>
[05/50] [abbrv] git commit: Code cleanup
Posted by jb...@apache.org.
Code cleanup
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1470999 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/d8543b6b
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/d8543b6b
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/d8543b6b
Branch: refs/heads/master
Commit: d8543b6bb9d98fd9ef3f91db9fb2fdc73174e46e
Parents: 913bf55
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Apr 23 15:06:38 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Apr 23 15:06:38 2013 +0000
----------------------------------------------------------------------
.../karaf/cellar/cloud/BlobStoreDiscoveryService.java | 6 +++---
.../cellar/cloud/BlobStoreDiscoveryServiceFactory.java | 9 ++++-----
2 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d8543b6b/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
----------------------------------------------------------------------
diff --git a/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java b/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
index 522140d..5d7ef0a 100644
--- a/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
+++ b/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
@@ -139,7 +139,7 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
@Override
public void signIn() {
DateTime now = new DateTime();
- createBlob(container, ipAddress, new ServiceContainer(getHostAdress(), getIpAddress(), now));
+ createBlob(container, ipAddress, new ServiceContainer(getHostName(), getIpAddress(), now));
}
/**
@@ -148,7 +148,7 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
@Override
public void refresh() {
DateTime now = new DateTime();
- createBlob(container, ipAddress, new ServiceContainer(getHostAdress(), getIpAddress(), now));
+ createBlob(container, ipAddress, new ServiceContainer(getHostName(), getIpAddress(), now));
}
/**
@@ -272,7 +272,7 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
*
* @return the hostname of the local node.
*/
- protected String getHostAdress() {
+ protected String getHostName() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException ex) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d8543b6b/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryServiceFactory.java
----------------------------------------------------------------------
diff --git a/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryServiceFactory.java b/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryServiceFactory.java
index 8c70507..3dc994f 100644
--- a/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryServiceFactory.java
+++ b/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryServiceFactory.java
@@ -26,6 +26,9 @@ import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
+/**
+ * A factory for blob store discovery service.
+ */
public class BlobStoreDiscoveryServiceFactory implements ManagedServiceFactory {
private static final transient Logger LOGGER = LoggerFactory.getLogger(BlobStoreDiscoveryServiceFactory.class);
@@ -40,11 +43,6 @@ public class BlobStoreDiscoveryServiceFactory implements ManagedServiceFactory {
private final BundleContext bundleContext;
- /**
- * Constructor
- *
- * @param bundleContext
- */
public BlobStoreDiscoveryServiceFactory(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
@@ -94,6 +92,7 @@ public class BlobStoreDiscoveryServiceFactory implements ManagedServiceFactory {
}
}
+ @Override
public void deleted(String pid) {
LOGGER.debug("CELLAR CLOUD: deleting blob store discovery service {}", pid);
ServiceRegistration oldRegistration = registrations.remove(pid);
[39/50] [abbrv] git commit: [KARAF-2349] Add debug support in itests
Posted by jb...@apache.org.
[KARAF-2349] Add debug support in itests
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1495876 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/111c15c9
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/111c15c9
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/111c15c9
Branch: refs/heads/master
Commit: 111c15c957d0c4bed5d6800f9202b1f5e437e6f9
Parents: 124d44e
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Sun Jun 23 19:30:07 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Sun Jun 23 19:30:07 2013 +0000
----------------------------------------------------------------------
.../org/apache/karaf/cellar/itests/CellarTestSupport.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/111c15c9/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
index bd594f6..ba91700 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
@@ -40,6 +40,7 @@ import javax.inject.Inject;
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
+import org.apache.karaf.tooling.exam.options.KarafDistributionOption;
import org.apache.karaf.tooling.exam.options.LogLevelOption;
import org.ops4j.pax.exam.MavenUtils;
import org.ops4j.pax.exam.Option;
@@ -185,11 +186,18 @@ public class CellarTestSupport {
@Configuration
public Option[] config() {
- return new Option[]{
+ Option[] options = new Option[]{
cellarDistributionConfiguration(), keepRuntimeFolder(), logLevel(LogLevelOption.LogLevel.INFO),
editConfigurationFileExtend("etc/system.properties", "cellar.feature.url", maven().groupId("org.apache.karaf.cellar").artifactId("apache-karaf-cellar").versionAsInProject().classifier("features").type("xml").getURL()),
editConfigurationFileExtend("etc/config.properties", "org.apache.aries.blueprint.synchronous", "true")
};
+ String debug = System.getProperty("debugMain");
+ if (debug != null) {
+ int l = options.length;
+ options = Arrays.copyOf(options, l + 1);
+ options[l] = KarafDistributionOption.debugConfiguration();
+ }
+ return options;
}
/**
[37/50] [abbrv] git commit: [KARAF-2343] Fixed cellar-event support
Posted by jb...@apache.org.
[KARAF-2343] Fixed cellar-event support
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1493465 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/03405c5d
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/03405c5d
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/03405c5d
Branch: refs/heads/master
Commit: 03405c5d2e98667d1ada34509119579cb4e65e2b
Parents: 7ea3c3a
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Sun Jun 16 07:02:02 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Sun Jun 16 07:02:02 2013 +0000
----------------------------------------------------------------------
.../apache/karaf/cellar/event/EventSupport.java | 17 ++++++++++-------
.../karaf/cellar/event/LocalEventListener.java | 9 ++++++---
2 files changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/03405c5d/event/src/main/java/org/apache/karaf/cellar/event/EventSupport.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/EventSupport.java b/event/src/main/java/org/apache/karaf/cellar/event/EventSupport.java
index 909805d..d8a11b2 100644
--- a/event/src/main/java/org/apache/karaf/cellar/event/EventSupport.java
+++ b/event/src/main/java/org/apache/karaf/cellar/event/EventSupport.java
@@ -25,7 +25,7 @@ import java.util.Map;
* Generic Cellar OSGi event support.
*/
public class EventSupport extends CellarSupport {
-
+
protected EventAdmin eventAdmin;
/**
@@ -40,12 +40,14 @@ public class EventSupport extends CellarSupport {
Map<String, Serializable> properties = new HashMap<String, Serializable>();
for (String propertyName : propertyNames) {
- Object property = event.getProperty(propertyName);
- if (property instanceof Serializable) {
- properties.put(propertyName, (Serializable) property);
+ // event property (org.osgi.framework.ServiceEvent for instance) contains non serializable objects (like source or service reference)
+ if (!propertyName.equals("event")) {
+ Object property = event.getProperty(propertyName);
+ if (property instanceof Serializable)
+ properties.put(propertyName, (Serializable) property);
}
}
-
+
return properties;
}
@@ -56,6 +58,7 @@ public class EventSupport extends CellarSupport {
* @param name the property name to check.
* @return true if the property exists in the event, false else.
*/
+
public boolean hasEventProperty(Event event, String name) {
String[] propertyNames = event.getPropertyNames();
@@ -71,7 +74,7 @@ public class EventSupport extends CellarSupport {
/**
* Post events via {@link EventAdmin}.
*
- * @param topicName the topic name.
+ * @param topicName the topic name.
* @param properties the event properties.
*/
public void postEvent(String topicName, Map<String, Serializable> properties) {
@@ -87,7 +90,7 @@ public class EventSupport extends CellarSupport {
/**
* Send events via {@link EventAdmin}.
*
- * @param topicName the topic name.
+ * @param topicName the topic name.
* @param properties the event properties.
*/
public void sendEvent(String topicName, Map<String, Serializable> properties) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/03405c5d/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java b/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
index dfa9632..f535ab3 100644
--- a/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
+++ b/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
@@ -35,6 +35,10 @@ public class LocalEventListener extends EventSupport implements EventHandler {
@Override
public void handleEvent(Event event) {
+ // ignore log entry event
+ if (event.getTopic().startsWith("org/osgi/service/log/LogEntry"))
+ return;
+
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
LOGGER.warn("CELLAR EVENT: cluster event producer is OFF");
@@ -53,7 +57,7 @@ public class LocalEventListener extends EventSupport implements EventHandler {
// filter already processed events
if (hasEventProperty(event, Constants.EVENT_PROCESSED_KEY)) {
- if (event.getProperty(Constants.EVENT_PROCESSED_KEY).equals(Constants.EVENT_PROCESSED_VALUE)){
+ if (event.getProperty(Constants.EVENT_PROCESSED_KEY).equals(Constants.EVENT_PROCESSED_VALUE)) {
LOGGER.debug("CELLAR EVENT: filtered out event {}", event.getTopic());
return;
}
@@ -68,8 +72,7 @@ public class LocalEventListener extends EventSupport implements EventHandler {
ClusterEvent clusterEvent = new ClusterEvent(topicName, properties);
clusterEvent.setSourceGroup(group);
eventProducer.produce(clusterEvent);
- } else if (!topicName.startsWith("org/osgi/service/log/LogEntry/"))
- LOGGER.warn("CELLAR EVENT: event {} is marked as BLOCKED OUTBOUND", topicName);
+ } else LOGGER.warn("CELLAR EVENT: event {} is marked as BLOCKED OUTBOUND", topicName);
}
}
}
[19/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1476912 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/9b430fe7
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/9b430fe7
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/9b430fe7
Branch: refs/heads/master
Commit: 9b430fe719d059efeae0d619cb72c3129062cedd
Parents: f52c623
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Mon Apr 29 07:40:38 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Mon Apr 29 07:40:38 2013 +0000
----------------------------------------------------------------------
.../cellar/shell/ClusterCommandSupport.java | 3 +++
.../karaf/cellar/shell/NodePingCommand.java | 8 +++----
.../karaf/cellar/shell/NodesListCommand.java | 2 +-
.../apache/karaf/cellar/shell/SyncCommand.java | 2 +-
.../shell/consumer/ConsumerStartCommand.java | 4 ++--
.../shell/consumer/ConsumerStatusCommand.java | 4 ++--
.../shell/consumer/ConsumerStopCommand.java | 2 +-
.../cellar/shell/consumer/ConsumerSupport.java | 3 +++
.../cellar/shell/group/GroupCreateCommand.java | 4 ++--
.../cellar/shell/group/GroupDeleteCommand.java | 9 ++-----
.../cellar/shell/group/GroupJoinCommand.java | 6 ++---
.../cellar/shell/group/GroupListCommand.java | 4 ++--
.../cellar/shell/group/GroupPickCommand.java | 8 +++----
.../cellar/shell/group/GroupQuitCommand.java | 6 ++---
.../cellar/shell/group/GroupSetCommand.java | 2 +-
.../karaf/cellar/shell/group/GroupSupport.java | 15 +++++++-----
.../shell/handler/HandlersStartCommand.java | 6 ++---
.../shell/handler/HandlersStatusCommand.java | 6 ++---
.../shell/handler/HandlersStopCommand.java | 6 ++---
.../cellar/shell/handler/HandlersSupport.java | 3 +++
.../shell/producer/ProducerStartCommand.java | 4 ++--
.../shell/producer/ProducerStatusCommand.java | 4 ++--
.../shell/producer/ProducerStopCommand.java | 4 ++--
.../cellar/shell/producer/ProducerSupport.java | 3 +++
.../OSGI-INF/blueprint/shell-cluster.xml | 25 --------------------
25 files changed, 64 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/ClusterCommandSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/ClusterCommandSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/ClusterCommandSupport.java
index 9c814da..3ce20b4 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/ClusterCommandSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/ClusterCommandSupport.java
@@ -16,6 +16,9 @@ package org.apache.karaf.cellar.shell;
import org.apache.karaf.cellar.core.command.ExecutionContext;
import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
+/**
+ * Abstract cluster shell command.
+ */
public abstract class ClusterCommandSupport extends CellarCommandSupport {
protected ExecutionContext executionContext;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/NodePingCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/NodePingCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/NodePingCommand.java
index e4d61b4..f26b52f 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/NodePingCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/NodePingCommand.java
@@ -21,18 +21,18 @@ import org.apache.karaf.shell.commands.Command;
import java.util.Arrays;
import java.util.HashSet;
-@Command(scope = "cluster", name = "node-ping", description = "Ping a cluster node.")
+@Command(scope = "cluster", name = "node-ping", description = "Ping a cluster node")
public class NodePingCommand extends ClusterCommandSupport {
private static Long TIMEOUT = 5000L;
- @Argument(index = 0, name = "node", description = "The ID of the node to ping.", required = true, multiValued = false)
+ @Argument(index = 0, name = "node", description = "The ID of the node to ping", required = true, multiValued = false)
String nodeId;
- @Argument(index = 1, name = "iterations", description = "The number of iterations to perform.", required = false, multiValued = false)
+ @Argument(index = 1, name = "iterations", description = "The number of iterations to perform", required = false, multiValued = false)
Integer iterations = 10;
- @Argument(index = 2, name = "interval", description = "The time in millis to wait between iteration.", required = false, multiValued = false)
+ @Argument(index = 2, name = "interval", description = "The time in millis to wait between iteration", required = false, multiValued = false)
Long interval = 1000L;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/NodesListCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/NodesListCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/NodesListCommand.java
index 4cbf665..822538f 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/NodesListCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/NodesListCommand.java
@@ -18,7 +18,7 @@ import org.apache.karaf.shell.commands.Command;
import java.util.Set;
-@Command(scope = "cluster", name = "node-list", description = "List the nodes in the cluster.")
+@Command(scope = "cluster", name = "node-list", description = "List the nodes in the cluster")
public class NodesListCommand extends ClusterCommandSupport {
private static final String HEADER_FORMAT = " %-30s %-20s %-5s";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/SyncCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/SyncCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/SyncCommand.java
index ba073b8..4782abd 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/SyncCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/SyncCommand.java
@@ -21,7 +21,7 @@ import org.osgi.framework.ServiceReference;
import java.util.Set;
-@Command(scope = "cluster", name = "sync", description = "Force the call of all cluster synchronizers available.")
+@Command(scope = "cluster", name = "sync", description = "Force the call of all cluster synchronizers available")
public class SyncCommand extends ClusterCommandSupport {
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStartCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStartCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStartCommand.java
index 4a7a99e..666613e 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStartCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStartCommand.java
@@ -19,10 +19,10 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "consumer-start", description = "Start an event consumer.")
+@Command(scope = "cluster", name = "consumer-start", description = "Start a cluster event consumer")
public class ConsumerStartCommand extends ConsumerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStatusCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStatusCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStatusCommand.java
index 411977f..a3cd144 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStatusCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStatusCommand.java
@@ -18,10 +18,10 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "consumer-status", description = "Status of an event consumer.")
+@Command(scope = "cluster", name = "consumer-status", description = "Status of a cluster event consumer")
public class ConsumerStatusCommand extends ConsumerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStopCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStopCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStopCommand.java
index 10651a5..92ef7c0 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStopCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStopCommand.java
@@ -19,7 +19,7 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "consumer-stop", description = "Stop an event consumer.")
+@Command(scope = "cluster", name = "consumer-stop", description = "Stop a cluster event consumer")
public class ConsumerStopCommand extends ConsumerSupport {
@Argument(index = 0, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
index 267be4b..572f7ab 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
@@ -24,6 +24,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+/**
+ * Generic cluster event consumer shell command support.
+ */
public abstract class ConsumerSupport extends ClusterCommandSupport {
protected static final String HEADER_FORMAT = " %-30s %-5s";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupCreateCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupCreateCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupCreateCommand.java
index 569db8d..1f50a5a 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupCreateCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupCreateCommand.java
@@ -17,10 +17,10 @@ import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
-@Command(scope = "cluster", name = "group-create", description = "Create a cluster group.")
+@Command(scope = "cluster", name = "group-create", description = "Create a cluster group")
public class GroupCreateCommand extends GroupSupport {
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupDeleteCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupDeleteCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupDeleteCommand.java
index 85ceb0d..b587969 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupDeleteCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupDeleteCommand.java
@@ -14,18 +14,13 @@
package org.apache.karaf.cellar.shell.group;
import org.apache.karaf.cellar.core.Group;
-import org.apache.karaf.cellar.core.Node;
-import org.apache.karaf.cellar.core.control.ManageGroupAction;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
-import java.util.LinkedList;
-import java.util.List;
-
-@Command(scope = "cluster", name = "group-delete", description = "Delete a cluster group.")
+@Command(scope = "cluster", name = "group-delete", description = "Delete a cluster group")
public class GroupDeleteCommand extends GroupSupport {
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java
index be0882c..c04dfff 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java
@@ -20,13 +20,13 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "group-join", description = "Join node(s) to a cluster group.")
+@Command(scope = "cluster", name = "group-join", description = "Join node(s) to a cluster group")
public class GroupJoinCommand extends GroupSupport {
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
- @Argument(index = 1, name = "node", description = "The node(s) ID.", required = true, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID", required = true, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java
index 26bca79..6feb809 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java
@@ -19,10 +19,10 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "group-list", description = "List the cluster groups.")
+@Command(scope = "cluster", name = "group-list", description = "List the cluster groups")
public class GroupListCommand extends GroupSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupPickCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupPickCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupPickCommand.java
index 5fa3ac9..186cad3 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupPickCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupPickCommand.java
@@ -24,16 +24,16 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-@Command(scope = "cluster", name = "group-pick", description = "Picks a number of nodes from one cluster group and moves them into an other.")
+@Command(scope = "cluster", name = "group-pick", description = "Picks a number of nodes from one cluster group and moves them into another")
public class GroupPickCommand extends GroupSupport {
- @Argument(index = 0, name = "sourceGroupName", description = "The source cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "sourceGroupName", description = "The source cluster group name", required = true, multiValued = false)
String sourceGroupName;
- @Argument(index = 1, name = "targetGroupName", description = "The destination cluster group name.", required = true, multiValued = false)
+ @Argument(index = 1, name = "targetGroupName", description = "The destination cluster group name", required = true, multiValued = false)
String targetGroupName;
- @Argument(index = 2, name = "count", description = "The number of nodes to transfer.", required = false, multiValued = false)
+ @Argument(index = 2, name = "count", description = "The number of nodes to transfer", required = false, multiValued = false)
int count = 1;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java
index e4f2f3b..2272624 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java
@@ -20,13 +20,13 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "group-quit", description = "Quit node(s) from a cluster group.")
+@Command(scope = "cluster", name = "group-quit", description = "Quit node(s) from a cluster group")
public class GroupQuitCommand extends GroupSupport {
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
- @Argument(index = 1, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID", required = false, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java
index 8121912..1dbc9d0 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java
@@ -20,7 +20,7 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "group-set", description = "Set the target nodes to a cluster group.")
+@Command(scope = "cluster", name = "group-set", description = "Set the target nodes to a cluster group")
public class GroupSetCommand extends GroupSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
index a71e0d0..9392b19 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
@@ -25,6 +25,9 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+/**
+ * Generic cluster group shell command support.
+ */
public abstract class GroupSupport extends ClusterCommandSupport {
protected static final String HEADER_FORMAT = " %-20s %s";
@@ -37,12 +40,12 @@ public abstract class GroupSupport extends ClusterCommandSupport {
/**
* Executes the command.
*
- * @param action
- * @param group
- * @param nodeIds
- * @param suppressOutput
- * @return
- * @throws Exception
+ * @param action the group action to perform.
+ * @param group the cluster group name.
+ * @param nodeIds the node IDs.
+ * @param suppressOutput true to display command output, false else.
+ * @return the Object resulting of the command execution.
+ * @throws Exception in case of execution failure.
*/
protected Object doExecute(ManageGroupAction action, String group, Group source, Collection<String> nodeIds, Boolean suppressOutput) throws Exception {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java
index a57bd8c..28cbbd8 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java
@@ -18,13 +18,13 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "handlers", description = "Start an event handler.")
+@Command(scope = "cluster", name = "handlers", description = "Start a cluster event handler")
public class HandlersStartCommand extends HandlersSupport {
- @Argument(index = 0, name = "handler", description = "The event handler ID.", required = true, multiValued = false)
+ @Argument(index = 0, name = "handler", description = "The cluster event handler ID", required = true, multiValued = false)
String handler;
- @Argument(index = 1, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID", required = false, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java
index 042dbca..d08c7f0 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java
@@ -18,13 +18,13 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "handler-status", description = "Status of a given event handler.")
+@Command(scope = "cluster", name = "handler-status", description = "Status of a cluster event handler")
public class HandlersStatusCommand extends HandlersSupport {
- @Argument(index = 0, name = "handler", description = "The event handler ID.", required = false, multiValued = false)
+ @Argument(index = 0, name = "handler", description = "The cluster event handler", required = false, multiValued = false)
String handler;
- @Argument(index = 1, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID", required = false, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java
index f51902f..d77e294 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java
@@ -18,13 +18,13 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "handler-stop", description = "Stop an event handler.")
+@Command(scope = "cluster", name = "handler-stop", description = "Stop a cluster event handler")
public class HandlersStopCommand extends HandlersSupport {
- @Argument(index = 0, name = "handler", description = "The event handler ID.", required = true, multiValued = false)
+ @Argument(index = 0, name = "handler", description = "The event handler", required = true, multiValued = false)
String handler;
- @Argument(index = 1, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID", required = false, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
index d632d27..ddde493 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
@@ -23,6 +23,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+/**
+ * Generic cluster event handler shell command support.
+ */
public abstract class HandlersSupport extends ClusterCommandSupport {
protected static final String HEADER_FORMAT = " %-30s %-5s %s";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java
index 923d79c..5c5f520 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java
@@ -19,10 +19,10 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "producer-start", description = "Start an event producer.")
+@Command(scope = "cluster", name = "producer-start", description = "Start a cluster event producer")
public class ProducerStartCommand extends ProducerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java
index 0b96438..1dd2310 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java
@@ -18,10 +18,10 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "producer-status", description = "Status of an event producer.")
+@Command(scope = "cluster", name = "producer-status", description = "Status of a cluster event producer")
public class ProducerStatusCommand extends ProducerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java
index 535c722..e79ad5e 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java
@@ -19,10 +19,10 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "producer-stop", description = "Stop an event producer.")
+@Command(scope = "cluster", name = "producer-stop", description = "Stop a cluster event producer")
public class ProducerStopCommand extends ProducerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
List<String> nodes;
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
index fee1ad8..34f1bb0 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
@@ -24,6 +24,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+/**
+ * Generic cluster event producer shell command support.
+ */
public abstract class ProducerSupport extends ClusterCommandSupport {
protected static final String HEADER_FORMAT = " %-30s %-5s";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9b430fe7/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml
----------------------------------------------------------------------
diff --git a/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml b/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml
index dd4fa8e..84a8f80 100644
--- a/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml
+++ b/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml
@@ -15,28 +15,24 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
- <!-- Command Bundle -->
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
<command name="cluster/node-list">
<action class="org.apache.karaf.cellar.shell.NodesListCommand">
<property name="clusterManager" ref="clusterManager"/>
</action>
</command>
-
<command name="cluster/node-ping">
<action class="org.apache.karaf.cellar.shell.NodePingCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="executionContext" ref="executionContext"/>
</action>
</command>
-
<command name="cluster/sync">
<action class="org.apache.karaf.cellar.shell.SyncCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
</action>
</command>
-
<command name="cluster/consumer-start">
<action class="org.apache.karaf.cellar.shell.consumer.ConsumerStartCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -46,7 +42,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/consumer-stop">
<action class="org.apache.karaf.cellar.shell.consumer.ConsumerStopCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -56,7 +51,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/consumer-status">
<action class="org.apache.karaf.cellar.shell.consumer.ConsumerStatusCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -66,7 +60,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/producer-start">
<action class="org.apache.karaf.cellar.shell.producer.ProducerStartCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -76,7 +69,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/producer-stop">
<action class="org.apache.karaf.cellar.shell.producer.ProducerStopCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -86,7 +78,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/producer-status">
<action class="org.apache.karaf.cellar.shell.producer.ProducerStatusCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -96,7 +87,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/handler-start">
<action class="org.apache.karaf.cellar.shell.handler.HandlersStartCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -106,7 +96,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/handler-stop">
<action class="org.apache.karaf.cellar.shell.handler.HandlersStopCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -116,7 +105,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/handler-status">
<action class="org.apache.karaf.cellar.shell.handler.HandlersStatusCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -126,7 +114,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/group-join">
<action class="org.apache.karaf.cellar.shell.group.GroupJoinCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -138,7 +125,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/group-quit">
<action class="org.apache.karaf.cellar.shell.group.GroupQuitCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -150,7 +136,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/group-set">
<action class="org.apache.karaf.cellar.shell.group.GroupSetCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -162,7 +147,6 @@
<ref component-id="allNodesCompleter"/>
</completers>
</command>
-
<command name="cluster/group-pick">
<action class="org.apache.karaf.cellar.shell.group.GroupPickCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -173,7 +157,6 @@
<ref component-id="allGroupCompleter"/>
</completers>
</command>
-
<command name="cluster/group-list">
<action class="org.apache.karaf.cellar.shell.group.GroupListCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -181,7 +164,6 @@
<property name="executionContext" ref="executionContext"/>
</action>
</command>
-
<command name="cluster/group-create">
<action class="org.apache.karaf.cellar.shell.group.GroupCreateCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -189,7 +171,6 @@
<property name="executionContext" ref="executionContext"/>
</action>
</command>
-
<command name="cluster/group-delete">
<action class="org.apache.karaf.cellar.shell.group.GroupDeleteCommand">
<property name="clusterManager" ref="clusterManager"/>
@@ -200,27 +181,21 @@
<ref component-id="allGroupCompleter"/>
</completers>
</command>
-
</command-bundle>
- <!-- Reference to the Cluster Manager -->
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager" availability="optional"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager" availability="optional"/>
<reference id="executionContext" interface="org.apache.karaf.cellar.core.command.ExecutionContext" availability="optional"/>
- <!-- Completers -->
<bean id="allNodesCompleter" class="org.apache.karaf.cellar.core.shell.completer.AllNodeCompleter">
<property name="clusterManager" ref="clusterManager"/>
</bean>
-
<bean id="allGroupCompleter" class="org.apache.karaf.cellar.core.shell.completer.AllGroupsCompleter">
<property name="groupManager" ref="groupManager"/>
</bean>
-
<bean id="localGroupCompleter" class="org.apache.karaf.cellar.core.shell.completer.LocalGroupsCompleter">
<property name="groupManager" ref="groupManager"/>
</bean>
-
<bean id="otherGroupCompleter" class="org.apache.karaf.cellar.core.shell.completer.OtherGroupsCompleter">
<property name="groupManager" ref="groupManager"/>
</bean>
[09/50] [abbrv] git commit: Code cleanup
Posted by jb...@apache.org.
Code cleanup
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471327 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/cbc5c6e9
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/cbc5c6e9
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/cbc5c6e9
Branch: refs/heads/master
Commit: cbc5c6e90ba6a64a6bb5454be57a98d7b3b410a3
Parents: f74a514
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed Apr 24 09:39:25 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed Apr 24 09:39:25 2013 +0000
----------------------------------------------------------------------
.../apache/karaf/cellar/core/CellarSupport.java | 59 +++++++--------
.../karaf/cellar/core/ClusterManager.java | 55 +++++++-------
.../karaf/cellar/core/Configurations.java | 2 +-
.../org/apache/karaf/cellar/core/Consumer.java | 6 +-
.../apache/karaf/cellar/core/Dispatcher.java | 4 +-
.../org/apache/karaf/cellar/core/Group.java | 10 +--
.../apache/karaf/cellar/core/GroupManager.java | 77 ++++++++++----------
.../org/apache/karaf/cellar/core/Handler.java | 8 +-
.../karaf/cellar/core/HandlerRegistry.java | 6 +-
.../org/apache/karaf/cellar/core/MultiNode.java | 14 ++++
.../java/org/apache/karaf/cellar/core/Node.java | 12 +--
.../org/apache/karaf/cellar/core/Producer.java | 6 +-
.../apache/karaf/cellar/core/Synchronizer.java | 13 +++-
.../cellar/core/command/BasicCommandStore.java | 2 +
.../core/command/ClusteredExecutionContext.java | 2 +
.../karaf/cellar/core/command/Command.java | 13 ++--
.../cellar/core/command/CommandHandler.java | 31 ++++----
.../cellar/core/command/ResultHandler.java | 27 +++++--
.../karaf/cellar/core/command/TimeoutTask.java | 3 +-
.../cellar/core/completer/AllNodeCompleter.java | 4 +-
.../core/completer/NodeCompleterSupport.java | 1 +
.../karaf/cellar/core/control/BasicSwitch.java | 25 +++----
.../core/control/ConsumerSwitchCommand.java | 20 +----
.../control/ConsumerSwitchCommandHandler.java | 2 +
.../core/control/ConsumerSwitchResult.java | 18 -----
.../core/control/ManageGroupCommandHandler.java | 14 ++--
.../core/control/ManageHandlersCommand.java | 5 --
.../control/ManageHandlersCommandHandler.java | 8 +-
.../core/control/ManageHandlersResult.java | 5 --
.../core/control/ProducerSwitchCommand.java | 21 ------
.../control/ProducerSwitchCommandHandler.java | 11 ++-
.../core/control/ProducerSwitchResult.java | 18 -----
.../karaf/cellar/core/control/Switch.java | 14 ++--
.../karaf/cellar/core/discovery/Discovery.java | 4 +-
.../cellar/core/discovery/DiscoveryTask.java | 16 ++--
.../apache/karaf/cellar/core/event/Event.java | 7 +-
.../karaf/cellar/core/event/EventConsumer.java | 13 ++--
.../cellar/core/event/EventDispatchTask.java | 56 +++++---------
.../cellar/core/event/EventDispatcher.java | 6 +-
.../karaf/cellar/core/event/EventHandler.java | 4 +-
.../cellar/core/event/EventHandlerRegistry.java | 7 +-
.../event/EventHandlerRegistryDispatcher.java | 7 +-
.../core/event/EventHandlerServiceRegistry.java | 17 +----
.../karaf/cellar/core/event/EventProducer.java | 7 +-
.../karaf/cellar/core/event/EventTracker.java | 16 ++--
.../core/event/EventTransportFactory.java | 19 +++--
.../exception/ProducerNotFoundException.java | 4 +
.../core/exception/StoreNotFoundException.java | 4 +
.../cellar/core/shell/CellarCommandSupport.java | 1 -
.../shell/completer/AllGroupsCompleter.java | 8 +-
.../shell/completer/GroupCompleterSupport.java | 12 ++-
.../shell/completer/LocalGroupsCompleter.java | 8 +-
.../shell/completer/OtherGroupsCompleter.java | 6 ++
.../karaf/cellar/core/utils/CellarUtils.java | 57 ++++++++++-----
.../cellar/core/utils/CombinedClassLoader.java | 10 +--
.../resources/OSGI-INF/blueprint/blueprint.xml | 6 +-
.../karaf/cellar/core/CellarSupportTest.java | 1 +
.../cellar/core/utils/CellarUtilsTest.java | 13 ++++
58 files changed, 408 insertions(+), 417 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/CellarSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/CellarSupport.java b/core/src/main/java/org/apache/karaf/cellar/core/CellarSupport.java
index af7e474..cbde2f4 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/CellarSupport.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/CellarSupport.java
@@ -28,7 +28,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
- * Cellar support.
+ * Cellar generic support. This class provides a set of util methods used by other classes.
*/
public class CellarSupport {
@@ -39,11 +39,13 @@ public class CellarSupport {
protected ConfigurationAdmin configurationAdmin;
/**
- * Lists the BlackList for the specified feature.
+ * Get a set of resources in the Cellar cluster groups configuration.
*
- * @param category
- * @param group
- * @return
+ * @param listType the comma separated list of resources.
+ * @param group the cluster group name.
+ * @param category the resource category name.
+ * @param type the event type (inbound, outbound).
+ * @return the set of resources.
*/
public Set<String> getListEntries(String listType, String group, String category, EventType type) {
Set<String> result = null;
@@ -83,13 +85,13 @@ public class CellarSupport {
}
/**
- * Lists the BlackList for the specified feature.
+ * Get the resources in the Cellar cluster groups configuration.
*
- * @param category
- * @param groups
- * @param category
- * @param type
- * @return
+ * @param listType the comma separated string of resources.
+ * @param groups the cluster groups names.
+ * @param category the resource category name.
+ * @param type the event type (inbound, outbound).
+ * @return the set of resources.
*/
public Set<String> getListEntries(String listType, Collection<String> groups, String category, EventType type) {
Set<String> result = null;
@@ -107,12 +109,13 @@ public class CellarSupport {
}
/**
- * Lists the BlackList for the specified feature.
+ * Get a set of resources in the Cellar cluster groups configuration.
*
- * @param category
- * @param category
- * @param type
- * @return
+ * @param listType a comma separated string of resources.
+ * @param group the cluster group.
+ * @param category the resource category name.
+ * @param type the event type (inbound, outbound).
+ * @return the set of resources.
*/
public Set<String> getListEntries(String listType, Group group, String category, EventType type) {
Set<String> result = null;
@@ -129,19 +132,19 @@ public class CellarSupport {
}
/**
- * Returns true if the specified event is allowed.
+ * Check if a resource is allowed for a type of cluster event.
*
- * @param category
- * @param event
- * @param type
- * @return
+ * @param group the cluster group.
+ * @param category the resource category name.
+ * @param event the resource name.
+ * @param type the event type (inbound, outbound).
*/
public Boolean isAllowed(Group group, String category, String event, EventType type) {
Boolean result = true;
Set<String> whiteList = getListEntries(Configurations.WHITELIST, group, category, type);
Set<String> blackList = getListEntries(Configurations.BLACKLIST, group, category, type);
- //If no white listed items we assume all are accepted.
+ // if no white listed items we assume all are accepted.
if (whiteList != null && !whiteList.isEmpty()) {
result = false;
for (String whiteListItem : whiteList) {
@@ -150,7 +153,7 @@ public class CellarSupport {
}
}
- //If any blackList item matched, then false is returned.
+ // if any blackList item matched, then false is returned.
if (blackList != null && !blackList.isEmpty()) {
for (String blackListItem : blackList) {
if (wildCardMatch(event, blackListItem)) {
@@ -163,11 +166,11 @@ public class CellarSupport {
}
/**
- * Matches text using a pattern containing wildcards.
+ * Check if a string match a regex.
*
- * @param item
- * @param pattern
- * @return
+ * @param item the string to check.
+ * @param pattern the regex pattern.
+ * @return true if the item string matches the pattern, false else.
*/
protected boolean wildCardMatch(String item, String pattern) {
// update the pattern to have a valid regex pattern
@@ -175,11 +178,9 @@ public class CellarSupport {
// use the regex
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(item);
-
return m.matches();
}
-
public ConfigurationAdmin getConfigurationAdmin() {
return configurationAdmin;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/ClusterManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/ClusterManager.java b/core/src/main/java/org/apache/karaf/cellar/core/ClusterManager.java
index 8330435..afb475c 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/ClusterManager.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/ClusterManager.java
@@ -24,87 +24,86 @@ import java.util.Set;
public interface ClusterManager {
/**
- * Returns a named distributed map.
+ * Get a map in the cluster.
*
- * @param mapName
- * @return
+ * @param mapName the map name in the cluster.
+ * @return the map in the cluster.
*/
public Map getMap(String mapName);
/**
- * Returns a named distributed list.
+ * Get a list in the cluster.
*
- * @param listName
- * @return
+ * @param listName the list name in the cluster.
+ * @return the list in the cluster.
*/
public List getList(String listName);
-
/**
- * Returns a named distributed list.
+ * Get a set in the cluster.
*
- * @param setName
- * @return
+ * @param setName the set name in the cluster.
+ * @return the set in the cluster.
*/
public Set getSet(String setName);
-
/**
- * Returns a list of {@code Node}s.
+ * Get the nodes in the cluster.
*
- * @return
+ * @return the set of nodes in the cluster.
*/
public Set<Node> listNodes();
/**
- * Returns the {@link Node} with specified id.
+ * Get the nodes with a given ID.
*
- * @return
+ * @param ids the collection of ID to look for.
+ * @return the set of nodes.
*/
public Set<Node> listNodes(Collection<String> ids);
/**
- * Returns the {@link Node} with specified {@link Group}.
+ * Get the nodes in a given cluster group.
*
- * @return
+ * @param group the cluster group.
+ * @return the set of nodes in the cluster group.
*/
public Set<Node> listNodesByGroup(Group group);
-
/**
- * Returns the {@link Node} with specified id.
+ * Get a node identified by a given ID.
*
- * @return
+ * @param id the id of the node to look for.
+ * @return the node.
*/
public Node findNodeById(String id);
-
/**
- * Returns the {@link Node} on which the command was executed.
+ * Get the local node.
*
- * @return
+ * @return the local node.
*/
public Node getNode();
/**
- * Generate an Id unique across the cluster.
+ * Generate an unique ID across the cluster.
*
- * @return
+ * @return a unique ID across the cluster.
*/
public String generateId();
/**
- * Start the clustering support on the {@link Node}.
+ * Start the local node.
*/
public void start();
/**
- * Stops the node.
+ * Stop the local node.
*/
public void stop();
/**
- * Restarts the clustering support on the {@link Node}.
+ * Restart the local node.
*/
public void restart();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/Configurations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/Configurations.java b/core/src/main/java/org/apache/karaf/cellar/core/Configurations.java
index b2878b8..d630494 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/Configurations.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/Configurations.java
@@ -14,7 +14,7 @@
package org.apache.karaf.cellar.core;
/**
- * Configurations.
+ * Configurations constants.
*/
public class Configurations {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/Consumer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/Consumer.java b/core/src/main/java/org/apache/karaf/cellar/core/Consumer.java
index 20b2ca8..0c3639e 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/Consumer.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/Consumer.java
@@ -25,14 +25,14 @@ public interface Consumer<T extends Serializable> {
/**
* Consume an object.
*
- * @param obj
+ * @param obj the object to consume.
*/
public void consume(T obj);
/**
- * Returns the {@code Switch}.
+ * Get the consumer switch.
*
- * @return
+ * @return the consumer switch.
*/
public Switch getSwitch();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/Dispatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/Dispatcher.java b/core/src/main/java/org/apache/karaf/cellar/core/Dispatcher.java
index b2fdb27..89a22b7 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/Dispatcher.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/Dispatcher.java
@@ -21,9 +21,9 @@ import java.io.Serializable;
public interface Dispatcher<T extends Serializable> {
/**
- * Dispatches the object to the appropriate handler.
+ * Dispatch an object to the appropriate handler.
*
- * @param obj
+ * @param obj the object to dispatch.
*/
public void dispatch(T obj);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/Group.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/Group.java b/core/src/main/java/org/apache/karaf/cellar/core/Group.java
index e3a0f5b..561570b 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/Group.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/Group.java
@@ -13,23 +13,17 @@
*/
package org.apache.karaf.cellar.core;
-import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
/**
- * Cellar group.
+ * Cellar cluster group.
*/
public class Group implements MultiNode {
private String name;
private Set<Node> nodes = new HashSet<Node>();
- /**
- * Constructor
- *
- * @param name
- */
public Group(String name) {
this.name = name;
}
@@ -42,10 +36,12 @@ public class Group implements MultiNode {
this.name = name;
}
+ @Override
public Set<Node> getNodes() {
return nodes;
}
+ @Override
public void setNodes(Set<Node> nodes) {
this.nodes = nodes;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/GroupManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/GroupManager.java b/core/src/main/java/org/apache/karaf/cellar/core/GroupManager.java
index cad4f3c..92b0472 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/GroupManager.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/GroupManager.java
@@ -17,120 +17,119 @@ import java.util.Map;
import java.util.Set;
/**
- * Generic group manager interface.
+ * Generic cluster group manager interface.
*/
public interface GroupManager {
/**
- * Returns the local {@link Node}.
+ * Get the local node.
*
- * @return
+ * @return the local node.
*/
public Node getNode();
/**
- * Creates {@link Group}
+ * Create a new cluster group.
*
- * @param groupName
- * @return
+ * @param groupName the new cluster group name.
+ * @return the created cluster group.
*/
public Group createGroup(String groupName);
/**
- * Deletes {@link Group}
+ * Delete an existing cluster group.
*
- * @param groupName
+ * @param groupName the cluster group name to delete.
*/
public void deleteGroup(String groupName);
/**
- * Return the {@link Group} by name.
+ * Look for a cluster group with a given name.
*
- * @param groupName
- * @return
+ * @param groupName the cluster group name to look for.
+ * @return the cluster group found, or null if no cluster group found.
*/
public Group findGroupByName(String groupName);
/**
- * Returns a map of {@link Node}s.
+ * Get the list of cluster groups.
*
- * @return
+ * @return a map of cluster groups name and cluster groups.
*/
public Map<String, Group> listGroups();
/**
- * Returns the {@link Group}s of the specified {@link Node}.
+ * Get the list of local cluster groups.
+ * A "local" cluster group means a cluster group where the local node is belonging.
*
- * @return
+ * @return a set of local cluster groups.
*/
public Set<Group> listLocalGroups();
/**
- * Check if the local node is part of the given group.
+ * Check if a given cluster group is a local one.
+ * A "local" clsuter group means a cluster group where the local node is belonging.
*
- * @param groupName the group name.
- * @return true if the local node is part of the group, false else.
+ * @param groupName the cluster group name.
+ * @return true if the cluster group is a local one, false else.
*/
public boolean isLocalGroup(String groupName);
/**
- * Returns the {@link Group}s of the specified {@link Node}.
+ * Get the list of all cluster groups "hosting" the local node.
*
- * @return
+ * @return the list of all cluster groups "hosting" the local node.
*/
public Set<Group> listAllGroups();
-
/**
- * Returns the {@link Group}s of the specified {@link Node}.
+ * Get the cluster groups where a given node is belonging.
*
- * @param node
- * @return
+ * @param node the node.
+ * @return the set of cluster groups "hosting" the node.
*/
public Set<Group> listGroups(Node node);
/**
- * Retrurns the {@link Group} names of the current {@Node}.
+ * Get the cluster group names "hosting" the local node.
*
- * @return
+ * @return the set of cluster group names "hosting" the local node.
*/
public Set<String> listGroupNames();
/**
- * Returns the {@link Group} names of the specified {@link Node}.
+ * Get the cluster group names "hosting" a given node.
*
- * @param node
- * @return
+ * @param node the node.
+ * @return the set of cluster group names "hosting" the given node.
*/
public Set<String> listGroupNames(Node node);
-
/**
- * Registers current {@link Node} to the {@link Group}.
+ * Register the local node in a given cluster group.
*
- * @param group
+ * @param group the cluster group to join.
*/
public void registerGroup(Group group);
/**
- * Registers current {@link Node} to the {@link Group}.
+ * Register the locla node in a given cluster group.
*
- * @param groupName
+ * @param groupName the cluster group name to join.
*/
public void registerGroup(String groupName);
-
/**
- * UnRegisters current {@link Node} to the {@link Group}.
+ * Un-register the local node from a given cluster group.
*
- * @param group
+ * @param group the cluster group to quit.
*/
public void unRegisterGroup(Group group);
/**
- * UnRegisters current {@link Node} to the {@link Group}.
+ * Un-register the local node from a given cluster group.
*
- * @param groupName
+ * @param groupName the cluster group name to quite.
*/
public void unRegisterGroup(String groupName);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/Handler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/Handler.java b/core/src/main/java/org/apache/karaf/cellar/core/Handler.java
index 32db7af..0fd0db0 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/Handler.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/Handler.java
@@ -23,16 +23,16 @@ import java.io.Serializable;
public interface Handler<T extends Serializable> {
/**
- * Returns the Class of the object that is to be handled.
+ * Get the type of the event handled by this handler.
*
- * @return
+ * @return the type of the event that the handler can handle.
*/
public Class<T> getType();
/**
- * Returns the {@code Switch}.
+ * Get the handler switch.
*
- * @return
+ * @return the handler switch.
*/
public Switch getSwitch();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/HandlerRegistry.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/HandlerRegistry.java b/core/src/main/java/org/apache/karaf/cellar/core/HandlerRegistry.java
index f7e24ef..b4f0860 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/HandlerRegistry.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/HandlerRegistry.java
@@ -21,10 +21,10 @@ import java.io.Serializable;
public interface HandlerRegistry<T extends Serializable, H extends Handler<T>> {
/**
- * Returns the {@code Handler} for the given object.
+ * Get the handler that can handle a given cluster event.
*
- * @param obj
- * @return
+ * @param obj the cluster event to handle.
+ * @return the handler in the registry that can handle the given cluster event.
*/
public H getHandler(T obj);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/MultiNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/MultiNode.java b/core/src/main/java/org/apache/karaf/cellar/core/MultiNode.java
index 6a5a1ad..3fe2577 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/MultiNode.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/MultiNode.java
@@ -16,9 +16,23 @@ package org.apache.karaf.cellar.core;
import java.io.Serializable;
import java.util.Set;
+/**
+ * Multiple nodes container (group) interface.
+ */
public interface MultiNode extends Serializable {
+ /**
+ * Set the nodes hosted in the multi-node container.
+ *
+ * @param nodes the set of nodes to store in this container.
+ */
public void setNodes(Set<Node> nodes);
+
+ /**
+ * Get the list of nodes in the multi-node container.
+ *
+ * @return the set of nodes in the multi-node container.
+ */
public Set<Node> getNodes();
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/Node.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/Node.java b/core/src/main/java/org/apache/karaf/cellar/core/Node.java
index 097a1f9..c05d6b2 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/Node.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/Node.java
@@ -21,23 +21,23 @@ import java.io.Serializable;
public interface Node extends Serializable {
/**
- * Returns the identifier of the node.
+ * Get the ID of the node.
*
- * @return
+ * @return the node ID.
*/
public String getId();
/**
- * Returns the name of the host
+ * Get the hostname of the node.
*
- * @return
+ * @return the node hostname.
*/
public String getHost();
/**
- * Returns the Port of the host
+ * Get the port number of the node.
*
- * @return
+ * @return the node port number.
*/
public int getPort();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/Producer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/Producer.java b/core/src/main/java/org/apache/karaf/cellar/core/Producer.java
index 8edef4a..1e45aeb 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/Producer.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/Producer.java
@@ -25,14 +25,14 @@ public interface Producer<T extends Serializable> {
/**
* Produce an object.
*
- * @param obj
+ * @param obj the object to produce.
*/
public void produce(T obj);
/**
- * Returns the {@code Switch}.
+ * Get the producer switch.
*
- * @return
+ * @return the producer switch.
*/
public Switch getSwitch();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/Synchronizer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/Synchronizer.java b/core/src/main/java/org/apache/karaf/cellar/core/Synchronizer.java
index d1a9024..2258207 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/Synchronizer.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/Synchronizer.java
@@ -19,19 +19,24 @@ package org.apache.karaf.cellar.core;
public interface Synchronizer {
/**
- * Pushes local state to the shared resource.
+ * Push local resources states in a cluster group.
+ *
+ * @param group the cluster group where to push local resources states.
*/
public void push(Group group);
/**
- * Pull state changes from the shared resource.
+ * Pull resources states from a cluster group to update local states.
+ *
+ * @param group the cluster group where to pull the resources states.
*/
public void pull(Group group);
/**
- * Returns true if synchronization is enabled.
+ * Check if the sync flag is enabled for a given cluster group.
*
- * @return
+ * @param group the cluster group.
+ * @return true if sync flag is enabled, false else.
*/
public Boolean isSyncEnabled(Group group);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/command/BasicCommandStore.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/command/BasicCommandStore.java b/core/src/main/java/org/apache/karaf/cellar/core/command/BasicCommandStore.java
index defaf77..ac01eec 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/command/BasicCommandStore.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/command/BasicCommandStore.java
@@ -23,10 +23,12 @@ public class BasicCommandStore implements CommandStore {
private ConcurrentMap<String, Command> pending = new ConcurrentHashMap<String, Command>();
+ @Override
public ConcurrentMap<String, Command> getPending() {
return pending;
}
+ @Override
public void setPending(ConcurrentMap<String, Command> pending) {
this.pending = pending;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/command/ClusteredExecutionContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/command/ClusteredExecutionContext.java b/core/src/main/java/org/apache/karaf/cellar/core/command/ClusteredExecutionContext.java
index 589f56f..2dbc049 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/command/ClusteredExecutionContext.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/command/ClusteredExecutionContext.java
@@ -34,6 +34,7 @@ public class ClusteredExecutionContext implements ExecutionContext {
private ScheduledExecutorService timeoutScheduler = new ScheduledThreadPoolExecutor(10);
public ClusteredExecutionContext() {
+ // nothing to do
}
public ClusteredExecutionContext(Producer producer, CommandStore commandStore) {
@@ -41,6 +42,7 @@ public class ClusteredExecutionContext implements ExecutionContext {
this.commandStore = commandStore;
}
+ @Override
public <R extends Result, C extends Command<R>> Map<Node, R> execute(C command) throws StoreNotFoundException, ProducerNotFoundException, InterruptedException {
if (command == null) {
throw new StoreNotFoundException("Command store not found");
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/command/Command.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/command/Command.java b/core/src/main/java/org/apache/karaf/cellar/core/command/Command.java
index 08b197b..052714d 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/command/Command.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/command/Command.java
@@ -57,9 +57,9 @@ public class Command<R extends Result> extends Event {
}
/**
- * Adds {@code Results} to the result queue.
+ * Add {@code Results} to the result queue.
*
- * @param results
+ * @param results the results in the queue.
*/
public void addResults(R... results) {
if (results != null && results.length > 0) {
@@ -78,11 +78,11 @@ public class Command<R extends Result> extends Event {
}
/**
- * Returns the responses.
- * If no results found it returns an empty map.
+ * Return the responses.
+ * If no result is found, it returns an empty map.
*
- * @return
- * @throws Exception
+ * @return a map of results.
+ * @throws Exception in case of interruption.
*/
public Map<Node, R> getResult() throws InterruptedException {
Map<Node, R> nodeResults = null;
@@ -92,7 +92,6 @@ public class Command<R extends Result> extends Event {
return nodeResults;
}
-
public long getTimeout() {
return timeout;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/command/CommandHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/command/CommandHandler.java b/core/src/main/java/org/apache/karaf/cellar/core/command/CommandHandler.java
index 74e7e20..9a33c6c 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/command/CommandHandler.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/command/CommandHandler.java
@@ -30,10 +30,11 @@ public abstract class CommandHandler<C extends Command<R>, R extends Result> ext
protected Producer producer;
/**
- * Handles the the {@code Command}.
+ * Handle a {@code Command}.
*
- * @param command
+ * @param command the command to handle.
*/
+ @Override
public void handle(C command) {
if (producer != null) {
R result = execute(command);
@@ -47,31 +48,33 @@ public abstract class CommandHandler<C extends Command<R>, R extends Result> ext
}
/**
- * Executes a {@code Command} and returns a {@code Result}.
+ * Execute a {@code Command} and return a {@code Result}.
*
- * @param command
- * @return
+ * @param command the command to execute.
+ * @return the result of the execution.
*/
public abstract R execute(C command);
+ /**
+ * Get the type of the command.
+ *
+ * @return the type class.
+ */
+ @Override
public abstract Class<C> getType();
- public abstract Switch getSwitch();
-
/**
- * Returns the {@code Producer}.
+ * Get the switch of the command handler.
*
- * @return
+ * @return the command handler switch.
*/
+ @Override
+ public abstract Switch getSwitch();
+
public Producer getProducer() {
return producer;
}
- /**
- * Sets the {@code Producer}.
- *
- * @param producer
- */
public void setProducer(Producer producer) {
this.producer = producer;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/command/ResultHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/command/ResultHandler.java b/core/src/main/java/org/apache/karaf/cellar/core/command/ResultHandler.java
index 988dc7b..8786e03 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/command/ResultHandler.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/command/ResultHandler.java
@@ -19,7 +19,7 @@ import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventHandler;
/**
- * An event handler class the handles result event.
+ * Handler for the cluster result events.
*/
public class ResultHandler<R extends Result> implements EventHandler<R> {
@@ -29,10 +29,11 @@ public class ResultHandler<R extends Result> implements EventHandler<R> {
private CommandStore commandStore;
/**
- * Retrieves the correlated command from the store and sets the result on the command object.
+ * Retrieve the correlated command from the store and set the result on the command object.
*
- * @param result
+ * @param result the cluster result event.
*/
+ @Override
public void handle(R result) {
if (commandStore != null && commandStore.getPending() != null) {
String id = result.getId();
@@ -44,10 +45,26 @@ public class ResultHandler<R extends Result> implements EventHandler<R> {
}
}
+ /**
+ * Get the type of result.
+ *
+ * @return the result type.
+ */
+ @Override
public Class<R> getType() {
return null;
}
+ /**
+ * Get the result handler switch.
+ *
+ * @return the result handler switch.
+ */
+ @Override
+ public Switch getSwitch() {
+ return handlerSwitch;
+ }
+
public CommandStore getCommandStore() {
return commandStore;
}
@@ -56,8 +73,4 @@ public class ResultHandler<R extends Result> implements EventHandler<R> {
this.commandStore = commandStore;
}
- public Switch getSwitch() {
- return handlerSwitch;
- }
-
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/command/TimeoutTask.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/command/TimeoutTask.java b/core/src/main/java/org/apache/karaf/cellar/core/command/TimeoutTask.java
index b881b1d..6546339 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/command/TimeoutTask.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/command/TimeoutTask.java
@@ -29,8 +29,9 @@ public class TimeoutTask implements Runnable {
/**
* Runs the timeout task.
*/
+ @Override
public void run() {
- //Check if command is still pending.
+ // check if command is still pending
Boolean pending = store.getPending().containsKey(command);
if (pending) {
store.getPending().remove(command);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/completer/AllNodeCompleter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/completer/AllNodeCompleter.java b/core/src/main/java/org/apache/karaf/cellar/core/completer/AllNodeCompleter.java
index a061afc..5bfbb3e 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/completer/AllNodeCompleter.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/completer/AllNodeCompleter.java
@@ -23,8 +23,8 @@ public class AllNodeCompleter extends NodeCompleterSupport {
/**
* Always returns true.
*
- * @param node
- * @return
+ * @param node the node.
+ * @return return true.
*/
@Override
protected boolean acceptsNode(Node node) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/completer/NodeCompleterSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/completer/NodeCompleterSupport.java b/core/src/main/java/org/apache/karaf/cellar/core/completer/NodeCompleterSupport.java
index b70d895..6d4c33d 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/completer/NodeCompleterSupport.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/completer/NodeCompleterSupport.java
@@ -27,6 +27,7 @@ public abstract class NodeCompleterSupport implements Completer {
private ClusterManager clusterManager;
+ @Override
public int complete(String buffer, int cursor, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
try {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/BasicSwitch.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/BasicSwitch.java b/core/src/main/java/org/apache/karaf/cellar/core/control/BasicSwitch.java
index 3513b3d..35a4f29 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/BasicSwitch.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/BasicSwitch.java
@@ -21,48 +21,47 @@ public class BasicSwitch implements Switch {
private SwitchStatus status = SwitchStatus.ON;
private String name;
- /**
- * Constructor
- *
- * @param name
- */
public BasicSwitch(String name) {
this.name = name;
}
- /**
- * Constructor
- *
- * @param name
- * @param status
- */
public BasicSwitch(String name, SwitchStatus status) {
this.status = status;
this.name = name;
}
+ /**
+ * Turn on the switch.
+ */
+ @Override
public void turnOn() {
this.status = SwitchStatus.ON;
}
+ /**
+ * Turn off the switch.
+ */
+ @Override
public void turnOff() {
this.status = SwitchStatus.OFF;
}
/**
- * Returns the status of the {@code Switch}.
+ * Return the current status of the {@code Switch}.
*
* @return
*/
+ @Override
public SwitchStatus getStatus() {
return status;
}
/**
- * Returns the name of the {@code Switch}.
+ * Return the name of the {@code Switch}.
*
* @return
*/
+ @Override
public String getName() {
return name;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchCommand.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchCommand.java
index 6d71b96..de90a59 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchCommand.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchCommand.java
@@ -22,40 +22,28 @@ public class ConsumerSwitchCommand extends Command<ConsumerSwitchResult> {
private SwitchStatus status = null;
- /**
- * Constructor
- *
- * @param id
- */
public ConsumerSwitchCommand(String id) {
super(id);
}
- /**
- * Constructor
- *
- * @param id
- * @param status
- */
public ConsumerSwitchCommand(String id, SwitchStatus status) {
super(id);
this.status = status;
}
-
/**
- * Returns the {@code SwitchStatus}
+ * Return the {@code SwitchStatus}.
*
- * @return
+ * @return the current switch status.
*/
public SwitchStatus getStatus() {
return status;
}
/**
- * Sets the {@code SwitchStatus}
+ * Set the {@code SwitchStatus}.
*
- * @param status
+ * @param status the new switch status.
*/
public void setStatus(SwitchStatus status) {
this.status = status;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchCommandHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchCommandHandler.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchCommandHandler.java
index 9087f47..828db15 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchCommandHandler.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchCommandHandler.java
@@ -76,10 +76,12 @@ public class ConsumerSwitchCommandHandler extends CommandHandler<ConsumerSwitchC
}
}
+ @Override
public Class<ConsumerSwitchCommand> getType() {
return ConsumerSwitchCommand.class;
}
+ @Override
public Switch getSwitch() {
return commandSwitch;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchResult.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchResult.java
index 8ca906e..1ef7274 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchResult.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ConsumerSwitchResult.java
@@ -23,33 +23,15 @@ public class ConsumerSwitchResult extends Result {
protected Boolean success = Boolean.TRUE;
protected Boolean status = Boolean.TRUE;
- /**
- * Constructor
- *
- * @param id
- */
public ConsumerSwitchResult(String id) {
super(id);
}
- /**
- * Constructor
- *
- * @param id
- * @param success
- */
public ConsumerSwitchResult(String id, Boolean success) {
super(id);
this.success = success;
}
- /**
- * Constructor
- *
- * @param id
- * @param success
- * @param status
- */
public ConsumerSwitchResult(String id, Boolean success, Boolean status) {
super(id);
this.success = success;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/ManageGroupCommandHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageGroupCommandHandler.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageGroupCommandHandler.java
index 940d18b..ab236dd 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageGroupCommandHandler.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageGroupCommandHandler.java
@@ -60,9 +60,9 @@ public class ManageGroupCommandHandler extends CommandHandler<ManageGroupCommand
}
/**
- * Adds the {@link Group} list to the result.
+ * Add the {@link Group} list to the result.
*
- * @param result
+ * @param result the result where to add the group list.
*/
public void addGroupListToResult(ManageGroupResult result) {
Set<Group> groups = groupManager.listAllGroups();
@@ -75,9 +75,9 @@ public class ManageGroupCommandHandler extends CommandHandler<ManageGroupCommand
}
/**
- * Adds {@link Node} to the target {@link Group}.
+ * Add {@link Node} to the target {@link Group}.
*
- * @param targetGroupName
+ * @param targetGroupName the target group name where to add the node.
*/
public void joinGroup(String targetGroupName) {
Node node = clusterManager.getNode();
@@ -95,9 +95,9 @@ public class ManageGroupCommandHandler extends CommandHandler<ManageGroupCommand
}
/**
- * Removes {@link Node} from the target {@link Group}.
+ * Remove a {@link Node} from the target {@link Group}.
*
- * @param targetGroupName
+ * @param targetGroupName the target group name where to remove the node.
*/
public void quitGroup(String targetGroupName) {
Node node = clusterManager.getNode();
@@ -112,7 +112,7 @@ public class ManageGroupCommandHandler extends CommandHandler<ManageGroupCommand
}
/**
- * Removes {@link Node} from ALL {@link Group}s.
+ * Remove {@link Node} from all {@link Group}s.
*/
public void purgeGroups() {
Node node = clusterManager.getNode();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommand.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommand.java
index 4945ec4..e2cda72 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommand.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommand.java
@@ -23,11 +23,6 @@ public class ManageHandlersCommand extends Command<ManageHandlersResult> {
private String handlerName;
private Boolean status = Boolean.TRUE;
- /**
- * Constructor
- *
- * @param id
- */
public ManageHandlersCommand(String id) {
super(id);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommandHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommandHandler.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommandHandler.java
index fe42966..601984e 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommandHandler.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommandHandler.java
@@ -42,10 +42,10 @@ public class ManageHandlersCommandHandler extends CommandHandler<ManageHandlersC
private Consumer consumer;
/**
- * Returns a map containing all managed {@code EventHandler}s and their status.
+ * Return a map containing all managed {@code EventHandler}s and their status.
*
- * @param command
- * @return
+ * @param command the manage handlers command to execute.
+ * @return a result containing the map of event handlers (and their status).
*/
@Override
public ManageHandlersResult execute(ManageHandlersCommand command) {
@@ -95,7 +95,7 @@ public class ManageHandlersCommandHandler extends CommandHandler<ManageHandlersC
/**
* Store the handler switch configuration in configuration admin.
*
- * @param handler the handler to store
+ * @param handler the handler to store.
* @param switchStatus the switch status to store.
*/
private void persist(String handler, SwitchStatus switchStatus) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersResult.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersResult.java
index 197fb81..12dad36 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersResult.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersResult.java
@@ -25,11 +25,6 @@ public class ManageHandlersResult extends Result {
public Map<String, String> handlers = new HashMap<String, String>();
- /**
- * Constructor.
- *
- * @param id
- */
public ManageHandlersResult(String id) {
super(id);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommand.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommand.java
index 6df7508..f2f6722 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommand.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommand.java
@@ -22,40 +22,19 @@ public class ProducerSwitchCommand extends Command<ProducerSwitchResult> {
private SwitchStatus status = null;
- /**
- * Constructor
- *
- * @param id
- */
public ProducerSwitchCommand(String id) {
super(id);
}
- /**
- * Constructor
- *
- * @param id
- * @param status
- */
public ProducerSwitchCommand(String id, SwitchStatus status) {
super(id);
this.status = status;
}
- /**
- * Returns the {@code SwitchStatus}
- *
- * @return
- */
public SwitchStatus getStatus() {
return status;
}
- /**
- * Sets the {@code SwitchStatus}
- *
- * @param status
- */
public void setStatus(SwitchStatus status) {
this.status = status;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java
index 2cbfd00..39e8b08 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java
@@ -17,7 +17,6 @@ import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Producer;
import org.apache.karaf.cellar.core.command.CommandHandler;
import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
import java.util.Dictionary;
@@ -30,10 +29,12 @@ public class ProducerSwitchCommandHandler extends CommandHandler<ProducerSwitchC
private final Switch commandSwitch = new BasicSwitch(SWITCH_ID);
/**
- * Handle the {@code ProducerSwitchCommand} command.
+ * Execute a producer switch command.
*
- * @param command
+ * @param command the producer switch command to execute.
+ * @return the result of the command execution.
*/
+ @Override
public ProducerSwitchResult execute(ProducerSwitchCommand command) {
// query
if (command.getStatus() == null) {
@@ -75,18 +76,22 @@ public class ProducerSwitchCommandHandler extends CommandHandler<ProducerSwitchC
}
}
+ @Override
public Class<ProducerSwitchCommand> getType() {
return ProducerSwitchCommand.class;
}
+ @Override
public Switch getSwitch() {
return commandSwitch;
}
+ @Override
public Producer getProducer() {
return producer;
}
+ @Override
public void setProducer(Producer producer) {
this.producer = producer;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchResult.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchResult.java
index 6fae8e4..3ce485e 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchResult.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchResult.java
@@ -23,33 +23,15 @@ public class ProducerSwitchResult extends Result {
protected Boolean success = Boolean.TRUE;
protected Boolean status = Boolean.TRUE;
- /**
- * Constructor
- *
- * @param id
- */
public ProducerSwitchResult(String id) {
super(id);
}
- /**
- * Constructor
- *
- * @param id
- * @param success
- */
public ProducerSwitchResult(String id, Boolean success) {
super(id);
this.success = success;
}
- /**
- * Constructor
- *
- * @param id
- * @param success
- * @param status
- */
public ProducerSwitchResult(String id, Boolean success, Boolean status) {
super(id);
this.success = success;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/control/Switch.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/Switch.java b/core/src/main/java/org/apache/karaf/cellar/core/control/Switch.java
index 020452a..0ba42ab 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/Switch.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/Switch.java
@@ -14,31 +14,31 @@
package org.apache.karaf.cellar.core.control;
/**
- * An interface that describes objects that can be turned on/off and act like a switch.
+ * An interface that describes switch that can be turned on/off.
*/
public interface Switch {
/**
- * Returns the name of the Switch.
+ * Returns the name of the switch.
*
- * @return
+ * @return the switch name.
*/
public String getName();
/**
- * Turns on.
+ * Turns on the switch.
*/
public void turnOn();
/**
- * Turns off
+ * Turns off the switch.
*/
public void turnOff();
/**
- * Returns the status of the switch.
+ * Returns the current status of the switch.
*
- * @return
+ * @return the current status of the switch.
*/
public SwitchStatus getStatus();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/discovery/Discovery.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/discovery/Discovery.java b/core/src/main/java/org/apache/karaf/cellar/core/discovery/Discovery.java
index 7882f6c..ce16744 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/discovery/Discovery.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/discovery/Discovery.java
@@ -11,9 +11,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.karaf.cellar.core.discovery;
+/**
+ * Constants for Discovery.
+ */
public class Discovery {
public static final String PID = "org.apache.karaf.cellar.discovery";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/discovery/DiscoveryTask.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/discovery/DiscoveryTask.java b/core/src/main/java/org/apache/karaf/cellar/core/discovery/DiscoveryTask.java
index b370a78..7e185cc 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/discovery/DiscoveryTask.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/discovery/DiscoveryTask.java
@@ -14,10 +14,8 @@
package org.apache.karaf.cellar.core.discovery;
import java.io.IOException;
-import java.util.Collections;
import java.util.Dictionary;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -40,18 +38,18 @@ public class DiscoveryTask implements Runnable {
private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
public void init() {
- LOGGER.debug("CELLAR DISCOVERY: a new Task initalized");
+ LOGGER.debug("CELLAR DISCOVERY: a new Task initialized");
scheduler.scheduleWithFixedDelay(this, 10, 10, TimeUnit.SECONDS);
}
public void destroy() {
- LOGGER.debug("CELLAR DISCOVERY: task is beeing destroyed");
+ LOGGER.debug("CELLAR DISCOVERY: task is being destroyed");
scheduler.shutdown();
}
@Override
public void run() {
- LOGGER.trace("CELLAR DISCOVERY: Starting the discovery task.");
+ LOGGER.trace("CELLAR DISCOVERY: starting the discovery task");
if (configurationAdmin != null) {
Set<String> members = new LinkedHashSet<String>();
@@ -60,15 +58,15 @@ public class DiscoveryTask implements Runnable {
service.refresh();
Set<String> discovered = service.discoverMembers();
members.addAll(discovered);
- LOGGER.trace("CELLAR DISCOVERY: Service {} found members {}", service, discovered);
+ LOGGER.trace("CELLAR DISCOVERY: service {} found members {}", service, discovered);
}
try {
LOGGER.trace("CELLAR DISCOVERY: retrieving configuration for PID={}", Discovery.PID);
Configuration configuration = configurationAdmin.getConfiguration(Discovery.PID);
Dictionary properties = configuration.getProperties();
if (properties == null) {
- //this is a new configuration ...
- LOGGER.trace("CELLAR DISCOVERY: configuration is new!");
+ // this is a new configuration ...
+ LOGGER.trace("CELLAR DISCOVERY: configuration is new");
properties = new Hashtable();
}
String newMemberText = CellarUtils.createStringFromSet(members, true);
@@ -81,7 +79,7 @@ public class DiscoveryTask implements Runnable {
LOGGER.trace("CELLAR DISCOVERY: found a valid member in the configuration will skip");
}
} catch (IOException e) {
- LOGGER.error("Failed to update member list", e);
+ LOGGER.error("CELLAR DISCOVERY: failed to update member list", e);
}
} else {
LOGGER.trace("CELLAR DISCOVERY: no discovery services found ... ");
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/Event.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/Event.java b/core/src/main/java/org/apache/karaf/cellar/core/event/Event.java
index 70a01a8..4abc472 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/Event.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/Event.java
@@ -20,7 +20,7 @@ import java.io.Serializable;
import java.util.Set;
/**
- * Represents an event that is broadcasted to the cluster.
+ * This class represents an event that is broad-casted to the cluster.
* The event is always generated by a single node (source) but can have none or multiple destinations.
*/
public class Event implements Serializable {
@@ -32,11 +32,6 @@ public class Event implements Serializable {
protected Boolean force = Boolean.FALSE;
protected Boolean postPublish = Boolean.FALSE;
- /**
- * Constructor
- *
- * @param id
- */
public Event(String id) {
this.id = id;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/EventConsumer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/EventConsumer.java b/core/src/main/java/org/apache/karaf/cellar/core/event/EventConsumer.java
index 4f7340b..3cea5ee 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/EventConsumer.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/EventConsumer.java
@@ -21,24 +21,27 @@ import org.apache.karaf.cellar.core.Consumer;
public interface EventConsumer<E extends Event> extends Consumer<E> {
/**
- * Consumes {@code Event}s to the cluster.
+ * Consume {@code Event}s to the cluster.
*
- * @param event
+ * @param event the cluster event to consume.
*/
+ @Override
public void consume(E event);
/**
- * Start consuming
+ * Start to consume cluster events.
*/
public void start();
/**
- * Stop consuming
+ * Stop to consume cluster events.
*/
public void stop();
/**
- * Returns true if Consumer is consuming
+ * Check the current event consumer status.
+ *
+ * @return true if the consumer is consuming, false else.
*/
public Boolean isConsuming();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatchTask.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatchTask.java b/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatchTask.java
index f14a261..a1a02a7 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatchTask.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatchTask.java
@@ -28,38 +28,17 @@ public class EventDispatchTask<E extends Event> implements Runnable {
private long timeout = 10000;
private long interval = 1000;
- /**
- * Constructor
- *
- * @param event
- * @param handlerRegistry
- */
public EventDispatchTask(E event, EventHandlerRegistry handlerRegistry) {
this.event = event;
this.handlerRegistry = handlerRegistry;
}
- /**
- * Constructor
- *
- * @param event
- * @param handlerRegistry
- * @param timeout
- */
public EventDispatchTask(E event, EventHandlerRegistry handlerRegistry, long timeout) {
this.event = event;
this.handlerRegistry = handlerRegistry;
this.timeout = timeout;
}
- /**
- * Constructor
- *
- * @param handlerRegistry
- * @param timeout
- * @param interval
- * @param event
- */
public EventDispatchTask(EventHandlerRegistry handlerRegistry, long timeout, long interval, E event) {
this.handlerRegistry = handlerRegistry;
this.timeout = timeout;
@@ -67,28 +46,29 @@ public class EventDispatchTask<E extends Event> implements Runnable {
this.event = event;
}
+ @Override
public void run() {
try {
- boolean dispatched = false;
+ boolean dispatched = false;
- for (long delay = 0; delay < timeout && !dispatched; delay += interval) {
- EventHandler handler = handlerRegistry.getHandler(event);
- if (handler != null) {
- handler.handle(event);
- dispatched = true;
- } else {
- try {
- Thread.sleep(interval);
- } catch (InterruptedException e) {
- LOGGER.warn("Interupted while waiting for event handler", e);
+ for (long delay = 0; delay < timeout && !dispatched; delay += interval) {
+ EventHandler handler = handlerRegistry.getHandler(event);
+ if (handler != null) {
+ handler.handle(event);
+ dispatched = true;
+ } else {
+ try {
+ Thread.sleep(interval);
+ } catch (InterruptedException e) {
+ LOGGER.warn("Interrupted while waiting for cluster event handler", e);
+ }
}
}
- }
- if (!dispatched) {
- LOGGER.warn("Failed to retrieve handler for event {}", event.getClass());
- }
- }catch(Exception ex) {
- LOGGER.error("Error while dispatching task",ex);
+ if (!dispatched) {
+ LOGGER.warn("Failed to retrieve handler for cluster event {}", event.getClass());
+ }
+ } catch (Exception ex) {
+ LOGGER.error("Error while dispatching task", ex);
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatcher.java b/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatcher.java
index ea0009e..0ba35bc 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatcher.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatcher.java
@@ -16,14 +16,14 @@ package org.apache.karaf.cellar.core.event;
import org.apache.karaf.cellar.core.Dispatcher;
/**
- * A dispatcher which dispatches each event to the appropriate Handler.
+ * A dispatcher which dispatches each cluster event to the appropriate handler.
*/
public interface EventDispatcher<E extends Event> extends Dispatcher<E> {
/**
- * Dispatches the Event to the appropriate handler.
+ * Dispatch the cluster event to the appropriate handler.
*
- * @param event
+ * @param event the cluster event to dispatch.
*/
public void dispatch(E event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandler.java b/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandler.java
index 03370b3..161dd9a 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandler.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandler.java
@@ -23,7 +23,9 @@ public interface EventHandler<E extends Event> extends Handler<E> {
public static String MANAGED_FILTER = "(managed=true)";
/**
- * Called to handle {@code Event}.
+ * Handle a cluster {@code Event}.
+ *
+ * @param event the cluster event to handle.
*/
public void handle(E event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerRegistry.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerRegistry.java b/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerRegistry.java
index 558b4aa..8345816 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerRegistry.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerRegistry.java
@@ -19,11 +19,12 @@ import org.apache.karaf.cellar.core.HandlerRegistry;
public interface EventHandlerRegistry<E extends Event> extends HandlerRegistry<E, Handler<E>> {
/**
- * Returns the {@code EventHandler} for the given {@code Event}.
+ * Return the cluster {@code EventHandler} for a given cluster {@code Event}.
*
- * @param event
- * @return
+ * @param event the cluster event to handle.
+ * @return the cluster event handler to use.
*/
+ @Override
public EventHandler<E> getHandler(E event);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerRegistryDispatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerRegistryDispatcher.java b/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerRegistryDispatcher.java
index dc19967..6e4a087 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerRegistryDispatcher.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerRegistryDispatcher.java
@@ -24,9 +24,6 @@ public class EventHandlerRegistryDispatcher<E extends Event> implements EventDis
private ExecutorService threadPool;
private EventHandlerRegistry handlerRegistry;
- /**
- * Initialization
- */
public void init() {
if (threadPool == null) {
threadPool = Executors.newCachedThreadPool();
@@ -34,9 +31,9 @@ public class EventHandlerRegistryDispatcher<E extends Event> implements EventDis
}
/**
- * Dispatches an {@code Event} to the appropriate {@code EventHandler}.
+ * Dispatch a cluster {@code Event} to the appropriate cluster {@code EventHandler}.
*
- * @param event
+ * @param event the cluster event to dispatch.
*/
public void dispatch(E event) {
EventDispatchTask task = new EventDispatchTask(event, handlerRegistry);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerServiceRegistry.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerServiceRegistry.java b/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerServiceRegistry.java
index 5d125de..f8ebee9 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerServiceRegistry.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/EventHandlerServiceRegistry.java
@@ -13,32 +13,23 @@
*/
package org.apache.karaf.cellar.core.event;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
/**
* Event handler service registry.
*/
public class EventHandlerServiceRegistry<E extends Event> implements EventHandlerRegistry<E> {
- private static final transient Logger LOGGER = LoggerFactory.getLogger(EventHandlerRegistryDispatcher.class);
-
private Map<Class,EventHandler> eventHandlerMap = new ConcurrentHashMap<Class,EventHandler>();
/**
- * Returns the appropriate {@code EventHandler} found inside the {@code HandlerRegistry}.
+ * Return the appropriate cluster {@code EventHandler} found inside the cluster {@code HandlerRegistry}.
*
- * @param event
- * @return
+ * @param event the cluster event to handle.
+ * @return the corresponding cluster event handler to use.
*/
+ @Override
public EventHandler<E> getHandler(E event) {
if (event != null) {
Class clazz = event.getClass();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/EventProducer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/EventProducer.java b/core/src/main/java/org/apache/karaf/cellar/core/event/EventProducer.java
index 41e8444..ec9355b 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/EventProducer.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/EventProducer.java
@@ -16,15 +16,16 @@ package org.apache.karaf.cellar.core.event;
import org.apache.karaf.cellar.core.Producer;
/**
- * Transmits events to the cluster.
+ * Broadcast cluster events to the cluster.
*/
public interface EventProducer<E extends Event> extends Producer<E> {
/**
- * Produce {@code Event}s to the cluster.
+ * Produce and broadcast cluster {@code Event}s to the cluster.
*
- * @param event
+ * @param event the cluster event to produce and broadcast.
*/
+ @Override
public void produce(E event);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/EventTracker.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/EventTracker.java b/core/src/main/java/org/apache/karaf/cellar/core/event/EventTracker.java
index 86f11c7..37e3038 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/EventTracker.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/EventTracker.java
@@ -14,29 +14,29 @@
package org.apache.karaf.cellar.core.event;
/**
- * Event tracker interface.
+ * Track a cluster event.
*/
public interface EventTracker<E extends Event> {
/**
- * Starts tracking the occurance of an {@code Event}.
+ * Start to track the occurrence of a cluster {@code Event}.
*
- * @param event
+ * @param event the cluster event to track.
*/
public void start(E event);
/**
- * Stops tracking the occurance of an {@code Event}.
+ * Stop to track the occurrence of a cluster {@code Event}.
*
- * @param event
+ * @param event the cluster event to track.
*/
public void stop(E event);
/**
- * Returns true if the {@code Event} is being tracked.
+ * Check if a cluster event is pending.
*
- * @param event
- * @return
+ * @param event the cluster event to check.
+ * @return true if the cluster event is pending, false else.
*/
public Boolean isPending(E event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/event/EventTransportFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/event/EventTransportFactory.java b/core/src/main/java/org/apache/karaf/cellar/core/event/EventTransportFactory.java
index cfa613f..a5e4cee 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/event/EventTransportFactory.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/event/EventTransportFactory.java
@@ -13,23 +13,26 @@
*/
package org.apache.karaf.cellar.core.event;
+/**
+ * A factory to create producer and consumer of cluster events.
+ */
public interface EventTransportFactory {
/**
- * Returns an Event Producer that produces {@link Event}s for a specific {@link org.apache.karaf.cellar.core.Group}.
+ * Return a cluster {@link EventProducer} that produces cluster {@link Event}s for a specific cluster {@link org.apache.karaf.cellar.core.Group}.
*
- * @param name
- * @param pubsub
- * @return
+ * @param name the event producer name.
+ * @param pubsub true to enable pubsub mode, false else.
+ * @return the cluster event producer.
*/
public EventProducer getEventProducer(String name, Boolean pubsub);
/**
- * Returns an Event Consumer that consumes {@link Event}s for a specific {@link org.apache.karaf.cellar.core.Group}.
+ * Return a cluster {@link EventConsumer} that consumes cluster {@link Event}s for a specific cluster {@link org.apache.karaf.cellar.core.Group}.
*
- * @param name
- * @param pubsub
- * @return
+ * @param name the event consumer name.
+ * @param pubsub true to enable pubsub mode, false else.
+ * @return the cluster event consumer.
*/
public EventConsumer getEventConsumer(String name, Boolean pubsub);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/exception/ProducerNotFoundException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/exception/ProducerNotFoundException.java b/core/src/main/java/org/apache/karaf/cellar/core/exception/ProducerNotFoundException.java
index c27b0ed..7b40dda 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/exception/ProducerNotFoundException.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/exception/ProducerNotFoundException.java
@@ -13,9 +13,13 @@
*/
package org.apache.karaf.cellar.core.exception;
+/**
+ * Exception raised when no cluster event producer has been found.
+ */
public class ProducerNotFoundException extends Exception {
public ProducerNotFoundException() {
+ // nothing to do
}
public ProducerNotFoundException(String message) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/exception/StoreNotFoundException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/exception/StoreNotFoundException.java b/core/src/main/java/org/apache/karaf/cellar/core/exception/StoreNotFoundException.java
index 56ec9a6..329ea58 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/exception/StoreNotFoundException.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/exception/StoreNotFoundException.java
@@ -13,9 +13,13 @@
*/
package org.apache.karaf.cellar.core.exception;
+/**
+ * Exception raised with a store is not found.
+ */
public class StoreNotFoundException extends Exception {
public StoreNotFoundException() {
+ // nothing to do
}
public StoreNotFoundException(String message) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java
index dad4c77..6ff9191 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java
@@ -15,7 +15,6 @@ package org.apache.karaf.cellar.core.shell;
import org.apache.karaf.cellar.core.ClusterManager;
import org.apache.karaf.cellar.core.GroupManager;
-import org.apache.karaf.cellar.core.event.EventTransportFactory;
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.osgi.service.cm.ConfigurationAdmin;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllGroupsCompleter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllGroupsCompleter.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllGroupsCompleter.java
index f8884e0..b5e776c 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllGroupsCompleter.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllGroupsCompleter.java
@@ -16,10 +16,16 @@ package org.apache.karaf.cellar.core.shell.completer;
import org.apache.karaf.cellar.core.Group;
/**
- * All groups completer.
+ * Completer for all cluster groups.
*/
public class AllGroupsCompleter extends GroupCompleterSupport {
+ /**
+ * Accept all cluster groups for completion.
+ *
+ * @param group the cluster group to check.
+ * @return always return true.
+ */
@Override
protected boolean acceptsGroup(Group group) {
return true;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/GroupCompleterSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/GroupCompleterSupport.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/GroupCompleterSupport.java
index 1ecf21c..bd172ef 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/GroupCompleterSupport.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/GroupCompleterSupport.java
@@ -21,14 +21,21 @@ import org.apache.karaf.shell.console.completer.StringsCompleter;
import java.util.List;
/**
- * Abstract group completer.
+ * Abstract cluster group completer.
*/
public abstract class GroupCompleterSupport implements Completer {
protected GroupManager groupManager;
+ /**
+ * Check if a cluster group should be accepted for completion.
+ *
+ * @param group the cluster group to check.
+ * @return true if the cluster group has been accepted, false else.
+ */
protected abstract boolean acceptsGroup(Group group);
+ @Override
public int complete(String buffer, int cursor, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
try {
@@ -41,12 +48,11 @@ public abstract class GroupCompleterSupport implements Completer {
}
}
} catch (Exception e) {
- // Ignore
+ // ignore
}
return delegate.complete(buffer, cursor, candidates);
}
-
public GroupManager getGroupManager() {
return groupManager;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/LocalGroupsCompleter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/LocalGroupsCompleter.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/LocalGroupsCompleter.java
index 588aea8..16b42d5 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/LocalGroupsCompleter.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/LocalGroupsCompleter.java
@@ -17,10 +17,16 @@ import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.Node;
/**
- * Local groups completer.
+ * Local cluster groups completer.
*/
public class LocalGroupsCompleter extends GroupCompleterSupport {
+ /**
+ * Add cluster groups where the local node is belonging.
+ *
+ * @param group the cluster group candidate for completion.
+ * @return true if the cluster group has been accepted, false else.
+ */
@Override
protected boolean acceptsGroup(Group group) {
Node node = groupManager.getNode();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/cbc5c6e9/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/OtherGroupsCompleter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/OtherGroupsCompleter.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/OtherGroupsCompleter.java
index 4657f51..1098bea 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/OtherGroupsCompleter.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/OtherGroupsCompleter.java
@@ -21,6 +21,12 @@ import org.apache.karaf.cellar.core.Node;
*/
public class OtherGroupsCompleter extends GroupCompleterSupport {
+ /**
+ * Accept the cluster groups which don't include the local node.
+ *
+ * @param group the cluster group to check.
+ * @return true if the cluster group doesn't include the local node, false else.
+ */
@Override
protected boolean acceptsGroup(Group group) {
Node node = groupManager.getNode();
[13/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471423 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/1fbc626a
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/1fbc626a
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/1fbc626a
Branch: refs/heads/master
Commit: 1fbc626a6929de869795f38d014f2a7db120f836
Parents: 2184d48
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed Apr 24 14:11:12 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed Apr 24 14:11:12 2013 +0000
----------------------------------------------------------------------
.../karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/1fbc626a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
index 7abcadf..f22001b 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
@@ -22,7 +22,7 @@ import org.apache.karaf.shell.commands.Command;
import java.util.Map;
import java.util.Set;
-@Command(scope = "cluster", name = "service-list", description = "List the cluster distributed services")
+@Command(scope = "cluster", name = "service-list", description = "List the services available on the cluster")
public class ListDistributedServicesCommand extends CellarCommandSupport {
private static final String LIST_FORMAT = "%-80s %-20s";
@@ -46,7 +46,7 @@ public class ListDistributedServicesCommand extends CellarCommandSupport {
}
} else {
- System.out.println("No distributed service");
+ System.out.println("No service available on the cluster");
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
[41/50] [abbrv] git commit: [KARAF-2317] Display only up and running
nodes in cluster:group-list command and CellarGroupMBean
Posted by jb...@apache.org.
[KARAF-2317] Display only up and running nodes in cluster:group-list command and CellarGroupMBean
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1496397 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/2e00e51a
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/2e00e51a
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/2e00e51a
Branch: refs/heads/master
Commit: 2e00e51adffa5f0bcc901626da3e8190ad9abe78
Parents: ffad533
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Jun 25 10:02:39 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Jun 25 10:02:39 2013 +0000
----------------------------------------------------------------------
.../management/internal/CellarGroupMBeanImpl.java | 7 +++++--
.../apache/karaf/cellar/shell/group/GroupSupport.java | 13 ++++++++-----
2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2e00e51a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarGroupMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarGroupMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarGroupMBeanImpl.java
index bf1a255..5580c02 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarGroupMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarGroupMBeanImpl.java
@@ -165,8 +165,11 @@ public class CellarGroupMBeanImpl extends StandardMBean implements CellarGroupMB
for (Group group : allGroups) {
StringBuffer members = new StringBuffer();
for (Node node : group.getNodes()) {
- members.append(node.getId());
- members.append(" ");
+ // display only up and running nodes in the cluster
+ if (clusterManager.findNodeById(node.getId()) != null) {
+ members.append(node.getId());
+ members.append(" ");
+ }
}
CompositeData data = new CompositeDataSupport(groupType,
new String[]{ "name", "members" },
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2e00e51a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
index 9392b19..dbe5cdb 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
@@ -95,12 +95,15 @@ public abstract class GroupSupport extends ClusterCommandSupport {
if (g.getNodes() != null && !g.getNodes().isEmpty()) {
String mark = " ";
for (Node member : g.getNodes()) {
- buffer.append(member.getId());
- if (member.equals(clusterManager.getNode())) {
- mark = "*";
- buffer.append(mark);
+ // display only up and running nodes in the cluster
+ if (clusterManager.findNodeById(member.getId()) != null) {
+ buffer.append(member.getId());
+ if (member.equals(clusterManager.getNode())) {
+ mark = "*";
+ buffer.append(mark);
+ }
+ buffer.append(" ");
}
- buffer.append(" ");
}
System.out.println(String.format(OUTPUT_FORMAT, mark, g.getName(), buffer.toString()));
} else System.out.println(String.format(OUTPUT_FORMAT, "", g.getName(), ""));
[26/50] [abbrv] git commit: [KARAF-2111] Use karaf-pax-exam for itests
Posted by jb...@apache.org.
[KARAF-2111] Use karaf-pax-exam for itests
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1483253 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/85934454
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/85934454
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/85934454
Branch: refs/heads/master
Commit: 85934454369cd03bb04c9fa5e218e5226afce234
Parents: 5c36aa3
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu May 16 08:50:52 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu May 16 08:50:52 2013 +0000
----------------------------------------------------------------------
itests/pom.xml | 1 -
.../java/org/apache/karaf/cellar/itests/CellarBundleTest.java | 2 ++
.../org/apache/karaf/cellar/itests/CellarChildNodesTest.java | 2 ++
.../org/apache/karaf/cellar/itests/CellarConfigurationTest.java | 2 ++
.../java/org/apache/karaf/cellar/itests/CellarEventTest.java | 2 ++
.../java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java | 2 ++
.../java/org/apache/karaf/cellar/itests/CellarGroupsTest.java | 2 ++
.../org/apache/karaf/cellar/itests/CellarInstallationTest.java | 2 ++
.../test/java/org/apache/karaf/cellar/itests/CellarObrTest.java | 2 ++
.../karaf/cellar/itests/CellarSampleCamelHazelcastTest.java | 2 ++
.../apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java | 2 ++
.../java/org/apache/karaf/cellar/itests/CellarTestSupport.java | 4 +++-
pom.xml | 2 +-
13 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/pom.xml
----------------------------------------------------------------------
diff --git a/itests/pom.xml b/itests/pom.xml
index 465ec38..944065e 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -64,7 +64,6 @@
<dependency>
<groupId>org.apache.karaf.tooling.exam</groupId>
<artifactId>org.apache.karaf.tooling.exam.container</artifactId>
- <version>3.0.0.RC1</version>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarBundleTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarBundleTest.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarBundleTest.java
index b34f78f..98438cd 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarBundleTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarBundleTest.java
@@ -18,6 +18,7 @@ import static org.junit.Assert.assertNotNull;
import org.apache.karaf.cellar.core.ClusterManager;
import org.apache.karaf.features.FeaturesService;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -29,6 +30,7 @@ import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
public class CellarBundleTest extends CellarTestSupport {
@Test
+ @Ignore
public void testCellarBundleModule() throws Exception {
FeaturesService featuresService = getOsgiService(FeaturesService.class);
assertNotNull(featuresService);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarChildNodesTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarChildNodesTest.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarChildNodesTest.java
index 9561caf..90b5b0d 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarChildNodesTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarChildNodesTest.java
@@ -21,6 +21,7 @@ import java.util.Set;
import org.apache.karaf.cellar.core.ClusterManager;
import org.apache.karaf.cellar.core.Node;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -32,6 +33,7 @@ import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
public class CellarChildNodesTest extends CellarTestSupport {
@Test
+ @Ignore
public void testClusterWithChildNodes() throws InterruptedException {
installCellar();
createCellarChild("child1");
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarConfigurationTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarConfigurationTest.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarConfigurationTest.java
index dc941ef..aca4794 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarConfigurationTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarConfigurationTest.java
@@ -19,6 +19,7 @@ import static org.junit.Assert.assertTrue;
import org.apache.karaf.cellar.core.ClusterManager;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -32,6 +33,7 @@ public class CellarConfigurationTest extends CellarTestSupport {
private static final String TESTPID = "org.apache.karaf.cellar.tst";
@Test
+ @Ignore
public void testCellarFeaturesModule() throws InterruptedException {
installCellar();
createCellarChild("child1");
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarEventTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarEventTest.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarEventTest.java
index 74370bd..7bb08da 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarEventTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarEventTest.java
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertNotNull;
import org.apache.karaf.cellar.core.ClusterManager;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -28,6 +29,7 @@ import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
public class CellarEventTest extends CellarTestSupport {
@Test
+ @Ignore
public void testCellarEventFeatureInstall() throws Exception {
installCellar();
Thread.sleep(DEFAULT_TIMEOUT);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java
index 80365bd..670ebba 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java
@@ -21,6 +21,7 @@ import java.util.Set;
import org.apache.karaf.cellar.core.ClusterManager;
import org.apache.karaf.cellar.core.Node;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -35,6 +36,7 @@ public class CellarFeaturesTest extends CellarTestSupport {
private static final String INSTALLED = "[installed ]";
@Test
+ @Ignore
public void testCellarFeaturesModule() throws InterruptedException {
installCellar();
createCellarChild("child1");
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarGroupsTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarGroupsTest.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarGroupsTest.java
index 0afc852..27d8f54 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarGroupsTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarGroupsTest.java
@@ -24,6 +24,7 @@ import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.GroupManager;
import org.apache.karaf.cellar.core.Node;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -35,6 +36,7 @@ import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
public class CellarGroupsTest extends CellarTestSupport {
@Test
+ @Ignore
public void testGroupsWithChildNodes() throws InterruptedException {
installCellar();
createCellarChild("child1");
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarInstallationTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarInstallationTest.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarInstallationTest.java
index 0f3b2c1..11441d4 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarInstallationTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarInstallationTest.java
@@ -16,6 +16,7 @@ package org.apache.karaf.cellar.itests;
import static org.junit.Assert.assertNotNull;
import org.apache.karaf.cellar.core.ClusterManager;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -27,6 +28,7 @@ import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
public class CellarInstallationTest extends CellarTestSupport {
@Test
+ @Ignore
public void testInstallation() throws InterruptedException {
installCellar();
ClusterManager clusterManager = getOsgiService(ClusterManager.class);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarObrTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarObrTest.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarObrTest.java
index d12fd7a..b39b03c 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarObrTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarObrTest.java
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertNotNull;
import org.apache.karaf.cellar.core.ClusterManager;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -28,6 +29,7 @@ import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
public class CellarObrTest extends CellarTestSupport {
@Test
+ @Ignore
public void testCellarObrFeatureInstall() throws Exception {
installCellar();
Thread.sleep(DEFAULT_TIMEOUT);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleCamelHazelcastTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleCamelHazelcastTest.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleCamelHazelcastTest.java
index 4600b8d..b32c1eb 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleCamelHazelcastTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleCamelHazelcastTest.java
@@ -21,6 +21,7 @@ import java.util.Set;
import org.apache.karaf.cellar.core.ClusterManager;
import org.apache.karaf.cellar.core.Node;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -32,6 +33,7 @@ import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
public class CellarSampleCamelHazelcastTest extends CellarTestSupport {
@Test
+ @Ignore
public void testCamelSampleApp() throws InterruptedException {
installCellar();
createCellarChild("child1");
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java
index 3a8cc95..f47afd6 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java
@@ -22,6 +22,7 @@ import java.util.Set;
import org.apache.karaf.cellar.core.ClusterManager;
import org.apache.karaf.cellar.core.Node;
import org.junit.After;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -33,6 +34,7 @@ import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
public class CellarSampleDosgiGreeterTest extends CellarTestSupport {
@Test
+ @Ignore
public void testDosgiGreeter() throws InterruptedException {
installCellar();
createCellarChild("child1");
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
index b86127e..bd594f6 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
@@ -187,7 +187,9 @@ public class CellarTestSupport {
public Option[] config() {
return new Option[]{
cellarDistributionConfiguration(), keepRuntimeFolder(), logLevel(LogLevelOption.LogLevel.INFO),
- editConfigurationFileExtend("etc/system.properties", "cellar.feature.url", maven().groupId("org.apache.karaf.cellar").artifactId("apache-karaf-cellar").versionAsInProject().classifier("features").type("xml").getURL())};
+ editConfigurationFileExtend("etc/system.properties", "cellar.feature.url", maven().groupId("org.apache.karaf.cellar").artifactId("apache-karaf-cellar").versionAsInProject().classifier("features").type("xml").getURL()),
+ editConfigurationFileExtend("etc/config.properties", "org.apache.aries.blueprint.synchronous", "true")
+ };
}
/**
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/85934454/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d7807da..1c557f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
<osgi.version>4.3.1</osgi.version>
<osgi.compendium.version>4.3.1</osgi.compendium.version>
<pax.exam.version>2.6.0</pax.exam.version>
- <pax.exam.karaf.version>3.0.0.RC1</pax.exam.karaf.version>
+ <pax.exam.karaf.version>2.3.1</pax.exam.karaf.version>
<servlet.api.version>2.5</servlet.api.version>
<slf4j.version>1.7.2</slf4j.version>
</properties>
[24/50] [abbrv] git commit: [KARAF-2277] Fix Cellar WebConsole plugin
with Equinox
Posted by jb...@apache.org.
[KARAF-2277] Fix Cellar WebConsole plugin with Equinox
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1478659 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/c981561f
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/c981561f
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/c981561f
Branch: refs/heads/master
Commit: c981561fbd9a9ed5110aafa49f446028365860a5
Parents: 63d3f67
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Fri May 3 06:58:28 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Fri May 3 06:58:28 2013 +0000
----------------------------------------------------------------------
.../apache/karaf/cellar/webconsole/CellarPlugin.java | 14 +++++++-------
.../OSGI-INF/blueprint/webconsole-cellar.xml | 3 +--
2 files changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/c981561f/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/CellarPlugin.java
----------------------------------------------------------------------
diff --git a/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/CellarPlugin.java b/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/CellarPlugin.java
index 974ca2d..ac3f167 100644
--- a/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/CellarPlugin.java
+++ b/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/CellarPlugin.java
@@ -33,28 +33,25 @@ import java.io.PrintWriter;
import java.net.URL;
import java.util.Set;
+/**
+ * WebConsole plugin for Cellar cluster groups.
+ */
public class CellarPlugin extends AbstractWebConsolePlugin {
private static final transient Logger LOGGER = LoggerFactory.getLogger(CellarPlugin.class);
public static final String NAME = "cellar";
-
public static final String LABEL = "Cellar";
-
private ClassLoader classLoader;
-
private String cellarJs = "/cellar/res/ui/cellar.js";
private ClusterManager clusterManager;
private GroupManager groupManager;
-
private BundleContext bundleContext;
public void start() {
super.activate(bundleContext);
-
this.classLoader = this.getClass().getClassLoader();
-
this.LOGGER.info("{} plugin activated", LABEL);
}
@@ -98,7 +95,7 @@ public class CellarPlugin extends AbstractWebConsolePlugin {
try {
Thread.sleep(800);
} catch (InterruptedException e) {
- // we ignore this
+ // ignore
}
this.renderJSON(resp, null);
} else {
@@ -135,6 +132,9 @@ public class CellarPlugin extends AbstractWebConsolePlugin {
protected URL getResource(String path) {
path = path.substring(NAME.length() + 1);
+ if (path == null || path.isEmpty()) {
+ return null;
+ }
URL url = this.classLoader.getResource(path);
if (url != null) {
InputStream ins = null;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/c981561f/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml
----------------------------------------------------------------------
diff --git a/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml b/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml
index 3aa8b8f..6c60241 100644
--- a/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml
+++ b/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml
@@ -17,8 +17,7 @@
limitations under the License.
-->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
[15/50] [abbrv] git commit: Code cleanup
Posted by jb...@apache.org.
Code cleanup
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471486 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/33d67d18
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/33d67d18
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/33d67d18
Branch: refs/heads/master
Commit: 33d67d18dcdacf02bae6a3841c2c7019e2683e1f
Parents: 47d1c9e
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed Apr 24 15:35:47 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed Apr 24 15:35:47 2013 +0000
----------------------------------------------------------------------
.../cellar/features/ClusterFeaturesEvent.java | 70 ++++++++++++++++++++
.../cellar/features/ClusterRepositoryEvent.java | 43 ++++++++++++
.../apache/karaf/cellar/features/Constants.java | 2 +-
.../karaf/cellar/features/FeatureInfo.java | 2 +-
.../cellar/features/FeaturesEventHandler.java | 32 ++++++---
.../karaf/cellar/features/FeaturesSupport.java | 27 +++++---
.../cellar/features/FeaturesSynchronizer.java | 25 ++++---
.../cellar/features/LocalFeaturesListener.java | 45 +++++++------
.../cellar/features/RemoteFeaturesEvent.java | 70 --------------------
.../cellar/features/RemoteRepositoryEvent.java | 50 --------------
.../cellar/features/RepositoryEventHandler.java | 18 +++--
.../features/shell/FeatureCommandSupport.java | 53 +++++++--------
.../features/shell/InstallFeatureCommand.java | 20 +++---
.../features/shell/ListGroupFeatures.java | 20 +++---
.../features/shell/UninstallFeatureCommand.java | 20 +++---
.../cellar/features/shell/UrlAddCommand.java | 30 ++++-----
.../cellar/features/shell/UrlListCommand.java | 8 +--
.../cellar/features/shell/UrlRemoveCommand.java | 30 ++++-----
.../resources/OSGI-INF/blueprint/blueprint.xml | 16 ++---
.../internal/CellarFeaturesMBeanImpl.java | 12 ++--
20 files changed, 311 insertions(+), 282 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java b/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java
new file mode 100644
index 0000000..0a82ad3
--- /dev/null
+++ b/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.features;
+
+import org.apache.karaf.cellar.core.event.Event;
+import org.apache.karaf.features.FeatureEvent.EventType;
+
+/**
+ * Cluster features event.
+ */
+public class ClusterFeaturesEvent extends Event {
+
+ private static final String separator = "/";
+
+ private String name;
+ private String version;
+ private Boolean noClean;
+ private Boolean noRefresh;
+ private EventType type;
+
+ public ClusterFeaturesEvent(String name, String version, EventType type) {
+ super(name + separator + version);
+ this.name = name;
+ this.version = version;
+ this.noClean = false;
+ this.noRefresh = false;
+ this.type = type;
+ }
+
+ public ClusterFeaturesEvent(String name, String version, Boolean noClean, Boolean noRefresh, EventType type) {
+ super(name + separator + version);
+ this.name = name;
+ this.version = version;
+ this.noClean = noClean;
+ this.noRefresh = noRefresh;
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public Boolean getNoClean() {
+ return noClean;
+ }
+
+ public Boolean getNoRefresh() {
+ return noRefresh;
+ }
+
+ public EventType getType() {
+ return type;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java b/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
new file mode 100644
index 0000000..2073d36
--- /dev/null
+++ b/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.features;
+
+import org.apache.karaf.cellar.core.event.Event;
+import org.apache.karaf.features.RepositoryEvent.EventType;
+
+/**
+ * Cluster features repository event.
+ */
+public class ClusterRepositoryEvent extends Event {
+
+ private EventType type;
+
+ public ClusterRepositoryEvent(String id, EventType type) {
+ super(id);
+ this.type = type;
+ }
+
+ public EventType getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ return "ClusterRepositoryEvent [type=" + type + ", id=" + id
+ + ", sourceNode=" + sourceNode + ", sourceGroup=" + sourceGroup
+ + ", destination=" + destination + ", force=" + force
+ + ", postPublish=" + postPublish + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/Constants.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/Constants.java b/features/src/main/java/org/apache/karaf/cellar/features/Constants.java
index c559a06..8ee51bd 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/Constants.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/Constants.java
@@ -14,7 +14,7 @@
package org.apache.karaf.cellar.features;
/**
- * Features constants.
+ * Features configuration constants.
*/
public class Constants {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/FeatureInfo.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeatureInfo.java b/features/src/main/java/org/apache/karaf/cellar/features/FeatureInfo.java
index c2d29ae..1f9277f 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeatureInfo.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeatureInfo.java
@@ -16,7 +16,7 @@ package org.apache.karaf.cellar.features;
import java.io.Serializable;
/**
- * Feature info.
+ * Feature info to store in the cluster.
*/
public class FeatureInfo implements Serializable {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
index b09aff4..5d4ea54 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
@@ -28,9 +28,9 @@ import org.slf4j.LoggerFactory;
import java.util.EnumSet;
/**
- * Features event handler.
+ * Handler for cluster features event.
*/
-public class FeaturesEventHandler extends FeaturesSupport implements EventHandler<RemoteFeaturesEvent> {
+public class FeaturesEventHandler extends FeaturesSupport implements EventHandler<ClusterFeaturesEvent> {
private static final transient Logger LOGGER = LoggerFactory.getLogger(FeaturesSynchronizer.class);
@@ -49,11 +49,11 @@ public class FeaturesEventHandler extends FeaturesSupport implements EventHandle
}
/**
- * Features Event.
+ * Handle a received cluster features event.
*
- * @param event
+ * @param event the received cluster feature event.
*/
- public void handle(RemoteFeaturesEvent event) {
+ public void handle(ClusterFeaturesEvent event) {
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
LOGGER.warn("CELLAR FEATURES: {} switch is OFF, cluster event is not handled", SWITCH_ID);
@@ -68,7 +68,7 @@ public class FeaturesEventHandler extends FeaturesSupport implements EventHandle
// check if the group is local
if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
- LOGGER.debug("CELLAR FEATURES: node is not part of the event cluster group");
+ LOGGER.debug("CELLAR FEATURES: node is not part of the event cluster group {}", event.getSourceGroup().getName());
return;
}
@@ -105,15 +105,27 @@ public class FeaturesEventHandler extends FeaturesSupport implements EventHandle
}
}
} catch (Exception e) {
- LOGGER.error("CELLAR FEATURES: failed to handle feature event", e);
+ LOGGER.error("CELLAR FEATURES: failed to handle cluster feature event", e);
}
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED INBOUND", name);
+ } else LOGGER.warn("CELLAR FEATURES: feature {} is marked BLOCKED INBOUND for cluster group {}", name, event.getSourceGroup().getName());
}
- public Class<RemoteFeaturesEvent> getType() {
- return RemoteFeaturesEvent.class;
+ /**
+ * Get the event type that this handler is able to handle.
+ *
+ * @return the cluster features event type.
+ */
+ @Override
+ public Class<ClusterFeaturesEvent> getType() {
+ return ClusterFeaturesEvent.class;
}
+ /**
+ * Get the handler switch.
+ *
+ * @return the handler switch.
+ */
+ @Override
public Switch getSwitch() {
// load the switch status from the config
try {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
index 8f9e5e3..7d66b6a 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
@@ -28,7 +28,7 @@ import java.util.List;
import java.util.Map;
/**
- * Features support.
+ * Generic features support.
*/
public class FeaturesSupport extends CellarSupport {
@@ -82,9 +82,10 @@ public class FeaturesSupport extends CellarSupport {
}
/**
- * Pushes a {@code Feature} and its status to the distributed list of features.
+ * Push a {@code Feature} and its status in a cluster group.
*
- * @param feature
+ * @param feature the feature to push in the cluster group.
+ * @param group the cluster group.
*/
public void pushFeature(Feature feature, Group group) {
if (feature != null) {
@@ -97,15 +98,17 @@ public class FeaturesSupport extends CellarSupport {
Boolean installed = featuresService.isInstalled(feature);
clusterFeatures.put(info, installed);
}
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED OUTBOUND", feature.getName());
+ } else LOGGER.warn("CELLAR FEATURES: feature {} is marked BLOCKED OUTBOUND for cluster group {}", feature.getName(), groupName);
} else LOGGER.warn("CELLAR FEATURES: feature is null");
}
/**
- * Pushes a {@code Feature} and its status to the distributed list of features.
+ * Push a {@code Feature} and its status in a cluster group.
* This version of the method force the bundle status, without looking the features service.
*
- * @param feature
+ * @param feature the feature to push in the cluster group.
+ * @param group the cluster group.
+ * @param force true to force the bundle status (ignoring the features service), false else.
*/
public void pushFeature(Feature feature, Group group, Boolean force) {
if (feature != null) {
@@ -117,14 +120,15 @@ public class FeaturesSupport extends CellarSupport {
FeatureInfo info = new FeatureInfo(feature.getName(), feature.getVersion());
clusterFeatures.put(info, force);
}
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED OUTBOUND", feature.getName());
+ } else LOGGER.warn("CELLAR FEATURES: feature {} is marked BLOCKED OUTBOUND for cluster group {}", feature.getName(), groupName);
} else LOGGER.warn("CELLAR FEATURES: feature is null");
}
/**
- * Pushed a {@code Repository} to the distributed list of repositories.
+ * Push a features {@code Repository} in a cluster group.
*
- * @param repository
+ * @param repository the features repository to push in the cluster group.
+ * @param group the cluster group.
*/
public void pushRepository(Repository repository, Group group) {
String groupName = group.getName();
@@ -144,9 +148,10 @@ public class FeaturesSupport extends CellarSupport {
}
/**
- * Removes a {@code Repository} to the distributed list of repositories.
+ * Remove a features {@code Repository} from a cluster group.
*
- * @param repository
+ * @param repository the features repository to remove from the cluster group.
+ * @param group the cluster group.
*/
public void removeRepository(Repository repository, Group group) {
String groupName = group.getName();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
index 70d47f6..6c3b919 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
@@ -13,13 +13,11 @@
*/
package org.apache.karaf.cellar.features;
-import org.apache.karaf.cellar.core.ClusterManager;
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.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;
@@ -40,6 +38,7 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
private static final transient Logger LOGGER = LoggerFactory.getLogger(FeaturesSynchronizer.class);
+ @Override
public void init() {
super.init();
Set<Group> groups = groupManager.listLocalGroups();
@@ -48,23 +47,26 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
if (isSyncEnabled(group)) {
pull(group);
push(group);
- } else LOGGER.warn("CELLAR FEATURES: sync is disabled for group {}", group.getName());
+ } else LOGGER.warn("CELLAR FEATURES: sync is disabled for cluster group {}", group.getName());
}
}
}
+ @Override
public void destroy() {
super.destroy();
}
/**
- * Get the features from the cluster group.
+ * Pull the features repositories and features states from a cluster group, and update the local states.
*
* @param group the cluster group.
*/
+ @Override
public void pull(Group group) {
if (group != null) {
String groupName = group.getName();
+ LOGGER.debug("CELLAR FEATURES: pulling features repositories and features from cluster group {}", groupName);
List<String> clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
clusterManager.getList(Constants.FEATURES + Configurations.SEPARATOR + groupName);
@@ -76,7 +78,7 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
for (String url : clusterRepositories) {
try {
if (!isRepositoryRegisteredLocally(url)) {
- LOGGER.debug("CELLAR FEATURES: adding new repository {}", url);
+ LOGGER.debug("CELLAR FEATURES: adding new features repository {}", url);
featuresService.addRepository(new URI(url));
}
} catch (MalformedURLException e) {
@@ -121,7 +123,7 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
LOGGER.error("CELLAR FEATURES: failed to uninstall feature {}/{} ", new Object[]{info.getName(), info.getVersion()}, e);
}
}
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED INBOUND", name);
+ } else LOGGER.warn("CELLAR FEATURES: feature {} is marked BLOCKED INBOUND for cluster group {}", name, groupName);
}
}
} finally {
@@ -131,14 +133,15 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
}
/**
- * Push features repositories and features status to the cluster group.
+ * Push features repositories and features local states to a cluster group.
*
* @param group the cluster group.
*/
+ @Override
public void push(Group group) {
if (group != null) {
String groupName = group.getName();
- LOGGER.info("CELLAR FEATURES: Pulling features from group {}.",groupName);
+ LOGGER.info("CELLAR FEATURES: pushing features repositories and features in cluster group {}", groupName);
clusterManager.getList(Constants.FEATURES + Configurations.SEPARATOR + groupName);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
@@ -174,6 +177,12 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
}
}
+ /**
+ * Check if the sync flag is enabled for a cluster group.
+ *
+ * @param group the cluster group.
+ * @return true if the sync flag is enabled, false else.
+ */
@Override
public Boolean isSyncEnabled(Group group) {
Boolean result = Boolean.FALSE;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java b/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
index 82bf1d5..85bff69 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
@@ -24,7 +24,6 @@ import org.apache.karaf.features.RepositoryEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -48,10 +47,11 @@ public class LocalFeaturesListener extends FeaturesSupport implements org.apache
}
/**
- * Called when a {@code FeatureEvent} occurs.
+ * This method is called when a local feature has changed.
*
- * @param event
+ * @param event the local feature event.
*/
+ @Override
public void featureEvent(FeatureEvent event) {
// check if the producer is ON
@@ -73,7 +73,7 @@ public class LocalFeaturesListener extends FeaturesSupport implements org.apache
if (isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND)) {
FeatureEvent.EventType type = event.getType();
- // update the distributed map
+ // update the features in the cluster group
if (FeatureEvent.EventType.FeatureInstalled.equals(event.getType())) {
pushFeature(event.getFeature(), group, true);
} else {
@@ -81,20 +81,21 @@ public class LocalFeaturesListener extends FeaturesSupport implements org.apache
}
// broadcast the event
- RemoteFeaturesEvent featureEvent = new RemoteFeaturesEvent(name, version, type);
+ ClusterFeaturesEvent featureEvent = new ClusterFeaturesEvent(name, version, type);
featureEvent.setSourceGroup(group);
eventProducer.produce(featureEvent);
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED OUTBOUND", name);
+ } else LOGGER.warn("CELLAR FEATURES: feature {} is marked BLOCKED OUTBOUND for cluster group {}", name, group.getName());
}
}
}
}
/**
- * Called when a {@code RepositoryEvent} occurs.
+ * This method is called when a local features repository has changed.
*
* @param event
*/
+ @Override
public void repositoryEvent(RepositoryEvent event) {
// check if the producer is ON
@@ -111,48 +112,48 @@ public class LocalFeaturesListener extends FeaturesSupport implements org.apache
if (groups != null && !groups.isEmpty()) {
for (Group group : groups) {
- RemoteRepositoryEvent repositoryEvent = new RemoteRepositoryEvent(event.getRepository().getURI().toString(), event.getType());
- repositoryEvent.setSourceGroup(group);
+ ClusterRepositoryEvent clusterRepositoryEvent = new ClusterRepositoryEvent(event.getRepository().getURI().toString(), event.getType());
+ clusterRepositoryEvent.setSourceGroup(group);
RepositoryEvent.EventType type = event.getType();
- // update the distributed map
+ // update the features repositories in the cluster group
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());
+ // update the features in the cluster group
+ Map<FeatureInfo, Boolean> clusterFeatures = 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;
+ for (FeatureInfo clusterFeature : clusterFeatures.keySet()) {
+ if (clusterFeature.getName().equals(feature.getName()) && clusterFeature.getVersion().equals(feature.getVersion())) {
+ featureInfo = clusterFeature;
break;
}
}
if (featureInfo == null) {
featureInfo = new FeatureInfo(feature.getName(), feature.getVersion());
- distributedFeatures.put(featureInfo, false);
+ clusterFeatures.put(featureInfo, false);
}
}
} catch (Exception e) {
- LOGGER.warn("CELLAR FEATURES: can't update the distributed features map", e);
+ LOGGER.warn("CELLAR FEATURES: failed to update the cluster group", e);
}
} else {
removeRepository(event.getRepository(), group);
- // update the feature map
- Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName());
+ // update the features in the cluster group
+ Map<FeatureInfo, Boolean> clusterFeatures = 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);
+ clusterFeatures.remove(info);
}
} catch (Exception e) {
- LOGGER.warn("CELLAR FEATURES: can't update the distributed features map", e);
+ LOGGER.warn("CELLAR FEATURES: failed to update the cluster group", e);
}
}
// broadcast the cluster event
- eventProducer.produce(repositoryEvent);
+ eventProducer.produce(clusterRepositoryEvent);
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/RemoteFeaturesEvent.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/RemoteFeaturesEvent.java b/features/src/main/java/org/apache/karaf/cellar/features/RemoteFeaturesEvent.java
deleted file mode 100644
index fddbaf2..0000000
--- a/features/src/main/java/org/apache/karaf/cellar/features/RemoteFeaturesEvent.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.cellar.features;
-
-import org.apache.karaf.cellar.core.event.Event;
-import org.apache.karaf.features.FeatureEvent.EventType;
-
-/**
- * Remove features event.
- */
-public class RemoteFeaturesEvent extends Event {
-
- private static final String separator = "/";
-
- private String name;
- private String version;
- private Boolean noClean;
- private Boolean noRefresh;
- private EventType type;
-
- public RemoteFeaturesEvent(String name, String version, EventType type) {
- super(name + separator + version);
- this.name = name;
- this.version = version;
- this.noClean = false;
- this.noRefresh = false;
- this.type = type;
- }
-
- public RemoteFeaturesEvent(String name, String version, Boolean noClean, Boolean noRefresh, EventType type) {
- super(name + separator + version);
- this.name = name;
- this.version = version;
- this.noClean = noClean;
- this.noRefresh = noRefresh;
- this.type = type;
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public Boolean getNoClean() {
- return noClean;
- }
-
- public Boolean getNoRefresh() {
- return noRefresh;
- }
-
- public EventType getType() {
- return type;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/RemoteRepositoryEvent.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/RemoteRepositoryEvent.java b/features/src/main/java/org/apache/karaf/cellar/features/RemoteRepositoryEvent.java
deleted file mode 100644
index f80678e..0000000
--- a/features/src/main/java/org/apache/karaf/cellar/features/RemoteRepositoryEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.cellar.features;
-
-import org.apache.karaf.cellar.core.event.Event;
-import org.apache.karaf.features.RepositoryEvent.EventType;
-
-/**
- * Remote repository event.
- */
-public class RemoteRepositoryEvent extends Event {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private EventType type;
-
- public RemoteRepositoryEvent(String id, EventType type) {
- super(id);
- this.type = type;
- }
-
- public EventType getType() {
- return type;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "RemoteRepositoryEvent [type=" + type + ", id=" + id
- + ", sourceNode=" + sourceNode + ", sourceGroup=" + sourceGroup
- + ", destination=" + destination + ", force=" + force
- + ", postPublish=" + postPublish + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java b/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
index 59a60d2..4077c57 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
@@ -24,9 +24,9 @@ import org.slf4j.LoggerFactory;
import java.net.URI;
/**
- * Repository event handler.
+ * Handler for cluster features repository event.
*/
-public class RepositoryEventHandler extends FeaturesSupport implements EventHandler<RemoteRepositoryEvent> {
+public class RepositoryEventHandler extends FeaturesSupport implements EventHandler<ClusterRepositoryEvent> {
private static final transient Logger LOGGER = LoggerFactory.getLogger(RepositoryEventHandler.class);
@@ -44,7 +44,13 @@ public class RepositoryEventHandler extends FeaturesSupport implements EventHand
super.destroy();
}
- public void handle(RemoteRepositoryEvent event) {
+ /**
+ * Handle cluster features repository event.
+ *
+ * @param event the cluster event to handle.
+ */
+ @Override
+ public void handle(ClusterRepositoryEvent event) {
// check if the handler is ON
if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
@@ -88,10 +94,12 @@ public class RepositoryEventHandler extends FeaturesSupport implements EventHand
}
}
- public Class<RemoteRepositoryEvent> getType() {
- return RemoteRepositoryEvent.class;
+ @Override
+ public Class<ClusterRepositoryEvent> getType() {
+ return ClusterRepositoryEvent.class;
}
+ @Override
public Switch getSwitch() {
return eventSwitch;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java
index 5866ee4..9bb1e31 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
import java.util.Map;
/**
- * Abstract feature command.
+ * Abstract cluster feature shell command.
*/
public abstract class FeatureCommandSupport extends CellarCommandSupport {
@@ -39,14 +39,14 @@ public abstract class FeatureCommandSupport extends CellarCommandSupport {
protected BundleContext bundleContext;
/**
- * Forces the features status for a specific group.
+ * Force the features status for a specific group.
* Why? Its required if no group member currently in the cluster.
* If a member of the group joins later, it won't find the change, unless we force it.
*
- * @param groupName
- * @param feature
- * @param version
- * @param status
+ * @param groupName the cluster group name.
+ * @param feature the feature name.
+ * @param version the feature version.
+ * @param status the feature status (installed, uninstalled).
*/
public Boolean updateFeatureStatus(String groupName, String feature, String version, Boolean status) {
@@ -58,10 +58,10 @@ public abstract class FeatureCommandSupport extends CellarCommandSupport {
if (group == null || group.getNodes().isEmpty()) {
FeatureInfo info = new FeatureInfo(feature, version);
- Map<FeatureInfo, Boolean> features = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
// check the existing configuration
if (version == null || (version.trim().length() < 1)) {
- for (FeatureInfo f : features.keySet()) {
+ for (FeatureInfo f : clusterFeatures.keySet()) {
if (f.getName().equals(feature)) {
version = f.getVersion();
info.setVersion(version);
@@ -69,7 +69,7 @@ public abstract class FeatureCommandSupport extends CellarCommandSupport {
}
}
- // check the Features Service.
+ // check the features service
try {
for (Feature f : featuresService.listFeatures()) {
if (f.getName().equals(feature)) {
@@ -82,7 +82,7 @@ public abstract class FeatureCommandSupport extends CellarCommandSupport {
}
if (info.getVersion() != null && (info.getVersion().trim().length() > 0)) {
- features.put(info, status);
+ clusterFeatures.put(info, status);
result = Boolean.TRUE;
}
}
@@ -93,23 +93,23 @@ public abstract class FeatureCommandSupport extends CellarCommandSupport {
}
/**
- * Check if a feature is present in the distributed map.
+ * Check if a feature is present in the cluster group.
*
- * @param groupName the target cluster group.
- * @param feature the target feature name.
- * @param version the target feature version.
- * @return true if the feature exists in the distributed map, false else
+ * @param groupName the cluster group.
+ * @param feature the feature name.
+ * @param version the feature version.
+ * @return true if the feature exists in the cluster group, false else.
*/
public boolean featureExists(String groupName, String feature, String version) {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
- if (distributedFeatures == null)
+ if (clusterFeatures == null)
return false;
- for (FeatureInfo distributedFeature : distributedFeatures.keySet()) {
+ for (FeatureInfo distributedFeature : clusterFeatures.keySet()) {
if (version == null) {
if (distributedFeature.getName().equals(feature))
return true;
@@ -125,6 +125,15 @@ public abstract class FeatureCommandSupport extends CellarCommandSupport {
}
}
+ /**
+ * Check if a cluster features event is allowed.
+ *
+ * @param group the cluster group.
+ * @param category the features category name.
+ * @param name the feature name.
+ * @param type the event type (inbound, outbound).
+ * @return true if the cluster features event is allowed, false else.
+ */
public boolean isAllowed(Group group, String category, String name, EventType type) {
CellarSupport support = new CellarSupport();
support.setClusterManager(this.clusterManager);
@@ -133,14 +142,6 @@ public abstract class FeatureCommandSupport extends CellarCommandSupport {
return support.isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND);
}
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
public FeaturesService getFeaturesService() {
return featuresService;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
index a703f62..d84f33e 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
@@ -17,14 +17,14 @@ import org.apache.karaf.cellar.core.Group;
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.features.ClusterFeaturesEvent;
import org.apache.karaf.cellar.features.Constants;
-import org.apache.karaf.cellar.features.RemoteFeaturesEvent;
import org.apache.karaf.features.FeatureEvent;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
-@Command(scope = "cluster", name = "feature-install", description = "Install a feature assigned to a cluster group.")
+@Command(scope = "cluster", name = "feature-install", description = "Install a feature in a cluster group")
public class InstallFeatureCommand extends FeatureCommandSupport {
@Option(name = "-c", aliases = { "--no-clean" }, description = "Do not uninstall bundles on failure", required = false, multiValued = false)
@@ -33,13 +33,13 @@ public class InstallFeatureCommand extends FeatureCommandSupport {
@Option(name = "-r", aliases = { "--no-auto-refresh" }, description = "Do not automatically refresh bundles", required = false, multiValued = false)
boolean noRefresh;
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
- @Argument(index = 1, name = "feature", description = "The feature name.", required = true, multiValued = false)
+ @Argument(index = 1, name = "feature", description = "The feature name", required = true, multiValued = false)
String feature;
- @Argument(index = 2, name = "version", description = "The feature version.", required = false, multiValued = false)
+ @Argument(index = 2, name = "version", description = "The feature version", required = false, multiValued = false)
String version;
private EventProducer eventProducer;
@@ -62,22 +62,22 @@ public class InstallFeatureCommand extends FeatureCommandSupport {
// check if the feature exists in the map
if (!featureExists(groupName, feature, version)) {
if (version != null)
- System.err.println("Feature " + feature + "/" + version + " doesn't exist for the cluster group " + groupName);
- else System.err.println("Feature " + feature + " doesn't exist for the cluster group " + groupName);
+ System.err.println("Feature " + feature + "/" + version + " doesn't exist in the cluster group " + groupName);
+ else System.err.println("Feature " + feature + " doesn't exist in the cluster group " + groupName);
return null;
}
// check if the outbound event is allowed
if (!isAllowed(group, Constants.FEATURES_CATEGORY, feature, EventType.OUTBOUND)) {
- System.err.println("Feature " + feature + " is blocked outbound");
+ System.err.println("Feature " + feature + " is blocked outbound for cluster group " + groupName);
return null;
}
- // update the distributed resource
+ // update the features in the cluster group
updateFeatureStatus(groupName, feature, version, true);
// broadcast the cluster event
- RemoteFeaturesEvent event = new RemoteFeaturesEvent(feature, version, noClean, noRefresh, FeatureEvent.EventType.FeatureInstalled);
+ ClusterFeaturesEvent event = new ClusterFeaturesEvent(feature, version, noClean, noRefresh, FeatureEvent.EventType.FeatureInstalled);
event.setSourceGroup(group);
eventProducer.produce(event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/shell/ListGroupFeatures.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/ListGroupFeatures.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/ListGroupFeatures.java
index 397922a..dace14d 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/ListGroupFeatures.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/ListGroupFeatures.java
@@ -23,16 +23,16 @@ import org.apache.karaf.shell.commands.Option;
import java.util.Map;
-@Command(scope = "cluster", name = "feature-list", description = "List the features assigned to a cluster group.")
+@Command(scope = "cluster", name = "feature-list", description = "List the features in a cluster group")
public class ListGroupFeatures extends FeatureCommandSupport {
protected static final String HEADER_FORMAT = " %-11s %-15s %s";
protected static final String OUTPUT_FORMAT = "[%-11s] [%-15s] %s";
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
- @Option(name = "-i", aliases = { "--installed" }, description = "Display only installed features.", required = false, multiValued = false)
+ @Option(name = "-i", aliases = { "--installed" }, description = "Display only installed features", required = false, multiValued = false)
boolean installed;
@Override
@@ -46,15 +46,15 @@ public class ListGroupFeatures extends FeatureCommandSupport {
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- Map<FeatureInfo, Boolean> features = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
- if (features != null && !features.isEmpty()) {
- System.out.println(String.format("Features for cluster group " + groupName));
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
+ if (clusterFeatures != null && !clusterFeatures.isEmpty()) {
+ System.out.println(String.format("Features in cluster group " + groupName));
System.out.println(String.format(HEADER_FORMAT, "Status", "Version", "Name"));
- for (FeatureInfo info : features.keySet()) {
+ for (FeatureInfo info : clusterFeatures.keySet()) {
String name = info.getName();
String version = info.getVersion();
String statusString = "";
- boolean status = features.get(info);
+ boolean status = clusterFeatures.get(info);
if (status) {
statusString = "installed";
} else {
@@ -63,10 +63,10 @@ public class ListGroupFeatures extends FeatureCommandSupport {
if (version == null)
version = "";
if (!installed || (installed && status)) {
- System.out.println(String.format(OUTPUT_FORMAT, status, version, name));
+ System.out.println(String.format(OUTPUT_FORMAT, statusString, version, name));
}
}
- } else System.err.println("No features found for cluster group " + groupName);
+ } else System.err.println("No features in cluster group " + groupName);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
index 983149e..08c915e 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java
@@ -17,22 +17,22 @@ import org.apache.karaf.cellar.core.Group;
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.features.ClusterFeaturesEvent;
import org.apache.karaf.cellar.features.Constants;
-import org.apache.karaf.cellar.features.RemoteFeaturesEvent;
import org.apache.karaf.features.FeatureEvent;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
-@Command(scope = "cluster", name = "feature-uninstall", description = "Uninstall a feature assigned to a cluster group.")
+@Command(scope = "cluster", name = "feature-uninstall", description = "Uninstall a feature from a cluster group")
public class UninstallFeatureCommand extends FeatureCommandSupport {
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
- @Argument(index = 1, name = "feature", description = "The feature name.", required = true, multiValued = false)
+ @Argument(index = 1, name = "feature", description = "The feature name", required = true, multiValued = false)
String feature;
- @Argument(index = 2, name = "version", description = "The feature version.", required = false, multiValued = false)
+ @Argument(index = 2, name = "version", description = "The feature version", required = false, multiValued = false)
String version;
private EventProducer eventProducer;
@@ -55,22 +55,22 @@ public class UninstallFeatureCommand extends FeatureCommandSupport {
// check if the feature exists in the map
if (!featureExists(groupName, feature, version)) {
if (version != null)
- System.err.println("Feature " + feature + "/" + version + " doesn't exist for the cluster group " + groupName);
- else System.err.println("Feature " + feature + " doesn't exist for the cluster group " + groupName);
+ System.err.println("Feature " + feature + "/" + version + " doesn't exist in the cluster group " + groupName);
+ else System.err.println("Feature " + feature + " doesn't exist in the cluster group " + groupName);
return null;
}
// check if the outbound event is allowed
if (!isAllowed(group, Constants.FEATURES_CATEGORY, feature, EventType.OUTBOUND)) {
- System.err.println("Feature " + feature + " is blocked outbound");
+ System.err.println("Feature " + feature + " is blocked outbound for cluster group " + groupName);
return null;
}
- // update distributed set
+ // update the features in the cluster group
updateFeatureStatus(groupName, feature, version, false);
// broadcast the cluster event
- RemoteFeaturesEvent event = new RemoteFeaturesEvent(feature, version, FeatureEvent.EventType.FeatureUninstalled);
+ ClusterFeaturesEvent event = new ClusterFeaturesEvent(feature, version, FeatureEvent.EventType.FeatureUninstalled);
event.setForce(true);
event.setSourceGroup(group);
eventProducer.produce(event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
index 6b87b5d..83f3e01 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
@@ -19,7 +19,7 @@ import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.features.Constants;
import org.apache.karaf.cellar.features.FeatureInfo;
-import org.apache.karaf.cellar.features.RemoteRepositoryEvent;
+import org.apache.karaf.cellar.features.ClusterRepositoryEvent;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.Repository;
import org.apache.karaf.features.RepositoryEvent;
@@ -30,13 +30,13 @@ import java.net.URI;
import java.util.List;
import java.util.Map;
-@Command(scope = "cluster", name = "feature-url-add", description = "Adds a list of repository URLs to the features service in the given cluster group")
+@Command(scope = "cluster", name = "feature-url-add", description = "Add a list of features repository URLs in a cluster group")
public class UrlAddCommand extends FeatureCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
- @Argument(index = 1, name = "urls", description = "One or more repository URLs separated by whitespaces", required = true, multiValued = true)
+ @Argument(index = 1, name = "urls", description = "One or more features repository URLs separated by whitespaces", required = true, multiValued = true)
List<String> urls;
private EventProducer eventProducer;
@@ -59,15 +59,15 @@ public class UrlAddCommand extends FeatureCommandSupport {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- // get the repositories distributed list
- List<String> distributedRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
- // get the features distributed map
- Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
+ // get the features repositories in the cluster group
+ List<String> clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
+ // get the features in the cluster group
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
for (String url : urls) {
// check if the URL is already registered
boolean found = false;
- for (String repository : distributedRepositories) {
+ for (String repository : clusterRepositories) {
if (repository.equals(url)) {
found = true;
break;
@@ -103,25 +103,25 @@ public class UrlAddCommand extends FeatureCommandSupport {
localRegistered = true;
}
- // update the distributed list
- distributedRepositories.add(url);
+ // update the features repositories in the cluster group
+ clusterRepositories.add(url);
- // update the distributed feature map
+ // update the features in the cluster group
for (Feature feature : repository.getFeatures()) {
FeatureInfo info = new FeatureInfo(feature.getName(), feature.getVersion());
- distributedFeatures.put(info, false);
+ clusterFeatures.put(info, false);
}
- // unregister the repository if it's not local registered
+ // un-register the repository if it's not local registered
if (!localRegistered)
featuresService.removeRepository(new URI(url));
// broadcast the cluster event
- RemoteRepositoryEvent event = new RemoteRepositoryEvent(url, RepositoryEvent.EventType.RepositoryAdded);
+ ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryAdded);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
- System.err.println("Repository URL " + url + " already registered");
+ System.err.println("Features repository URL " + url + " already registered");
}
}
} finally {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlListCommand.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlListCommand.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlListCommand.java
index e831917..db5bcda 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlListCommand.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlListCommand.java
@@ -21,7 +21,7 @@ import org.apache.karaf.shell.commands.Command;
import java.util.List;
-@Command(scope = "cluster", name = "feature-url-list", description = "Displays a list of all defined repository URLs in the given cluster group")
+@Command(scope = "cluster", name = "feature-url-list", description = "List the features repository URLs in a cluster group")
public class UrlListCommand extends FeatureCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
@@ -36,10 +36,10 @@ public class UrlListCommand extends FeatureCommandSupport {
return null;
}
- // get the distributed list
- List<String> repositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
+ // get the features repositories in the cluster group
+ List<String> clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
- for (String repository : repositories) {
+ for (String repository : clusterRepositories) {
System.out.println(repository);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
index 6383cea..2e25b3b 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
@@ -19,7 +19,7 @@ import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.features.Constants;
import org.apache.karaf.cellar.features.FeatureInfo;
-import org.apache.karaf.cellar.features.RemoteRepositoryEvent;
+import org.apache.karaf.cellar.features.ClusterRepositoryEvent;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.Repository;
import org.apache.karaf.features.RepositoryEvent;
@@ -30,13 +30,13 @@ import java.net.URI;
import java.util.List;
import java.util.Map;
-@Command(scope = "cluster", name = "feature-url-remove", description = "Removes the given list of repository URLs for the given cluster group")
+@Command(scope = "cluster", name = "feature-url-remove", description = "Remove features repository URLs from a cluster group")
public class UrlRemoveCommand extends FeatureCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
- @Argument(index = 1, name = "urls", description = "One or more repository URLs separated by whitespaces", required = true, multiValued = true)
+ @Argument(index = 1, name = "urls", description = "One or more features repository URLs separated by whitespaces", required = true, multiValued = true)
List<String> urls;
private EventProducer eventProducer;
@@ -56,15 +56,15 @@ public class UrlRemoveCommand extends FeatureCommandSupport {
return null;
}
- // get the distributed list
- List<String> distributedRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
- // get the features distributed map
- Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
+ // get the features repositories in the cluster group
+ List<String> clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
+ // get the features in the cluster group
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
for (String url : urls) {
// looking for the URL in the list
boolean found = false;
- for (String repository : distributedRepositories) {
+ for (String repository : clusterRepositories) {
if (repository.equals(url)) {
found = true;
break;
@@ -100,25 +100,25 @@ public class UrlRemoveCommand extends FeatureCommandSupport {
localRegistered = true;
}
- // update the list
- distributedRepositories.remove(url);
+ // update the features repositories in the cluster group
+ clusterRepositories.remove(url);
- // update the distributed feature map
+ // update the features in the cluster group
for (Feature feature : repository.getFeatures()) {
FeatureInfo info = new FeatureInfo(feature.getName(), feature.getVersion());
- distributedFeatures.remove(info);
+ clusterFeatures.remove(info);
}
- // unregister the repository if it's not local registered
+ // un-register the repository if it's not local registered
if (!localRegistered)
featuresService.removeRepository(new URI(url));
// broadcast a cluster event
- RemoteRepositoryEvent event = new RemoteRepositoryEvent(url, RepositoryEvent.EventType.RepositoryRemoved);
+ ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryRemoved);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
- System.err.println("Repository URL " + url + " not found");
+ System.err.println("Features repository URL " + url + " not found in cluster group " + groupName);
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/features/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/features/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/features/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index c8bcaa0..902e2e3 100644
--- a/features/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/features/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -18,7 +18,7 @@
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- Local Features Listener -->
- <bean id="featuresListener" class="org.apache.karaf.cellar.features.LocalFeaturesListener" init-method="init"
+ <bean id="localListener" class="org.apache.karaf.cellar.features.LocalFeaturesListener" init-method="init"
destroy-method="destroy">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
@@ -26,7 +26,7 @@
<property name="configurationAdmin" ref="configurationAdmin"/>
<property name="featuresService" ref="featuresService"/>
</bean>
- <service ref="featuresListener" interface="org.apache.karaf.features.FeaturesListener"/>
+ <service ref="localListener" interface="org.apache.karaf.features.FeaturesListener"/>
<!-- Features/Repositories Synchronizer -->
<bean id="synchronizer" class="org.apache.karaf.cellar.features.FeaturesSynchronizer"
@@ -38,27 +38,27 @@
</bean>
<service ref="synchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
- <!-- Cluster Event Handler -->
- <bean id="featuresHandler" class="org.apache.karaf.cellar.features.FeaturesEventHandler"
+ <!-- Cluster Features Event Handler -->
+ <bean id="featuresEventHandler" class="org.apache.karaf.cellar.features.FeaturesEventHandler"
init-method="init" destroy-method="destroy">
<property name="featuresService" ref="featuresService"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
- <service ref="featuresHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
+ <service ref="featuresEventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
<service-properties>
<entry key="managed" value="true"/>
</service-properties>
</service>
- <!-- Cluster Event Handler -->
- <bean id="repositoryHandler" class="org.apache.karaf.cellar.features.RepositoryEventHandler"
+ <!-- Cluster Features Repositories Event Handler -->
+ <bean id="repositoryEventHandler" class="org.apache.karaf.cellar.features.RepositoryEventHandler"
init-method="init" destroy-method="destroy">
<property name="featuresService" ref="featuresService"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
- <service ref="repositoryHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
+ <service ref="repositoryEventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33d67d18/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
index fed0538..3caa66c 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
@@ -18,10 +18,10 @@ import org.apache.karaf.cellar.core.*;
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.features.ClusterFeaturesEvent;
import org.apache.karaf.cellar.features.Constants;
import org.apache.karaf.cellar.features.FeatureInfo;
-import org.apache.karaf.cellar.features.RemoteFeaturesEvent;
-import org.apache.karaf.cellar.features.RemoteRepositoryEvent;
+import org.apache.karaf.cellar.features.ClusterRepositoryEvent;
import org.apache.karaf.cellar.management.CellarFeaturesMBean;
import org.apache.karaf.features.*;
import org.osgi.framework.BundleEvent;
@@ -162,7 +162,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
}
// broadcast the cluster event
- RemoteFeaturesEvent event = new RemoteFeaturesEvent(name, version, noClean, noRefresh, FeatureEvent.EventType.FeatureInstalled);
+ ClusterFeaturesEvent event = new ClusterFeaturesEvent(name, version, noClean, noRefresh, FeatureEvent.EventType.FeatureInstalled);
event.setSourceGroup(group);
eventProducer.produce(event);
}
@@ -236,7 +236,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
- RemoteFeaturesEvent event = new RemoteFeaturesEvent(name, version, FeatureEvent.EventType.FeatureUninstalled);
+ ClusterFeaturesEvent event = new ClusterFeaturesEvent(name, version, FeatureEvent.EventType.FeatureUninstalled);
event.setSourceGroup(group);
eventProducer.produce(event);
}
@@ -364,7 +364,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
featuresService.removeRepository(new URI(url));
// broadcast the cluster event
- RemoteRepositoryEvent event = new RemoteRepositoryEvent(url, RepositoryEvent.EventType.RepositoryAdded);
+ ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryAdded);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
@@ -443,7 +443,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
featuresService.removeRepository(new URI(url));
// broadcast a cluster event
- RemoteRepositoryEvent event = new RemoteRepositoryEvent(url, RepositoryEvent.EventType.RepositoryRemoved);
+ ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryRemoved);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
[43/50] [abbrv] git commit: [KARAF-2480] Fix dynamic import in Cellar
modules
Posted by jb...@apache.org.
[KARAF-2480] Fix dynamic import in Cellar modules
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1528743 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/0dda1462
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/0dda1462
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/0dda1462
Branch: refs/heads/master
Commit: 0dda1462a8f4f597780456c1dd78933cf540da1f
Parents: 83431c1
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu Oct 3 08:22:48 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu Oct 3 08:22:48 2013 +0000
----------------------------------------------------------------------
bundle/pom.xml | 2 +-
cloud/pom.xml | 2 +-
config/pom.xml | 2 +-
core/pom.xml | 2 +-
dosgi/pom.xml | 2 +-
event/pom.xml | 2 +-
features/pom.xml | 2 +-
hazelcast/pom.xml | 2 +-
obr/pom.xml | 3 ++-
shell/pom.xml | 2 +-
utils/pom.xml | 2 +-
webconsole/pom.xml | 2 +-
12 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/bundle/pom.xml
----------------------------------------------------------------------
diff --git a/bundle/pom.xml b/bundle/pom.xml
index 88bdbf2..fce2daa 100644
--- a/bundle/pom.xml
+++ b/bundle/pom.xml
@@ -47,7 +47,7 @@
org.osgi*,
org.slf4j;resolution:=optional
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.bundle*;version="${project.version}"
</osgi.export>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/cloud/pom.xml
----------------------------------------------------------------------
diff --git a/cloud/pom.xml b/cloud/pom.xml
index 29d0d78..08bcece 100644
--- a/cloud/pom.xml
+++ b/cloud/pom.xml
@@ -42,7 +42,7 @@
org.osgi*,
org.slf4j;resolution:=optional
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,org.jclouds.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,org.jclouds.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.cloud*;version="${project.version}"
</osgi.export>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/config/pom.xml
----------------------------------------------------------------------
diff --git a/config/pom.xml b/config/pom.xml
index a57c6ef..d33396f 100644
--- a/config/pom.xml
+++ b/config/pom.xml
@@ -46,7 +46,7 @@
org.osgi*,
org.slf4j;resolution:=optional
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.config*;version="${project.version}"
</osgi.export>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 4f4682a..94d59e1 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -39,7 +39,7 @@
org.osgi*,
org.slf4j;resolution:=optional
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.core*;version="${project.version}"
</osgi.export>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/dosgi/pom.xml
----------------------------------------------------------------------
diff --git a/dosgi/pom.xml b/dosgi/pom.xml
index aa4650d..d22efde 100644
--- a/dosgi/pom.xml
+++ b/dosgi/pom.xml
@@ -46,7 +46,7 @@
org.osgi*,
org.slf4j;resolution:=optional
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.dosgi*;version="${project.version}"
</osgi.export>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/event/pom.xml
----------------------------------------------------------------------
diff --git a/event/pom.xml b/event/pom.xml
index 5d4b9a7..4cab00d 100644
--- a/event/pom.xml
+++ b/event/pom.xml
@@ -40,7 +40,7 @@
org.osgi*,
org.slf4j;resolution:=optional
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.event*;version="${project.version}"
</osgi.export>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/features/pom.xml
----------------------------------------------------------------------
diff --git a/features/pom.xml b/features/pom.xml
index df8cb56..cfad1b2 100644
--- a/features/pom.xml
+++ b/features/pom.xml
@@ -47,7 +47,7 @@
org.osgi*,
org.slf4j;resolution:=optional
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.features*;version="${project.version}"
</osgi.export>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/hazelcast/pom.xml
----------------------------------------------------------------------
diff --git a/hazelcast/pom.xml b/hazelcast/pom.xml
index b17e5e9..0447803 100644
--- a/hazelcast/pom.xml
+++ b/hazelcast/pom.xml
@@ -44,7 +44,7 @@
org.osgi*,
org.slf4j;resolution:=optional
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.hazelcast*;version="${project.version}"
</osgi.export>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/obr/pom.xml
----------------------------------------------------------------------
diff --git a/obr/pom.xml b/obr/pom.xml
index 38e48a0..132476d 100644
--- a/obr/pom.xml
+++ b/obr/pom.xml
@@ -50,7 +50,8 @@
</osgi.import>
<osgi.dynamic.import>
org.apache.felix.bundlerepository,
- org.osgi.service.obr
+ org.osgi.service.obr,
+ *
</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.obr*;version="${project.version}"
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/shell/pom.xml
----------------------------------------------------------------------
diff --git a/shell/pom.xml b/shell/pom.xml
index b75eee8..6426e24 100644
--- a/shell/pom.xml
+++ b/shell/pom.xml
@@ -46,7 +46,7 @@
org.apache.karaf.shell.commands;version="[3,4)",
org.osgi*
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.shell*;version="${project.version}"
</osgi.export>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/utils/pom.xml
----------------------------------------------------------------------
diff --git a/utils/pom.xml b/utils/pom.xml
index 276f9ed..ce5948b 100644
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -39,7 +39,7 @@
org.apache.karaf.cellar.core*;version="${project.version}",
org.osgi*
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.utils*;version="${project.version}"
</osgi.export>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/0dda1462/webconsole/pom.xml
----------------------------------------------------------------------
diff --git a/webconsole/pom.xml b/webconsole/pom.xml
index 11619d7..ecba450 100644
--- a/webconsole/pom.xml
+++ b/webconsole/pom.xml
@@ -40,7 +40,7 @@
org.osgi.service.blueprint,
org.slf4j;resolution:=optional
</osgi.import>
- <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+ <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*,*</osgi.dynamic.import>
<osgi.export>
org.apache.karaf.cellar.webconsole*;version="${project.version}"
</osgi.export>
[28/50] [abbrv] git commit: [KARAF-2142] Change the state only of the
local node when using producer, consumer, handler commands or MBeans
Posted by jb...@apache.org.
[KARAF-2142] Change the state only of the local node when using producer, consumer, handler commands or MBeans
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1483413 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/4c5d87a3
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/4c5d87a3
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/4c5d87a3
Branch: refs/heads/master
Commit: 4c5d87a38028c500432b77b70865bb22b2802ff9
Parents: 3ca8c65
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu May 16 15:39:02 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu May 16 15:39:02 2013 +0000
----------------------------------------------------------------------
.../management/internal/CellarMBeanImpl.java | 131 +++++++++++--------
.../cellar/shell/consumer/ConsumerSupport.java | 9 +-
.../cellar/shell/handler/HandlersSupport.java | 9 +-
.../cellar/shell/producer/ProducerSupport.java | 9 +-
4 files changed, 101 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4c5d87a3/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
index 0ae453f..ea6406a 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
@@ -119,11 +119,11 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
Map<Node, ManageHandlersResult> results = executionContext.execute(command);
CompositeType compositeType = new CompositeType("Event Handler", "Karaf Cellar cluster event handler",
- new String[]{ "node", "handler", "status", "local" },
- new String[]{ "Node hosting event handler", "Name of the event handler", "Current status of the event handler", "True if the node is local" },
- new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN });
+ new String[]{"node", "handler", "status", "local"},
+ new String[]{"Node hosting event handler", "Name of the event handler", "Current status of the event handler", "True if the node is local"},
+ new OpenType[]{SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN});
TabularType tableType = new TabularType("Event Handlers", "Table of Karaf Cellar cluster event handlers",
- compositeType, new String[]{ "node", "handler" });
+ compositeType, new String[]{"node", "handler"});
TabularDataSupport table = new TabularDataSupport(tableType);
for (Map.Entry<Node, ManageHandlersResult> handlersResultEntry : results.entrySet()) {
@@ -135,8 +135,8 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
String status = handlerEntry.getValue();
boolean local = (node.equals(clusterManager.getNode()));
CompositeDataSupport data = new CompositeDataSupport(compositeType,
- new String[]{ "node", "handler", "status", "local" },
- new Object[]{ node.getId(), handler, status, local });
+ new String[]{"node", "handler", "status", "local"},
+ new Object[]{node.getId(), handler, status, local});
table.put(data);
}
}
@@ -149,13 +149,17 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
public void handlerStart(String handlerId, String nodeId) throws Exception {
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId());
- Node node = clusterManager.findNodeById(nodeId);
- if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
- }
-
Set<Node> nodes = new HashSet<Node>();
- nodes.add(node);
+
+ if (nodeId == null || nodeId.isEmpty()) {
+ nodes.add(clusterManager.getNode());
+ } else {
+ Node node = clusterManager.findNodeById(nodeId);
+ if (node == null) {
+ throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ }
+ nodes.add(node);
+ }
command.setHandlerName(handlerId);
command.setDestination(nodes);
@@ -166,13 +170,16 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
public void handlerStop(String handlerId, String nodeId) throws Exception {
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId());
- Node node = clusterManager.findNodeById(nodeId);
- if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
- }
-
Set<Node> nodes = new HashSet<Node>();
- nodes.add(node);
+ if (nodeId == null || nodeId.isEmpty()) {
+ nodes.add(clusterManager.getNode());
+ } else {
+ Node node = clusterManager.findNodeById(nodeId);
+ if (node == null) {
+ throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ }
+ nodes.add(node);
+ }
command.setHandlerName(handlerId);
command.setDestination(nodes);
@@ -187,19 +194,19 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
Map<Node, ConsumerSwitchResult> results = executionContext.execute(command);
CompositeType compositeType = new CompositeType("Event Consumer", "Karaf Cellar cluster event consumer",
- new String[]{ "node", "status", "local" },
- new String[]{ "Node hosting event consumer", "Current status of the event consumer", "True if the node is local" },
- new OpenType[]{ SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN });
+ new String[]{"node", "status", "local"},
+ new String[]{"Node hosting event consumer", "Current status of the event consumer", "True if the node is local"},
+ new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
TabularType tableType = new TabularType("Event Consumers", "Table of Karaf Cellar cluster event consumers",
- compositeType, new String[]{ "node" });
+ compositeType, new String[]{"node"});
TabularDataSupport table = new TabularDataSupport(tableType);
for (Node node : results.keySet()) {
boolean local = (node.equals(clusterManager.getNode()));
ConsumerSwitchResult consumerSwitchResult = results.get(node);
CompositeDataSupport data = new CompositeDataSupport(compositeType,
- new String[]{ "node", "status", "local" },
- new Object[]{ node.getId(), consumerSwitchResult.getStatus(), local });
+ new String[]{"node", "status", "local"},
+ new Object[]{node.getId(), consumerSwitchResult.getStatus(), local});
table.put(data);
}
@@ -210,13 +217,17 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
public void consumerStart(String nodeId) throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
- Node node = clusterManager.findNodeById(nodeId);
- if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
- }
-
Set<Node> nodes = new HashSet<Node>();
- nodes.add(node);
+
+ if (nodeId == null || nodeId.isEmpty()) {
+ nodes.add(clusterManager.getNode());
+ } else {
+ Node node = clusterManager.findNodeById(nodeId);
+ if (node == null) {
+ throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ }
+ nodes.add(node);
+ }
command.setDestination(nodes);
command.setStatus(SwitchStatus.ON);
@@ -227,13 +238,17 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
public void consumerStop(String nodeId) throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
- Node node = clusterManager.findNodeById(nodeId);
- if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
- }
-
Set<Node> nodes = new HashSet<Node>();
- nodes.add(node);
+
+ if (nodeId == null || nodeId.isEmpty()) {
+ nodes.add(clusterManager.getNode());
+ } else {
+ Node node = clusterManager.findNodeById(nodeId);
+ if (node == null) {
+ throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ }
+ nodes.add(node);
+ }
command.setDestination(nodes);
command.setStatus(SwitchStatus.OFF);
@@ -248,19 +263,19 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
Map<Node, ProducerSwitchResult> results = executionContext.execute(command);
CompositeType compositeType = new CompositeType("Event Producer", "Karaf Cellar cluster event producer",
- new String[]{ "node", "status", "local" },
- new String[]{ "Node hosting event producer", "Current status of the event producer", "True if the node is local" },
- new OpenType[]{ SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN });
+ new String[]{"node", "status", "local"},
+ new String[]{"Node hosting event producer", "Current status of the event producer", "True if the node is local"},
+ new OpenType[]{SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
TabularType tableType = new TabularType("Event Producers", "Table of Karaf Cellar cluster event producers",
- compositeType, new String[]{ "node" });
+ compositeType, new String[]{"node"});
TabularDataSupport table = new TabularDataSupport(tableType);
for (Node node : results.keySet()) {
boolean local = (node.equals(clusterManager.getNode()));
ProducerSwitchResult producerSwitchResult = results.get(node);
CompositeDataSupport data = new CompositeDataSupport(compositeType,
- new String[]{ "node", "status", "local" },
- new Object[]{ node.getId(), producerSwitchResult.getStatus(), local });
+ new String[]{"node", "status", "local"},
+ new Object[]{node.getId(), producerSwitchResult.getStatus(), local});
table.put(data);
}
@@ -271,13 +286,17 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
public void producerStop(String nodeId) throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
- Node node = clusterManager.findNodeById(nodeId);
- if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
- }
-
Set<Node> nodes = new HashSet<Node>();
- nodes.add(node);
+
+ if (nodeId == null || nodeId.isEmpty()) {
+ nodes.add(clusterManager.getNode());
+ } else {
+ Node node = clusterManager.findNodeById(nodeId);
+ if (node == null) {
+ throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ }
+ nodes.add(node);
+ }
command.setDestination(nodes);
command.setStatus(SwitchStatus.OFF);
@@ -288,13 +307,17 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
public void producerStart(String nodeId) throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
- Node node = clusterManager.findNodeById(nodeId);
- if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist)");
- }
-
Set<Node> nodes = new HashSet<Node>();
- nodes.add(node);
+
+ if (nodeId == null || nodeId.isEmpty()) {
+ nodes.add(clusterManager.getNode());
+ } else {
+ Node node = clusterManager.findNodeById(nodeId);
+ if (node == null) {
+ throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist)");
+ }
+ nodes.add(node);
+ }
command.setDestination(nodes);
command.setStatus(SwitchStatus.ON);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4c5d87a3/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
index 572f7ab..17f7cc3 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
@@ -49,7 +49,14 @@ public abstract class ConsumerSupport extends ClusterCommandSupport {
}
}
} else {
- recipientList = clusterManager.listNodes();
+ if (status == null) {
+ // in case of status display, select all nodes
+ recipientList = clusterManager.listNodes();
+ } else {
+ // in case of status change, select only the local node
+ recipientList = new HashSet<Node>();
+ recipientList.add(clusterManager.getNode());
+ }
}
if (recipientList.size() < 1) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4c5d87a3/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
index ddde493..bcbc67c 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
@@ -48,7 +48,14 @@ public abstract class HandlersSupport extends ClusterCommandSupport {
}
}
} else {
- recipientList = clusterManager.listNodes();
+ if (status == null) {
+ // in case of status display, select all nodes
+ recipientList = clusterManager.listNodes();
+ } else {
+ // in case of status change, select only the local node
+ recipientList = new HashSet<Node>();
+ recipientList.add(clusterManager.getNode());
+ }
}
if (recipientList.size() < 1) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4c5d87a3/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
index 34f1bb0..84fd040 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
@@ -49,7 +49,14 @@ public abstract class ProducerSupport extends ClusterCommandSupport {
}
}
} else {
- recipientList = clusterManager.listNodes();
+ if (status == null) {
+ // in case of status display, select all nodes
+ recipientList = clusterManager.listNodes();
+ } else {
+ // in case of status change, select only the local node
+ recipientList = new HashSet<Node>();
+ recipientList.add(clusterManager.getNode());
+ }
}
if (recipientList.size() < 1) {
[47/50] [abbrv] git commit: [KARAF-2498] Change log level to DEBUG
for blocked resources
Posted by jb...@apache.org.
[KARAF-2498] Change log level to DEBUG for blocked resources
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1529137 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/ef5dec8d
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/ef5dec8d
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/ef5dec8d
Branch: refs/heads/master
Commit: ef5dec8d1aef77fd8accec2a63e794bed4e6214e
Parents: fe98fae
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Fri Oct 4 12:18:21 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Fri Oct 4 12:18:21 2013 +0000
----------------------------------------------------------------------
.../org/apache/karaf/cellar/bundle/BundleEventHandler.java | 6 +++---
.../org/apache/karaf/cellar/bundle/BundleSynchronizer.java | 8 ++++----
.../org/apache/karaf/cellar/bundle/LocalBundleListener.java | 6 +++---
.../karaf/cellar/config/ConfigurationEventHandler.java | 4 ++--
.../karaf/cellar/config/ConfigurationSynchronizer.java | 8 ++++----
.../karaf/cellar/config/LocalConfigurationListener.java | 4 ++--
.../karaf/cellar/core/control/ManageGroupCommandHandler.java | 1 -
.../cellar/core/control/ManageHandlersCommandHandler.java | 6 +-----
.../org/apache/karaf/cellar/dosgi/EndpointDescription.java | 2 --
.../apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java | 2 +-
.../org/apache/karaf/cellar/event/ClusterEventHandler.java | 4 ++--
.../org/apache/karaf/cellar/event/LocalEventListener.java | 4 ++--
.../apache/karaf/cellar/features/FeaturesEventHandler.java | 4 ++--
.../org/apache/karaf/cellar/features/FeaturesSupport.java | 4 ++--
.../apache/karaf/cellar/features/FeaturesSynchronizer.java | 6 +++---
.../apache/karaf/cellar/features/LocalFeaturesListener.java | 6 +++---
.../apache/karaf/cellar/features/RepositoryEventHandler.java | 2 +-
.../apache/karaf/cellar/hazelcast/HazelcastGroupManager.java | 4 ++--
.../org/apache/karaf/cellar/hazelcast/QueueConsumer.java | 2 +-
.../org/apache/karaf/cellar/hazelcast/QueueProducer.java | 2 +-
.../org/apache/karaf/cellar/hazelcast/TopicConsumer.java | 2 +-
.../org/apache/karaf/cellar/hazelcast/TopicProducer.java | 2 +-
.../hazelcast/factory/HazelcastConfigurationManager.java | 2 +-
.../karaf/cellar/hazelcast/merge/CellarMergePolicy.java | 2 +-
.../org/apache/karaf/cellar/obr/ObrBundleEventHandler.java | 4 ++--
.../java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java | 2 +-
.../java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java | 2 +-
27 files changed, 47 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/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 d555d56..757ca3e 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
@@ -49,7 +49,7 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Cl
// check if the handler switch is ON
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR BUNDLE: {} switch is OFF, cluster event is not handled", SWITCH_ID);
+ LOGGER.debug("CELLAR BUNDLE: {} switch is OFF, cluster event is not handled", SWITCH_ID);
return;
}
@@ -72,7 +72,7 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Cl
List<Feature> matchingFeatures = retrieveFeature(event.getLocation());
for (Feature feature : matchingFeatures) {
if (!isAllowed(event.getSourceGroup(), "features", feature.getName(), EventType.INBOUND)) {
- LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in feature {} marked BLOCKED INBOUND for cluster group {}", event.getLocation(), feature.getName(), event.getSourceGroup().getName());
+ LOGGER.debug("CELLAR BUNDLE: bundle {} is contained in feature {} marked BLOCKED INBOUND for cluster group {}", event.getLocation(), feature.getName(), event.getSourceGroup().getName());
return;
}
}
@@ -92,7 +92,7 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Cl
updateBundle(event.getSymbolicName(), event.getVersion());
LOGGER.debug("CELLAR BUNDLE: updating {}/{}", event.getSymbolicName(), event.getVersion());
}
- } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked BLOCKED INBOUND for cluster group {}", event.getSymbolicName(), event.getSourceGroup().getName());
+ } else LOGGER.debug("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/ef5dec8d/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 6194be9..b2ad279 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
@@ -50,7 +50,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
if (isSyncEnabled(group)) {
pull(group);
push(group);
- } else LOGGER.warn("CELLAR BUNDLE: sync is disabled for cluster group {}", group.getName());
+ } else LOGGER.debug("CELLAR BUNDLE: sync is disabled for cluster group {}", group.getName());
}
}
}
@@ -96,7 +96,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
} catch (BundleException e) {
LOGGER.error("CELLAR BUNDLE: failed to pull bundle {}", id, e);
}
- } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked BLOCKED INBOUND for cluster group {}", bundleLocation, groupName);
+ } else LOGGER.debug("CELLAR BUNDLE: bundle {} is marked BLOCKED INBOUND for cluster group {}", bundleLocation, groupName);
}
}
}
@@ -116,7 +116,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR BUNDLE: cluster event producer is OFF");
+ LOGGER.debug("CELLAR BUNDLE: cluster event producer is OFF");
return;
}
@@ -181,7 +181,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
eventProducer.produce(event);
}
- } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked BLOCKED OUTBOUND for cluster group {}", bundleLocation, groupName);
+ } else LOGGER.debug("CELLAR BUNDLE: bundle {} is marked BLOCKED OUTBOUND for cluster group {}", bundleLocation, groupName);
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/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 71df359..359c7c2 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
@@ -58,7 +58,7 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR BUNDLE: cluster event producer is OFF");
+ LOGGER.debug("CELLAR BUNDLE: cluster event producer is OFF");
return;
}
@@ -109,7 +109,7 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun
List<Feature> matchingFeatures = retrieveFeature(bundleLocation);
for (Feature feature : matchingFeatures) {
if (!isAllowed(group, "features", feature.getName(), EventType.OUTBOUND)) {
- LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in feature {} marked BLOCKED OUTBOUND for cluster group {}", bundleLocation, feature.getName(), group.getName());
+ LOGGER.debug("CELLAR BUNDLE: bundle {} is contained in feature {} marked BLOCKED OUTBOUND for cluster group {}", bundleLocation, feature.getName(), group.getName());
return;
}
}
@@ -124,7 +124,7 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
- } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked BLOCKED OUTBOUND for cluster group {}", bundleLocation, group.getName());
+ } else LOGGER.debug("CELLAR BUNDLE: bundle {} is marked BLOCKED OUTBOUND for cluster group {}", bundleLocation, group.getName());
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
index 1ebfde6..7cf7211 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
@@ -46,7 +46,7 @@ public class ConfigurationEventHandler extends ConfigurationSupport implements E
// check if the handler is ON
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR CONFIG: {} switch is OFF, cluster event not handled", SWITCH_ID);
+ LOGGER.debug("CELLAR CONFIG: {} switch is OFF, cluster event not handled", SWITCH_ID);
return;
}
@@ -96,7 +96,7 @@ public class ConfigurationEventHandler extends ConfigurationSupport implements E
} catch (IOException ex) {
LOGGER.error("CELLAR CONFIG: failed to read cluster configuration", ex);
}
- } else LOGGER.warn("CELLAR CONFIG: configuration PID {} is marked BLOCKED INBOUND for cluster group {}", pid, groupName);
+ } else LOGGER.debug("CELLAR CONFIG: configuration PID {} is marked BLOCKED INBOUND for cluster group {}", pid, groupName);
}
public void init() {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
index a30b459..567daad 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
@@ -51,7 +51,7 @@ public class ConfigurationSynchronizer extends ConfigurationSupport implements S
if (isSyncEnabled(group)) {
pull(group);
push(group);
- } else LOGGER.warn("CELLAR CONFIG: sync is disabled for cluster group {}", group.getName());
+ } else LOGGER.debug("CELLAR CONFIG: sync is disabled for cluster group {}", group.getName());
}
}
}
@@ -94,7 +94,7 @@ public class ConfigurationSynchronizer extends ConfigurationSupport implements S
} catch (IOException ex) {
LOGGER.error("CELLAR CONFIG: failed to read local configuration", ex);
}
- } else LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked BLOCKED INBOUND for cluster group {}", clusterConfiguration, groupName);
+ } else LOGGER.debug("CELLAR CONFIG: configuration with PID {} is marked BLOCKED INBOUND for cluster group {}", clusterConfiguration, groupName);
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
@@ -111,7 +111,7 @@ public class ConfigurationSynchronizer extends ConfigurationSupport implements S
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR CONFIG: cluster event producer is OFF");
+ LOGGER.debug("CELLAR CONFIG: cluster event producer is OFF");
return;
}
@@ -139,7 +139,7 @@ public class ConfigurationSynchronizer extends ConfigurationSupport implements S
event.setSourceGroup(group);
eventProducer.produce(event);
} else
- LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked BLOCKED OUTBOUND for cluster group {}", pid, groupName);
+ LOGGER.debug("CELLAR CONFIG: configuration with PID {} is marked BLOCKED OUTBOUND for cluster group {}", pid, groupName);
}
} catch (IOException ex) {
LOGGER.error("CELLAR CONFIG: failed to read configuration (IO error)", ex);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java b/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
index de4e105..f35d9fb 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
@@ -46,7 +46,7 @@ public class LocalConfigurationListener extends ConfigurationSupport implements
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR CONFIG: cluster event producer is OFF");
+ LOGGER.debug("CELLAR CONFIG: cluster event producer is OFF");
return;
}
@@ -100,7 +100,7 @@ public class LocalConfigurationListener extends ConfigurationSupport implements
} catch (Exception e) {
LOGGER.error("CELLAR CONFIG: failed to update configuration with PID {} in the cluster group {}", pid, group.getName(), e);
}
- } else LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked BLOCKED OUTBOUND for cluster group {}", pid, group.getName());
+ } else LOGGER.debug("CELLAR CONFIG: configuration with PID {} is marked BLOCKED OUTBOUND for cluster group {}", pid, group.getName());
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/core/src/main/java/org/apache/karaf/cellar/core/control/ManageGroupCommandHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageGroupCommandHandler.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageGroupCommandHandler.java
index ab236dd..61bcace 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageGroupCommandHandler.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageGroupCommandHandler.java
@@ -36,7 +36,6 @@ public class ManageGroupCommandHandler extends CommandHandler<ManageGroupCommand
ManageGroupAction action = command.getAction();
String targetGroupName = command.getGroupName();
- Node node = clusterManager.getNode();
if (ManageGroupAction.JOIN.equals(action)) {
joinGroup(targetGroupName);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommandHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommandHandler.java b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommandHandler.java
index 601984e..d4ad1db 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommandHandler.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/control/ManageHandlersCommandHandler.java
@@ -14,7 +14,6 @@
package org.apache.karaf.cellar.core.control;
import org.apache.karaf.cellar.core.Configurations;
-import org.apache.karaf.cellar.core.Consumer;
import org.apache.karaf.cellar.core.command.CommandHandler;
import org.apache.karaf.cellar.core.event.EventHandler;
import org.osgi.framework.BundleContext;
@@ -25,7 +24,6 @@ import org.osgi.service.cm.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import java.util.Dictionary;
/**
@@ -39,8 +37,6 @@ public class ManageHandlersCommandHandler extends CommandHandler<ManageHandlersC
private final Switch commandSwitch = new BasicSwitch(SWITCH_ID);
- private Consumer consumer;
-
/**
* Return a map containing all managed {@code EventHandler}s and their status.
*
@@ -109,7 +105,7 @@ public class ManageHandlersCommandHandler extends CommandHandler<ManageHandlersC
}
}
} catch (Exception e) {
- LOGGER.warn("Can't persist the handler " + handler + " status", e);
+ LOGGER.warn("Can't persist the handler {} status", handler, e);
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/EndpointDescription.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/EndpointDescription.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/EndpointDescription.java
index 83f6128..193b182 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/EndpointDescription.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/EndpointDescription.java
@@ -19,7 +19,6 @@ import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
-import java.io.Serializable;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.LinkedHashSet;
@@ -32,7 +31,6 @@ import java.util.Set;
*/
public class EndpointDescription implements MultiNode {
- //Id is {package}-{version}.
private final String id;
private final Set<Node> nodes = new LinkedHashSet<Node>();
private final Map<String, Object> properties = new HashMap<String, Object>();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
----------------------------------------------------------------------
diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
index cfe8e27..67f8d04 100644
--- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
+++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
@@ -56,7 +56,7 @@ public class RemoteServiceCallHandler extends CellarSupport implements EventHand
// check if the handler switch is ON
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR DOSGI: {} switch is OFF, cluster event is not handled", SWITCH_ID);
+ LOGGER.debug("CELLAR DOSGI: {} switch is OFF, cluster event is not handled", SWITCH_ID);
return;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/event/src/main/java/org/apache/karaf/cellar/event/ClusterEventHandler.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/ClusterEventHandler.java b/event/src/main/java/org/apache/karaf/cellar/event/ClusterEventHandler.java
index fee96ad..e0b9f12 100644
--- a/event/src/main/java/org/apache/karaf/cellar/event/ClusterEventHandler.java
+++ b/event/src/main/java/org/apache/karaf/cellar/event/ClusterEventHandler.java
@@ -41,7 +41,7 @@ public class ClusterEventHandler extends EventSupport implements EventHandler<Cl
// check if the handler is ON
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR EVENT: {} is OFF, cluster event not handled", SWITCH_ID);
+ LOGGER.debug("CELLAR EVENT: {} is OFF, cluster event not handled", SWITCH_ID);
return;
}
@@ -64,7 +64,7 @@ public class ClusterEventHandler extends EventSupport implements EventHandler<Cl
properties.put(Constants.EVENT_SOURCE_GROUP_KEY, event.getSourceGroup());
properties.put(Constants.EVENT_SOURCE_NODE_KEY, event.getSourceNode());
postEvent(event.getTopicName(), properties);
- } else LOGGER.warn("CELLAR EVENT: event {} is marked BLOCKED INBOUND for cluster group {}", event.getTopicName(), event.getSourceGroup().getName());
+ } else LOGGER.debug("CELLAR EVENT: event {} is marked BLOCKED INBOUND for cluster group {}", event.getTopicName(), event.getSourceGroup().getName());
} catch (Exception e) {
LOGGER.error("CELLAR EVENT: failed to handle event", e);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java b/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
index f535ab3..71a9d9f 100644
--- a/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
+++ b/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
@@ -41,7 +41,7 @@ public class LocalEventListener extends EventSupport implements EventHandler {
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR EVENT: cluster event producer is OFF");
+ LOGGER.debug("CELLAR EVENT: cluster event producer is OFF");
return;
}
@@ -72,7 +72,7 @@ public class LocalEventListener extends EventSupport implements EventHandler {
ClusterEvent clusterEvent = new ClusterEvent(topicName, properties);
clusterEvent.setSourceGroup(group);
eventProducer.produce(clusterEvent);
- } else LOGGER.warn("CELLAR EVENT: event {} is marked as BLOCKED OUTBOUND", topicName);
+ } else LOGGER.debug("CELLAR EVENT: event {} is marked as BLOCKED OUTBOUND for cluster group {}", topicName, group.getName());
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
index fc16741..b011402 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
@@ -56,7 +56,7 @@ public class FeaturesEventHandler extends FeaturesSupport implements EventHandle
public void handle(ClusterFeaturesEvent event) {
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR FEATURES: {} switch is OFF, cluster event is not handled", SWITCH_ID);
+ LOGGER.debug("CELLAR FEATURES: {} switch is OFF, cluster event is not handled", SWITCH_ID);
return;
}
@@ -107,7 +107,7 @@ public class FeaturesEventHandler extends FeaturesSupport implements EventHandle
} catch (Exception e) {
LOGGER.error("CELLAR FEATURES: failed to handle cluster feature event", e);
}
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked BLOCKED INBOUND for cluster group {}", name, event.getSourceGroup().getName());
+ } else LOGGER.debug("CELLAR FEATURES: feature {} is marked BLOCKED INBOUND for cluster group {}", name, event.getSourceGroup().getName());
}
/**
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
index 7d66b6a..f33b63a 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java
@@ -98,7 +98,7 @@ public class FeaturesSupport extends CellarSupport {
Boolean installed = featuresService.isInstalled(feature);
clusterFeatures.put(info, installed);
}
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked BLOCKED OUTBOUND for cluster group {}", feature.getName(), groupName);
+ } else LOGGER.debug("CELLAR FEATURES: feature {} is marked BLOCKED OUTBOUND for cluster group {}", feature.getName(), groupName);
} else LOGGER.warn("CELLAR FEATURES: feature is null");
}
@@ -120,7 +120,7 @@ public class FeaturesSupport extends CellarSupport {
FeatureInfo info = new FeatureInfo(feature.getName(), feature.getVersion());
clusterFeatures.put(info, force);
}
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked BLOCKED OUTBOUND for cluster group {}", feature.getName(), groupName);
+ } else LOGGER.debug("CELLAR FEATURES: feature {} is marked BLOCKED OUTBOUND for cluster group {}", feature.getName(), groupName);
} else LOGGER.warn("CELLAR FEATURES: feature is null");
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
index 6c3b919..3576f67 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java
@@ -47,7 +47,7 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
if (isSyncEnabled(group)) {
pull(group);
push(group);
- } else LOGGER.warn("CELLAR FEATURES: sync is disabled for cluster group {}", group.getName());
+ } else LOGGER.debug("CELLAR FEATURES: sync is disabled for cluster group {}", group.getName());
}
}
}
@@ -123,7 +123,7 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
LOGGER.error("CELLAR FEATURES: failed to uninstall feature {}/{} ", new Object[]{info.getName(), info.getVersion()}, e);
}
}
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked BLOCKED INBOUND for cluster group {}", name, groupName);
+ } else LOGGER.debug("CELLAR FEATURES: feature {} is marked BLOCKED INBOUND for cluster group {}", name, groupName);
}
}
} finally {
@@ -141,7 +141,7 @@ public class FeaturesSynchronizer extends FeaturesSupport implements Synchronize
public void push(Group group) {
if (group != null) {
String groupName = group.getName();
- LOGGER.info("CELLAR FEATURES: pushing features repositories and features in cluster group {}", groupName);
+ LOGGER.debug("CELLAR FEATURES: pushing features repositories and features in cluster group {}", groupName);
clusterManager.getList(Constants.FEATURES + Configurations.SEPARATOR + groupName);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java b/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
index 85bff69..f29b0e7 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java
@@ -56,7 +56,7 @@ public class LocalFeaturesListener extends FeaturesSupport implements org.apache
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR FEATURES: cluster event producer is OFF");
+ LOGGER.debug("CELLAR FEATURES: cluster event producer is OFF");
return;
}
@@ -84,7 +84,7 @@ public class LocalFeaturesListener extends FeaturesSupport implements org.apache
ClusterFeaturesEvent featureEvent = new ClusterFeaturesEvent(name, version, type);
featureEvent.setSourceGroup(group);
eventProducer.produce(featureEvent);
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked BLOCKED OUTBOUND for cluster group {}", name, group.getName());
+ } else LOGGER.debug("CELLAR FEATURES: feature {} is marked BLOCKED OUTBOUND for cluster group {}", name, group.getName());
}
}
}
@@ -100,7 +100,7 @@ public class LocalFeaturesListener extends FeaturesSupport implements org.apache
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR FEATURES: cluster event producer is OFF");
+ LOGGER.debug("CELLAR FEATURES: cluster event producer is OFF");
return;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java b/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
index 21d43c7..3799ec9 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
@@ -54,7 +54,7 @@ public class RepositoryEventHandler extends FeaturesSupport implements EventHand
// check if the handler is ON
if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.error("CELLAR FEATURES: {} switch is OFF, cluster event is not handled", SWITCH_ID);
+ LOGGER.debug("CELLAR FEATURES: {} switch is OFF, cluster event is not handled", SWITCH_ID);
return;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastGroupManager.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastGroupManager.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastGroupManager.java
index b781c6a..24156b9 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastGroupManager.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastGroupManager.java
@@ -343,7 +343,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
String groupName = group.getName();
createGroup(groupName);
- LOGGER.info("CELLAR HAZELCAST: registering cluster group {}.", groupName);
+ LOGGER.debug("CELLAR HAZELCAST: registering cluster group {}.", groupName);
Properties serviceProperties = new Properties();
serviceProperties.put("type", "group");
serviceProperties.put("name", groupName);
@@ -649,7 +649,7 @@ public class HazelcastGroupManager implements GroupManager, EntryListener, Confi
*/
@Override
public void entryUpdated(EntryEvent entryEvent) {
- LOGGER.info("CELLAR HAZELCAST: cluster group configuration has been updated, updating local configuration");
+ LOGGER.debug("CELLAR HAZELCAST: cluster group configuration has been updated, updating local configuration");
try {
Configuration conf = configurationAdmin.getConfiguration(GROUPS);
Dictionary props = conf.getProperties();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueConsumer.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueConsumer.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueConsumer.java
index da601ee..4734d89 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueConsumer.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/QueueConsumer.java
@@ -118,7 +118,7 @@ public class QueueConsumer<E extends Event> implements EventConsumer<E>, ItemLis
dispatcher.dispatch(event);
} else {
if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR HAZELCAST: {} switch is OFF, cluster event is not consumed", SWITCH_ID);
+ LOGGER.debug("CELLAR HAZELCAST: {} switch is OFF, cluster event is not consumed", SWITCH_ID);
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/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 d196f89..b8c9436 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
@@ -79,7 +79,7 @@ public class QueueProducer<E extends Event> implements EventProducer<E> {
}
} else {
if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR HAZELCAST: {} switch is OFF, don't produce the cluster event", SWITCH_ID);
+ LOGGER.debug("CELLAR HAZELCAST: {} switch is OFF, don't produce the cluster event", SWITCH_ID);
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicConsumer.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicConsumer.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicConsumer.java
index ba9ef5e..a3c09e9 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicConsumer.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/TopicConsumer.java
@@ -67,7 +67,7 @@ public class TopicConsumer<E extends Event> implements EventConsumer<E>, Message
dispatcher.dispatch(event);
} else {
if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR HAZELCAST: {} switch is OFF, cluster event is not consumed", SWITCH_ID);
+ LOGGER.debug("CELLAR HAZELCAST: {} switch is OFF, cluster event is not consumed", SWITCH_ID);
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/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 f39d9c3..5978573 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
@@ -61,7 +61,7 @@ public class TopicProducer<E extends Event> implements EventProducer<E> {
topic.publish(event);
} else {
if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR HAZELCAST: {} switch is OFF, don't produce the cluster event", SWITCH_ID);
+ LOGGER.debug("CELLAR HAZELCAST: {} switch is OFF, don't produce the cluster event", SWITCH_ID);
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
index 1d7501b..a724962 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
@@ -63,7 +63,7 @@ public class HazelcastConfigurationManager {
if (properties.containsKey(Discovery.DISCOVERED_MEMBERS_PROPERTY_NAME)) {
Set<String> newDiscoveredMemberSet = CellarUtils.createSetFromString((String) properties.get(Discovery.DISCOVERED_MEMBERS_PROPERTY_NAME));
if (!CellarUtils.collectionEquals(discoveredMemberSet, newDiscoveredMemberSet)) {
- LOGGER.info("Hazelcast discoveredMemberSet has been changed from {} to {}", discoveredMemberSet, newDiscoveredMemberSet);
+ LOGGER.debug("Hazelcast discoveredMemberSet has been changed from {} to {}", discoveredMemberSet, newDiscoveredMemberSet);
discoveredMemberSet = newDiscoveredMemberSet;
updated = Boolean.TRUE;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java
index 4e40b60..6af9043 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/merge/CellarMergePolicy.java
@@ -43,7 +43,7 @@ public class CellarMergePolicy implements MergePolicy {
*/
@Override
public Object merge(String mapName, MapEntry mergingEntry, MapEntry existingEntry) {
- LOGGER.info("Cellar merge policy triggered merging entry {}, existing entry {}",mergingEntry,existingEntry);
+ LOGGER.debug("Cellar merge policy triggered merging entry {}, existing entry {}",mergingEntry,existingEntry);
Object mergingDataValue = mergingEntry != null ? mergingEntry.getValue() : null;
Object existingDataValue = existingEntry != null ? existingEntry.getValue() : null;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
index ddba579..3e06b31 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
@@ -115,7 +115,7 @@ public class ObrBundleEventHandler extends ObrSupport implements EventHandler<Cl
// check if the handler is ON
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR OBR: {} switch is OFF", SWITCH_ID);
+ LOGGER.debug("CELLAR OBR: {} switch is OFF", SWITCH_ID);
return;
}
@@ -159,7 +159,7 @@ public class ObrBundleEventHandler extends ObrSupport implements EventHandler<Cl
}
} else LOGGER.warn("CELLAR OBR: could not resolve targets");
}
- } else LOGGER.warn("CELLAR OBR: bundle {} is marked as BLOCKED INBOUND", bundleId);
+ } else LOGGER.debug("CELLAR OBR: bundle {} is marked as BLOCKED INBOUND for cluster group {}", bundleId, event.getSourceGroup().getName());
} catch (Exception e) {
LOGGER.error("CELLAR OBR: failed to handle bundle event {}", bundleId, e);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
index 2fb1d62..78b1e6e 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
@@ -54,7 +54,7 @@ public class ObrUrlEventHandler extends ObrSupport implements EventHandler<Clust
// check if the handler is ON
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR OBR: switch is OFF", SWITCH_ID);
+ LOGGER.debug("CELLAR OBR: {} switch is OFF", SWITCH_ID);
return;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/ef5dec8d/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
index 048d63e..a846814 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
@@ -113,7 +113,7 @@ public class ObrUrlSynchronizer extends ObrSupport implements Synchronizer {
// TODO fire event to the other nodes ?
}
} else {
- LOGGER.warn("CELLAR OBR: URL {} is blocked outbound for cluster group {}", repository.getURI().toString(), groupName);
+ LOGGER.debug("CELLAR OBR: URL {} is marked BLOCKED OUTBOUND for cluster group {}", repository.getURI().toString(), groupName);
}
}
} finally {
[17/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1476084 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/d0e8505f
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/d0e8505f
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/d0e8505f
Branch: refs/heads/master
Commit: d0e8505f8dbb3cc81b1381a4137cac11b0e3ed56
Parents: b43a255
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Fri Apr 26 07:23:47 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Fri Apr 26 07:23:47 2013 +0000
----------------------------------------------------------------------
.../cellar/management/CellarBundleMBean.java | 43 ++++++-
.../cellar/management/CellarConfigMBean.java | 55 ++++++++-
.../cellar/management/CellarFeaturesMBean.java | 87 +++++++++++++-
.../cellar/management/CellarGroupMBean.java | 39 +++++-
.../karaf/cellar/management/CellarMBean.java | 69 ++++++++++-
.../cellar/management/CellarNodeMBean.java | 17 ++-
.../internal/CellarBundleMBeanImpl.java | 80 +++++++------
.../internal/CellarConfigMBeanImpl.java | 102 ++++++++--------
.../internal/CellarFeaturesMBeanImpl.java | 119 ++++++++++---------
.../internal/CellarGroupMBeanImpl.java | 5 +
.../management/internal/CellarMBeanImpl.java | 10 ++
.../internal/CellarNodeMBeanImpl.java | 7 +-
.../resources/OSGI-INF/blueprint/blueprint.xml | 63 +++++-----
13 files changed, 510 insertions(+), 186 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/CellarBundleMBean.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/CellarBundleMBean.java b/management/src/main/java/org/apache/karaf/cellar/management/CellarBundleMBean.java
index 4962888..927790e 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/CellarBundleMBean.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/CellarBundleMBean.java
@@ -16,15 +16,56 @@ package org.apache.karaf.cellar.management;
import javax.management.openmbean.TabularData;
/**
- * MBean interface describing the operations and attributes on Cellar bundles.
+ * Describe the operations and attributes on the Cellar bundle MBean.
*/
public interface CellarBundleMBean {
+ /**
+ * Install a bundle in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param location the bundle location.
+ * @throws Exception in case of install failure.
+ */
void install(String group, String location) throws Exception;
+
+ /**
+ * Uninstall a bundle from a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param symbolicName the bundle symbolic name.
+ * @param version the bundle version.
+ * @throws Exception in case of uninstall failure.
+ */
void uninstall(String group, String symbolicName, String version) throws Exception;
+
+ /**
+ * Start a bundle in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param symbolicName the bundle symbolic name.
+ * @param version the bundle version.
+ * @throws Exception in case of start failure.
+ */
void start(String group, String symbolicName, String version) throws Exception;
+
+ /**
+ * Stop a bundle in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param symbolicName the bundle symbolic name.
+ * @param version the bundle version.
+ * @throws Exception in case of stop failure.
+ */
void stop(String group, String symbolicName, String version) throws Exception;
+ /**
+ * Get the bundles in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @return the list of bundles in the cluster group.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData getBundles(String group) throws Exception;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/CellarConfigMBean.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/CellarConfigMBean.java b/management/src/main/java/org/apache/karaf/cellar/management/CellarConfigMBean.java
index e992599..31dfb45 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/CellarConfigMBean.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/CellarConfigMBean.java
@@ -17,15 +17,68 @@ import javax.management.openmbean.TabularData;
import java.util.List;
/**
- * Config interface describing the operations and attributes available on a Cellar configuration.
+ * Describe the operations and attributes available on the Cellar configuration MBean.
*/
public interface CellarConfigMBean {
+ /**
+ * Get the list of configuration PID in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @return the list of configuration PID.
+ * @throws Exception in case of retrieval failure.
+ */
List<String> listConfig(String group) throws Exception;
+
+ /**
+ * Delete a configuration from a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param pid the configuration PID to delete.
+ * @throws Exception in case of deletion failure.
+ */
void deleteConfig(String group, String pid) throws Exception;
+
+ /**
+ * List the properties of a configuration in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param pid the configuration PID.
+ * @return the list of properties for the configuration.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData listProperties(String group, String pid) throws Exception;
+
+ /**
+ * Set the value of a property for a configuration in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param pid the configuration PID.
+ * @param key the property key.
+ * @param value the property value.
+ * @throws Exception in case of set failure.
+ */
void setProperty(String group, String pid, String key, String value) throws Exception;
+
+ /**
+ * Append String at the end of the value of a property for a configuration in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param pid the configuration PID.
+ * @param key the property key.
+ * @param value the property value.
+ * @throws Exception in case of append failure.
+ */
void appendProperty(String group, String pid, String key, String value) throws Exception;
+
+ /**
+ * Delete a property for a configuration in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param pid the configuration PID.
+ * @param key the property key.
+ * @throws Exception in case of delete failure.
+ */
void deleteProperty(String group, String pid, String key) throws Exception;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java b/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
index db3f05e..b380b41 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
@@ -17,20 +17,105 @@ import javax.management.openmbean.TabularData;
import java.util.List;
/**
- * MBean interface describing the operations and attributes on a Cellar feature.
+ * Describe the operations and attributes on the Cellar Features MBean.
*/
public interface CellarFeaturesMBean {
+ /**
+ * Add a features repository URL in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param url the features repository URL.
+ * @throws Exception in case of add failure.
+ */
void addUrl(String group, String url) throws Exception;
+
+ /**
+ * Remove a features repository URL from a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param url the features repository URL.
+ * @throws Exception in case of remove failure.
+ */
void removeUrl(String group, String url) throws Exception;
+
+ /**
+ * Install a feature in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param name the feature name.
+ * @throws Exception in case of install failure.
+ */
void install(String group, String name) throws Exception;
+
+ /**
+ * Install a feature in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param name the feature name.
+ * @param noClean true to not uninstall the bundles if the installation of the feature failed, false else.
+ * @param noRefresh true to not automatically refresh the bundles, false else.
+ * @throws Exception in case of install failure.
+ */
void install(String group, String name, boolean noClean, boolean noRefresh) throws Exception;
+
+ /**
+ * Install a feature in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param name the feature name.
+ * @param version the feature version.
+ * @throws Exception in case of install failure.
+ */
void install(String group, String name, String version) throws Exception;
+
+ /**
+ * Install a feature in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param name the feature name.
+ * @param version the feature version.
+ * @param noClean true to not uninstall the bundles if the installation of the feature failed, false else.
+ * @param noRefresh true to not automatically refresh the bundles, false else.
+ * @throws Exception in case of install failure.
+ */
void install(String group, String name, String version, boolean noClean, boolean noRefresh) throws Exception;
+
+ /**
+ * Uninstall a feature from a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param name the feature name.
+ * @throws Exception in case of uninstall failure.
+ */
void uninstall(String group, String name) throws Exception;
+
+ /**
+ * Uninstall a feature from a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param name the feature name.
+ * @param version the feature version.
+ * @throws Exception in case of uninstall failure.
+ */
void uninstall(String group, String name, String version) throws Exception;
+ /**
+ * Get the list of features repository URLs in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @return the list of features repository URLs.
+ * @throws Exception in case of retrieval failure.
+ */
List<String> getUrls(String group) throws Exception;
+
+ /**
+ * Get the list of features in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @return the list of features.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData getFeatures(String group) throws Exception;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/CellarGroupMBean.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/CellarGroupMBean.java b/management/src/main/java/org/apache/karaf/cellar/management/CellarGroupMBean.java
index 59ce13b..35c72f7 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/CellarGroupMBean.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/CellarGroupMBean.java
@@ -16,17 +16,50 @@ package org.apache.karaf.cellar.management;
import javax.management.openmbean.TabularData;
/**
- * Cellar Group MBean to manipule Cellar cluster group.
+ * Describe the operations and attributes of the Cellar Cluster Group MBean.
*/
public interface CellarGroupMBean {
- // Operations
+ /**
+ * Create a cluster group.
+ *
+ * @param name the cluster group name.
+ * @throws Exception in case of create failure.
+ */
void create(String name) throws Exception;
+
+ /**
+ * Delete a cluster group.
+ *
+ * @param name the cluster group name.
+ * @throws Exception in case of delete failure.
+ */
void delete(String name) throws Exception;
+
+ /**
+ * Join a node in a cluster group.
+ *
+ * @param name the cluster group name.
+ * @param nodeId the node ID.
+ * @throws Exception in case of join failure.
+ */
void join(String name, String nodeId) throws Exception;
+
+ /**
+ * Quit a node from a cluster group.
+ *
+ * @param name the cluster group name.
+ * @param nodeId the node ID.
+ * @throws Exception in case of quit failure.
+ */
void quit(String name, String nodeId) throws Exception;
- // Attributes
+ /**
+ * Get the list of cluster groups.
+ *
+ * @return the list of cluster groups.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData getGroups() throws Exception;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/CellarMBean.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/CellarMBean.java b/management/src/main/java/org/apache/karaf/cellar/management/CellarMBean.java
index 088b499..9167cce 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/CellarMBean.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/CellarMBean.java
@@ -16,22 +16,89 @@ package org.apache.karaf.cellar.management;
import javax.management.openmbean.TabularData;
/**
- * Cellar MBean describing the core attributes and operation that you can do on Cellar.
+ * Describe the operations and attributes of the Cellar core MBean.
*/
public interface CellarMBean {
+ /**
+ * Force the sync of the different nodes in the cluster.
+ *
+ * @throws Exception in case of sync failure.
+ */
void sync() throws Exception;
+ /**
+ * Get the status of the cluster event consumers.
+ *
+ * @return the status of the cluster event consumers.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData consumerStatus() throws Exception;
+
+ /**
+ * Start a cluster event consumer on a node.
+ *
+ * @param nodeId the node ID.
+ * @throws Exception in case of start failure.
+ */
void consumerStart(String nodeId) throws Exception;
+
+ /**
+ * Stop a cluster event consumer on a node.
+ *
+ * @param nodeId the node ID.
+ * @throws Exception in case of stop failure.
+ */
void consumerStop(String nodeId) throws Exception;
+ /**
+ * Get the status of the cluster event handlers.
+ *
+ * @return the status of the cluster event handlers.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData handlerStatus() throws Exception;
+
+ /**
+ * Start a cluster event handler on a node.
+ *
+ * @param handlerId the cluster event handler ID.
+ * @param nodeId the node ID.
+ * @throws Exception in case of start failure.
+ */
void handlerStart(String handlerId, String nodeId) throws Exception;
+
+ /**
+ * Stop a cluster event handler on a node.
+ *
+ * @param handlerId the cluster event handler ID.
+ * @param nodeId the node ID.
+ * @throws Exception in case of stop failure.
+ */
void handlerStop(String handlerId, String nodeId) throws Exception;
+ /**
+ * Get the status of the cluster event producers.
+ *
+ * @return the status of the cluster event producers.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData producerStatus() throws Exception;
+
+ /**
+ * Start a cluster event producer on a node.
+ *
+ * @param nodeId the node ID.
+ * @throws Exception in case of start failure.
+ */
void producerStart(String nodeId) throws Exception;
+
+ /**
+ * Stop a cluster event producer on a node.
+ *
+ * @param nodeId the node ID.
+ * @throws Exception in case of stop failure.
+ */
void producerStop(String nodeId) throws Exception;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/CellarNodeMBean.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/CellarNodeMBean.java b/management/src/main/java/org/apache/karaf/cellar/management/CellarNodeMBean.java
index bc1e699..af7e970 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/CellarNodeMBean.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/CellarNodeMBean.java
@@ -16,14 +16,25 @@ package org.apache.karaf.cellar.management;
import javax.management.openmbean.TabularData;
/**
- * Cellar Node MBean to manipulate Cellar cluster nodes.
+ * Describe the operations and attributes on the Cellar Node MBean.
*/
public interface CellarNodeMBean {
- // Operations
+ /**
+ * Ping a node.
+ *
+ * @param nodeId the node ID.
+ * @return the time (in milliseconds) to reach the node.
+ * @throws Exception in case of ping failure.
+ */
long pingNode(String nodeId) throws Exception;
- // Attributes
+ /**
+ * Get the list of nodes.
+ *
+ * @return the list of nodes.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData getNodes() throws Exception;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
index cb73f72..1f88d06 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
@@ -35,7 +35,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
- * Implementation of the Cellar bundle MBean.
+ * Implementation of the Cellar Bundle MBean.
*/
public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundleMBean {
@@ -80,6 +80,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
this.eventProducer = eventProducer;
}
+ @Override
public void install(String groupName, String location) throws Exception {
// check if cluster group exists
Group group = groupManager.findGroupByName(groupName);
@@ -98,7 +99,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, location, EventType.OUTBOUND)) {
- throw new IllegalArgumentException("Bundle location " + location + " is blocked outbound");
+ throw new IllegalArgumentException("Bundle location " + location + " is blocked outbound for cluster group " + groupName);
}
// get the name and version in the location MANIFEST
@@ -111,12 +112,12 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- // populate the cluster map
- Map<String, BundleState> bundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ // update the cluster group
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
BundleState state = new BundleState();
state.setLocation(location);
state.setStatus(BundleEvent.INSTALLED);
- bundles.put(name + "/" + version, state);
+ clusterBundles.put(name + "/" + version, state);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
@@ -127,6 +128,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
eventProducer.produce(event);
}
+ @Override
public void uninstall(String groupName, String symbolicName, String version) throws Exception {
// check if the cluster group exists
Group group = groupManager.findGroupByName(groupName);
@@ -139,22 +141,22 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
throw new IllegalStateException("Cluster event producer is OFF for this node");
}
- // update the cluster map
+ // update the cluster group
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
String key = null;
String location = null;
try {
- Map<String, BundleState> distributedBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
- key = selector(symbolicName, version, distributedBundles);
+ key = selector(symbolicName, version, clusterBundles);
if (key == null) {
throw new IllegalArgumentException("Bundle " + key + " is not found in cluster group " + groupName);
}
- BundleState state = distributedBundles.get(key);
+ BundleState state = clusterBundles.get(key);
if (state == null) {
throw new IllegalArgumentException("Bundle " + key + " is not found in cluster group " + groupName);
}
@@ -166,10 +168,10 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, location, EventType.OUTBOUND)) {
- throw new IllegalArgumentException("Bundle location " + location + " is blocked outbound");
+ throw new IllegalArgumentException("Bundle location " + location + " is blocked outbound for cluster group " + groupName);
}
- distributedBundles.remove(key);
+ clusterBundles.remove(key);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
@@ -181,6 +183,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
eventProducer.produce(event);
}
+ @Override
public void start(String groupName, String symbolicName, String version) throws Exception {
// check if the cluster group exists
Group group = groupManager.findGroupByName(groupName);
@@ -193,21 +196,21 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
throw new IllegalStateException("Cluster event producer is OFF for this node");
}
- // update the cluster map
+ // update the cluster group
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
String key = null;
String location = null;
try {
- Map<String, BundleState> distributedBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
- key = selector(symbolicName, version, distributedBundles);
+ key = selector(symbolicName, version, clusterBundles);
if (key == null) {
throw new IllegalStateException("Bundle " + key + " not found in cluster group " + groupName);
}
- BundleState state = distributedBundles.get(key);
+ BundleState state = clusterBundles.get(key);
if (state == null) {
throw new IllegalStateException("Bundle " + key + " not found in cluster group " + groupName);
}
@@ -219,22 +222,23 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, location, EventType.OUTBOUND)) {
- throw new IllegalArgumentException("Bundle location " + location + " is blocked outbound");
+ throw new IllegalArgumentException("Bundle location " + location + " is blocked outbound for cluster group " + groupName);
}
state.setStatus(BundleEvent.STARTED);
- distributedBundles.put(key, state);
+ clusterBundles.put(key, state);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
- // broadcast the event
+ // broadcast the cluster event
String[] split = key.split("/");
ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleEvent.STARTED);
event.setSourceGroup(group);
eventProducer.produce(event);
}
+ @Override
public void stop(String groupName, String symbolicName, String version) throws Exception {
// check if the cluster group exists
Group group = groupManager.findGroupByName(groupName);
@@ -247,48 +251,49 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
throw new IllegalStateException("Cluster event producer is OFF for this node");
}
- // update the cluster map
+ // update the cluster group
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
String key = null;
String location = null;
try {
- Map<String, BundleState> distributedBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
- key = selector(symbolicName, version, distributedBundles);
+ key = selector(symbolicName, version, clusterBundles);
if (key == null) {
throw new IllegalStateException("Bundle " + key + " not found in cluster group " + groupName);
}
- BundleState state = distributedBundles.get(key);
+ BundleState state = clusterBundles.get(key);
if (state == null) {
throw new IllegalStateException("Bundle " + key + " not found in cluster group " + groupName);
}
location = state.getLocation();
- // check if the bundle location is allowed
+ // check if the bundle location is allowed outbound
CellarSupport support = new CellarSupport();
support.setClusterManager(this.clusterManager);
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, location, EventType.OUTBOUND)) {
- throw new IllegalArgumentException("Bundle location " + location + " is blocked outbound");
+ throw new IllegalArgumentException("Bundle location " + location + " is blocked outbound for cluster group " + groupName);
}
state.setStatus(BundleEvent.STOPPED);
- distributedBundles.put(key, state);
+ clusterBundles.put(key, state);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
- // broadcast the event
+ // broadcast the cluster event
String[] split = key.split("/");
ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleEvent.STOPPED);
event.setSourceGroup(group);
eventProducer.produce(event);
}
+ @Override
public TabularData getBundles(String groupName) throws Exception {
CompositeType compositeType = new CompositeType("Bundle", "Karaf Cellar bundle",
new String[]{"id", "name", "version", "status", "location"},
@@ -301,9 +306,9 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
- Map<String, BundleState> bundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
int id = 0;
- for (String bundle : bundles.keySet()) {
+ for (String bundle : clusterBundles.keySet()) {
String[] tokens = bundle.split("/");
String name = null;
String version = null;
@@ -313,7 +318,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
} else {
name = bundle;
}
- BundleState state = bundles.get(bundle);
+ BundleState state = clusterBundles.get(bundle);
String status;
switch (state.getStatus()) {
case BundleEvent.INSTALLED:
@@ -356,9 +361,12 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
/**
* Bundle selector.
*
+ * @param name the bundle name, regex, or ID.
+ * @param version the bundle version.
+ * @param clusterBundles the cluster bundles map.
* @return the bundle key is the distributed bundle map.
*/
- private String selector(String name, String version, Map<String, BundleState> distributedBundles) {
+ private String selector(String name, String version, Map<String, BundleState> clusterBundles) {
String key = null;
if (version == null || version.trim().isEmpty()) {
// looking for bundle using ID
@@ -366,9 +374,9 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
try {
id = Integer.parseInt(name);
int index = 0;
- for (String bundle : distributedBundles.keySet()) {
+ for (String clusterBundle : clusterBundles.keySet()) {
if (index == id) {
- key = bundle;
+ key = clusterBundle;
break;
}
index++;
@@ -382,8 +390,8 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
Pattern namePattern = Pattern.compile(name);
// looking for bundle using only the name
- for (String bundle : distributedBundles.keySet()) {
- BundleState state = distributedBundles.get(bundle);
+ for (String bundle : clusterBundles.keySet()) {
+ BundleState state = clusterBundles.get(bundle);
if (state.getName() != null) {
// bundle name is populated, check if it matches the regex
Matcher matcher = namePattern.matcher(state.getName());
@@ -416,9 +424,9 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
// add regex support of the name
Pattern namePattern = Pattern.compile(name);
- for (String bundle : distributedBundles.keySet()) {
+ for (String bundle : clusterBundles.keySet()) {
String[] split = bundle.split("/");
- BundleState state = distributedBundles.get(bundle);
+ BundleState state = clusterBundles.get(bundle);
if (split[1].equals(version)) {
if (state.getName() != null) {
// bundle name is populated, check if it matches the regex
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarConfigMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarConfigMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarConfigMBeanImpl.java
index 5be849a..e2bfbf1 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarConfigMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarConfigMBeanImpl.java
@@ -29,7 +29,7 @@ import javax.management.openmbean.*;
import java.util.*;
/**
- * Implementation of the Cellar Config MBean allowing to manipulate Cellar config admin layer.
+ * Implementation of the Cellar Config MBean.
*/
public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfigMBean {
@@ -42,6 +42,7 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
super(CellarConfigMBean.class);
}
+ @Override
public List<String> listConfig(String groupName) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -51,14 +52,15 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
List<String> result = new ArrayList<String>();
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- for (String pid : distributedConfigurations.keySet()) {
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ for (String pid : clusterConfigurations.keySet()) {
result.add(pid);
}
return result;
}
+ @Override
public void deleteConfig(String groupName, String pid) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -77,13 +79,13 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
- throw new IllegalStateException("Configuration PID " + pid + " is blocked outbound");
+ throw new IllegalStateException("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
}
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (distributedConfigurations != null) {
- // update the distributed map
- Properties properties = distributedConfigurations.remove(pid);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ if (clusterConfigurations != null) {
+ // update the cluster group
+ Properties properties = clusterConfigurations.remove(pid);
// broadcast the cluster event
ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
@@ -91,11 +93,12 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
event.setType(ConfigurationEvent.CM_DELETED);
eventProducer.produce(event);
} else {
- throw new IllegalArgumentException("Configuration distributed map not found for cluster group " + groupName);
+ throw new IllegalArgumentException("No configuration found in cluster group " + groupName);
}
}
- public TabularData listProperties(String group, String pid) throws Exception {
+ @Override
+ public TabularData listProperties(String groupName, String pid) throws Exception {
CompositeType compositeType = new CompositeType("Property", "Cellar Config Property",
new String[]{"key", "value"},
@@ -105,13 +108,13 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
compositeType, new String[]{"key"});
TabularData table = new TabularDataSupport(tableType);
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + group);
- Properties properties = distributedConfigurations.get(pid);
- if (properties != null) {
- Enumeration propertyNames = properties.propertyNames();
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ Properties clusterProperties = clusterConfigurations.get(pid);
+ if (clusterProperties != null) {
+ Enumeration propertyNames = clusterProperties.propertyNames();
while (propertyNames.hasMoreElements()) {
String key = (String) propertyNames.nextElement();
- String value = (String) properties.get(key);
+ String value = (String) clusterProperties.get(key);
CompositeDataSupport data = new CompositeDataSupport(compositeType,
new String[]{"key", "value"},
new String[]{key, value});
@@ -121,6 +124,7 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
return table;
}
+ @Override
public void setProperty(String groupName, String pid, String key, String value) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -139,28 +143,29 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
- throw new IllegalStateException("Configuration PID " + pid + " is blocked outbound");
+ throw new IllegalStateException("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
}
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (distributedConfigurations != null) {
- // update the distributed map
- Properties properties = distributedConfigurations.get(pid);
- if (properties == null) {
- properties = new Properties();
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ if (clusterConfigurations != null) {
+ // update the cluster group
+ Properties clusterProperties = clusterConfigurations.get(pid);
+ if (clusterProperties == null) {
+ clusterProperties = new Properties();
}
- properties.put(key, value);
- distributedConfigurations.put(pid, properties);
+ clusterProperties.put(key, value);
+ clusterConfigurations.put(pid, clusterProperties);
// broadcast the cluster event
ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
- throw new IllegalArgumentException("Configuration distributed map not found for cluster group " + groupName);
+ throw new IllegalArgumentException("No configuration found in cluster group " + groupName);
}
}
+ @Override
public void appendProperty(String groupName, String pid, String key, String value) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -170,7 +175,7 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
// check if the producer is on
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- throw new IllegalStateException("Cluster event producer is off");
+ throw new IllegalStateException("Cluster event producer is OFF");
}
// check if the pid is allowed outbound
@@ -179,35 +184,36 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
- throw new IllegalStateException("Configuration PID " + pid + " is blocked outbound");
+ throw new IllegalStateException("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
}
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (distributedConfigurations != null) {
- // update the distributed map
- Properties properties = distributedConfigurations.get(pid);
- if (properties == null) {
- properties = new Properties();
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ if (clusterConfigurations != null) {
+ // update the cluster group
+ Properties clusterProperties = clusterConfigurations.get(pid);
+ if (clusterProperties == null) {
+ clusterProperties = new Properties();
}
- Object currentValue = properties.get(key);
+ Object currentValue = clusterProperties.get(key);
if (currentValue == null) {
- properties.put(key, value);
+ clusterProperties.put(key, value);
} else if (currentValue instanceof String) {
- properties.put(key, currentValue + value);
+ clusterProperties.put(key, currentValue + value);
} else {
throw new IllegalStateException("Append failed: current value is not a String");
}
- distributedConfigurations.put(pid, properties);
+ clusterConfigurations.put(pid, clusterProperties);
// broadcast the cluster event
ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
- throw new IllegalArgumentException("Configuration distributed map not found for cluster group " + groupName);
+ throw new IllegalArgumentException("No configuration found in cluster group " + groupName);
}
}
+ @Override
public void deleteProperty(String groupName, String pid, String key) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -217,7 +223,7 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
// check if the event producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- throw new IllegalStateException("Cluster event producer is off");
+ throw new IllegalStateException("Cluster event producer is OFF");
}
// check if the pid is allowed outbound
@@ -226,23 +232,23 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
- throw new IllegalArgumentException("Configuration PID " + pid + " is blocked outbound");
+ throw new IllegalArgumentException("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
}
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (distributedConfigurations != null) {
- // update the distributed map
- Properties distributedDictionary = distributedConfigurations.get(pid);
- if (distributedDictionary != null) {
- distributedDictionary.remove(key);
- distributedConfigurations.put(pid, distributedDictionary);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ if (clusterConfigurations != null) {
+ // update the cluster group
+ Properties clusterDictionary = clusterConfigurations.get(pid);
+ if (clusterDictionary != null) {
+ clusterDictionary.remove(key);
+ clusterConfigurations.put(pid, clusterDictionary);
// broadcast the cluster event
ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
eventProducer.produce(event);
}
} else {
- throw new IllegalArgumentException("Configuration distributed map not found for cluster group " + groupName);
+ throw new IllegalArgumentException("No configuration found in cluster group " + groupName);
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
index 3caa66c..c5bfac3 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
@@ -36,7 +36,7 @@ import java.util.List;
import java.util.Map;
/**
- * Implementation of the CellarFeaturesMBean to manipulate Cellar features.
+ * Implementation of the Cellar Features MBean.
*/
public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeaturesMBean {
@@ -90,6 +90,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
this.configurationAdmin = configurationAdmin;
}
+ @Override
public void install(String groupName, String name, String version, boolean noClean, boolean noRefresh) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -99,7 +100,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- throw new IllegalStateException("Cluster event producer is OFF for this node");
+ throw new IllegalStateException("Cluster event producer is OFF");
}
// check if the feature is allowed outbound
@@ -108,19 +109,19 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND)) {
- throw new IllegalArgumentException("Feature " + name + " is blocked outbound");
+ throw new IllegalArgumentException("Feature " + name + " is blocked outbound for cluster group " + groupName);
}
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- // get the features distributed map
- Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
+ // get the features in the cluster group
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
// check if the feature exist
FeatureInfo feature = null;
- for (FeatureInfo info : distributedFeatures.keySet()) {
+ for (FeatureInfo info : clusterFeatures.keySet()) {
if (version == null) {
if (info.getName().equals(name)) {
feature = info;
@@ -136,23 +137,21 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
if (feature == null) {
if (version == null)
- throw new IllegalArgumentException("Feature " + name + " doesn't exist for cluster group " + groupName);
+ throw new IllegalArgumentException("Feature " + name + " doesn't exist in cluster group " + groupName);
else
- throw new IllegalArgumentException("Feature " + name + "/" + version + " doesn't exist for cluster group " + groupName);
+ throw new IllegalArgumentException("Feature " + name + "/" + version + " doesn't exist in cluster group " + groupName);
}
- // update the distributed map
- distributedFeatures.put(feature, true);
- // update the bundle distributed map
+ // update the cluster group
+ clusterFeatures.put(feature, true);
try {
- // update the distributed bundles map
List<BundleInfo> bundles = featuresService.getFeature(feature.getName(), version).getBundles();
- Map<String, BundleState> bundlesMap = clusterManager.getMap(org.apache.karaf.cellar.bundle.Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(org.apache.karaf.cellar.bundle.Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
for (BundleInfo bundle : bundles) {
BundleState state = new BundleState();
state.setLocation(bundle.getLocation());
state.setStatus(BundleEvent.STARTED);
- bundlesMap.put(bundle.toString(), state);
+ clusterBundles.put(bundle.toString(), state);
}
} catch (Exception e) {
// ignore
@@ -167,18 +166,22 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
eventProducer.produce(event);
}
+ @Override
public void install(String groupName, String name, String version) throws Exception {
this.install(groupName, name, version, false, false);
}
+ @Override
public void install(String groupName, String name) throws Exception {
this.install(groupName, name, null);
}
+ @Override
public void install(String groupName, String name, boolean noClean, boolean noRefresh) throws Exception {
this.install(groupName, name, null, noClean, noRefresh);
}
+ @Override
public void uninstall(String groupName, String name, String version) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -188,7 +191,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- throw new IllegalStateException("Cluster event producer is OFF for this node");
+ throw new IllegalStateException("Cluster event producer is OFF");
}
// check if the feature is allowed outbound
@@ -197,19 +200,19 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND)) {
- throw new IllegalArgumentException("Feature " + name + " is blocked outbound");
+ throw new IllegalArgumentException("Feature " + name + " is blocked outbound for cluster group " + groupName);
}
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- // get the features distributed map
- Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
+ // get the features in the cluster group
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
// check if the feature exist
FeatureInfo feature = null;
- for (FeatureInfo info : distributedFeatures.keySet()) {
+ for (FeatureInfo info : clusterFeatures.keySet()) {
if (version == null) {
if (info.getName().equals(name)) {
feature = info;
@@ -225,26 +228,29 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
if (feature == null) {
if (version == null)
- throw new IllegalArgumentException("Feature " + name + " doesn't exist for cluster group " + groupName);
+ throw new IllegalArgumentException("Feature " + name + " doesn't exist in cluster group " + groupName);
else
- throw new IllegalArgumentException("Feature " + name + "/" + version + " doesn't exist for cluster group " + groupName);
+ throw new IllegalArgumentException("Feature " + name + "/" + version + " doesn't exist in cluster group " + groupName);
}
- // update the distributed map
- distributedFeatures.put(feature, false);
+ // update the cluster group
+ clusterFeatures.put(feature, false);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
+ // broadcast the cluster event
ClusterFeaturesEvent event = new ClusterFeaturesEvent(name, version, FeatureEvent.EventType.FeatureUninstalled);
event.setSourceGroup(group);
eventProducer.produce(event);
}
+ @Override
public void uninstall(String groupName, String name) throws Exception {
this.uninstall(groupName, name, null);
}
+ @Override
public TabularData getFeatures(String group) throws Exception {
CompositeType featuresType = new CompositeType("Feature", "Karaf Cellar feature",
new String[]{"name", "version", "installed"},
@@ -258,10 +264,10 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
- Map<FeatureInfo, Boolean> allFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group);
- if (allFeatures != null && !allFeatures.isEmpty()) {
- for (FeatureInfo feature : allFeatures.keySet()) {
- boolean installed = allFeatures.get(feature);
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group);
+ if (clusterFeatures != null && !clusterFeatures.isEmpty()) {
+ for (FeatureInfo feature : clusterFeatures.keySet()) {
+ boolean installed = clusterFeatures.get(feature);
CompositeData data = new CompositeDataSupport(featuresType,
new String[]{"name", "version", "installed"},
new Object[]{feature.getName(), feature.getVersion(), installed});
@@ -275,6 +281,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
return table;
}
+ @Override
public List<String> getUrls(String groupName) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -282,17 +289,18 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
}
- // get the distributed URLs list
- List<String> urls = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
+ // get the features repositories in the cluster group
+ List<String> clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
List<String> result = new ArrayList<String>();
- for (String url : urls) {
- result.add(url);
+ for (String clusterRepository : clusterRepositories) {
+ result.add(clusterRepository);
}
return result;
}
+ @Override
public void addUrl(String groupName, String url) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -308,14 +316,14 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- // get the repositories distributed list
- List<String> distributedRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
- // get the features distributed map
- Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
+ // get the features repositories in the cluster group
+ List<String> clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
+ // get the features in the cluster group
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
// check if the URL is already registered
boolean found = false;
- for (String repository : distributedRepositories) {
+ for (String repository : clusterRepositories) {
if (repository.equals(url)) {
found = true;
break;
@@ -337,7 +345,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
try {
featuresService.addRepository(new URI(url));
} catch (Exception e) {
- throw new IllegalArgumentException("Repository URL " + url + " is not valid: " + e.getMessage());
+ throw new IllegalArgumentException("Features repository URL " + url + " is not valid: " + e.getMessage());
}
// get the repository
for (Repository registeredRepository : featuresService.listRepositories()) {
@@ -350,16 +358,15 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
localRegistered = true;
}
- // update the distributed list
- distributedRepositories.add(url);
+ // update the cluster group
+ clusterRepositories.add(url);
- // update the distributed feature map
for (Feature feature : repository.getFeatures()) {
FeatureInfo info = new FeatureInfo(feature.getName(), feature.getVersion());
- distributedFeatures.put(info, false);
+ clusterFeatures.put(info, false);
}
- // unregister the repository if it's not local registered
+ // un-register the repository if it's not local registered
if (!localRegistered)
featuresService.removeRepository(new URI(url));
@@ -368,13 +375,14 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
- throw new IllegalArgumentException("Repository URL " + url + " already registered");
+ throw new IllegalArgumentException("Features repository URL " + url + " already registered");
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
}
+ @Override
public void removeUrl(String groupName, String url) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -387,15 +395,15 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
throw new IllegalStateException("Cluster event producer is OFF");
}
- // get the distributed list
- List<String> distributedRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
- // get the features distributed map
- Map<FeatureInfo, Boolean> distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
+ // get the features repositories in the cluster group
+ List<String> clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
+ // get the features in the cluster group
+ Map<FeatureInfo, Boolean> clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
// looking for the URL in the list
boolean found = false;
- for (String repository : distributedRepositories) {
- if (repository.equals(url)) {
+ for (String clusterRepository : clusterRepositories) {
+ if (clusterRepository.equals(url)) {
found = true;
break;
}
@@ -416,7 +424,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
try {
featuresService.addRepository(new URI(url));
} catch (Exception e) {
- throw new IllegalArgumentException("Repository URL " + url + " is not valid: " + e.getMessage());
+ throw new IllegalArgumentException("Features repository URL " + url + " is not valid: " + e.getMessage());
}
// get the repository
for (Repository registeredRepository : featuresService.listRepositories()) {
@@ -429,16 +437,15 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
localRegistered = true;
}
- // update the list
- distributedRepositories.remove(url);
+ // update the cluster group
+ clusterRepositories.remove(url);
- // update the distributed feature map
for (Feature feature : repository.getFeatures()) {
FeatureInfo info = new FeatureInfo(feature.getName(), feature.getVersion());
- distributedFeatures.remove(info);
+ clusterFeatures.remove(info);
}
- // unregister the repository if it's not local registered
+ // un-register the repository if it's not local registered
if (!localRegistered)
featuresService.removeRepository(new URI(url));
@@ -447,7 +454,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
- throw new IllegalArgumentException("Repository URL " + url + " not found");
+ throw new IllegalArgumentException("Features repository URL " + url + " not found in cluster group " + groupName);
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarGroupMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarGroupMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarGroupMBeanImpl.java
index 1d4b9ba..bf1a255 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarGroupMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarGroupMBeanImpl.java
@@ -67,6 +67,7 @@ public class CellarGroupMBeanImpl extends StandardMBean implements CellarGroupMB
super(CellarGroupMBean.class);
}
+ @Override
public void create(String name) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(name);
@@ -76,6 +77,7 @@ public class CellarGroupMBeanImpl extends StandardMBean implements CellarGroupMB
groupManager.createGroup(name);
}
+ @Override
public void delete(String name) throws Exception {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
@@ -101,6 +103,7 @@ public class CellarGroupMBeanImpl extends StandardMBean implements CellarGroupMB
}
}
+ @Override
public void join(String groupName, String nodeId) throws Exception {
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
@@ -123,6 +126,7 @@ public class CellarGroupMBeanImpl extends StandardMBean implements CellarGroupMB
executionContext.execute(command);
}
+ @Override
public void quit(String groupName, String nodeId) throws Exception {
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
@@ -144,6 +148,7 @@ public class CellarGroupMBeanImpl extends StandardMBean implements CellarGroupMB
executionContext.execute(command);
}
+ @Override
public TabularData getGroups() throws Exception {
Set<Group> allGroups = groupManager.listAllGroups();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
index e2d89f4..0ae453f 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
@@ -86,6 +86,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
this.groupManager = groupManager;
}
+ @Override
public void sync() throws Exception {
Set<Group> localGroups = groupManager.listLocalGroups();
for (Group group : localGroups) {
@@ -107,6 +108,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
}
}
+ @Override
public TabularData handlerStatus() throws Exception {
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId());
@@ -143,6 +145,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
return table;
}
+ @Override
public void handlerStart(String handlerId, String nodeId) throws Exception {
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId());
@@ -159,6 +162,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
command.setStatus(Boolean.TRUE);
}
+ @Override
public void handlerStop(String handlerId, String nodeId) throws Exception {
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId());
@@ -175,6 +179,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
command.setStatus(Boolean.FALSE);
}
+ @Override
public TabularData consumerStatus() throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
command.setStatus(null);
@@ -201,6 +206,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
return table;
}
+ @Override
public void consumerStart(String nodeId) throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
@@ -217,6 +223,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
executionContext.execute(command);
}
+ @Override
public void consumerStop(String nodeId) throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
@@ -233,6 +240,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
executionContext.execute(command);
}
+ @Override
public TabularData producerStatus() throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
command.setStatus(null);
@@ -259,6 +267,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
return table;
}
+ @Override
public void producerStop(String nodeId) throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
@@ -275,6 +284,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
executionContext.execute(command);
}
+ @Override
public void producerStart(String nodeId) throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarNodeMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarNodeMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarNodeMBeanImpl.java
index 6a7f72b..53c1d8c 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarNodeMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarNodeMBeanImpl.java
@@ -16,9 +16,6 @@ package org.apache.karaf.cellar.management.internal;
import org.apache.karaf.cellar.core.ClusterManager;
import org.apache.karaf.cellar.core.Node;
import org.apache.karaf.cellar.core.command.ExecutionContext;
-import org.apache.karaf.cellar.core.control.ManageGroupAction;
-import org.apache.karaf.cellar.core.control.ManageGroupCommand;
-import org.apache.karaf.cellar.core.control.ManageGroupResult;
import org.apache.karaf.cellar.management.CellarNodeMBean;
import org.apache.karaf.cellar.utils.ping.Ping;
@@ -28,7 +25,7 @@ import javax.management.openmbean.*;
import java.util.*;
/**
- * Implementation of the Cellar Node MBean to manipulate Cellar cluster nodes.
+ * Implementation of the Cellar Node MBean.
*/
public class CellarNodeMBeanImpl extends StandardMBean implements CellarNodeMBean {
@@ -55,6 +52,7 @@ public class CellarNodeMBeanImpl extends StandardMBean implements CellarNodeMBea
this.executionContext = executionContext;
}
+ @Override
public long pingNode(String nodeId) throws Exception {
Node node = clusterManager.findNodeById(nodeId);
if (node == null) {
@@ -68,6 +66,7 @@ public class CellarNodeMBeanImpl extends StandardMBean implements CellarNodeMBea
return (stop - start);
}
+ @Override
public TabularData getNodes() throws Exception {
CompositeType nodeType = new CompositeType("Node", "Karaf Cellar cluster node",
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/d0e8505f/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 0494666..d5ade55 100644
--- a/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -14,7 +14,6 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <!-- Reference to the Cellar services -->
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
<reference id="executionContext" interface="org.apache.karaf.cellar.core.command.ExecutionContext"/>
@@ -22,25 +21,44 @@
<reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
<reference id="featuresService" interface="org.apache.karaf.features.FeaturesService"/>
+ <!-- Core Cellar MBean -->
<bean id="cellarMBean" class="org.apache.karaf.cellar.management.internal.CellarMBeanImpl">
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
<property name="executionContext" ref="executionContext"/>
</bean>
+ <service ref="cellarMBean" auto-export="interfaces">
+ <service-properties>
+ <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=core,name=${karaf.name}"/>
+ </service-properties>
+ </service>
+ <!-- Cellar Node MBean -->
<bean id="cellarNodeMBean" class="org.apache.karaf.cellar.management.internal.CellarNodeMBeanImpl">
<property name="clusterManager" ref="clusterManager"/>
<property name="executionContext" ref="executionContext"/>
</bean>
+ <service ref="cellarNodeMBean" auto-export="interfaces">
+ <service-properties>
+ <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=node,name=${karaf.name}"/>
+ </service-properties>
+ </service>
+ <!-- Cellar Config MBean -->
<bean id="cellarConfigMBean" class="org.apache.karaf.cellar.management.internal.CellarConfigMBeanImpl">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
<property name="eventProducer" ref="eventProducer"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
+ <service ref="cellarConfigMBean" auto-export="interfaces">
+ <service-properties>
+ <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=config,name=${karaf.name}"/>
+ </service-properties>
+ </service>
+ <!-- Cellar Features MBean -->
<bean id="cellarFeaturesMBean" class="org.apache.karaf.cellar.management.internal.CellarFeaturesMBeanImpl">
<property name="clusterManager" ref="clusterManager"/>
<property name="eventProducer" ref="eventProducer"/>
@@ -48,50 +66,31 @@
<property name="configurationAdmin" ref="configurationAdmin"/>
<property name="featuresService" ref="featuresService"/>
</bean>
+ <service ref="cellarFeaturesMBean" auto-export="interfaces">
+ <service-properties>
+ <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=feature,name=${karaf.name}"/>
+ </service-properties>
+ </service>
+ <!-- Cellar Cluster Group MBean -->
<bean id="cellarGroupMBean" class="org.apache.karaf.cellar.management.internal.CellarGroupMBeanImpl">
<property name="clusterManager" ref="clusterManager"/>
<property name="executionContext" ref="executionContext"/>
<property name="groupManager" ref="groupManager"/>
</bean>
+ <service ref="cellarGroupMBean" auto-export="interfaces">
+ <service-properties>
+ <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=group,name=${karaf.name}"/>
+ </service-properties>
+ </service>
+ <!-- Cellar Bundle MBean -->
<bean id="cellarBundleMBean" class="org.apache.karaf.cellar.management.internal.CellarBundleMBeanImpl">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
<property name="eventProducer" ref="eventProducer"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
-
- <service ref="cellarMBean" auto-export="interfaces">
- <service-properties>
- <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=core,name=${karaf.name}"/>
- </service-properties>
- </service>
-
- <service ref="cellarNodeMBean" auto-export="interfaces">
- <service-properties>
- <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=node,name=${karaf.name}"/>
- </service-properties>
- </service>
-
- <service ref="cellarConfigMBean" auto-export="interfaces">
- <service-properties>
- <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=config,name=${karaf.name}"/>
- </service-properties>
- </service>
-
- <service ref="cellarFeaturesMBean" auto-export="interfaces">
- <service-properties>
- <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=feature,name=${karaf.name}"/>
- </service-properties>
- </service>
-
- <service ref="cellarGroupMBean" auto-export="interfaces">
- <service-properties>
- <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=group,name=${karaf.name}"/>
- </service-properties>
- </service>
-
<service ref="cellarBundleMBean" auto-export="interfaces">
<service-properties>
<entry key="jmx.objectname" value="org.apache.karaf.cellar:type=bundle,name=${karaf.name}"/>
[06/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471026 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/e08a2e87
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/e08a2e87
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/e08a2e87
Branch: refs/heads/master
Commit: e08a2e87156df21ca80a0d02e712a669c1105bd8
Parents: d8543b6
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Apr 23 16:19:27 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Apr 23 16:19:27 2013 +0000
----------------------------------------------------------------------
.../karaf/cellar/bundle/BundleSynchronizer.java | 4 +-
.../cellar/bundle/LocalBundleListener.java | 2 +-
.../bundle/shell/InstallBundleCommand.java | 2 +-
.../cellar/bundle/shell/ListBundleCommand.java | 2 +-
.../cellar/bundle/shell/StartBundleCommand.java | 2 +-
.../cellar/bundle/shell/StopBundleCommand.java | 2 +-
.../bundle/shell/UninstallBundleCommand.java | 2 +-
.../resources/OSGI-INF/blueprint/blueprint.xml | 2 +-
.../config/ClusterConfigurationEvent.java | 45 +++++++++++
.../config/ConfigurationEventHandler.java | 53 +++++++------
.../cellar/config/ConfigurationSupport.java | 30 +++++---
.../config/ConfigurationSynchronizer.java | 81 ++++++++++----------
.../config/LocalConfigurationListener.java | 59 ++++++--------
.../cellar/config/RemoteConfigurationEvent.java | 55 -------------
.../config/shell/ConfigCommandSupport.java | 11 ++-
.../cellar/config/shell/DeleteCommand.java | 16 ++--
.../karaf/cellar/config/shell/ListCommand.java | 12 +--
.../cellar/config/shell/PropAppendCommand.java | 20 ++---
.../cellar/config/shell/PropDelCommand.java | 21 ++---
.../cellar/config/shell/PropListCommand.java | 14 ++--
.../cellar/config/shell/PropSetCommand.java | 20 ++---
.../completers/ClusterConfigCompleter.java | 11 +--
.../resources/OSGI-INF/blueprint/blueprint.xml | 2 +-
.../internal/CellarConfigMBeanImpl.java | 10 +--
24 files changed, 242 insertions(+), 236 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/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 be04ae9..4114ce5 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
@@ -34,8 +34,8 @@ import java.util.Map;
import java.util.Set;
/**
- * The BundleSynchronizer is called when Cellar starts or a node join a cluster group.
- * The purpose is synchronize bundles local state with the states in cluster groups.
+ * The BundleSynchronizer is called when Cellar starts or a node joins a cluster group.
+ * The purpose is to synchronize bundles local state with the states in the cluster groups.
*/
public class BundleSynchronizer extends BundleSupport implements Synchronizer {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/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 4209278..cba2f83 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
@@ -30,7 +30,7 @@ import java.util.Set;
/**
* LocalBundleListener is listening for local bundles changes.
- * When a local bundle change occurs, this listener updates the cluster and broadcast a cluster bundle event.
+ * When a local bundle change occurs, this listener updates the cluster and broadcasts a cluster bundle event.
*/
public class LocalBundleListener extends BundleSupport implements SynchronousBundleListener {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/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 903cfab..81ebc46 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
@@ -34,7 +34,7 @@ import java.util.Map;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
-@Command(scope = "cluster", name = "bundle-install", description = "Install a bundle in a cluster group.")
+@Command(scope = "cluster", name = "bundle-install", description = "Install bundles in a cluster group")
public class InstallBundleCommand extends CellarCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/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 e836ccb..eaf1ace 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
@@ -25,7 +25,7 @@ import org.osgi.framework.BundleEvent;
import java.util.Map;
-@Command(scope = "cluster", name = "bundle-list", description = "List the bundles in a cluster group.")
+@Command(scope = "cluster", name = "bundle-list", description = "List the bundles in a cluster group")
public class ListBundleCommand extends CellarCommandSupport {
protected static final String HEADER_FORMAT = " %-4s %-11s %s";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/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 a695477..beee496 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
@@ -27,7 +27,7 @@ import org.osgi.framework.BundleEvent;
import java.util.Map;
-@Command(scope = "cluster", name = "bundle-start", description = "Start a bundle in a cluster group.")
+@Command(scope = "cluster", name = "bundle-start", description = "Start a bundle in a cluster group")
public class StartBundleCommand extends BundleCommandSupport {
private EventProducer eventProducer;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/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 86d9c6f..2f94b07 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
@@ -27,7 +27,7 @@ import org.osgi.framework.BundleEvent;
import java.util.Map;
-@Command(scope = "cluster", name = "bundle-stop", description = "Stop a bundle in a cluster group.")
+@Command(scope = "cluster", name = "bundle-stop", description = "Stop a bundle in a cluster group")
public class StopBundleCommand extends BundleCommandSupport {
private EventProducer eventProducer;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/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 3f58c0f..d48a360 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
@@ -27,7 +27,7 @@ import org.osgi.framework.BundleEvent;
import java.util.Map;
-@Command(scope = "cluster", name = "bundle-uninstall", description = "Uninstall a bundle from a cluster group.")
+@Command(scope = "cluster", name = "bundle-uninstall", description = "Uninstall a bundle from a cluster group")
public class UninstallBundleCommand extends BundleCommandSupport {
private EventProducer eventProducer;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index efd5e20..20ab5a5 100644
--- a/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -18,7 +18,7 @@
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- Local Bundle Listener -->
- <bean id="localBundleListener" class="org.apache.karaf.cellar.bundle.LocalBundleListener" init-method="init"
+ <bean id="localListener" class="org.apache.karaf.cellar.bundle.LocalBundleListener" init-method="init"
destroy-method="destroy">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/ClusterConfigurationEvent.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ClusterConfigurationEvent.java b/config/src/main/java/org/apache/karaf/cellar/config/ClusterConfigurationEvent.java
new file mode 100644
index 0000000..d3eb7ee
--- /dev/null
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ClusterConfigurationEvent.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.config;
+
+import org.apache.karaf.cellar.core.event.Event;
+
+/**
+ * Cluster configuration event.
+ */
+public class ClusterConfigurationEvent extends Event {
+
+ private int type;
+
+ public ClusterConfigurationEvent(String id) {
+ super(id);
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return "ClusterConfigurationEvent [type=" + type + ", id=" + id
+ + ", sourceNode=" + sourceNode + ", sourceGroup=" + sourceGroup
+ + ", destination=" + destination + ", force=" + force
+ + ", postPublish=" + postPublish + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
index e355dc3..1ebfde6 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
@@ -31,9 +31,9 @@ import java.util.Map;
import java.util.Properties;
/**
- * Configuration event handler.
+ * ConfigurationEventHandler handles received configuration cluster event.
*/
-public class ConfigurationEventHandler extends ConfigurationSupport implements EventHandler<RemoteConfigurationEvent> {
+public class ConfigurationEventHandler extends ConfigurationSupport implements EventHandler<ClusterConfigurationEvent> {
private static final transient Logger LOGGER = LoggerFactory.getLogger(ConfigurationEventHandler.class);
@@ -41,7 +41,8 @@ public class ConfigurationEventHandler extends ConfigurationSupport implements E
private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
- public void handle(RemoteConfigurationEvent event) {
+ @Override
+ public void handle(ClusterConfigurationEvent event) {
// check if the handler is ON
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
@@ -57,20 +58,20 @@ public class ConfigurationEventHandler extends ConfigurationSupport implements E
// check if the group is local
if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
- LOGGER.debug("CELLAR CONFIG: node is not part of the event cluster group");
+ LOGGER.debug("CELLAR CONFIG: node is not part of the event cluster group {}",event.getSourceGroup().getName());
return;
}
Group group = event.getSourceGroup();
String groupName = group.getName();
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
String pid = event.getId();
if (isAllowed(event.getSourceGroup(), Constants.CATEGORY, pid, EventType.INBOUND)) {
- Properties distributedDictionary = distributedConfigurations.get(pid);
+ Properties clusterDictionary = clusterConfigurations.get(pid);
Configuration conf;
try {
conf = configurationAdmin.getConfiguration(pid, null);
@@ -81,37 +82,37 @@ public class ConfigurationEventHandler extends ConfigurationSupport implements E
deleteStorage(pid);
}
} else {
- if (distributedDictionary != null) {
+ if (clusterDictionary != null) {
Dictionary localDictionary = conf.getProperties();
if (localDictionary == null)
localDictionary = new Properties();
localDictionary = filter(localDictionary);
- if (!equals(distributedDictionary, localDictionary)) {
- conf.update((Dictionary) distributedDictionary);
- persistConfiguration(configurationAdmin, pid, distributedDictionary);
+ if (!equals(clusterDictionary, localDictionary)) {
+ conf.update((Dictionary) clusterDictionary);
+ persistConfiguration(configurationAdmin, pid, clusterDictionary);
}
}
}
} catch (IOException ex) {
- LOGGER.error("CELLAR CONFIG: failed to read remote distributed map", ex);
+ LOGGER.error("CELLAR CONFIG: failed to read cluster configuration", ex);
}
- } else LOGGER.warn("CELLAR CONFIG: configuration with pid {} is marked as BLOCKED INBOUND", pid);
+ } else LOGGER.warn("CELLAR CONFIG: configuration PID {} is marked BLOCKED INBOUND for cluster group {}", pid, groupName);
}
- /**
- * Initialization Method.
- */
public void init() {
-
+ // nothing to do
}
- /**
- * Destruction Method.
- */
public void destroy() {
-
+ // nothing to do
}
+ /**
+ * Get the cluster configuration event handler switch.
+ *
+ * @return the cluster configuration event handler switch.
+ */
+ @Override
public Switch getSwitch() {
// load the switch status from the config
try {
@@ -125,13 +126,19 @@ public class ConfigurationEventHandler extends ConfigurationSupport implements E
}
}
} catch (Exception e) {
- // ignore
+ // nothing to do
}
return eventSwitch;
}
- public Class<RemoteConfigurationEvent> getType() {
- return RemoteConfigurationEvent.class;
+ /**
+ * Get the cluster event type.
+ *
+ * @return the cluster configuration event type.
+ */
+ @Override
+ public Class<ClusterConfigurationEvent> getType() {
+ return ClusterConfigurationEvent.class;
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
index 3113bd4..fa6f986 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
@@ -24,7 +24,7 @@ import java.net.URL;
import java.util.*;
/**
- * Configuration support.
+ * Generic configuration support.
*/
public class ConfigurationSupport extends CellarSupport {
@@ -35,10 +35,10 @@ public class ConfigurationSupport extends CellarSupport {
protected File storage;
/**
- * Reads a {@code Dictionary} object and creates a property object out of it.
+ * Read a {@code Dictionary} and create a corresponding {@code Properties}.
*
- * @param dictionary
- * @return
+ * @param dictionary the source dictionary.
+ * @return the corresponding properties.
*/
public Properties dictionaryToProperties(Dictionary dictionary) {
Properties properties = new Properties();
@@ -59,8 +59,8 @@ public class ConfigurationSupport extends CellarSupport {
/**
* Returns true if dictionaries are equal.
*
- * @param source the first dictionary
- * @param target the second dictionary
+ * @param source the source dictionary.
+ * @param target the target dictionary.
* @return true if the two dictionaries are equal, false else.
*/
protected boolean equals(Dictionary source, Dictionary target) {
@@ -98,7 +98,6 @@ public class ConfigurationSupport extends CellarSupport {
* @param dictionary the source dictionary.
* @return the filtered dictionary
*/
-
public Dictionary filter(Dictionary dictionary) {
Dictionary result = new Properties();
if (dictionary != null) {
@@ -115,10 +114,10 @@ public class ConfigurationSupport extends CellarSupport {
}
/**
- * Returns true if property is Filtered.
+ * Check if a property is in the default excluded list.
*
- * @param propertyName
- * @return
+ * @param propertyName the property name to check.
+ * @return true is the property is excluded, false else.
*/
public boolean isExcludedProperty(String propertyName) {
for (int i = 0; i < EXCLUDED_PROPERTIES.length; i++) {
@@ -131,8 +130,10 @@ public class ConfigurationSupport extends CellarSupport {
/**
* Persist a configuration to a storage.
*
- * @param pid
- * @throws Exception
+ * @param admin the configuration admin service.
+ * @param pid the configuration PID to store.
+ * @param props the properties to store, linked to the configuration PID.
+ * @throws Exception in case of store failure.
*/
protected void persistConfiguration(ConfigurationAdmin admin, String pid, Dictionary props) {
try {
@@ -188,6 +189,11 @@ public class ConfigurationSupport extends CellarSupport {
}
}
+ /**
+ * Delete the storage of a configuration.
+ *
+ * @param pid the configuration PID to delete.
+ */
protected void deleteStorage(String pid) {
File cfgFile = new File(storage, pid + ".cfg");
cfgFile.delete();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
index 3cd4fd1..a30b459 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
@@ -26,14 +26,13 @@ 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;
/**
- * Configuration synchronizer.
+ * The ConfigurationSynchronizer is called when Cellar starts or when a node joins a cluster group.
+ * The purpose is to synchronize local configurations with the configurations in the cluster groups.
*/
public class ConfigurationSynchronizer extends ConfigurationSupport implements Synchronizer {
@@ -41,16 +40,10 @@ public class ConfigurationSynchronizer extends ConfigurationSupport implements S
private EventProducer eventProducer;
- /**
- * Constructor
- */
public ConfigurationSynchronizer() {
-
+ // nothing to do
}
- /**
- * Registration method
- */
public void init() {
Set<Group> groups = groupManager.listLocalGroups();
if (groups != null && !groups.isEmpty()) {
@@ -63,44 +56,45 @@ public class ConfigurationSynchronizer extends ConfigurationSupport implements S
}
}
- /**
- * Destruction method
- */
public void destroy() {
-
+ // nothing to do
}
/**
- * Gets the configuration from the distributed map.
+ * Pull the configuration from a cluster group to update the local ones.
+ *
+ * @param group the cluster group where to get the configurations.
*/
public void pull(Group group) {
if (group != null) {
String groupName = group.getName();
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ LOGGER.debug("CELLAR CONFIG: pulling configurations from cluster group {}", groupName);
+
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- for (String pid : distributedConfigurations.keySet()) {
- if (isAllowed(group, Constants.CATEGORY, pid, EventType.INBOUND)) {
- Dictionary remoteDictionary = distributedConfigurations.get(pid);
+ for (String clusterConfiguration : clusterConfigurations.keySet()) {
+ if (isAllowed(group, Constants.CATEGORY, clusterConfiguration, EventType.INBOUND)) {
+ Dictionary clusterDictionary = clusterConfigurations.get(clusterConfiguration);
try {
// update the local configuration if needed
- Configuration conf = configurationAdmin.getConfiguration(pid, null);
- Dictionary localDictionary = conf.getProperties();
+ Configuration localConfiguration = configurationAdmin.getConfiguration(clusterConfiguration, null);
+ Dictionary localDictionary = localConfiguration.getProperties();
if (localDictionary == null)
localDictionary = new Properties();
localDictionary = filter(localDictionary);
- if (!equals(localDictionary, remoteDictionary)) {
- conf.update(localDictionary);
- persistConfiguration(configurationAdmin, pid, localDictionary);
+ if (!equals(localDictionary, clusterDictionary)) {
+ localConfiguration.update(localDictionary);
+ persistConfiguration(configurationAdmin, clusterConfiguration, localDictionary);
}
} catch (IOException ex) {
- LOGGER.error("CELLAR CONFIG: failed to read distributed map", ex);
+ LOGGER.error("CELLAR CONFIG: failed to read local configuration", ex);
}
- } else LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked as BLOCKED INBOUND", pid);
+ } else LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked BLOCKED INBOUND for cluster group {}", clusterConfiguration, groupName);
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
@@ -109,7 +103,9 @@ public class ConfigurationSynchronizer extends ConfigurationSupport implements S
}
/**
- * Publish local configuration to the cluster.
+ * Push local configurations to a cluster group.
+ *
+ * @param group the cluster group where to update the configurations.
*/
public void push(Group group) {
@@ -121,33 +117,34 @@ public class ConfigurationSynchronizer extends ConfigurationSupport implements S
if (group != null) {
String groupName = group.getName();
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ LOGGER.debug("CELLAR CONFIG: pushing configurations to cluster group {}", groupName);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- Configuration[] configs;
+ Configuration[] localConfigurations;
try {
- configs = configurationAdmin.listConfigurations(null);
- for (Configuration conf : configs) {
- String pid = conf.getPid();
+ localConfigurations = configurationAdmin.listConfigurations(null);
+ for (Configuration localConfiguration : localConfigurations) {
+ String pid = localConfiguration.getPid();
// check if the pid is marked as local.
if (isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
- Dictionary localDictionary = conf.getProperties();
+ Dictionary localDictionary = localConfiguration.getProperties();
localDictionary = filter(localDictionary);
- // update the distributed map
- distributedConfigurations.put(pid, dictionaryToProperties(localDictionary));
+ // update the configurations in the cluster group
+ clusterConfigurations.put(pid, dictionaryToProperties(localDictionary));
// broadcast the cluster event
- RemoteConfigurationEvent event = new RemoteConfigurationEvent(pid);
+ ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
eventProducer.produce(event);
} else
- LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked as BLOCKED OUTBOUND", pid);
+ LOGGER.warn("CELLAR CONFIG: configuration with PID {} is marked BLOCKED OUTBOUND for cluster group {}", pid, groupName);
}
} catch (IOException ex) {
- LOGGER.error("CELLAR CONFIG: failed to read the distributed map (IO error)", ex);
+ LOGGER.error("CELLAR CONFIG: failed to read configuration (IO error)", ex);
} catch (InvalidSyntaxException ex) {
- LOGGER.error("CELLAR CONFIG: failed to read the distributed map (invalid filter syntax)", ex);
+ LOGGER.error("CELLAR CONFIG: failed to read configuration (invalid filter syntax)", ex);
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
@@ -155,6 +152,12 @@ public class ConfigurationSynchronizer extends ConfigurationSupport implements S
}
}
+ /**
+ * Check if configuration sync flag is enabled for a cluster group.
+ *
+ * @param group the cluster group.
+ * @return true if the configuration sync flag is enabled for the cluster group, false else.
+ */
@Override
public Boolean isSyncEnabled(Group group) {
Boolean result = Boolean.FALSE;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java b/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
index e16a7c6..de4e105 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
@@ -15,22 +15,20 @@ 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.*;
/**
- * Local configuration listener.
+ * LocalConfigurationListener is listening for local configuration changes.
+ * When a local configuration change occurs, this listener updates the cluster group and broadcasts a cluster config event.
*/
public class LocalConfigurationListener extends ConfigurationSupport implements ConfigurationListener {
@@ -39,11 +37,11 @@ public class LocalConfigurationListener extends ConfigurationSupport implements
private EventProducer eventProducer;
/**
- * Handle local configuration events.
- * If the event is a pending event stop it. Else broadcast it to the cluster.
+ * Callback method called when a local configuration changes.
*
- * @param event
+ * @param event the local configuration event.
*/
+ @Override
public void configurationEvent(ConfigurationEvent event) {
// check if the producer is ON
@@ -72,56 +70,47 @@ public class LocalConfigurationListener extends ConfigurationSupport implements
// 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());
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + group.getName());
- // broadcast the cluster event
try {
if (event.getType() == ConfigurationEvent.CM_DELETED) {
- // update the distributed map
- distributedConfigurations.remove(pid);
+ // update the configurations in the cluster group
+ clusterConfigurations.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);
+ ClusterConfigurationEvent clusterConfigurationEvent = new ClusterConfigurationEvent(pid);
+ clusterConfigurationEvent.setType(ConfigurationEvent.CM_DELETED);
+ clusterConfigurationEvent.setSourceNode(clusterManager.getNode());
+ clusterConfigurationEvent.setSourceGroup(group);
+ eventProducer.produce(clusterConfigurationEvent);
} else {
localDictionary = filter(localDictionary);
- Properties distributedDictionary = distributedConfigurations.get(pid);
+ Properties distributedDictionary = clusterConfigurations.get(pid);
if (!equals(localDictionary, distributedDictionary)) {
- // update the distributed map
- distributedConfigurations.put(pid, dictionaryToProperties(localDictionary));
+ // update the configurations in the cluster group
+ clusterConfigurations.put(pid, dictionaryToProperties(localDictionary));
// broadcast the cluster event
- RemoteConfigurationEvent remoteConfigurationEvent = new RemoteConfigurationEvent(pid);
- remoteConfigurationEvent.setSourceGroup(group);
- remoteConfigurationEvent.setSourceNode(clusterManager.getNode());
- eventProducer.produce(remoteConfigurationEvent);
+ ClusterConfigurationEvent clusterConfigurationEvent = new ClusterConfigurationEvent(pid);
+ clusterConfigurationEvent.setSourceGroup(group);
+ clusterConfigurationEvent.setSourceNode(clusterManager.getNode());
+ eventProducer.produce(clusterConfigurationEvent);
}
}
} catch (Exception e) {
- LOGGER.error("CELLAR CONFIG: failed to push configuration with PID {} to the distributed map", pid, e);
+ LOGGER.error("CELLAR CONFIG: failed to update configuration with PID {} in the cluster group {}", pid, group.getName(), 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 BLOCKED OUTBOUND for cluster group {}", pid, group.getName());
}
}
}
-
- /**
- * Initialization Method.
- */
public void init() {
-
+ // nothing to do
}
- /**
- * Destruction Method.
- */
public void destroy() {
-
+ // nothing to do
}
public EventProducer getEventProducer() {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/RemoteConfigurationEvent.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/RemoteConfigurationEvent.java b/config/src/main/java/org/apache/karaf/cellar/config/RemoteConfigurationEvent.java
deleted file mode 100644
index def8443..0000000
--- a/config/src/main/java/org/apache/karaf/cellar/config/RemoteConfigurationEvent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.cellar.config;
-
-import org.apache.karaf.cellar.core.event.Event;
-
-/**
- * Remote configuration event.
- */
-public class RemoteConfigurationEvent extends Event {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private int type;
-
- public RemoteConfigurationEvent(String id) {
- super(id);
- }
-
- public int getType() {
- return type;
- }
-
- public void setType(int type) {
- this.type = type;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "RemoteConfigurationEvent [type=" + type + ", id=" + id
- + ", sourceNode=" + sourceNode + ", sourceGroup=" + sourceGroup
- + ", destination=" + destination + ", force=" + force
- + ", postPublish=" + postPublish + "]";
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/shell/ConfigCommandSupport.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/ConfigCommandSupport.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/ConfigCommandSupport.java
index 5b3c185..631a749 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/shell/ConfigCommandSupport.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/ConfigCommandSupport.java
@@ -19,10 +19,19 @@ import org.apache.karaf.cellar.core.event.EventType;
import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
/**
- * Abstract config command support.
+ * Abstract cluster config command support.
*/
public abstract class ConfigCommandSupport extends CellarCommandSupport {
+ /**
+ * Check if a configuration is allowed.
+ *
+ * @param group the cluster group.
+ * @param category the configuration category constant.
+ * @param pid the configuration PID.
+ * @param type the cluster event type.
+ * @return true if the cluster event type is allowed, false else.
+ */
public boolean isAllowed(Group group, String category, String pid, EventType type) {
CellarSupport support = new CellarSupport();
support.setClusterManager(this.clusterManager);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/shell/DeleteCommand.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/DeleteCommand.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/DeleteCommand.java
index 2fb0c2f..220dc41 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/shell/DeleteCommand.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/DeleteCommand.java
@@ -13,8 +13,8 @@
*/
package org.apache.karaf.cellar.config.shell;
+import org.apache.karaf.cellar.config.ClusterConfigurationEvent;
import org.apache.karaf.cellar.config.Constants;
-import org.apache.karaf.cellar.config.RemoteConfigurationEvent;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.control.SwitchStatus;
@@ -27,7 +27,7 @@ import org.osgi.service.cm.ConfigurationEvent;
import java.util.Map;
import java.util.Properties;
-@Command(scope = "cluster", name = "config-delete", description = "Delete a configuration from the cluster")
+@Command(scope = "cluster", name = "config-delete", description = "Delete a configuration from a cluster group")
public class DeleteCommand extends ConfigCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
@@ -55,17 +55,17 @@ public class DeleteCommand extends ConfigCommandSupport {
// check if the config pid is allowed
if (!isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
- System.err.println("Configuration PID " + pid + " is blocked outbound");
+ System.err.println("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
return null;
}
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (distributedConfigurations != null) {
- // update the distributed map
- Properties properties = distributedConfigurations.remove(pid);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ if (clusterConfigurations != null) {
+ // update configurations in the cluster group
+ clusterConfigurations.remove(pid);
// broadcast a cluster event
- RemoteConfigurationEvent event = new RemoteConfigurationEvent(pid);
+ ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
event.setType(ConfigurationEvent.CM_DELETED);
eventProducer.produce(event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java
index 652ed40..8ef55bf 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java
@@ -24,7 +24,7 @@ import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
-@Command(scope = "cluster", name = "config-list", description = "List the configuration PIDs assigned to a group")
+@Command(scope = "cluster", name = "config-list", description = "List the configurations in a cluster group")
public class ListCommand extends ConfigCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
@@ -45,15 +45,15 @@ public class ListCommand extends ConfigCommandSupport {
return null;
}
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (distributedConfigurations != null && !distributedConfigurations.isEmpty()) {
- for (String pid : distributedConfigurations.keySet()) {
+ if (clusterConfigurations != null && !clusterConfigurations.isEmpty()) {
+ for (String pid : clusterConfigurations.keySet()) {
if (searchPid == null || (searchPid != null && searchPid.equals(pid))) {
System.out.println("----------------------------------------------------------------");
System.out.println("Pid: " + pid);
if (!minimal) {
- Properties properties = distributedConfigurations.get(pid);
+ Properties properties = clusterConfigurations.get(pid);
if (properties != null) {
System.out.println("Properties:");
for (Enumeration e = properties.keys(); e.hasMoreElements(); ) {
@@ -64,7 +64,7 @@ public class ListCommand extends ConfigCommandSupport {
}
}
}
- } else System.err.println("No configuration PID found for cluster group " + groupName);
+ } else System.err.println("No configuration PID found in cluster group " + groupName);
return null;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java
index 2793a30..8cbcba0 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java
@@ -13,8 +13,8 @@
*/
package org.apache.karaf.cellar.config.shell;
+import org.apache.karaf.cellar.config.ClusterConfigurationEvent;
import org.apache.karaf.cellar.config.Constants;
-import org.apache.karaf.cellar.config.RemoteConfigurationEvent;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.control.SwitchStatus;
@@ -26,7 +26,7 @@ import org.apache.karaf.cellar.core.event.EventType;
import java.util.Map;
import java.util.Properties;
-@Command(scope = "cluster", name = "config-propappend", description = "Append to the property value for a configuration PID in a cluster group name")
+@Command(scope = "cluster", name = "config-propappend", description = "Append to the property value for a configuration PID in a cluster group")
public class PropAppendCommand extends ConfigCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
@@ -60,14 +60,14 @@ public class PropAppendCommand extends ConfigCommandSupport {
// check if the config pid is allowed
if (!isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
- System.err.println("Configuration PID " + pid + " is blocked outbound");
+ System.err.println("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
return null;
}
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (distributedConfigurations != null) {
- // update the distributed map
- Properties properties = distributedConfigurations.get(pid);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ if (clusterConfigurations != null) {
+ // update the configurations in the cluster group
+ Properties properties = clusterConfigurations.get(pid);
if (properties == null) {
properties = new Properties();
}
@@ -80,14 +80,14 @@ public class PropAppendCommand extends ConfigCommandSupport {
System.err.println("Append failed: current value is not a String");
return null;
}
- distributedConfigurations.put(pid, properties);
+ clusterConfigurations.put(pid, properties);
// broadcast the cluster event
- RemoteConfigurationEvent event = new RemoteConfigurationEvent(pid);
+ ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
- System.out.println("Configuration distributed map not found for cluster group " + groupName);
+ System.out.println("No configuration found in cluster group " + groupName);
}
return null;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/shell/PropDelCommand.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropDelCommand.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropDelCommand.java
index 8f5d073..d416949 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropDelCommand.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropDelCommand.java
@@ -16,7 +16,7 @@ package org.apache.karaf.cellar.config.shell;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.cellar.config.Constants;
-import org.apache.karaf.cellar.config.RemoteConfigurationEvent;
+import org.apache.karaf.cellar.config.ClusterConfigurationEvent;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.control.SwitchStatus;
@@ -26,7 +26,7 @@ import org.apache.karaf.cellar.core.event.EventType;
import java.util.Map;
import java.util.Properties;
-@Command(scope = "cluster", name = "config-propdel", description = "Delete a property from a configuration PID assigned to a cluster group")
+@Command(scope = "cluster", name = "config-propdel", description = "Delete a property from a configuration in a cluster group")
public class PropDelCommand extends ConfigCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
@@ -57,24 +57,25 @@ public class PropDelCommand extends ConfigCommandSupport {
// check if the configuration PID is allowed
if (!isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
- System.err.println("Configuration PID " + pid + " is blocked outbound");
+ System.err.println("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
return null;
}
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (distributedConfigurations != null) {
- // update the distributed map
- Properties distributedDictionary = distributedConfigurations.get(pid);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ if (clusterConfigurations != null) {
+ // update the configurations in the cluster group
+ Properties distributedDictionary = clusterConfigurations.get(pid);
if (distributedDictionary != null) {
distributedDictionary.remove(key);
- distributedConfigurations.put(pid, distributedDictionary);
+ clusterConfigurations.put(pid, distributedDictionary);
+
// broadcast the cluster event
- RemoteConfigurationEvent event = new RemoteConfigurationEvent(pid);
+ ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
eventProducer.produce(event);
}
} else {
- System.out.println("Configuration distributed map is not found for cluster group " + groupName);
+ System.out.println("No configuration found in cluster group " + groupName);
}
return null;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
index f629bbc..8d8d800 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
@@ -23,7 +23,7 @@ import org.apache.karaf.shell.commands.Command;
import java.util.Map;
import java.util.Properties;
-@Command(scope = "cluster", name = "config-proplist", description = "List the configuration PIDs assigned to a cluster group")
+@Command(scope = "cluster", name = "config-proplist", description = "List the configurations in a cluster group")
public class PropListCommand extends CellarCommandSupport {
protected static final String OUTPUT_FORMAT = "%-40s %s";
@@ -43,14 +43,14 @@ public class PropListCommand extends CellarCommandSupport {
return null;
}
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (distributedConfigurations != null && !distributedConfigurations.isEmpty()) {
- Properties properties = distributedConfigurations.get(pid);
+ if (clusterConfigurations != null && !clusterConfigurations.isEmpty()) {
+ Properties properties = clusterConfigurations.get(pid);
if (properties == null || properties.isEmpty()) {
- System.err.println("No configuration PID found for group " + groupName);
+ System.err.println("Configuration PID " + pid + " not found in cluster group " + groupName);
} else {
- System.out.println(String.format("Property list for configuration PID " + pid + " for group " + groupName));
+ System.out.println(String.format("Property list for configuration PID " + pid + " for cluster group " + groupName));
System.out.println(String.format(OUTPUT_FORMAT, "Key", "Value"));
for (Object key : properties.keySet()) {
@@ -58,7 +58,7 @@ public class PropListCommand extends CellarCommandSupport {
System.out.println(String.format(OUTPUT_FORMAT, key, value));
}
}
- } else System.err.println("No configuration PID found for group " + groupName);
+ } else System.err.println("No configuration found in cluster group " + groupName);
return null;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
index 8c6fce8..a3f8d4c 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
@@ -13,8 +13,8 @@
*/
package org.apache.karaf.cellar.config.shell;
+import org.apache.karaf.cellar.config.ClusterConfigurationEvent;
import org.apache.karaf.cellar.config.Constants;
-import org.apache.karaf.cellar.config.RemoteConfigurationEvent;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.control.SwitchStatus;
@@ -26,7 +26,7 @@ import org.apache.karaf.cellar.core.event.EventType;
import java.util.Map;
import java.util.Properties;
-@Command(scope = "cluster", name = "config-propset", description = "Sets the a property value for a configuration PID assigned to a cluster group")
+@Command(scope = "cluster", name = "config-propset", description = "Set a property value for a configuration in a cluster group")
public class PropSetCommand extends ConfigCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
@@ -60,26 +60,26 @@ public class PropSetCommand extends ConfigCommandSupport {
// check if the config pid is allowed
if (!isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
- System.err.println("Configuration PID " + pid + " is blocked outbound");
+ System.err.println("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
return null;
}
- Map<String, Properties> distributedConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (distributedConfigurations != null) {
- // update the distributed configuration
- Properties properties = distributedConfigurations.get(pid);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ if (clusterConfigurations != null) {
+ // update the configurations in the cluster group
+ Properties properties = clusterConfigurations.get(pid);
if (properties == null) {
properties = new Properties();
}
properties.put(key, value);
- distributedConfigurations.put(pid, properties);
+ clusterConfigurations.put(pid, properties);
// broadcast the cluster event
- RemoteConfigurationEvent event = new RemoteConfigurationEvent(pid);
+ ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
- System.out.println("Configuration distributed map not found for cluster group " + groupName);
+ System.out.println("No configuration found in cluster group " + groupName);
}
return null;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/java/org/apache/karaf/cellar/config/shell/completers/ClusterConfigCompleter.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/completers/ClusterConfigCompleter.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/completers/ClusterConfigCompleter.java
index e1a3c22..6481149 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/shell/completers/ClusterConfigCompleter.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/completers/ClusterConfigCompleter.java
@@ -26,22 +26,23 @@ import java.util.Map;
import java.util.Properties;
/**
- * Command completer on the cluster config.
+ * Command completer for the configuration from the cluster.
*/
public class ClusterConfigCompleter implements Completer {
protected ClusterManager clusterManager;
protected GroupManager groupManager;
+ @Override
public int complete(String buffer, int cursor, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
try {
Map<String, Group> groups = groupManager.listGroups();
if (groups != null && !groups.isEmpty()) {
for (String groupName : groups.keySet()) {
- Map<String, Properties> configurationTable = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
- if (configurationTable != null && !configurationTable.isEmpty()) {
- for (String pid : configurationTable.keySet()) {
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
+ if (clusterConfigurations != null && !clusterConfigurations.isEmpty()) {
+ for (String pid : clusterConfigurations.keySet()) {
if (delegate.getStrings() != null && !delegate.getStrings().contains(pid)) {
delegate.getStrings().add(pid);
}
@@ -51,7 +52,7 @@ public class ClusterConfigCompleter implements Completer {
}
} catch (Exception e) {
- // Ignore
+ // nothing to do
}
return delegate.complete(buffer, cursor, candidates);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index e5048e6..3610f4c 100644
--- a/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -28,7 +28,7 @@
">
<!-- Local Configuration Listener -->
- <bean id="configurationListener" class="org.apache.karaf.cellar.config.LocalConfigurationListener" init-method="init"
+ <bean id="localListener" class="org.apache.karaf.cellar.config.LocalConfigurationListener" init-method="init"
destroy-method="destroy">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e08a2e87/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarConfigMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarConfigMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarConfigMBeanImpl.java
index f5da71f..5be849a 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarConfigMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarConfigMBeanImpl.java
@@ -13,8 +13,8 @@
*/
package org.apache.karaf.cellar.management.internal;
+import org.apache.karaf.cellar.config.ClusterConfigurationEvent;
import org.apache.karaf.cellar.config.Constants;
-import org.apache.karaf.cellar.config.RemoteConfigurationEvent;
import org.apache.karaf.cellar.core.*;
import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
@@ -86,7 +86,7 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
Properties properties = distributedConfigurations.remove(pid);
// broadcast the cluster event
- RemoteConfigurationEvent event = new RemoteConfigurationEvent(pid);
+ ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
event.setType(ConfigurationEvent.CM_DELETED);
eventProducer.produce(event);
@@ -153,7 +153,7 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
distributedConfigurations.put(pid, properties);
// broadcast the cluster event
- RemoteConfigurationEvent event = new RemoteConfigurationEvent(pid);
+ ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
@@ -200,7 +200,7 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
distributedConfigurations.put(pid, properties);
// broadcast the cluster event
- RemoteConfigurationEvent event = new RemoteConfigurationEvent(pid);
+ ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
@@ -237,7 +237,7 @@ public class CellarConfigMBeanImpl extends StandardMBean implements CellarConfig
distributedDictionary.remove(key);
distributedConfigurations.put(pid, distributedDictionary);
// broadcast the cluster event
- RemoteConfigurationEvent event = new RemoteConfigurationEvent(pid);
+ ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
event.setSourceGroup(group);
eventProducer.produce(event);
}
[18/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1476898 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/f52c623c
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/f52c623c
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/f52c623c
Branch: refs/heads/master
Commit: f52c623c1d9d902fd6865e32a631d54738ebb68e
Parents: d0e8505
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Mon Apr 29 06:02:19 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Mon Apr 29 06:02:19 2013 +0000
----------------------------------------------------------------------
.../karaf/cellar/obr/ClusterObrBundleEvent.java | 40 +++++++++++++
.../karaf/cellar/obr/ClusterObrUrlEvent.java | 40 +++++++++++++
.../org/apache/karaf/cellar/obr/Constants.java | 2 +-
.../apache/karaf/cellar/obr/ObrBundleEvent.java | 41 --------------
.../karaf/cellar/obr/ObrBundleEventHandler.java | 22 ++++----
.../apache/karaf/cellar/obr/ObrBundleInfo.java | 2 +-
.../org/apache/karaf/cellar/obr/ObrSupport.java | 10 +++-
.../apache/karaf/cellar/obr/ObrUrlEvent.java | 41 --------------
.../karaf/cellar/obr/ObrUrlEventHandler.java | 33 +++++------
.../karaf/cellar/obr/ObrUrlSynchronizer.java | 28 ++++++----
.../cellar/obr/management/CellarOBRMBean.java | 40 ++++++++++++-
.../management/internal/CellarOBRMBeanImpl.java | 59 +++++++++++---------
.../cellar/obr/shell/ObrAddUrlCommand.java | 29 +++++-----
.../cellar/obr/shell/ObrCommandSupport.java | 13 +++++
.../cellar/obr/shell/ObrDeployCommand.java | 17 +++---
.../karaf/cellar/obr/shell/ObrListCommand.java | 12 ++--
.../cellar/obr/shell/ObrListUrlCommand.java | 16 +++---
.../cellar/obr/shell/ObrRemoveUrlCommand.java | 4 +-
.../resources/OSGI-INF/blueprint/blueprint.xml | 7 +--
.../OSGI-INF/blueprint/shell-commands.xml | 1 -
20 files changed, 258 insertions(+), 199 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/ClusterObrBundleEvent.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ClusterObrBundleEvent.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ClusterObrBundleEvent.java
new file mode 100644
index 0000000..4222ed5
--- /dev/null
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ClusterObrBundleEvent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.obr;
+
+import org.apache.karaf.cellar.core.event.Event;
+
+/**
+ * Cluster OBR bundle event.
+ */
+public class ClusterObrBundleEvent extends Event {
+
+ private String bundleId;
+ private int type;
+
+ public ClusterObrBundleEvent(String bundleId, int type) {
+ super(bundleId);
+ this.bundleId = bundleId;
+ this.type = type;
+ }
+
+ public String getBundleId() {
+ return this.bundleId;
+ }
+
+ public int getType() {
+ return this.type;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/ClusterObrUrlEvent.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ClusterObrUrlEvent.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ClusterObrUrlEvent.java
new file mode 100644
index 0000000..c1fc67f
--- /dev/null
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ClusterObrUrlEvent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.obr;
+
+import org.apache.karaf.cellar.core.event.Event;
+
+/**
+ * Cluster OBR URL event.
+ */
+public class ClusterObrUrlEvent extends Event {
+
+ private String url;
+ private int type;
+
+ public ClusterObrUrlEvent(String url, int type) {
+ super(url);
+ this.url = url;
+ this.type = type;
+ }
+
+ public String getUrl() {
+ return this.url;
+ }
+
+ public int getType() {
+ return this.type;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/Constants.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/Constants.java b/obr/src/main/java/org/apache/karaf/cellar/obr/Constants.java
index 5db4bc0..18cddff 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/Constants.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/Constants.java
@@ -14,7 +14,7 @@
package org.apache.karaf.cellar.obr;
/**
- * OBR constants
+ * Cellar OBR configuration constants.
*/
public class Constants {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEvent.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEvent.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEvent.java
deleted file mode 100644
index e31801a..0000000
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEvent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.cellar.obr;
-
-import org.apache.karaf.cellar.core.event.Event;
-import org.apache.karaf.cellar.core.event.EventType;
-
-/**
- * OBR bundle cluster event.
- */
-public class ObrBundleEvent extends Event {
-
- private String bundleId;
- private int type;
-
- public ObrBundleEvent(String bundleId, int type) {
- super(bundleId);
- this.bundleId = bundleId;
- this.type = type;
- }
-
- public String getBundleId() {
- return this.bundleId;
- }
-
- public int getType() {
- return this.type;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
index ba93c6b..ddba579 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
@@ -30,9 +30,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Bundles event handler.
+ * Handler for cluster OBR bundle event.
*/
-public class ObrBundleEventHandler extends ObrSupport implements EventHandler<ObrBundleEvent> {
+public class ObrBundleEventHandler extends ObrSupport implements EventHandler<ClusterObrBundleEvent> {
private static final transient Logger LOGGER = LoggerFactory.getLogger(ObrBundleEventHandler.class);
@@ -106,28 +106,28 @@ public class ObrBundleEventHandler extends ObrSupport implements EventHandler<Ob
}
/**
- * Process an OBR bundle event.
+ * Handle a received cluster OBR bundle event.
*
- * @param event the OBR bundle event.
+ * @param event the received cluster OBR bundle event.
*/
@Override
- public void handle(ObrBundleEvent event) {
+ public void handle(ClusterObrBundleEvent event) {
// check if the handler is ON
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR OBR: {} switch is OFF, cluster event not handled", SWITCH_ID);
+ LOGGER.warn("CELLAR OBR: {} switch is OFF", SWITCH_ID);
return;
}
if (groupManager == null) {
//in rare cases for example right after installation this happens!
- LOGGER.error("CELLAR OBR: retrieved event {} while groupManager is not available yet!", event);
+ LOGGER.error("CELLAR OBR: retrieved cluster event {} while groupManager is not available yet!", event);
return;
}
// check if the group is local
if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
- LOGGER.debug("CELLAR OBR: node is not part of the event cluster group");
+ LOGGER.debug("CELLAR OBR: node is not part of the event cluster group {}", event.getSourceGroup().getName());
return;
}
@@ -165,10 +165,12 @@ public class ObrBundleEventHandler extends ObrSupport implements EventHandler<Ob
}
}
- public Class<ObrBundleEvent> getType() {
- return ObrBundleEvent.class;
+ @Override
+ public Class<ClusterObrBundleEvent> getType() {
+ return ClusterObrBundleEvent.class;
}
+ @Override
public Switch getSwitch() {
// load the switch status from the config
try {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleInfo.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleInfo.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleInfo.java
index d0c9164..e210554 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleInfo.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleInfo.java
@@ -16,7 +16,7 @@ package org.apache.karaf.cellar.obr;
import java.io.Serializable;
/**
- * Simple wrapper class for OBR bundle information.
+ * OBR bundle info wrapper to be store in a cluster group.
*/
public class ObrBundleInfo implements Serializable {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/ObrSupport.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrSupport.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrSupport.java
index 001f348..83cb781 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrSupport.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrSupport.java
@@ -18,16 +18,20 @@ import org.apache.karaf.cellar.core.CellarSupport;
import org.osgi.framework.BundleContext;
/**
- * Cellar OBR support.
+ * Generic OBR support.
*/
public class ObrSupport extends CellarSupport {
protected BundleContext bundleContext;
protected RepositoryAdmin obrService;
- public void init() { }
+ public void init() {
+ // nothing to do
+ }
- public void destroy() { }
+ public void destroy() {
+ // nothing to do
+ }
public RepositoryAdmin getObrService() {
return this.obrService;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEvent.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEvent.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEvent.java
deleted file mode 100644
index 1378b9f..0000000
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEvent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.cellar.obr;
-
-import org.apache.karaf.cellar.core.event.Event;
-import org.apache.karaf.cellar.core.event.EventType;
-
-/**
- * OBR URLS_DISTRIBUTED_SET_NAME Event.
- */
-public class ObrUrlEvent extends Event {
-
- private String url;
- private int type;
-
- public ObrUrlEvent(String url, int type) {
- super(url);
- this.url = url;
- this.type = type;
- }
-
- public String getUrl() {
- return this.url;
- }
-
- public int getType() {
- return this.type;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
index b9d3279..2fb1d62 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlEventHandler.java
@@ -24,9 +24,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * OBR URLS_DISTRIBUTED_SET_NAME Event handler.
+ * Handler for cluster OBR URL event.
*/
-public class ObrUrlEventHandler extends ObrSupport implements EventHandler<ObrUrlEvent> {
+public class ObrUrlEventHandler extends ObrSupport implements EventHandler<ClusterObrUrlEvent> {
private static final transient Logger LOGGER = LoggerFactory.getLogger(ObrUrlEventHandler.class);
@@ -45,40 +45,39 @@ public class ObrUrlEventHandler extends ObrSupport implements EventHandler<ObrUr
}
/**
- * Process an OBR URLS_DISTRIBUTED_SET_NAME event.
+ * Handle a received cluster OBR URL event.
*
- * @param obrUrlEvent the OBR URLS_DISTRIBUTED_SET_NAME Event.
+ * @param event the received cluster OBR URL event.
*/
@Override
- public void handle(ObrUrlEvent obrUrlEvent) {
+ public void handle(ClusterObrUrlEvent event) {
// check if the handler is ON
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR OBR: {} switch is OFF, cluster event not handled", SWITCH_ID);
+ LOGGER.warn("CELLAR OBR: switch is OFF", SWITCH_ID);
return;
}
if (groupManager == null) {
//in rare cases for example right after installation this happens!
- LOGGER.error("CELLAR OBR: retrieved event {} while groupManager is not available yet!", obrUrlEvent);
+ LOGGER.error("CELLAR OBR: retrieved event {} while groupManager is not available yet!", event);
return;
}
// check if the group is local
- if (!groupManager.isLocalGroup(obrUrlEvent.getSourceGroup().getName())) {
- LOGGER.debug("CELLAR OBR: node is not part of the event cluster group");
+ if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
+ LOGGER.debug("CELLAR OBR: node is not part of the event cluster group {}", event.getSourceGroup().getName());
return;
}
- String url = obrUrlEvent.getUrl();
- String groupName = obrUrlEvent.getSourceGroup().getName();
+ String url = event.getUrl();
try {
- if (isAllowed(obrUrlEvent.getSourceGroup(), Constants.URLS_CONFIG_CATEGORY, url, EventType.INBOUND) || obrUrlEvent.getForce()) {
- if (obrUrlEvent.getType() == Constants.URL_ADD_EVENT_TYPE) {
+ if (isAllowed(event.getSourceGroup(), Constants.URLS_CONFIG_CATEGORY, url, EventType.INBOUND) || event.getForce()) {
+ if (event.getType() == Constants.URL_ADD_EVENT_TYPE) {
LOGGER.debug("CELLAR OBR: adding repository URL {}", url);
obrService.addRepository(url);
}
- if (obrUrlEvent.getType() == Constants.URL_REMOVE_EVENT_TYPE) {
+ if (event.getType() == Constants.URL_REMOVE_EVENT_TYPE) {
LOGGER.debug("CELLAR OBR: removing repository URL {}", url);
boolean removed = obrService.removeRepository(url);
if (!removed) {
@@ -91,10 +90,12 @@ public class ObrUrlEventHandler extends ObrSupport implements EventHandler<ObrUr
}
}
- public Class<ObrUrlEvent> getType() {
- return ObrUrlEvent.class;
+ @Override
+ public Class<ClusterObrUrlEvent> getType() {
+ return ClusterObrUrlEvent.class;
}
+ @Override
public Switch getSwitch() {
// load the switch status from the config
try {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
index e763f33..048d63e 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/ObrUrlSynchronizer.java
@@ -30,7 +30,7 @@ import java.util.List;
import java.util.Set;
/**
- * Bootstrap synchronizer for the OBR URLs.
+ * OBR URL Synchronizer.
*/
public class ObrUrlSynchronizer extends ObrSupport implements Synchronizer {
@@ -38,6 +38,7 @@ public class ObrUrlSynchronizer extends ObrSupport implements Synchronizer {
private List<EventProducer> producerList;
+ @Override
public void init() {
super.init();
Set<Group> groups = groupManager.listLocalGroups();
@@ -51,24 +52,26 @@ public class ObrUrlSynchronizer extends ObrSupport implements Synchronizer {
}
}
+ @Override
public void destroy() {
super.destroy();
}
/**
- * Pull the OBR URLS_DISTRIBUTED_SET_NAME from the cluster.
+ * Pull the OBR URLs from a cluster group to update the local state.
*
* @param group the cluster group.
*/
+ @Override
public void pull(Group group) {
if (group != null) {
String groupName = group.getName();
- Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- if (urls != null && !urls.isEmpty()) {
- for (String url : urls) {
+ if (clusterUrls != null && !clusterUrls.isEmpty()) {
+ for (String url : clusterUrls) {
try {
LOGGER.debug("CELLAR OBR: adding repository URL {}", url);
obrService.addRepository(url);
@@ -84,14 +87,15 @@ public class ObrUrlSynchronizer extends ObrSupport implements Synchronizer {
}
/**
- * Push the local OBR URLs to the cluster
+ * Push the local OBR URLs to a cluster group.
*
* @param group the cluster group.
*/
+ @Override
public void push(Group group) {
if (group != null) {
String groupName = group.getName();
- Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
@@ -99,17 +103,17 @@ public class ObrUrlSynchronizer extends ObrSupport implements Synchronizer {
Repository[] repositories = obrService.listRepositories();
for (Repository repository : repositories) {
if (isAllowed(group, Constants.URLS_CONFIG_CATEGORY, repository.getURI().toString(), EventType.OUTBOUND)) {
- urls.add(repository.getURI().toString());
- // push the bundles in the OBR distributed set
- Set<ObrBundleInfo> bundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ clusterUrls.add(repository.getURI().toString());
+ // update OBR bundles in the cluster group
+ Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
Resource[] resources = repository.getResources();
for (Resource resource : resources) {
ObrBundleInfo info = new ObrBundleInfo(resource.getPresentationName(), resource.getSymbolicName(), resource.getVersion().toString());
- bundles.add(info);
+ clusterBundles.add(info);
// TODO fire event to the other nodes ?
}
} else {
- LOGGER.warn("CELLAR OBR: URL " + repository.getURI().toString() + " is blocked outbound");
+ LOGGER.warn("CELLAR OBR: URL {} is blocked outbound for cluster group {}", repository.getURI().toString(), groupName);
}
}
} finally {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/management/CellarOBRMBean.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/management/CellarOBRMBean.java b/obr/src/main/java/org/apache/karaf/cellar/obr/management/CellarOBRMBean.java
index a8e322a..915e99c 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/management/CellarOBRMBean.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/management/CellarOBRMBean.java
@@ -17,15 +17,53 @@ import javax.management.openmbean.TabularData;
import java.util.List;
/**
- * MBean interface describing the operations and attributes on OBR service..
+ * Describe the operations and attributes of the Cellar OBR MBean.
*/
public interface CellarOBRMBean {
+ /**
+ * List the OBR URLs in a cluster group.
+ *
+ * @param groupName the cluster group name.
+ * @return the list of OBR URLs.
+ * @throws Exception in case of retrieval failure.
+ */
List<String> listUrls(String groupName) throws Exception;
+
+ /**
+ * List the OBR bundles in a cluster group.
+ *
+ * @param groupName the cluster group name.
+ * @return the list of OBR bundles.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData listBundles(String groupName) throws Exception;
+ /**
+ * Add an OBR URL in a cluster group.
+ *
+ * @param groupName the cluster group name.
+ * @param url the OBR URL.
+ * @throws Exception in case of add failure.
+ */
void addUrl(String groupName, String url) throws Exception;
+
+ /**
+ * Remove an OBR URL from a cluster group.
+ *
+ * @param groupName the cluster group name.
+ * @param url the OBR URL.
+ * @throws Exception in case of remove failure.
+ */
void removeUrl(String groupName, String url) throws Exception;
+
+ /**
+ * Deploy an OBR bundle in a cluster group.
+ *
+ * @param groupName the cluster group name.
+ * @param bundleId the bundle ID.
+ * @throws Exception in case of deploy failure.
+ */
void deploy(String groupName, String bundleId) throws Exception;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java b/obr/src/main/java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java
index c06e91f..2a2ac69 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/management/internal/CellarOBRMBeanImpl.java
@@ -20,10 +20,10 @@ import org.apache.karaf.cellar.core.*;
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.obr.ClusterObrBundleEvent;
+import org.apache.karaf.cellar.obr.ClusterObrUrlEvent;
import org.apache.karaf.cellar.obr.Constants;
-import org.apache.karaf.cellar.obr.ObrBundleEvent;
import org.apache.karaf.cellar.obr.ObrBundleInfo;
-import org.apache.karaf.cellar.obr.ObrUrlEvent;
import org.apache.karaf.cellar.obr.management.CellarOBRMBean;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -49,6 +49,7 @@ public class CellarOBRMBeanImpl extends StandardMBean implements CellarOBRMBean
super(CellarOBRMBean.class);
}
+ @Override
public List<String> listUrls(String groupName) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -57,13 +58,14 @@ public class CellarOBRMBeanImpl extends StandardMBean implements CellarOBRMBean
}
List<String> result = new ArrayList<String>();
- Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
- for (String url : urls) {
+ Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ for (String url : clusterUrls) {
result.add(url);
}
return result;
}
+ @Override
public TabularData listBundles(String groupName) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -82,8 +84,8 @@ public class CellarOBRMBeanImpl extends StandardMBean implements CellarOBRMBean
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- Set<ObrBundleInfo> bundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
- for (ObrBundleInfo info : bundles) {
+ Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ for (ObrBundleInfo info : clusterBundles) {
CompositeData data = new CompositeDataSupport(compositeType,
new String[]{ "name", "symbolic", "version" },
new Object[]{ info.getPresentationName(), info.getSymbolicName(), info.getVersion() });
@@ -96,6 +98,7 @@ public class CellarOBRMBeanImpl extends StandardMBean implements CellarOBRMBean
return table;
}
+ @Override
public void addUrl(String groupName, String url) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -114,31 +117,32 @@ public class CellarOBRMBeanImpl extends StandardMBean implements CellarOBRMBean
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.URLS_CONFIG_CATEGORY, url, EventType.OUTBOUND)) {
- throw new IllegalArgumentException("OBR URL " + url + " is blocked outbound");
+ throw new IllegalArgumentException("OBR URL " + url + " is blocked outbound for cluster group " + groupName);
}
- // push the OBR URL in the distributed set
- Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
- urls.add(url);
- // push the bundles in the OBR distributed set
- Set<ObrBundleInfo> bundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ // update OBR URLs in the cluster group
+ Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ clusterUrls.add(url);
+ // update OBR bundles in the cluster group
+ Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
synchronized (obrService) {
Repository repository = obrService.addRepository(url);
Resource[] resources = repository.getResources();
for (Resource resource : resources) {
ObrBundleInfo info = new ObrBundleInfo(resource.getPresentationName(), resource.getSymbolicName(), resource.getVersion().toString());
- bundles.add(info);
+ clusterBundles.add(info);
}
obrService.removeRepository(url);
}
- // create an cluster event and produce it
- ObrUrlEvent event = new ObrUrlEvent(url, Constants.URL_ADD_EVENT_TYPE);
+ // broadcast a cluster event
+ ClusterObrUrlEvent event = new ClusterObrUrlEvent(url, Constants.URL_ADD_EVENT_TYPE);
event.setForce(true);
event.setSourceGroup(group);
eventProducer.produce(event);
}
+ @Override
public void removeUrl(String groupName, String url) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -157,30 +161,31 @@ public class CellarOBRMBeanImpl extends StandardMBean implements CellarOBRMBean
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.URLS_CONFIG_CATEGORY, url, EventType.OUTBOUND)) {
- throw new IllegalArgumentException("OBR URL " + url + " is blocked outbound");
+ throw new IllegalArgumentException("OBR URL " + url + " is blocked outbound for cluster group " + groupName);
}
- // remove URL from the distributed map
- Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
- urls.remove(url);
- // remove bundles from the distributed map
- Set<ObrBundleInfo> bundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ // update the OBR URLs in the cluster group
+ Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ clusterUrls.remove(url);
+ // update the OBR bundles in the cluster group
+ Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
synchronized (obrService) {
Repository repository = obrService.addRepository(url);
Resource[] resources = repository.getResources();
for (Resource resource : resources) {
ObrBundleInfo info = new ObrBundleInfo(resource.getPresentationName(), resource.getSymbolicName(), resource.getVersion().toString());
- bundles.remove(info);
+ clusterBundles.remove(info);
}
obrService.removeRepository(url);
}
- // create an event and produce it
- ObrUrlEvent event = new ObrUrlEvent(url, Constants.URL_REMOVE_EVENT_TYPE);
+ // broadcast a cluster event
+ ClusterObrUrlEvent event = new ClusterObrUrlEvent(url, Constants.URL_REMOVE_EVENT_TYPE);
event.setSourceGroup(group);
eventProducer.produce(event);
}
+ @Override
public void deploy(String groupName, String bundleId) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -199,12 +204,12 @@ public class CellarOBRMBeanImpl extends StandardMBean implements CellarOBRMBean
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.BUNDLES_CONFIG_CATEGORY, bundleId, EventType.OUTBOUND)) {
- throw new IllegalArgumentException("OBR bundle " + bundleId + " is blocked outbound");
+ throw new IllegalArgumentException("OBR bundle " + bundleId + " is blocked outbound for cluster group " + groupName);
}
- // create an event and produce it
+ // broadcast a cluster event
int type = 0;
- ObrBundleEvent event = new ObrBundleEvent(bundleId, type);
+ ClusterObrBundleEvent event = new ClusterObrBundleEvent(bundleId, type);
event.setForce(true);
event.setSourceGroup(group);
eventProducer.produce(event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java
index 285946a..d8fade4 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java
@@ -20,25 +20,26 @@ import org.apache.karaf.cellar.core.Group;
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.obr.ClusterObrUrlEvent;
import org.apache.karaf.cellar.obr.Constants;
import org.apache.karaf.cellar.obr.ObrBundleInfo;
-import org.apache.karaf.cellar.obr.ObrUrlEvent;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import java.util.Set;
-@Command(scope = "cluster", name = "obr-add-url", description = "Register a repository URL in the distributed OBR service.")
+@Command(scope = "cluster", name = "obr-add-url", description = "Add an OBR URL in a cluster group")
public class ObrAddUrlCommand extends ObrCommandSupport {
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
- @Argument(index = 1, name = "url", description = "The repository URL to register in the OBR service.", required = true, multiValued = false)
+ @Argument(index = 1, name = "url", description = "The OBR URL.", required = true, multiValued = false)
String url;
private EventProducer eventProducer;
+ @Override
public Object doExecute() throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -49,33 +50,33 @@ public class ObrAddUrlCommand extends ObrCommandSupport {
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- System.err.println("Cluster event producer is OFF for this node");
+ System.err.println("Cluster event producer is OFF");
return null;
}
// check if the URL is allowed
if (!isAllowed(group, Constants.URLS_CONFIG_CATEGORY, url, EventType.OUTBOUND)) {
- System.err.println("OBR URL " + url + " is blocked outbound");
+ System.err.println("OBR URL " + url + " is blocked outbound for cluster group " + groupName);
return null;
}
- // push the OBR URL in the distributed set
- Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
- urls.add(url);
- // push the bundles in the OBR distributed set
- Set<ObrBundleInfo> bundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ // update the OBR URLs in the cluster group
+ Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ clusterUrls.add(url);
+ // update the OBR bundles in the cluster group
+ Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
synchronized(obrService) {
Repository repository = obrService.addRepository(url);
Resource[] resources = repository.getResources();
for (Resource resource : resources) {
ObrBundleInfo info = new ObrBundleInfo(resource.getPresentationName(),resource.getSymbolicName(), resource.getVersion().toString());
- bundles.add(info);
+ clusterBundles.add(info);
}
obrService.removeRepository(url);
}
- // broadcast the cluster event
- ObrUrlEvent event = new ObrUrlEvent(url, Constants.URL_ADD_EVENT_TYPE);
+ // broadcast a cluster event
+ ClusterObrUrlEvent event = new ClusterObrUrlEvent(url, Constants.URL_ADD_EVENT_TYPE);
event.setSourceGroup(group);
eventProducer.produce(event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrCommandSupport.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrCommandSupport.java b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrCommandSupport.java
index 413f319..5c75ad8 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrCommandSupport.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrCommandSupport.java
@@ -19,6 +19,9 @@ import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.event.EventType;
import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
+/**
+ * Generic cluster OBR shell command support.
+ */
public abstract class ObrCommandSupport extends CellarCommandSupport {
protected RepositoryAdmin obrService;
@@ -31,6 +34,15 @@ public abstract class ObrCommandSupport extends CellarCommandSupport {
this.obrService = obrService;
}
+ /**
+ * Check if an OBR cluster event is allowed.
+ *
+ * @param group the cluster group.
+ * @param category the OBR category name.
+ * @param id the event ID.
+ * @param type the event type (inbound, outbound).
+ * @return in case of check failure.
+ */
public boolean isAllowed(Group group, String category, String id, EventType type) {
CellarSupport support = new CellarSupport();
support.setClusterManager(this.clusterManager);
@@ -39,6 +51,7 @@ public abstract class ObrCommandSupport extends CellarCommandSupport {
return support.isAllowed(group, category, id, type);
}
+ @Override
public abstract Object doExecute() throws Exception;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java
index 7e36585..7c28539 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java
@@ -17,20 +17,19 @@ import org.apache.karaf.cellar.core.Group;
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.core.shell.CellarCommandSupport;
+import org.apache.karaf.cellar.obr.ClusterObrBundleEvent;
import org.apache.karaf.cellar.obr.Constants;
-import org.apache.karaf.cellar.obr.ObrBundleEvent;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
-@Command(scope = "cluster", name = "obr-deploy", description = "Deploy a bundle from the OBR assigned to a cluster group")
+@Command(scope = "cluster", name = "obr-deploy", description = "Deploy an OBR bundle in a cluster group")
public class ObrDeployCommand extends ObrCommandSupport {
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
- @Argument(index = 1, name="bundleId", description = "The bundle ID (symbolicname,version in the OBR) to deploy.", required = true, multiValued = false)
+ @Argument(index = 1, name="bundleId", description = "The bundle ID (symbolicname,version in the OBR) to deploy", required = true, multiValued = false)
String bundleId;
@Option(name = "-s", aliases = { "--start" }, description = "Start the deployed bundles.", required = false, multiValued = false)
@@ -49,20 +48,20 @@ public class ObrDeployCommand extends ObrCommandSupport {
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- System.err.println("Cluster event producer is OFF for this node");
+ System.err.println("Cluster event producer is OFF");
return null;
}
// check if the bundle is allowed
if (!isAllowed(group, Constants.BUNDLES_CONFIG_CATEGORY, bundleId, EventType.OUTBOUND)) {
- System.err.println("OBR bundle " + bundleId + " is blocked outbound");
+ System.err.println("OBR bundle " + bundleId + " is blocked outbound for cluster group " + groupName);
return null;
}
- // broadcast the cluster event
+ // broadcast a cluster event
int type = 0;
if (start) type = Constants.BUNDLE_START_EVENT_TYPE;
- ObrBundleEvent event = new ObrBundleEvent(bundleId, type);
+ ClusterObrBundleEvent event = new ClusterObrBundleEvent(bundleId, type);
event.setSourceGroup(group);
eventProducer.produce(event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java
index 6c2491f..5cba73b 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java
@@ -23,15 +23,13 @@ import org.apache.karaf.shell.commands.Command;
import java.util.Set;
-/**
- * cluster:obr-list command.
- */
-@Command(scope = "cluster", name = "obr-list", description = "List available bundles in the OBR of all nodes assigned to a cluster group")
+@Command(scope = "cluster", name = "obr-list", description = "List the OBR bundles in a cluster group")
public class ObrListCommand extends CellarCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
+ @Override
public Object doExecute() {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -43,11 +41,11 @@ public class ObrListCommand extends CellarCommandSupport {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- Set<ObrBundleInfo> bundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
int maxPName = 4;
int maxSName = 13;
int maxVersion = 7;
- for (ObrBundleInfo bundle : bundles) {
+ for (ObrBundleInfo bundle : clusterBundles) {
maxPName = Math.max(maxPName, emptyIfNull(bundle.getPresentationName()).length());
maxSName = Math.max(maxSName, emptyIfNull(bundle.getSymbolicName()).length());
maxVersion = Math.max(maxVersion, emptyIfNull(bundle.getVersion()).length());
@@ -55,7 +53,7 @@ public class ObrListCommand extends CellarCommandSupport {
String formatHeader = " %-" + maxPName + "s %-" + maxSName + "s %-" + maxVersion + "s";
String formatLine = "[%-" + maxPName + "s] [%-" + maxSName + "s] [%-" + maxVersion + "s]";
System.out.println(String.format(formatHeader, "NAME", "SYMBOLIC NAME", "VERSION"));
- for (ObrBundleInfo bundle : bundles) {
+ for (ObrBundleInfo bundle : clusterBundles) {
System.out.println(String.format(formatLine, emptyIfNull(bundle.getPresentationName()), emptyIfNull(bundle.getSymbolicName()), emptyIfNull(bundle.getVersion())));
}
} finally {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java
index 7120e11..b5c4031 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java
@@ -22,27 +22,25 @@ import org.apache.karaf.shell.commands.Command;
import java.util.Set;
-/**
- * cluster:obr-list command
- */
-@Command(scope = "cluster", name = "obr-list-url", description = "List repository URLs defined in the distributed OBR service assigned to a given group")
+@Command(scope = "cluster", name = "obr-list-url", description = "List the OBR URLs in a cluster group")
public class ObrListUrlCommand extends CellarCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
+ @Override
public Object doExecute() throws Exception {
- // cehck if the group exists
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
- // get the URLs from the distribution set
- Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
- if (urls != null) {
- for (String url : urls) {
+ // get the OBR URLs in a cluster group
+ Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
+ if (clusterUrls != null) {
+ for (String url : clusterUrls) {
System.out.println(url);
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java
index aa5d465..c7a2fe9 100644
--- a/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java
+++ b/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java
@@ -20,9 +20,9 @@ import org.apache.karaf.cellar.core.Group;
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.obr.ClusterObrUrlEvent;
import org.apache.karaf.cellar.obr.Constants;
import org.apache.karaf.cellar.obr.ObrBundleInfo;
-import org.apache.karaf.cellar.obr.ObrUrlEvent;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
@@ -75,7 +75,7 @@ public class ObrRemoveUrlCommand extends ObrCommandSupport {
}
// create an event and produce it
- ObrUrlEvent event = new ObrUrlEvent(url, Constants.URL_REMOVE_EVENT_TYPE);
+ ClusterObrUrlEvent event = new ClusterObrUrlEvent(url, Constants.URL_REMOVE_EVENT_TYPE);
event.setSourceGroup(group);
eventProducer.produce(event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/obr/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/obr/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 7b063b1..f98fb97 100644
--- a/obr/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/obr/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -14,7 +14,7 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <!-- OBR Bundles Event Handler -->
+ <!-- Cluster OBR Bundle Event Handler -->
<bean id="obrBundleEventHandler" class="org.apache.karaf.cellar.obr.ObrBundleEventHandler"
init-method="init" destroy-method="destroy">
<property name="obrService" ref="repositoryAdmin"/>
@@ -28,7 +28,7 @@
</service-properties>
</service>
- <!-- OBR URLS_DISTRIBUTED_SET_NAME Synchronizer -->
+ <!-- OBR URLs Synchronizer -->
<bean id="obrUrlSynchronizer" class="org.apache.karaf.cellar.obr.ObrUrlSynchronizer"
init-method="init" destroy-method="destroy">
<property name="obrService" ref="repositoryAdmin"/>
@@ -39,7 +39,7 @@
</bean>
<service ref="obrUrlSynchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
- <!-- OBR URLS_DISTRIBUTED_SET_NAME Event Handler -->
+ <!-- Cluster OBR URL Event Handler -->
<bean id="obrUrlEventHandler" class="org.apache.karaf.cellar.obr.ObrUrlEventHandler"
init-method="init" destroy-method="destroy">
<property name="obrService" ref="repositoryAdmin"/>
@@ -53,7 +53,6 @@
</service-properties>
</service>
- <!-- service references -->
<reference id="repositoryAdmin" interface="org.apache.felix.bundlerepository.RepositoryAdmin"/>
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f52c623c/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
----------------------------------------------------------------------
diff --git a/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml b/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
index 736164a..894d1fa 100644
--- a/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
+++ b/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
@@ -14,7 +14,6 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
- <!-- Command Bundle -->
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
<command name="cluster/obr-list">
<action class="org.apache.karaf.cellar.obr.shell.ObrListCommand">
[49/50] [abbrv] git commit: [KARAF-2432] Remove the dependency
attribute on the hazelcast bundle
Posted by jb...@apache.org.
[KARAF-2432] Remove the dependency attribute on the hazelcast bundle
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1531351 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/81978af2
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/81978af2
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/81978af2
Branch: refs/heads/master
Commit: 81978af23f48059fb7ce6b63b59dc5d5c2a24e86
Parents: 5fe6583
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Fri Oct 11 16:53:17 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Fri Oct 11 16:53:17 2013 +0000
----------------------------------------------------------------------
assembly/src/main/resources/features.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/81978af2/assembly/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/features.xml b/assembly/src/main/resources/features.xml
index 851ca92..62d3ca2 100644
--- a/assembly/src/main/resources/features.xml
+++ b/assembly/src/main/resources/features.xml
@@ -32,7 +32,7 @@
<configfile finalname="/etc/hazelcast.xml">
mvn:org.apache.karaf.cellar/apache-karaf-cellar/${project.version}/xml/hazelcast
</configfile>
- <bundle start-level="32" dependency="true">mvn:com.hazelcast/hazelcast/${hazelcast.version}</bundle>
+ <bundle start-level="32">mvn:com.hazelcast/hazelcast/${hazelcast.version}</bundle>
</feature>
<feature name="cellar-hazelcast" description="Cellar implementation based on Hazelcast" version="${project.version}" resolver="(obr)">
@@ -97,7 +97,7 @@
<feature version="${jclouds.version}">jclouds</feature>
<!-- Adding S3 as the default Blobstore -->
<feature>jclouds-aws-s3</feature>
- <bundle dependency="true">mvn:joda-time/joda-time/${joda-time.version}</bundle>
+ <bundle>mvn:joda-time/joda-time/${joda-time.version}</bundle>
<bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.cloud/${project.version}</bundle>
</feature>
[31/50] [abbrv] git commit: [KARAF-2272] Populate the bundle name in
the cluster
Posted by jb...@apache.org.
[KARAF-2272] Populate the bundle name in the cluster
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1484061 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/9020e910
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/9020e910
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/9020e910
Branch: refs/heads/master
Commit: 9020e91045960eaf673eb097c4becce4d360f975
Parents: 33ab36c
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Sat May 18 06:24:24 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Sat May 18 06:24:24 2013 +0000
----------------------------------------------------------------------
.../org/apache/karaf/cellar/bundle/BundleSynchronizer.java | 8 ++++++++
.../org/apache/karaf/cellar/bundle/LocalBundleListener.java | 5 +++++
.../karaf/cellar/bundle/shell/InstallBundleCommand.java | 3 +++
.../apache/karaf/cellar/bundle/shell/ListBundleCommand.java | 1 +
.../cellar/management/internal/CellarBundleMBeanImpl.java | 7 +++++++
.../cellar/management/internal/CellarFeaturesMBeanImpl.java | 1 +
6 files changed, 25 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9020e910/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 4114ce5..100ebd3 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
@@ -143,6 +143,14 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
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) ? bundle.getSymbolicName() : name;
+ // if there is no symbolic name, resort to location.
+ name = (name == null) ? bundle.getLocation() : name;
+ bundleState.setName(name);
+ bundleState.setName(bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME));
bundleState.setLocation(bundleLocation);
if (status == Bundle.ACTIVE)
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9020e910/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 cba2f83..ddbb6fb 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
@@ -69,7 +69,12 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun
if (groups != null && !groups.isEmpty()) {
for (Group group : groups) {
+ // get the bundle name or location.
String name = (String) event.getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_NAME);
+ // if there is no name, then default to symbolic name.
+ name = (name == null) ? event.getBundle().getSymbolicName() : name;
+ // if there is no symbolic name, resort to location.
+ name = (name == null) ? event.getBundle().getLocation() : name;
String symbolicName = event.getBundle().getSymbolicName();
String version = event.getBundle().getVersion().toString();
String bundleLocation = event.getBundle().getLocation();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9020e910/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 81ebc46..e6712fc 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
@@ -80,6 +80,9 @@ public class InstallBundleCommand extends CellarCommandSupport {
if (name == null) {
name = symbolicName;
}
+ if (name == null) {
+ name = url;
+ }
String version = manifest.getMainAttributes().getValue("Bundle-Version");
jarInputStream.close();
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9020e910/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 eaf1ace..6af87ec 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
@@ -70,6 +70,7 @@ public class ListBundleCommand extends CellarCommandSupport {
version = "";
}
BundleState state = clusterBundles.get(bundle);
+
String status;
switch (state.getStatus()) {
case BundleEvent.INSTALLED:
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9020e910/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
index 1f88d06..e087146 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
@@ -106,6 +106,12 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
JarInputStream jarInputStream = new JarInputStream(new URL(location).openStream());
Manifest manifest = jarInputStream.getManifest();
String name = manifest.getMainAttributes().getValue("Bundle-SymbolicName");
+ if (name == null) {
+ name = manifest.getMainAttributes().getValue("Bundle-SymbolicName");
+ }
+ if (name == null) {
+ name = location;
+ }
String version = manifest.getMainAttributes().getValue("Bundle-Version");
jarInputStream.close();
@@ -115,6 +121,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
// update the cluster group
Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
BundleState state = new BundleState();
+ state.setName(name);
state.setLocation(location);
state.setStatus(BundleEvent.INSTALLED);
clusterBundles.put(name + "/" + version, state);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9020e910/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
index c5bfac3..b75c149 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
@@ -145,6 +145,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
// update the cluster group
clusterFeatures.put(feature, true);
try {
+ // TODO does it make sense ?
List<BundleInfo> bundles = featuresService.getFeature(feature.getName(), version).getBundles();
Map<String, BundleState> clusterBundles = clusterManager.getMap(org.apache.karaf.cellar.bundle.Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
for (BundleInfo bundle : bundles) {
[36/50] [abbrv] git commit: [KARAF-2340] Cellar LocalBundleListener
now ignores the local bundle event coming from the framework (bundle ID 0)
Posted by jb...@apache.org.
[KARAF-2340] Cellar LocalBundleListener now ignores the local bundle event coming from the framework (bundle ID 0)
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1490170 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/7ea3c3a4
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/7ea3c3a4
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/7ea3c3a4
Branch: refs/heads/master
Commit: 7ea3c3a4846d480052719e85057bb4c52f1be7ec
Parents: 96aa817
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu Jun 6 06:45:25 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu Jun 6 06:45:25 2013 +0000
----------------------------------------------------------------------
.../java/org/apache/karaf/cellar/bundle/LocalBundleListener.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/7ea3c3a4/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 ddbb6fb..71df359 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
@@ -52,6 +52,10 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun
return;
}
+ if (event.getBundle().getBundleId() == 0) {
+ return;
+ }
+
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
LOGGER.warn("CELLAR BUNDLE: cluster event producer is OFF");
[44/50] [abbrv] git commit: [KARAF-2478] Producer and consumer status
is updated when configuration is changed on the cluster
Posted by jb...@apache.org.
[KARAF-2478] Producer and consumer status is updated when configuration is changed on the cluster
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1528803 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/3ebb1d4a
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/3ebb1d4a
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/3ebb1d4a
Branch: refs/heads/master
Commit: 3ebb1d4a79b54637f2b98ea8514253e9b063db86
Parents: 0dda146
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu Oct 3 10:51:27 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu Oct 3 10:51:27 2013 +0000
----------------------------------------------------------------------
.../hazelcast/HazelcastEventTransportFactory.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3ebb1d4a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastEventTransportFactory.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastEventTransportFactory.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastEventTransportFactory.java
index e39ce36..78f7f50 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastEventTransportFactory.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastEventTransportFactory.java
@@ -20,6 +20,7 @@ import org.apache.karaf.cellar.core.event.EventConsumer;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.event.EventTransportFactory;
import org.apache.karaf.cellar.core.utils.CombinedClassLoader;
+import org.osgi.service.cm.ConfigurationAdmin;
/**
* An event transport factory powered by Hazelcast.
@@ -28,6 +29,7 @@ public class HazelcastEventTransportFactory extends HazelcastInstanceAware imple
private Dispatcher dispatcher;
private CombinedClassLoader combinedClassLoader;
+ private ConfigurationAdmin configurationAdmin;
@Override
public EventProducer getEventProducer(String name, Boolean pubsub) {
@@ -37,6 +39,7 @@ public class HazelcastEventTransportFactory extends HazelcastInstanceAware imple
producer.setInstance(instance);
producer.setTopic(topic);
producer.setNode(getNode());
+ producer.setConfigurationAdmin(configurationAdmin);
producer.init();
return producer;
} else {
@@ -44,6 +47,7 @@ public class HazelcastEventTransportFactory extends HazelcastInstanceAware imple
QueueProducer producer = new QueueProducer();
producer.setQueue(queue);
producer.setNode(getNode());
+ producer.setConfigurationAdmin(configurationAdmin);
producer.init();
return producer;
}
@@ -58,6 +62,7 @@ public class HazelcastEventTransportFactory extends HazelcastInstanceAware imple
consumer.setInstance(instance);
consumer.setNode(getNode());
consumer.setDispatcher(dispatcher);
+ consumer.setConfigurationAdmin(configurationAdmin);
consumer.init();
return consumer;
} else {
@@ -67,6 +72,7 @@ public class HazelcastEventTransportFactory extends HazelcastInstanceAware imple
consumer.setQueue(queue);
consumer.setNode(getNode());
consumer.setDispatcher(dispatcher);
+ consumer.setConfigurationAdmin(configurationAdmin);
consumer.init();
return consumer;
}
@@ -88,4 +94,12 @@ public class HazelcastEventTransportFactory extends HazelcastInstanceAware imple
this.combinedClassLoader = combinedClassLoader;
}
+ public ConfigurationAdmin getConfigurationAdmin() {
+ return configurationAdmin;
+ }
+
+ public void setConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
+ this.configurationAdmin = configurationAdmin;
+ }
+
}
[50/50] [abbrv] git commit: Merge branch 'trunk'
Posted by jb...@apache.org.
Merge branch 'trunk'
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/0e15a67b
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/0e15a67b
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/0e15a67b
Branch: refs/heads/master
Commit: 0e15a67b21662784d93a34546dc5c60e690295f4
Parents: e4609aa 81978af
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Wed Dec 18 13:21:44 2013 +0100
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Wed Dec 18 13:21:44 2013 +0100
----------------------------------------------------------------------
----------------------------------------------------------------------
[11/50] [abbrv] git commit: Remove empty folder.
Posted by jb...@apache.org.
Remove empty folder.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471406 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/4574b219
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/4574b219
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/4574b219
Branch: refs/heads/master
Commit: 4574b219e7aa36cab98fca143893e03e80caf64f
Parents: 3b641e4
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed Apr 24 13:30:54 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed Apr 24 13:30:54 2013 +0000
----------------------------------------------------------------------
----------------------------------------------------------------------
[02/50] [abbrv] git commit: Cellar code cleanup
Posted by jb...@apache.org.
Cellar code cleanup
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1470942 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/4643c138
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/4643c138
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/4643c138
Branch: refs/heads/master
Commit: 4643c13875dbf580f6ee5bfc280daf71370a7b52
Parents: 8888367
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Apr 23 13:19:33 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Apr 23 13:19:33 2013 +0000
----------------------------------------------------------------------
.../karaf/cellar/bundle/BundleEventHandler.java | 36 ++++----
.../apache/karaf/cellar/bundle/BundleState.java | 3 +
.../karaf/cellar/bundle/BundleSupport.java | 94 +++++++++-----------
.../karaf/cellar/bundle/BundleSynchronizer.java | 52 ++++++-----
.../karaf/cellar/bundle/ClusterBundleEvent.java | 65 ++++++++++++++
.../apache/karaf/cellar/bundle/Constants.java | 3 +
.../cellar/bundle/LocalBundleListener.java | 39 ++++----
.../karaf/cellar/bundle/RemoteBundleEvent.java | 65 --------------
.../bundle/shell/BundleCommandSupport.java | 20 ++---
.../bundle/shell/InstallBundleCommand.java | 14 +--
.../cellar/bundle/shell/ListBundleCommand.java | 16 ++--
.../cellar/bundle/shell/StartBundleCommand.java | 18 ++--
.../cellar/bundle/shell/StopBundleCommand.java | 20 ++---
.../bundle/shell/UninstallBundleCommand.java | 20 ++---
.../resources/OSGI-INF/blueprint/blueprint.xml | 3 +-
.../internal/CellarBundleMBeanImpl.java | 12 ++-
16 files changed, 238 insertions(+), 242 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/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 2f0c6f6..e7f3443 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,6 @@ 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.apache.karaf.features.FeaturesService;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
import org.osgi.service.cm.Configuration;
@@ -28,9 +27,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
-import java.util.Map;
-public class BundleEventHandler extends BundleSupport implements EventHandler<RemoteBundleEvent> {
+/**
+ * The BundleEventHandler is responsible to process received cluster event for bundles.
+ */
+public class BundleEventHandler extends BundleSupport implements EventHandler<ClusterBundleEvent> {
private static final transient Logger LOGGER = LoggerFactory.getLogger(BundleEventHandler.class);
@@ -39,11 +40,12 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Re
private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
/**
- * Handles remote bundle events.
+ * Handle received bundle cluster events.
*
- * @param event
+ * @param event the received bundle cluster event.
*/
- public void handle(RemoteBundleEvent event) {
+ @Override
+ public void handle(ClusterBundleEvent event) {
// check if the handler switch is ON
if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
@@ -64,13 +66,13 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Re
}
try {
- //Check if the pid is marked as local.
+ // check if the pid is marked as local.
if (isAllowed(event.getSourceGroup(), Constants.CATEGORY, event.getLocation(), EventType.INBOUND)) {
- //check the features first
+ // check the features first
List<Feature> matchingFeatures = retrieveFeature(event.getLocation());
for (Feature feature : matchingFeatures) {
if (!isAllowed(event.getSourceGroup(), "features", feature.getName(), EventType.INBOUND)) {
- LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in a feature marked as BLOCKED INBOUND", event.getLocation());
+ LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in the feature {} marked as BLOCKED INBOUND for cluster group {}", event.getLocation(), feature.getName(), event.getSourceGroup());
return;
}
}
@@ -98,20 +100,15 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Re
}
}
- /**
- * Initialization Method.
- */
public void init() {
-
+ // nothing to do
}
- /**
- * Destruction Method.
- */
public void destroy() {
-
+ // nothing to do
}
+ @Override
public Switch getSwitch() {
// load the switch status from the config
try {
@@ -130,8 +127,9 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Re
return eventSwitch;
}
- public Class<RemoteBundleEvent> getType() {
- return RemoteBundleEvent.class;
+ @Override
+ public Class<ClusterBundleEvent> getType() {
+ return ClusterBundleEvent.class;
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleState.java
----------------------------------------------------------------------
diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleState.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleState.java
index 3d37118..64f287f 100644
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleState.java
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleState.java
@@ -15,6 +15,9 @@ package org.apache.karaf.cellar.bundle;
import java.io.Serializable;
+/**
+ * Serializable wrapper to store and transport bundle state.
+ */
public class BundleState implements Serializable {
private static final long serialVersionUID = 5933673686648413918L;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/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 befcd15..796a4f0 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
@@ -28,17 +28,21 @@ import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
+/**
+ * Generic Cellar bundle support.
+ */
public class BundleSupport extends CellarSupport {
protected BundleContext bundleContext;
private FeaturesService featuresService;
/**
- * Reads a {@code Dictionary} object and creates a property object out of it.
+ * Read a {@code Dictionary} and create a {@code Properties}.
*
- * @param dictionary
- * @return
+ * @param dictionary the {@code Dictionary} to read.
+ * @return the {@code Properties} corresponding to the {@code Dictionary}.
*/
+ /*
public Properties dictionaryToProperties(Dictionary dictionary) {
Properties properties = new Properties();
if (dictionary != null && dictionary.keys() != null) {
@@ -53,21 +57,24 @@ public class BundleSupport extends CellarSupport {
}
return properties;
}
-
+ */
/**
- * Installs a bundle using its location.
+ * Locally install a bundle.
+ *
+ * @param location the bundle location.
+ * @throws BundleException in case of installation failure.
*/
public void installBundleFromLocation(String location) throws BundleException {
getBundleContext().installBundle(location);
}
/**
- * Uninstalls a bundle using its Symbolic name and version.
+ * Locally uninstall a bundle.
*
- * @param symbolicName
- * @param version
- * @throws BundleException
+ * @param symbolicName the bundle symbolic name.
+ * @param version the bundle version.
+ * @throws BundleException in case of un-installation failure.
*/
public void uninstallBundle(String symbolicName, String version) throws BundleException {
Bundle[] bundles = getBundleContext().getBundles();
@@ -81,11 +88,11 @@ public class BundleSupport extends CellarSupport {
}
/**
- * Starts a bundle using its Symbolic name and version.
+ * Locally start a bundle.
*
- * @param symbolicName
- * @param version
- * @throws BundleException
+ * @param symbolicName the bundle symbolic name.
+ * @param version the bundle version.
+ * @throws BundleException in case of start failure.
*/
public void startBundle(String symbolicName, String version) throws BundleException {
Bundle[] bundles = getBundleContext().getBundles();
@@ -99,11 +106,11 @@ public class BundleSupport extends CellarSupport {
}
/**
- * Stops a bundle using its Symbolic name and version.
+ * Locally stop a bundle.
*
- * @param symbolicName
- * @param version
- * @throws BundleException
+ * @param symbolicName the bundle symbolic name.
+ * @param version the bundle version.
+ * @throws BundleException in case of stop failure.
*/
public void stopBundle(String symbolicName, String version) throws BundleException {
Bundle[] bundles = getBundleContext().getBundles();
@@ -117,11 +124,11 @@ public class BundleSupport extends CellarSupport {
}
/**
- * Updates a bundle using its Symbolic name and version.
+ * Locally update a bundle.
*
- * @param symbolicName
- * @param version
- * @throws BundleException
+ * @param symbolicName the bundle symbolic name.
+ * @param version the bundle version.
+ * @throws BundleException in case of update failure.
*/
public void updateBundle(String symbolicName, String version) throws BundleException {
Bundle[] bundles = getBundleContext().getBundles();
@@ -135,31 +142,12 @@ public class BundleSupport extends CellarSupport {
}
/**
- * Returns the {@link BundleContext}.
- *
- * @return
- */
- public BundleContext getBundleContext() {
- return this.bundleContext;
- }
-
- /**
- * Sets the {@link BundleContext}.
+ * Get the list of features where the bundle is belonging.
*
- * @param bundleContext
+ * @param bundleLocation the bundle location.
+ * @return the list of feature where the bundle is present.
+ * @throws Exception in case of retrieval failure.
*/
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public ConfigurationAdmin getConfigurationAdmin() {
- return configurationAdmin;
- }
-
- public void setConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
- this.configurationAdmin = configurationAdmin;
- }
-
protected List<Feature> retrieveFeature(String bundleLocation) throws Exception {
Feature[] features = featuresService.listFeatures();
List<Feature> matchingFeatures = new ArrayList<Feature>();
@@ -169,23 +157,25 @@ public class BundleSupport extends CellarSupport {
String location = bundleInfo.getLocation();
if (location.equalsIgnoreCase(bundleLocation)) {
matchingFeatures.add(feature);
- LOGGER.debug("CELLAR BUNDLE: found a feature {} containing bundle: {}", feature.getName(), bundleLocation);
+ LOGGER.debug("CELLAR BUNDLE: found a feature {} containing bundle {}", feature.getName(), bundleLocation);
}
}
}
return matchingFeatures;
}
-
- /**
- * @return the featuresService
- */
+
+ public BundleContext getBundleContext() {
+ return this.bundleContext;
+ }
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
public FeaturesService getFeaturesService() {
return featuresService;
}
- /**
- * @param featuresService the featuresService to set
- */
public void setFeaturesService(FeaturesService featureService) {
this.featuresService = featureService;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/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 a93602b..9957ee8 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
@@ -30,19 +30,19 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Dictionary;
-import java.util.List;
import java.util.Map;
import java.util.Set;
+/**
+ * The BundleSynchronizer is called when Cellar starts or a node join a cluster group.
+ * The purpose is synchronize bundles local state with the states in cluster groups.
+ */
public class BundleSynchronizer extends BundleSupport implements Synchronizer {
private static final transient Logger LOGGER = LoggerFactory.getLogger(BundleSynchronizer.class);
private EventProducer eventProducer;
- /**
- * Registration method
- */
public void init() {
Set<Group> groups = groupManager.listLocalGroups();
if (groups != null && !groups.isEmpty()) {
@@ -50,30 +50,32 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
if (isSyncEnabled(group)) {
pull(group);
push(group);
- } else LOGGER.warn("CELLAR BUNDLE: sync is disabled for group {}", group.getName());
+ } else LOGGER.warn("CELLAR BUNDLE: sync is disabled for cluster group {}", group.getName());
}
}
}
- /**
- * Destruction method
- */
public void destroy() {
-
+ // nothing to do
}
/**
- * Get the bundle to install from the distributed map
+ * Pull the bundles states from a cluster group.
+ *
+ * @param group the cluster group where to get the bundles states.
*/
+ @Override
public void pull(Group group) {
if (group != null) {
String groupName = group.getName();
- Map<String, BundleState> bundleDistributedMap = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ LOGGER.debug("CELLAR BUNDLE: pulling bundles from cluster group {}", groupName);
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- for (Map.Entry<String, BundleState> entry : bundleDistributedMap.entrySet()) {
+ for (Map.Entry<String, BundleState> entry : clusterBundles.entrySet()) {
String id = entry.getKey();
BundleState state = entry.getValue();
@@ -94,7 +96,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
} catch (BundleException e) {
LOGGER.error("CELLAR BUNDLE: failed to pull bundle {}", id, e);
}
- } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED INBOUND", bundleLocation);
+ } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED INBOUND for cluster group {}", bundleLocation, groupName);
}
}
}
@@ -105,8 +107,11 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
}
/**
- * Publishes local bundle to the cluster.
+ * Push local bundles states to a cluster group.
+ *
+ * @param group the cluster group where to update the bundles states.
*/
+ @Override
public void push(Group group) {
// check if the producer is ON
@@ -117,7 +122,8 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
if (group != null) {
String groupName = group.getName();
- Map<String, BundleState> distributedBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ LOGGER.debug("CELLAR BUNDLE: pushing bundles to cluster group {}", groupName);
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
@@ -133,7 +139,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
int status = bundle.getState();
String id = symbolicName + "/" + version;
- //Check if the pid is marked as local.
+ // check if the pid is marked as local.
if (isAllowed(group, Constants.CATEGORY, bundleLocation, EventType.OUTBOUND)) {
BundleState bundleState = new BundleState();
@@ -154,21 +160,21 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
bundleState.setStatus(status);
- BundleState existingState = distributedBundles.get(id);
+ BundleState existingState = clusterBundles.get(id);
if (existingState == null ||
!existingState.getLocation().equals(bundleState.getLocation()) ||
existingState.getStatus() != bundleState.getStatus()) {
// update the distributed map
- distributedBundles.put(id, bundleState);
+ clusterBundles.put(id, bundleState);
// broadcast the event
- RemoteBundleEvent event = new RemoteBundleEvent(symbolicName, version, bundleLocation, status);
+ ClusterBundleEvent event = new ClusterBundleEvent(symbolicName, version, bundleLocation, status);
event.setSourceGroup(group);
eventProducer.produce(event);
}
- } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED OUTBOUND", bundleLocation);
+ } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED OUTBOUND for cluster group {}", bundleLocation, groupName);
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
@@ -176,6 +182,12 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
}
}
+ /**
+ * Check if the bundle sync flag is enabled for a cluster group.
+ *
+ * @param group the cluster group to check.
+ * @return true if the sync flag is enabled, false else.
+ */
@Override
public Boolean isSyncEnabled(Group group) {
Boolean result = Boolean.FALSE;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java
----------------------------------------------------------------------
diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java
new file mode 100644
index 0000000..d551001
--- /dev/null
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.bundle;
+
+import org.apache.karaf.cellar.core.event.Event;
+
+public class ClusterBundleEvent extends Event {
+
+ private String symbolicName;
+ private String version;
+ private String location;
+ private int type;
+
+ public ClusterBundleEvent(String symbolicName, String version, String location, int type) {
+ super(symbolicName + "/" + version);
+ this.symbolicName = symbolicName;
+ this.version = version;
+ this.location = location;
+ this.type = type;
+ }
+
+ public String getSymbolicName() {
+ return symbolicName;
+ }
+
+ public void setSymbolicName(String symbolicName) {
+ this.symbolicName = symbolicName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/bundle/src/main/java/org/apache/karaf/cellar/bundle/Constants.java
----------------------------------------------------------------------
diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/Constants.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/Constants.java
index 95113dc..643acfa 100644
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/Constants.java
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/Constants.java
@@ -13,6 +13,9 @@
*/
package org.apache.karaf.cellar.bundle;
+/**
+ * Cellar bundle constants.
+ */
public class Constants {
public static final String CATEGORY = "bundle";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/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 e8872c7..79deee4 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
@@ -15,13 +15,11 @@ 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;
import org.apache.karaf.features.Feature;
import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
import org.osgi.framework.SynchronousBundleListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,6 +28,10 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+/**
+ * LocalBundleListener is listening for local bundles changes.
+ * When a local bundle change occurs, this listener updates the cluster and broadcast a cluster bundle event.
+ */
public class LocalBundleListener extends BundleSupport implements SynchronousBundleListener {
private static final transient Logger LOGGER = LoggerFactory.getLogger(LocalBundleListener.class);
@@ -37,14 +39,15 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun
private EventProducer eventProducer;
/**
- * Process {@link BundleEvent}s.
+ * Callback method called when a local bundle status change.
*
- * @param event
+ * @param event the local bundle event.
*/
+ @Override
public void bundleChanged(BundleEvent event) {
if (event.getBundle().getBundleId() == 0 && (event.getType() == BundleEvent.STOPPING || event.getType() == BundleEvent.STOPPED)) {
- LOGGER.debug("CELLAR BUNDLE: remove LocalBundleListener");
+ LOGGER.debug("CELLAR BUNDLE: Karaf shutdown detected, removing Cellar LocalBundleListener");
bundleContext.removeBundleListener(this);
return;
}
@@ -78,56 +81,50 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
- // update the cluster map
- Map<String, BundleState> bundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + group.getName());
+ // update bundles in the cluster group
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + group.getName());
if (type == BundleEvent.UNINSTALLED) {
- bundles.remove(symbolicName + "/" + version);
+ clusterBundles.remove(symbolicName + "/" + version);
} else {
- BundleState state = bundles.get(symbolicName + "/" + version);
+ BundleState state = clusterBundles.get(symbolicName + "/" + version);
if (state == null) {
state = new BundleState();
}
state.setName(name);
state.setStatus(type);
state.setLocation(bundleLocation);
- bundles.put(symbolicName + "/" + version, state);
+ clusterBundles.put(symbolicName + "/" + version, state);
}
// check the features first
List<Feature> matchingFeatures = retrieveFeature(bundleLocation);
for (Feature feature : matchingFeatures) {
if (!isAllowed(group, "features", feature.getName(), EventType.OUTBOUND)) {
- LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in a feature marked as BLOCKED OUTBOUND", bundleLocation);
+ LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in the feature {} marked as BLOCKED OUTBOUND for cluster group {}", bundleLocation, feature.getName(), group.getName());
return;
}
}
// broadcast the cluster event
- RemoteBundleEvent remoteBundleEvent = new RemoteBundleEvent(symbolicName, version, bundleLocation, type);
- remoteBundleEvent.setSourceGroup(group);
- eventProducer.produce(remoteBundleEvent);
+ ClusterBundleEvent clusterBundleEvent = new ClusterBundleEvent(symbolicName, version, bundleLocation, type);
+ clusterBundleEvent.setSourceGroup(group);
+ eventProducer.produce(clusterBundleEvent);
} catch (Exception e) {
LOGGER.error("CELLAR BUNDLE: failed to create bundle event", e);
} 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 BLOCKED OUTBOUND in cluster group {}", bundleLocation, group.getName());
}
}
}
}
- /**
- * Initialization Method.
- */
public void init() {
getBundleContext().addBundleListener(this);
}
- /**
- * Destruction Method.
- */
public void destroy() {
bundleContext.removeBundleListener(this);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/bundle/src/main/java/org/apache/karaf/cellar/bundle/RemoteBundleEvent.java
----------------------------------------------------------------------
diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/RemoteBundleEvent.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/RemoteBundleEvent.java
deleted file mode 100644
index 290b24e..0000000
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/RemoteBundleEvent.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.cellar.bundle;
-
-import org.apache.karaf.cellar.core.event.Event;
-
-public class RemoteBundleEvent extends Event {
-
- private String symbolicName;
- private String version;
- private String location;
- private int type;
-
- public RemoteBundleEvent(String symbolicName, String version, String location, int type) {
- super(symbolicName + "/" + version);
- this.symbolicName = symbolicName;
- this.version = version;
- this.location = location;
- this.type = type;
- }
-
- public String getSymbolicName() {
- return symbolicName;
- }
-
- public void setSymbolicName(String symbolicName) {
- this.symbolicName = symbolicName;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getLocation() {
- return location;
- }
-
- public void setLocation(String location) {
- this.location = location;
- }
-
- public int getType() {
- return type;
- }
-
- public void setType(int type) {
- this.type = type;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/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 b44fa32..97cc59b 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
@@ -23,23 +23,23 @@ import java.util.regex.Pattern;
public abstract class BundleCommandSupport extends CellarCommandSupport {
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
- @Argument(index = 1, name = "id", description = "The bundle ID or name.", required = true, multiValued = false)
+ @Argument(index = 1, name = "id", description = "The bundle ID or name", required = true, multiValued = false)
String name;
- @Argument(index = 2, name = "version", description = "The bundle version.", required = false, multiValued = false)
+ @Argument(index = 2, name = "version", description = "The bundle version", required = false, multiValued = false)
String version;
protected abstract Object doExecute() throws Exception;
/**
- * Bundle selector.
+ * Bundle selector on the cluster.
*
* @return the bundle key is the distributed bundle map.
*/
- protected String selector(Map<String, BundleState> distributedBundles) {
+ protected String selector(Map<String, BundleState> clusterBundles) {
String key = null;
if (version == null) {
// looking for bundle using ID
@@ -47,7 +47,7 @@ public abstract class BundleCommandSupport extends CellarCommandSupport {
try {
id = Integer.parseInt(name);
int index = 0;
- for (String bundle : distributedBundles.keySet()) {
+ for (String bundle : clusterBundles.keySet()) {
if (index == id) {
key = bundle;
break;
@@ -63,8 +63,8 @@ public abstract class BundleCommandSupport extends CellarCommandSupport {
Pattern namePattern = Pattern.compile(name);
// looking for bundle using only the name
- for (String bundle : distributedBundles.keySet()) {
- BundleState state = distributedBundles.get(bundle);
+ for (String bundle : clusterBundles.keySet()) {
+ BundleState state = clusterBundles.get(bundle);
if (state.getName() != null) {
// bundle name is populated, check if it matches the regex
Matcher matcher = namePattern.matcher(state.getName());
@@ -98,9 +98,9 @@ public abstract class BundleCommandSupport extends CellarCommandSupport {
// add regex support of the name
Pattern namePattern = Pattern.compile(name);
- for (String bundle : distributedBundles.keySet()) {
+ for (String bundle : clusterBundles.keySet()) {
String[] split = bundle.split("/");
- BundleState state = distributedBundles.get(bundle);
+ BundleState state = clusterBundles.get(bundle);
if (split[1].equals(version)) {
if (state.getName() != null) {
// bundle name is populated, check if it matches the regex
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/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 af4c1c9..903cfab 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
@@ -14,8 +14,8 @@
package org.apache.karaf.cellar.bundle.shell;
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.RemoteBundleEvent;
import org.apache.karaf.cellar.core.CellarSupport;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
@@ -34,7 +34,7 @@ import java.util.Map;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
-@Command(scope = "cluster", name = "bundle-install", description = "Install a bundle assigned to a cluster group.")
+@Command(scope = "cluster", name = "bundle-install", description = "Install a bundle in a cluster group.")
public class InstallBundleCommand extends CellarCommandSupport {
@Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
@@ -87,8 +87,8 @@ public class InstallBundleCommand extends CellarCommandSupport {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
- // populate the cluster map
- Map<String, BundleState> bundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ // update the cluster group
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
BundleState state = new BundleState();
state.setName(name);
state.setLocation(url);
@@ -97,17 +97,17 @@ public class InstallBundleCommand extends CellarCommandSupport {
} else {
state.setStatus(BundleEvent.INSTALLED);
}
- bundles.put(symbolicName + "/" + version, state);
+ clusterBundles.put(symbolicName + "/" + version, state);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
// broadcast the cluster event
- RemoteBundleEvent event = new RemoteBundleEvent(symbolicName, version, url, BundleEvent.INSTALLED);
+ ClusterBundleEvent event = new ClusterBundleEvent(symbolicName, version, url, BundleEvent.INSTALLED);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
- System.err.println("Bundle location " + url + " is blocked outbound");
+ System.err.println("Bundle location " + url + " is blocked outbound for cluster group " + groupName);
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/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 b88c276..e836ccb 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
@@ -25,13 +25,13 @@ import org.osgi.framework.BundleEvent;
import java.util.Map;
-@Command(scope = "cluster", name = "bundle-list", description = "List the bundles assigned to a cluster group.")
+@Command(scope = "cluster", name = "bundle-list", description = "List the bundles in a cluster group.")
public class ListBundleCommand extends CellarCommandSupport {
protected static final String HEADER_FORMAT = " %-4s %-11s %s";
protected static final String OUTPUT_FORMAT = "[%-4s] [%-11s] %s";
- @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+ @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
String groupName;
@Option(name = "-s", aliases = {}, description = "Shows the symbolic name", required = false, multiValued = false)
@@ -53,12 +53,12 @@ public class ListBundleCommand extends CellarCommandSupport {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
- Map<String, BundleState> bundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
- if (bundles != null && !bundles.isEmpty()) {
- System.out.println(String.format("Bundles for cluster group " + groupName));
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ if (clusterBundles != null && !clusterBundles.isEmpty()) {
+ System.out.println(String.format("Bundles in cluster group " + groupName));
System.out.println(String.format(HEADER_FORMAT, "ID", "State", "Name"));
int id = 0;
- for (String bundle : bundles.keySet()) {
+ for (String bundle : clusterBundles.keySet()) {
String[] tokens = bundle.split("/");
String symbolicName = null;
String version = null;
@@ -69,7 +69,7 @@ public class ListBundleCommand extends CellarCommandSupport {
symbolicName = bundle;
version = "";
}
- BundleState state = bundles.get(bundle);
+ BundleState state = clusterBundles.get(bundle);
String status;
switch (state.getStatus()) {
case BundleEvent.INSTALLED:
@@ -109,7 +109,7 @@ public class ListBundleCommand extends CellarCommandSupport {
id++;
}
} else {
- System.err.println("No bundles found for cluster group " + groupName);
+ System.err.println("No bundle found in cluster group " + groupName);
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/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 5af6208..a695477 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
@@ -14,8 +14,8 @@
package org.apache.karaf.cellar.bundle.shell;
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.RemoteBundleEvent;
import org.apache.karaf.cellar.core.CellarSupport;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
@@ -27,7 +27,7 @@ import org.osgi.framework.BundleEvent;
import java.util.Map;
-@Command(scope = "cluster", name = "bundle-start", description = "Start a bundle assigned to a cluster group.")
+@Command(scope = "cluster", name = "bundle-start", description = "Start a bundle in a cluster group.")
public class StartBundleCommand extends BundleCommandSupport {
private EventProducer eventProducer;
@@ -47,22 +47,22 @@ public class StartBundleCommand extends BundleCommandSupport {
return null;
}
- // update the distributed map
+ // update the bundle in the cluster group
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
String location;
String key = null;
try {
- Map<String, BundleState> distributedBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
- key = selector(distributedBundles);
+ key = selector(clusterBundles);
if (key == null) {
System.err.println("Bundle " + key + " not found in cluster group " + groupName);
}
- BundleState state = distributedBundles.get(key);
+ BundleState state = clusterBundles.get(key);
if (state == null) {
System.err.println("Bundle " + key + " not found in cluster group " + groupName);
return null;
@@ -75,19 +75,19 @@ public class StartBundleCommand extends BundleCommandSupport {
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, location, EventType.OUTBOUND)) {
- System.err.println("Bundle location " + location + " is blocked outbound");
+ System.err.println("Bundle location " + location + " is blocked outbound for cluster group " + groupName);
return null;
}
state.setStatus(BundleEvent.STARTED);
- distributedBundles.put(key, state);
+ clusterBundles.put(key, state);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
// broadcast the cluster event
String[] split = key.split("/");
- RemoteBundleEvent event = new RemoteBundleEvent(split[0], split[1], location, BundleEvent.STARTED);
+ ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleEvent.STARTED);
event.setSourceGroup(group);
eventProducer.produce(event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/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 2105d41..86d9c6f 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
@@ -14,22 +14,20 @@
package org.apache.karaf.cellar.bundle.shell;
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.RemoteBundleEvent;
import org.apache.karaf.cellar.core.CellarSupport;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
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.core.shell.CellarCommandSupport;
-import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.osgi.framework.BundleEvent;
import java.util.Map;
-@Command(scope = "cluster", name = "bundle-stop", description = "Stop a bundle assigned to a cluster group.")
+@Command(scope = "cluster", name = "bundle-stop", description = "Stop a bundle in a cluster group.")
public class StopBundleCommand extends BundleCommandSupport {
private EventProducer eventProducer;
@@ -48,23 +46,23 @@ public class StopBundleCommand extends BundleCommandSupport {
return null;
}
- // update the cluster map
+ // update the bundle in the cluster group
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
String location;
String key = null;
try {
- Map<String, BundleState> distributedBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
- key = selector(distributedBundles);
+ key = selector(clusterBundles);
if (key == null) {
System.err.println("Bundle " + key + " not found in cluster group " + groupName);
return null;
}
- BundleState state = distributedBundles.get(key);
+ BundleState state = clusterBundles.get(key);
if (state == null) {
System.err.println("Bundle " + key + " not found in cluster group " + groupName);
return null;
@@ -78,18 +76,18 @@ public class StopBundleCommand extends BundleCommandSupport {
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, location, EventType.OUTBOUND)) {
- System.err.println("Bundle location " + location + " is blocked outbound");
+ System.err.println("Bundle location " + location + " is blocked outbound for cluster group " + groupName);
return null;
}
- distributedBundles.put(key, state);
+ clusterBundles.put(key, state);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
// broadcast the cluster event
String[] split = key.split("/");
- RemoteBundleEvent event = new RemoteBundleEvent(split[0], split[1], location, BundleEvent.STOPPED);
+ ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleEvent.STOPPED);
event.setSourceGroup(group);
eventProducer.produce(event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/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 28ca68a..3f58c0f 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
@@ -14,22 +14,20 @@
package org.apache.karaf.cellar.bundle.shell;
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.RemoteBundleEvent;
import org.apache.karaf.cellar.core.CellarSupport;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
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.core.shell.CellarCommandSupport;
-import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.osgi.framework.BundleEvent;
import java.util.Map;
-@Command(scope = "cluster", name = "bundle-uninstall", description = "Uninstall a bundle assigned to a cluster group.")
+@Command(scope = "cluster", name = "bundle-uninstall", description = "Uninstall a bundle from a cluster group.")
public class UninstallBundleCommand extends BundleCommandSupport {
private EventProducer eventProducer;
@@ -49,23 +47,23 @@ public class UninstallBundleCommand extends BundleCommandSupport {
return null;
}
- // update the cluster map
+ // update the bundle in the cluster group
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
String location;
String key = null;
try {
- Map<String, BundleState> distributedBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
+ Map<String, BundleState> clusterBundles = clusterManager.getMap(Constants.BUNDLE_MAP + Configurations.SEPARATOR + groupName);
- key = selector(distributedBundles);
+ key = selector(clusterBundles);
if (key == null) {
System.err.println("Bundle " + key + " not found in cluster group " + groupName);
return null;
}
- BundleState state = distributedBundles.get(key);
+ BundleState state = clusterBundles.get(key);
if (state == null) {
System.err.println("Bundle " + key + " not found in cluster group " + groupName);
return null;
@@ -78,18 +76,18 @@ public class UninstallBundleCommand extends BundleCommandSupport {
support.setGroupManager(this.groupManager);
support.setConfigurationAdmin(this.configurationAdmin);
if (!support.isAllowed(group, Constants.CATEGORY, location, EventType.OUTBOUND)) {
- System.err.println("Bundle location " + location + " is blocked outbound");
+ System.err.println("Bundle location " + location + " is blocked outbound for cluster group " + groupName);
return null;
}
- distributedBundles.remove(key);
+ clusterBundles.remove(key);
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
// broadcast the cluster event
String[] split = key.split("/");
- RemoteBundleEvent event = new RemoteBundleEvent(split[0], split[1], location, BundleEvent.UNINSTALLED);
+ ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleEvent.UNINSTALLED);
event.setSourceGroup(group);
eventProducer.produce(event);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 646d53f..fbc6c97 100644
--- a/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -12,14 +12,13 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-
<blueprint default-availability="mandatory"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- Local Bundle Listener -->
- <bean id="bundleListener" class="org.apache.karaf.cellar.bundle.LocalBundleListener" init-method="init"
+ <bean id="localBundleListener" class="org.apache.karaf.cellar.bundle.LocalBundleListener" init-method="init"
destroy-method="destroy">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4643c138/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
index d7959d4..cb73f72 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarBundleMBeanImpl.java
@@ -14,15 +14,13 @@
package org.apache.karaf.cellar.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.RemoteBundleEvent;
import org.apache.karaf.cellar.core.*;
import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
-import org.apache.karaf.cellar.core.event.EventTransportFactory;
import org.apache.karaf.cellar.core.event.EventType;
import org.apache.karaf.cellar.management.CellarBundleMBean;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -124,7 +122,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
}
// broadcast the event
- RemoteBundleEvent event = new RemoteBundleEvent(name, version, location, BundleEvent.INSTALLED);
+ ClusterBundleEvent event = new ClusterBundleEvent(name, version, location, BundleEvent.INSTALLED);
event.setSourceGroup(group);
eventProducer.produce(event);
}
@@ -178,7 +176,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
// broadcast the event
String[] split = key.split("/");
- RemoteBundleEvent event = new RemoteBundleEvent(split[0], split[1], location, BundleEvent.UNINSTALLED);
+ ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleEvent.UNINSTALLED);
event.setSourceGroup(group);
eventProducer.produce(event);
}
@@ -232,7 +230,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
// broadcast the event
String[] split = key.split("/");
- RemoteBundleEvent event = new RemoteBundleEvent(split[0], split[1], location, BundleEvent.STARTED);
+ ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleEvent.STARTED);
event.setSourceGroup(group);
eventProducer.produce(event);
}
@@ -286,7 +284,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
// broadcast the event
String[] split = key.split("/");
- RemoteBundleEvent event = new RemoteBundleEvent(split[0], split[1], location, BundleEvent.STOPPED);
+ ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleEvent.STOPPED);
event.setSourceGroup(group);
eventProducer.produce(event);
}
[21/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1476942 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/07228e7c
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/07228e7c
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/07228e7c
Branch: refs/heads/master
Commit: 07228e7c67064c24b0f65766a28e9e0953fc9201
Parents: 4ad329d
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Mon Apr 29 09:39:22 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Mon Apr 29 09:39:22 2013 +0000
----------------------------------------------------------------------
.../karaf/cellar/webconsole/CellarPlugin.java | 23 +++++---------------
.../OSGI-INF/blueprint/webconsole-cellar.xml | 1 -
webconsole/src/main/resources/res/ui/cellar.js | 2 +-
3 files changed, 6 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/07228e7c/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/CellarPlugin.java
----------------------------------------------------------------------
diff --git a/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/CellarPlugin.java b/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/CellarPlugin.java
index 03f58cb..974ca2d 100644
--- a/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/CellarPlugin.java
+++ b/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/CellarPlugin.java
@@ -11,7 +11,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.karaf.cellar.webconsole;
import org.apache.felix.webconsole.AbstractWebConsolePlugin;
@@ -36,11 +35,6 @@ import java.util.Set;
public class CellarPlugin extends AbstractWebConsolePlugin {
- /**
- * Pseudo class version ID to keep the IDE quite.
- */
- private static final long serialVersionUID = 1L;
-
private static final transient Logger LOGGER = LoggerFactory.getLogger(CellarPlugin.class);
public static final String NAME = "cellar";
@@ -56,10 +50,6 @@ public class CellarPlugin extends AbstractWebConsolePlugin {
private BundleContext bundleContext;
- //
- // Blueprint lifecycle callback methods
- //
-
public void start() {
super.activate(bundleContext);
@@ -73,18 +63,17 @@ public class CellarPlugin extends AbstractWebConsolePlugin {
super.deactivate();
}
- //
- // AbstractWebConsolePlugin interface
- //
-
+ @Override
public String getLabel() {
return NAME;
}
+ @Override
public String getTitle() {
return LABEL;
}
+ @Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
boolean success = false;
@@ -117,6 +106,7 @@ public class CellarPlugin extends AbstractWebConsolePlugin {
}
}
+ @Override
protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws IOException {
// get request info from request attribute
final PrintWriter pw = response.getWriter();
@@ -143,9 +133,6 @@ public class CellarPlugin extends AbstractWebConsolePlugin {
pw.println("</script>");
}
- //
- // Additional methods
- //
protected URL getResource(String path) {
path = path.substring(NAME.length() + 1);
URL url = this.classLoader.getResource(path);
@@ -154,7 +141,7 @@ public class CellarPlugin extends AbstractWebConsolePlugin {
try {
ins = url.openStream();
if (ins == null) {
- this.LOGGER.error("Failed to open {}", url);
+ this.LOGGER.error("failed to open {}", url);
url = null;
}
} catch (IOException e) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/07228e7c/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml
----------------------------------------------------------------------
diff --git a/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml b/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml
index e9f0ddf..3aa8b8f 100644
--- a/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml
+++ b/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml
@@ -29,7 +29,6 @@
<property name="groupManager" ref="groupManager"/>
<property name="clusterManager" ref="clusterManager"/>
</bean>
-
<service ref="cellarPlugin" interface="javax.servlet.Servlet">
<service-properties>
<entry key="felix.webconsole.label" value="cellar"/>
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/07228e7c/webconsole/src/main/resources/res/ui/cellar.js
----------------------------------------------------------------------
diff --git a/webconsole/src/main/resources/res/ui/cellar.js b/webconsole/src/main/resources/res/ui/cellar.js
index 8d7d044..faad344 100644
--- a/webconsole/src/main/resources/res/ui/cellar.js
+++ b/webconsole/src/main/resources/res/ui/cellar.js
@@ -105,7 +105,7 @@ function renderGroupTableData(/* array of Objects */ data) {
}
/**
- * Adds under the parent element a group/member/actions row
+ * Add under the parent element a group/member/actions row
* @param parent
* @param group
*/
[45/50] [abbrv] git commit: [KARAF-2478] Fix hazelcast blueprint
descriptor
Posted by jb...@apache.org.
[KARAF-2478] Fix hazelcast blueprint descriptor
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1528806 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/95fb58ec
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/95fb58ec
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/95fb58ec
Branch: refs/heads/master
Commit: 95fb58ecf5898ecf42db16731858f26384d7ee19
Parents: 3ebb1d4
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu Oct 3 11:10:55 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu Oct 3 11:10:55 2013 +0000
----------------------------------------------------------------------
hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/95fb58ec/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 77bc51e..f746aec 100644
--- a/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -69,6 +69,7 @@
<property name="dispatcher" ref="dispatcher"/>
<property name="instance" ref="hazelcast"/>
<property name="combinedClassLoader" ref="combinedClassLoader"/>
+ <property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
<service ref="eventTransportFactory" interface="org.apache.karaf.cellar.core.event.EventTransportFactory"/>
[33/50] [abbrv] git commit: [KARAF-2286] Change log level of some
messages
Posted by jb...@apache.org.
[KARAF-2286] Change log level of some messages
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1484094 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/9e82eefc
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/9e82eefc
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/9e82eefc
Branch: refs/heads/master
Commit: 9e82eefc863ca3da3836de45db91a26c77cb81ee
Parents: a18c0f6
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Sat May 18 11:42:23 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Sat May 18 11:42:23 2013 +0000
----------------------------------------------------------------------
.../karaf/cellar/cloud/BlobStoreDiscoveryService.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/9e82eefc/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
----------------------------------------------------------------------
diff --git a/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java b/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
index 5d7ef0a..677d1a8 100644
--- a/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
+++ b/cloud/src/main/java/org/apache/karaf/cellar/cloud/BlobStoreDiscoveryService.java
@@ -103,8 +103,10 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
}
String ip = md.getName();
Object obj = readBlob(container, ip);
- if (obj == null)
- continue;
+ if (obj == null) {
+ LOGGER.debug("CELLAR CLOUD: no valid object found, skipping it");
+ continue;
+ }
// check if the IP hasn't been updated recently
if (obj instanceof DateTime) {
LOGGER.debug("CELLAR CLOUD: retrieved a DateTime from blog store");
@@ -181,9 +183,9 @@ public class BlobStoreDiscoveryService implements DiscoveryService {
ois = new ObjectInputStream(is);
result = ois.readObject();
} catch (IOException e) {
- LOGGER.error("CELLAR CLOUD: error while reading blob", e);
+ LOGGER.warn("CELLAR CLOUD: error while reading blob", e);
} catch (ClassNotFoundException e) {
- LOGGER.error("CELLAR CLOUD: error while reading blob", e);
+ LOGGER.warn("CELLAR CLOUD: error while reading blob", e);
} finally {
if (ois != null) {
try {
[34/50] [abbrv] git commit: [KARAF-2337] Upgrade to Apache POM 13
Posted by jb...@apache.org.
[KARAF-2337] Upgrade to Apache POM 13
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1485367 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/1301802c
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/1301802c
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/1301802c
Branch: refs/heads/master
Commit: 1301802cb699339a635507074c99bcbe65f01146
Parents: 9e82eef
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed May 22 19:34:07 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed May 22 19:34:07 2013 +0000
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/1301802c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1c557f4..0b7c447 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
- <version>12</version>
+ <version>13</version>
<relativePath />
</parent>
[20/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1476916 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/4ad329d1
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/4ad329d1
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/4ad329d1
Branch: refs/heads/master
Commit: 4ad329d1d8a50639469cea2c6006f5a61ca5de86
Parents: 9b430fe
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Mon Apr 29 08:24:32 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Mon Apr 29 08:24:32 2013 +0000
----------------------------------------------------------------------
.../main/java/org/apache/karaf/cellar/utils/ping/Ping.java | 3 +++
.../java/org/apache/karaf/cellar/utils/ping/PingHandler.java | 3 +++
.../main/java/org/apache/karaf/cellar/utils/ping/Pong.java | 3 +++
.../java/org/apache/karaf/cellar/utils/ping/PongHandler.java | 3 +++
utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml | 7 +++----
5 files changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4ad329d1/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Ping.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Ping.java b/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Ping.java
index 6da0c5a..d272e8c 100644
--- a/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Ping.java
+++ b/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Ping.java
@@ -15,6 +15,9 @@ package org.apache.karaf.cellar.utils.ping;
import org.apache.karaf.cellar.core.command.Command;
+/**
+ * Cluster ping event.
+ */
public class Ping extends Command<Pong> {
public Ping(String id) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4ad329d1/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PingHandler.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PingHandler.java b/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PingHandler.java
index 92e7ebe..45c1993 100644
--- a/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PingHandler.java
+++ b/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PingHandler.java
@@ -17,6 +17,9 @@ import org.apache.karaf.cellar.core.command.CommandHandler;
import org.apache.karaf.cellar.core.control.BasicSwitch;
import org.apache.karaf.cellar.core.control.Switch;
+/**
+ * Handler for cluster ping event.
+ */
public class PingHandler extends CommandHandler<Ping, Pong> {
public static final String SWITCH_ID = "org.apache.karaf.cellar.command.ping.switch";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4ad329d1/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Pong.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Pong.java b/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Pong.java
index b4a3a64..052a538 100644
--- a/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Pong.java
+++ b/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Pong.java
@@ -15,6 +15,9 @@ package org.apache.karaf.cellar.utils.ping;
import org.apache.karaf.cellar.core.command.Result;
+/**
+ * Cluster pong event.
+ */
public class Pong extends Result {
public Pong(String id) {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4ad329d1/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PongHandler.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PongHandler.java b/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PongHandler.java
index 3c257de..1a61a97 100644
--- a/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PongHandler.java
+++ b/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PongHandler.java
@@ -15,6 +15,9 @@ package org.apache.karaf.cellar.utils.ping;
import org.apache.karaf.cellar.core.command.ResultHandler;
+/**
+ * Handler for cluster pong event.
+ */
public class PongHandler extends ResultHandler<Pong> {
@Override
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4ad329d1/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index de28184..85cfb16 100644
--- a/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -15,17 +15,16 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <!-- Handler for the cluster ping event -->
<bean id="pingHandler" class="org.apache.karaf.cellar.utils.ping.PingHandler">
<property name="producer" ref="producer"/>
-
</bean>
+ <service ref="pingHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
+ <!-- Handler for the cluster pong event -->
<bean id="pongHandler" class="org.apache.karaf.cellar.utils.ping.PongHandler">
<property name="commandStore" ref="commandStore"/>
</bean>
-
- <!-- OSGi Services & References -->
- <service ref="pingHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
<service ref="pongHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager" availability="optional"/>
[10/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471404 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/3b641e4c
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/3b641e4c
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/3b641e4c
Branch: refs/heads/master
Commit: 3b641e4c9e740efa318817c3d14b132a624aa8f5
Parents: cbc5c6e
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed Apr 24 13:30:23 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed Apr 24 13:30:23 2013 +0000
----------------------------------------------------------------------
.../cellar/core/completer/AllNodeCompleter.java | 34 ------------
.../core/completer/NodeCompleterSupport.java | 58 --------------------
.../core/shell/completer/AllNodeCompleter.java | 34 ++++++++++++
.../shell/completer/NodeCompleterSupport.java | 58 ++++++++++++++++++++
.../OSGI-INF/blueprint/shell-cluster.xml | 2 +-
5 files changed, 93 insertions(+), 93 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3b641e4c/core/src/main/java/org/apache/karaf/cellar/core/completer/AllNodeCompleter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/completer/AllNodeCompleter.java b/core/src/main/java/org/apache/karaf/cellar/core/completer/AllNodeCompleter.java
deleted file mode 100644
index 5bfbb3e..0000000
--- a/core/src/main/java/org/apache/karaf/cellar/core/completer/AllNodeCompleter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.cellar.core.completer;
-
-import org.apache.karaf.cellar.core.Node;
-
-/**
- * A completer which includes all nodes.
- */
-public class AllNodeCompleter extends NodeCompleterSupport {
-
- /**
- * Always returns true.
- *
- * @param node the node.
- * @return return true.
- */
- @Override
- protected boolean acceptsNode(Node node) {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3b641e4c/core/src/main/java/org/apache/karaf/cellar/core/completer/NodeCompleterSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/completer/NodeCompleterSupport.java b/core/src/main/java/org/apache/karaf/cellar/core/completer/NodeCompleterSupport.java
deleted file mode 100644
index 6d4c33d..0000000
--- a/core/src/main/java/org/apache/karaf/cellar/core/completer/NodeCompleterSupport.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.cellar.core.completer;
-
-import org.apache.karaf.cellar.core.ClusterManager;
-import org.apache.karaf.cellar.core.Node;
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-
-import java.util.List;
-
-/**
- * Completer on the node.
- */
-public abstract class NodeCompleterSupport implements Completer {
-
- private ClusterManager clusterManager;
-
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- StringsCompleter delegate = new StringsCompleter();
- try {
- for (Node node : clusterManager.listNodes()) {
- if (acceptsNode(node)) {
- String id = node.getId();
- if (delegate.getStrings() != null && !delegate.getStrings().contains(id)) {
- delegate.getStrings().add(id);
- }
- }
- }
- } catch (Exception e) {
- // Ignore
- }
- return delegate.complete(buffer, cursor, candidates);
- }
-
- protected abstract boolean acceptsNode(Node node);
-
- public ClusterManager getClusterManager() {
- return clusterManager;
- }
-
- public void setClusterManager(ClusterManager clusterManager) {
- this.clusterManager = clusterManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3b641e4c/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllNodeCompleter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllNodeCompleter.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllNodeCompleter.java
new file mode 100644
index 0000000..be7f26f
--- /dev/null
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllNodeCompleter.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.core.shell.completer;
+
+import org.apache.karaf.cellar.core.Node;
+
+/**
+ * A completer which includes all nodes.
+ */
+public class AllNodeCompleter extends NodeCompleterSupport {
+
+ /**
+ * Always returns true.
+ *
+ * @param node the node.
+ * @return return true.
+ */
+ @Override
+ protected boolean acceptsNode(Node node) {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3b641e4c/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeCompleterSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeCompleterSupport.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeCompleterSupport.java
new file mode 100644
index 0000000..815a658
--- /dev/null
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeCompleterSupport.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.core.shell.completer;
+
+import org.apache.karaf.cellar.core.ClusterManager;
+import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.shell.console.Completer;
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+
+import java.util.List;
+
+/**
+ * Completer on the node.
+ */
+public abstract class NodeCompleterSupport implements Completer {
+
+ private ClusterManager clusterManager;
+
+ @Override
+ public int complete(String buffer, int cursor, List<String> candidates) {
+ StringsCompleter delegate = new StringsCompleter();
+ try {
+ for (Node node : clusterManager.listNodes()) {
+ if (acceptsNode(node)) {
+ String id = node.getId();
+ if (delegate.getStrings() != null && !delegate.getStrings().contains(id)) {
+ delegate.getStrings().add(id);
+ }
+ }
+ }
+ } catch (Exception e) {
+ // Ignore
+ }
+ return delegate.complete(buffer, cursor, candidates);
+ }
+
+ protected abstract boolean acceptsNode(Node node);
+
+ public ClusterManager getClusterManager() {
+ return clusterManager;
+ }
+
+ public void setClusterManager(ClusterManager clusterManager) {
+ this.clusterManager = clusterManager;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3b641e4c/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml
----------------------------------------------------------------------
diff --git a/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml b/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml
index f25974b..dd4fa8e 100644
--- a/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml
+++ b/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml
@@ -209,7 +209,7 @@
<reference id="executionContext" interface="org.apache.karaf.cellar.core.command.ExecutionContext" availability="optional"/>
<!-- Completers -->
- <bean id="allNodesCompleter" class="org.apache.karaf.cellar.core.completer.AllNodeCompleter">
+ <bean id="allNodesCompleter" class="org.apache.karaf.cellar.core.shell.completer.AllNodeCompleter">
<property name="clusterManager" ref="clusterManager"/>
</bean>
[30/50] [abbrv] git commit: [KARAF-2318] Exclude service.factoryPid
property from the Cellar sync
Posted by jb...@apache.org.
[KARAF-2318] Exclude service.factoryPid property from the Cellar sync
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1483677 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/33ab36cf
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/33ab36cf
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/33ab36cf
Branch: refs/heads/master
Commit: 33ab36cf60baa4a34b7d63d9a605c2bd54bc87e4
Parents: 8a85ea7
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Fri May 17 07:46:31 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Fri May 17 07:46:31 2013 +0000
----------------------------------------------------------------------
.../java/org/apache/karaf/cellar/config/ConfigurationSupport.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/33ab36cf/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
index fa6f986..f33d367 100644
--- a/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
+++ b/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
@@ -28,7 +28,7 @@ import java.util.*;
*/
public class ConfigurationSupport extends CellarSupport {
- private static String[] EXCLUDED_PROPERTIES = {"felix.fileinstall.filename", "felix.fileinstall.dir", "felix.fileinstall.tmpdir", "org.ops4j.pax.url.mvn.defaultRepositories"};
+ private static String[] EXCLUDED_PROPERTIES = {"service.factoryPid", "felix.fileinstall.filename", "felix.fileinstall.dir", "felix.fileinstall.tmpdir", "org.ops4j.pax.url.mvn.defaultRepositories"};
private static final String FELIX_FILEINSTALL_FILENAME = "felix.fileinstall.filename";
[46/50] [abbrv] git commit: [KARAF-2477] Inject the groupManager in
the Cellar config blueprint
Posted by jb...@apache.org.
[KARAF-2477] Inject the groupManager in the Cellar config blueprint
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1528846 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/fe98fae6
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/fe98fae6
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/fe98fae6
Branch: refs/heads/master
Commit: fe98fae66fc94460c96ea6c386c677819ae920dd
Parents: 95fb58e
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu Oct 3 13:22:25 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu Oct 3 13:22:25 2013 +0000
----------------------------------------------------------------------
config/src/main/resources/OSGI-INF/blueprint/blueprint.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/fe98fae6/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 881daf8..f2c0b95 100644
--- a/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -52,6 +52,7 @@
<bean id="eventHandler" class="org.apache.karaf.cellar.config.ConfigurationEventHandler"
init-method="init" destroy-method="destroy">
<property name="configurationAdmin" ref="configurationAdmin"/>
+ <property name="groupManager" ref="groupManager"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="storage" value="${storage}"/>
</bean>
[03/50] [abbrv] git commit: Code cleanup
Posted by jb...@apache.org.
Code cleanup
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1470985 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/65d177e5
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/65d177e5
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/65d177e5
Branch: refs/heads/master
Commit: 65d177e5e9c296ba239ac9a80902927c13eb5966
Parents: 4643c13
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Apr 23 14:43:42 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Apr 23 14:43:42 2013 +0000
----------------------------------------------------------------------
.../karaf/cellar/bundle/BundleEventHandler.java | 16 +++++++++---
.../karaf/cellar/bundle/BundleSupport.java | 27 --------------------
.../karaf/cellar/bundle/BundleSynchronizer.java | 4 +--
.../karaf/cellar/bundle/ClusterBundleEvent.java | 3 +++
.../cellar/bundle/LocalBundleListener.java | 4 +--
.../resources/OSGI-INF/blueprint/blueprint.xml | 2 +-
6 files changed, 21 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/65d177e5/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 e7f3443..d555d56 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
@@ -61,7 +61,7 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Cl
// check if the group is local
if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
- LOGGER.debug("CELLAR BUNDLE: node is not part of the event cluster group");
+ LOGGER.debug("CELLAR BUNDLE: node is not part of the event cluster group {}", event.getSourceGroup().getName());
return;
}
@@ -72,7 +72,7 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Cl
List<Feature> matchingFeatures = retrieveFeature(event.getLocation());
for (Feature feature : matchingFeatures) {
if (!isAllowed(event.getSourceGroup(), "features", feature.getName(), EventType.INBOUND)) {
- LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in the feature {} marked as BLOCKED INBOUND for cluster group {}", event.getLocation(), feature.getName(), event.getSourceGroup());
+ LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in feature {} marked BLOCKED INBOUND for cluster group {}", event.getLocation(), feature.getName(), event.getSourceGroup().getName());
return;
}
}
@@ -92,7 +92,7 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Cl
updateBundle(event.getSymbolicName(), event.getVersion());
LOGGER.debug("CELLAR BUNDLE: updating {}/{}", event.getSymbolicName(), event.getVersion());
}
- } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED INBOUND", event.getSymbolicName());
+ } else LOGGER.warn("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) {
@@ -108,6 +108,11 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Cl
// nothing to do
}
+ /**
+ * Get the cluster bundle event handler switch.
+ *
+ * @return the cluster bundle event handler switch.
+ */
@Override
public Switch getSwitch() {
// load the switch status from the config
@@ -127,6 +132,11 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Cl
return eventSwitch;
}
+ /**
+ * Get the cluster event type.
+ *
+ * @return the cluster bundle event type.
+ */
@Override
public Class<ClusterBundleEvent> getType() {
return ClusterBundleEvent.class;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/65d177e5/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 796a4f0..5e08447 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
@@ -20,13 +20,9 @@ import org.apache.karaf.features.FeaturesService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.service.cm.ConfigurationAdmin;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Enumeration;
import java.util.List;
-import java.util.Properties;
/**
* Generic Cellar bundle support.
@@ -37,29 +33,6 @@ public class BundleSupport extends CellarSupport {
private FeaturesService featuresService;
/**
- * Read a {@code Dictionary} and create a {@code Properties}.
- *
- * @param dictionary the {@code Dictionary} to read.
- * @return the {@code Properties} corresponding to the {@code Dictionary}.
- */
- /*
- public Properties dictionaryToProperties(Dictionary dictionary) {
- Properties properties = new Properties();
- if (dictionary != null && dictionary.keys() != null) {
-
- Enumeration keys = dictionary.keys();
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- if (key != null && dictionary.get(key) != null) {
- properties.put(key, dictionary.get(key));
- }
- }
- }
- return properties;
- }
- */
-
- /**
* Locally install a bundle.
*
* @param location the bundle location.
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/65d177e5/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 9957ee8..be04ae9 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
@@ -96,7 +96,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
} catch (BundleException e) {
LOGGER.error("CELLAR BUNDLE: failed to pull bundle {}", id, e);
}
- } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED INBOUND for cluster group {}", bundleLocation, groupName);
+ } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked BLOCKED INBOUND for cluster group {}", bundleLocation, groupName);
}
}
}
@@ -174,7 +174,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer {
eventProducer.produce(event);
}
- } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked as BLOCKED OUTBOUND for cluster group {}", bundleLocation, groupName);
+ } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked BLOCKED OUTBOUND for cluster group {}", bundleLocation, groupName);
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/65d177e5/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java
----------------------------------------------------------------------
diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java
index d551001..a043fb3 100644
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java
@@ -15,6 +15,9 @@ package org.apache.karaf.cellar.bundle;
import org.apache.karaf.cellar.core.event.Event;
+/**
+ * Cluster bundle event.
+ */
public class ClusterBundleEvent extends Event {
private String symbolicName;
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/65d177e5/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 79deee4..4209278 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
@@ -100,7 +100,7 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun
List<Feature> matchingFeatures = retrieveFeature(bundleLocation);
for (Feature feature : matchingFeatures) {
if (!isAllowed(group, "features", feature.getName(), EventType.OUTBOUND)) {
- LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in the feature {} marked as BLOCKED OUTBOUND for cluster group {}", bundleLocation, feature.getName(), group.getName());
+ LOGGER.warn("CELLAR BUNDLE: bundle {} is contained in feature {} marked BLOCKED OUTBOUND for cluster group {}", bundleLocation, feature.getName(), group.getName());
return;
}
}
@@ -115,7 +115,7 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
- } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked BLOCKED OUTBOUND in cluster group {}", bundleLocation, group.getName());
+ } else LOGGER.warn("CELLAR BUNDLE: bundle {} is marked BLOCKED OUTBOUND for cluster group {}", bundleLocation, group.getName());
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/65d177e5/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index fbc6c97..efd5e20 100644
--- a/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -39,7 +39,7 @@
</bean>
<service ref="synchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
- <!-- Cluster Event Handler -->
+ <!-- Cluster Bundle Event Handler -->
<bean id="eventHandler" class="org.apache.karaf.cellar.bundle.BundleEventHandler"
init-method="init" destroy-method="destroy">
<property name="configurationAdmin" ref="configurationAdmin"/>
[27/50] [abbrv] git commit: [KARAF-2127] Create a kar file for Cellar
Posted by jb...@apache.org.
[KARAF-2127] Create a kar file for Cellar
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1483303 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/3ca8c65a
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/3ca8c65a
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/3ca8c65a
Branch: refs/heads/master
Commit: 3ca8c65a7cb05b6bd966eabec638a864afd01cdd
Parents: 8593445
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu May 16 11:39:33 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu May 16 11:39:33 2013 +0000
----------------------------------------------------------------------
assembly/pom.xml | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3ca8c65a/assembly/pom.xml
----------------------------------------------------------------------
diff --git a/assembly/pom.xml b/assembly/pom.xml
index d44e559..072ff8d 100644
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -136,6 +136,35 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.karaf.tooling</groupId>
+ <artifactId>karaf-maven-plugin</artifactId>
+ <version>${karaf.version}</version>
+ <executions>
+ <!--
+ <execution>
+ <id>features-generate-descriptor</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>features-generate-descriptor</goal>
+ </goals>
+ <configuration>
+ <addBundlesToPrimaryFeature>false</addBundlesToPrimaryFeature>
+ </configuration>
+ </execution>
+ -->
+ <execution>
+ <id>features-create-kar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>features-create-kar</goal>
+ </goals>
+ <configuration>
+ <featuresFile>target/classes/features.xml</featuresFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
[14/50] [abbrv] git commit: Code cleanup.
Posted by jb...@apache.org.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471437 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/47d1c9ea
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/47d1c9ea
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/47d1c9ea
Branch: refs/heads/master
Commit: 47d1c9eaae072452518f9659982130c208d3b885
Parents: 1fbc626
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Wed Apr 24 14:32:30 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Wed Apr 24 14:32:30 2013 +0000
----------------------------------------------------------------------
assembly/src/main/resources/node.cfg | 2 +-
.../apache/karaf/cellar/event/ClusterEvent.java | 51 ++++++++
.../karaf/cellar/event/ClusterEventHandler.java | 115 +++++++++++++++++++
.../apache/karaf/cellar/event/Constants.java | 3 +
.../apache/karaf/cellar/event/EventSupport.java | 11 +-
.../karaf/cellar/event/LocalEventListener.java | 8 +-
.../apache/karaf/cellar/event/RemoteEvent.java | 48 --------
.../karaf/cellar/event/RemoteEventHandler.java | 105 -----------------
.../resources/OSGI-INF/blueprint/blueprint.xml | 5 +-
9 files changed, 182 insertions(+), 166 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47d1c9ea/assembly/src/main/resources/node.cfg
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/node.cfg b/assembly/src/main/resources/node.cfg
index b7781bf..1725ade 100644
--- a/assembly/src/main/resources/node.cfg
+++ b/assembly/src/main/resources/node.cfg
@@ -25,7 +25,7 @@ handler.org.apache.karaf.cellar.features.FeaturesEventHandler = true
# DOSGi event handler
handler.org.apache.karaf.cellar.dosgi.RemoteServiceCallHandler = true
# OSGi event handler
-handler.org.apache.karaf.cellar.event.RemoteEventHandler = true
+handler.org.apache.karaf.cellar.event.ClusterEventHandler = true
# OBR event handler
handler.org.apache.karaf.cellar.obr.ObrBundleEventHandler = true
handler.org.apache.karaf.cellar.obr.ObrUrlEventHandler = true
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47d1c9ea/event/src/main/java/org/apache/karaf/cellar/event/ClusterEvent.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/ClusterEvent.java b/event/src/main/java/org/apache/karaf/cellar/event/ClusterEvent.java
new file mode 100644
index 0000000..c5076fc
--- /dev/null
+++ b/event/src/main/java/org/apache/karaf/cellar/event/ClusterEvent.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.event;
+
+import org.apache.karaf.cellar.core.event.Event;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Cluster event.
+ */
+public class ClusterEvent extends Event {
+
+ private String topicName;
+ private Map<String, Serializable> properties;
+
+ public ClusterEvent(String topicName, Map<String, Serializable> properties) {
+ super(topicName);
+ this.topicName = topicName;
+ this.properties = properties;
+ }
+
+ public String getTopicName() {
+ return this.topicName;
+ }
+
+ public void setTopicName(String topicName) {
+ this.topicName = topicName;
+ }
+
+ public Map<String, Serializable> getProperties() {
+ return this.properties;
+ }
+
+ public void setProperties(Map<String, Serializable> properties) {
+ this.properties = properties;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47d1c9ea/event/src/main/java/org/apache/karaf/cellar/event/ClusterEventHandler.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/ClusterEventHandler.java b/event/src/main/java/org/apache/karaf/cellar/event/ClusterEventHandler.java
new file mode 100644
index 0000000..fee96ad
--- /dev/null
+++ b/event/src/main/java/org/apache/karaf/cellar/event/ClusterEventHandler.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.event;
+
+import org.apache.karaf.cellar.core.Configurations;
+import org.apache.karaf.cellar.core.control.BasicSwitch;
+import org.apache.karaf.cellar.core.control.Switch;
+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.osgi.service.cm.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Handler for cluster event.
+ */
+public class ClusterEventHandler extends EventSupport implements EventHandler<ClusterEvent> {
+
+ private static final transient Logger LOGGER = LoggerFactory.getLogger(ClusterEventHandler.class);
+
+ public static final String SWITCH_ID = "org.apache.karaf.cellar.event.handler";
+ private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
+
+ @Override
+ public void handle(ClusterEvent event) {
+
+ // check if the handler is ON
+ if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ LOGGER.warn("CELLAR EVENT: {} is OFF, cluster event not handled", SWITCH_ID);
+ return;
+ }
+
+ if (groupManager == null) {
+ // in rare cases for example right after installation this happens!
+ LOGGER.error("CELLAR EVENT: retrieved event {} while groupManager is not available yet!", event);
+ return;
+ }
+
+ // check if the group is local
+ if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
+ LOGGER.debug("CELLAR EVENT: node is not part of the event cluster group");
+ return;
+ }
+
+ try {
+ if (isAllowed(event.getSourceGroup(), Constants.CATEGORY, event.getTopicName(), EventType.INBOUND)) {
+ Map<String, Serializable> properties = event.getProperties();
+ properties.put(Constants.EVENT_PROCESSED_KEY, Constants.EVENT_PROCESSED_VALUE);
+ properties.put(Constants.EVENT_SOURCE_GROUP_KEY, event.getSourceGroup());
+ properties.put(Constants.EVENT_SOURCE_NODE_KEY, event.getSourceNode());
+ postEvent(event.getTopicName(), properties);
+ } else LOGGER.warn("CELLAR EVENT: event {} is marked BLOCKED INBOUND for cluster group {}", event.getTopicName(), event.getSourceGroup().getName());
+ } catch (Exception e) {
+ LOGGER.error("CELLAR EVENT: failed to handle event", e);
+ }
+ }
+
+ public void init() {
+ // nothing to do
+ }
+
+ public void destroy() {
+ // nothing to do
+ }
+
+ /**
+ * Get the handler switch.
+ *
+ * @return the handler switch.
+ */
+ @Override
+ public Switch getSwitch() {
+ // load the switch status from the config
+ try {
+ Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE);
+ if (configuration != null) {
+ Boolean status = new Boolean((String) configuration.getProperties().get(Configurations.HANDLER + "." + this.getClass().getName()));
+ if (status) {
+ eventSwitch.turnOn();
+ } else {
+ eventSwitch.turnOff();
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ return eventSwitch;
+ }
+
+ /**
+ * Get the event type handled by this handler.
+ *
+ * @return the cluster event type.
+ */
+ @Override
+ public Class<ClusterEvent> getType() {
+ return ClusterEvent.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47d1c9ea/event/src/main/java/org/apache/karaf/cellar/event/Constants.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/Constants.java b/event/src/main/java/org/apache/karaf/cellar/event/Constants.java
index 3fa5aec..0efa862 100644
--- a/event/src/main/java/org/apache/karaf/cellar/event/Constants.java
+++ b/event/src/main/java/org/apache/karaf/cellar/event/Constants.java
@@ -13,6 +13,9 @@
*/
package org.apache.karaf.cellar.event;
+/**
+ * Event configuration constants.
+ */
public class Constants {
public static final String CATEGORY = "event";
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47d1c9ea/event/src/main/java/org/apache/karaf/cellar/event/EventSupport.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/EventSupport.java b/event/src/main/java/org/apache/karaf/cellar/event/EventSupport.java
index 516b954..909805d 100644
--- a/event/src/main/java/org/apache/karaf/cellar/event/EventSupport.java
+++ b/event/src/main/java/org/apache/karaf/cellar/event/EventSupport.java
@@ -21,14 +21,17 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+/**
+ * Generic Cellar OSGi event support.
+ */
public class EventSupport extends CellarSupport {
protected EventAdmin eventAdmin;
/**
- * Reads a {@code Event} object and creates a map object out of it.
+ * Read a local {@code Event} and create a map object out of it.
*
- * @param event the event to read
+ * @param event the local event to read.
* @return the map
*/
public Map<String, Serializable> getEventProperties(Event event) {
@@ -47,9 +50,9 @@ public class EventSupport extends CellarSupport {
}
/**
- * Reads {@code Event} object and checks if a property exists.
+ * Read a local {@code Event} and check if a property exists.
*
- * @param event the event to read.
+ * @param event the local event to read.
* @param name the property name to check.
* @return true if the property exists in the event, false else.
*/
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47d1c9ea/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java b/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
index b11b31f..dfa9632 100644
--- a/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
+++ b/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
@@ -14,7 +14,6 @@
package org.apache.karaf.cellar.event;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -67,9 +65,9 @@ public class LocalEventListener extends EventSupport implements EventHandler {
Map<String, Serializable> properties = getEventProperties(event);
if (isAllowed(group, Constants.CATEGORY, topicName, EventType.OUTBOUND)) {
// broadcast the event
- RemoteEvent remoteEvent = new RemoteEvent(topicName, properties);
- remoteEvent.setSourceGroup(group);
- eventProducer.produce(remoteEvent);
+ ClusterEvent clusterEvent = new ClusterEvent(topicName, properties);
+ clusterEvent.setSourceGroup(group);
+ eventProducer.produce(clusterEvent);
} else if (!topicName.startsWith("org/osgi/service/log/LogEntry/"))
LOGGER.warn("CELLAR EVENT: event {} is marked as BLOCKED OUTBOUND", topicName);
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47d1c9ea/event/src/main/java/org/apache/karaf/cellar/event/RemoteEvent.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/RemoteEvent.java b/event/src/main/java/org/apache/karaf/cellar/event/RemoteEvent.java
deleted file mode 100644
index ff0ea96..0000000
--- a/event/src/main/java/org/apache/karaf/cellar/event/RemoteEvent.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.cellar.event;
-
-import org.apache.karaf.cellar.core.event.Event;
-
-import java.io.Serializable;
-import java.util.Map;
-
-public class RemoteEvent extends Event {
-
- private String topicName;
- private Map<String, Serializable> properties;
-
- public RemoteEvent(String topicName, Map<String, Serializable> properties) {
- super(topicName);
- this.topicName = topicName;
- this.properties = properties;
- }
-
- public String getTopicName() {
- return this.topicName;
- }
-
- public void setTopicName(String topicName) {
- this.topicName = topicName;
- }
-
- public Map<String, Serializable> getProperties() {
- return this.properties;
- }
-
- public void setProperties(Map<String, Serializable> properties) {
- this.properties = properties;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47d1c9ea/event/src/main/java/org/apache/karaf/cellar/event/RemoteEventHandler.java
----------------------------------------------------------------------
diff --git a/event/src/main/java/org/apache/karaf/cellar/event/RemoteEventHandler.java b/event/src/main/java/org/apache/karaf/cellar/event/RemoteEventHandler.java
deleted file mode 100644
index 1b1de90..0000000
--- a/event/src/main/java/org/apache/karaf/cellar/event/RemoteEventHandler.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.cellar.event;
-
-import org.apache.karaf.cellar.core.Configurations;
-import org.apache.karaf.cellar.core.control.BasicSwitch;
-import org.apache.karaf.cellar.core.control.Switch;
-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.osgi.service.cm.Configuration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Serializable;
-import java.util.Map;
-
-public class RemoteEventHandler extends EventSupport implements EventHandler<RemoteEvent> {
-
- private static final transient Logger LOGGER = LoggerFactory.getLogger(RemoteEventHandler.class);
-
- public static final String SWITCH_ID = "org.apache.karaf.cellar.event.handler";
- private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
-
- public void handle(RemoteEvent event) {
-
- // check if the handler is ON
- if (this.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR EVENT: {} is OFF, cluster event not handled", SWITCH_ID);
- return;
- }
-
- if (groupManager == null) {
- //in rare cases for example right after installation this happens!
- LOGGER.error("CELLAR EVENT: retrieved event {} while groupManager is not available yet!", event);
- return;
- }
-
- // check if the group is local
- if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
- LOGGER.debug("CELLAR EVENT: node is not part of the event cluster group");
- return;
- }
-
- try {
- if (isAllowed(event.getSourceGroup(), Constants.CATEGORY, event.getTopicName(), EventType.INBOUND)) {
- Map<String, Serializable> properties = event.getProperties();
- properties.put(Constants.EVENT_PROCESSED_KEY, Constants.EVENT_PROCESSED_VALUE);
- properties.put(Constants.EVENT_SOURCE_GROUP_KEY, event.getSourceGroup());
- properties.put(Constants.EVENT_SOURCE_NODE_KEY, event.getSourceNode());
- postEvent(event.getTopicName(), properties);
- } else LOGGER.warn("CELLAR EVENT: event {} is marked as BLOCKED INBOUND", event.getTopicName());
- } catch (Exception e) {
- LOGGER.error("CELLAR EVENT: failed to handle event", e);
- }
- }
-
- /**
- * Initialization method.
- */
- public void init() {
-
- }
-
- /**
- * Destroy method.
- */
- public void destroy() {
-
- }
-
- public Switch getSwitch() {
- // load the switch status from the config
- try {
- Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE);
- if (configuration != null) {
- Boolean status = new Boolean((String) configuration.getProperties().get(Configurations.HANDLER + "." + this.getClass().getName()));
- if (status) {
- eventSwitch.turnOn();
- } else {
- eventSwitch.turnOff();
- }
- }
- } catch (Exception e) {
- // ignore
- }
- return eventSwitch;
- }
-
- public Class<RemoteEvent> getType() {
- return RemoteEvent.class;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/47d1c9ea/event/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/event/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/event/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 2991731..31edd17 100644
--- a/event/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/event/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -39,18 +39,17 @@
</service>
<!-- Cluster Event Handler -->
- <bean id="remoteEventHandler" class="org.apache.karaf.cellar.event.RemoteEventHandler" init-method="init" destroy-method="destroy">
+ <bean id="clusterEventHandler" class="org.apache.karaf.cellar.event.ClusterEventHandler" init-method="init" destroy-method="destroy">
<property name="configurationAdmin" ref="configurationAdmin"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="eventAdmin" ref="eventAdmin"/>
</bean>
- <service ref="remoteEventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
+ <service ref="clusterEventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
<service-properties>
<entry key="managed" value="true"/>
</service-properties>
</service>
- <!-- Cluster Core Services -->
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
<reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
[42/50] [abbrv] git commit: [KARAF-2204] cluster:feature-url-add,
cluster:feature-url-remove and corresponding MBeans now support
installAll and uninstallAll option
Posted by jb...@apache.org.
[KARAF-2204] cluster:feature-url-add, cluster:feature-url-remove and corresponding MBeans now support installAll and uninstallAll option
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1496596 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/83431c10
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/83431c10
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/83431c10
Branch: refs/heads/master
Commit: 83431c10bfebcec21dee67ed659fabfa27d418f6
Parents: 2e00e51
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Jun 25 19:19:50 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Jun 25 19:19:50 2013 +0000
----------------------------------------------------------------------
.../cellar/features/ClusterRepositoryEvent.java | 20 +++++++++++++++++++-
.../cellar/features/RepositoryEventHandler.java | 4 ++--
.../cellar/features/shell/UrlAddCommand.java | 5 +++++
.../cellar/features/shell/UrlRemoveCommand.java | 5 +++++
.../cellar/management/CellarFeaturesMBean.java | 20 ++++++++++++++++++++
.../internal/CellarFeaturesMBeanImpl.java | 12 ++++++++++++
6 files changed, 63 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java b/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
index 2073d36..9480483 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java
@@ -22,6 +22,8 @@ import org.apache.karaf.features.RepositoryEvent.EventType;
public class ClusterRepositoryEvent extends Event {
private EventType type;
+ private Boolean install;
+ private Boolean uninstall;
public ClusterRepositoryEvent(String id, EventType type) {
super(id);
@@ -32,7 +34,23 @@ public class ClusterRepositoryEvent extends Event {
return type;
}
- @Override
+ public Boolean getInstall() {
+ return install;
+ }
+
+ public void setInstall(Boolean install) {
+ this.install = install;
+ }
+
+ public Boolean getUninstall() {
+ return uninstall;
+ }
+
+ public void setUninstall(Boolean uninstall) {
+ this.uninstall = uninstall;
+ }
+
+ @Override
public String toString() {
return "ClusterRepositoryEvent [type=" + type + ", id=" + id
+ ", sourceNode=" + sourceNode + ", sourceGroup=" + sourceGroup
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java b/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
index 4077c57..21d43c7 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java
@@ -77,14 +77,14 @@ public class RepositoryEventHandler extends FeaturesSupport implements EventHand
if (RepositoryEvent.EventType.RepositoryAdded.equals(type)) {
if (!isRepositoryRegisteredLocally(uri)) {
LOGGER.debug("CELLAR FEATURES: adding repository URI {}", uri);
- featuresService.addRepository(new URI(uri));
+ featuresService.addRepository(new URI(uri), event.getInstall());
} else {
LOGGER.debug("CELLAR FEATURES: repository URI {} is already registered locally");
}
} else {
if (isRepositoryRegisteredLocally(uri)) {
LOGGER.debug("CELLAR FEATURES: removing repository URI {}", uri);
- featuresService.removeRepository(new URI(uri));
+ featuresService.removeRepository(new URI(uri), event.getUninstall());
} else {
LOGGER.debug("CELLAR FEATURES: repository URI {} is not registered locally");
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
index 83f3e01..2f66c2a 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java
@@ -25,6 +25,7 @@ import org.apache.karaf.features.Repository;
import org.apache.karaf.features.RepositoryEvent;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
import java.net.URI;
import java.util.List;
@@ -39,6 +40,9 @@ public class UrlAddCommand extends FeatureCommandSupport {
@Argument(index = 1, name = "urls", description = "One or more features repository URLs separated by whitespaces", required = true, multiValued = true)
List<String> urls;
+ @Option(name = "-i", aliases = { "--install-all" }, description = "Install all features contained in the repository URLs", required = false, multiValued = false)
+ boolean install;
+
private EventProducer eventProducer;
@Override
@@ -118,6 +122,7 @@ public class UrlAddCommand extends FeatureCommandSupport {
// broadcast the cluster event
ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryAdded);
+ event.setInstall(install);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
----------------------------------------------------------------------
diff --git a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
index 2e25b3b..d579282 100644
--- a/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
+++ b/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java
@@ -25,6 +25,7 @@ import org.apache.karaf.features.Repository;
import org.apache.karaf.features.RepositoryEvent;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
import java.net.URI;
import java.util.List;
@@ -39,6 +40,9 @@ public class UrlRemoveCommand extends FeatureCommandSupport {
@Argument(index = 1, name = "urls", description = "One or more features repository URLs separated by whitespaces", required = true, multiValued = true)
List<String> urls;
+ @Option(name = "-u", aliases = { "--uninstall-all" }, description = "Uninstall all features contained in the repository URLs", required = false, multiValued = false)
+ boolean uninstall;
+
private EventProducer eventProducer;
@Override
@@ -115,6 +119,7 @@ public class UrlRemoveCommand extends FeatureCommandSupport {
// broadcast a cluster event
ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryRemoved);
+ event.setUninstall(uninstall);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java b/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
index b380b41..7e85c17 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/CellarFeaturesMBean.java
@@ -31,6 +31,16 @@ public interface CellarFeaturesMBean {
void addUrl(String group, String url) throws Exception;
/**
+ * Add a features repository URL in a cluster group, eventually installing all features described in the repository.
+ *
+ * @param group the cluster group name.
+ * @param url the features repository URL.
+ * @param install true to install all features described in the repository URL.
+ * @throws Exception
+ */
+ void addUrl(String group, String url, boolean install) throws Exception;
+
+ /**
* Remove a features repository URL from a cluster group.
*
* @param group the cluster group name.
@@ -40,6 +50,16 @@ public interface CellarFeaturesMBean {
void removeUrl(String group, String url) throws Exception;
/**
+ * Remove a features repository URL from a cluster group, eventually uninstalling all features described in the repository.
+ *
+ * @param group the cluster group name.
+ * @param url the features repository URL.
+ * @param uninstall true to uninstall all features described in the repository URL.
+ * @throws Exception
+ */
+ void removeUrl(String group, String url, boolean uninstall) throws Exception;
+
+ /**
* Install a feature in a cluster group.
*
* @param group the cluster group name.
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/83431c10/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
index b75c149..d353554 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
@@ -303,6 +303,11 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
@Override
public void addUrl(String groupName, String url) throws Exception {
+ this.addUrl(groupName, url, false);
+ }
+
+ @Override
+ public void addUrl(String groupName, String url, boolean install) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
@@ -373,6 +378,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
// broadcast the cluster event
ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryAdded);
+ event.setInstall(install);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {
@@ -385,6 +391,11 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
@Override
public void removeUrl(String groupName, String url) throws Exception {
+ this.removeUrl(groupName, url, false);
+ }
+
+ @Override
+ public void removeUrl(String groupName, String url, boolean uninstall) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
@@ -452,6 +463,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
// broadcast a cluster event
ClusterRepositoryEvent event = new ClusterRepositoryEvent(url, RepositoryEvent.EventType.RepositoryRemoved);
+ event.setUninstall(uninstall);
event.setSourceGroup(group);
eventProducer.produce(event);
} else {