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:27:20 UTC
[05/50] git commit: Code cleanup.
Code cleanup.
git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/branches/cellar-2.3.x@1476312 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/acd39040
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/acd39040
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/acd39040
Branch: refs/heads/cellar-2.3.x
Commit: acd39040807ce5fb2c0513e4c36d1d2939674973
Parents: 8d2db1c
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Fri Apr 26 17:37:35 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Fri Apr 26 17:37:35 2013 +0000
----------------------------------------------------------------------
.../cellar/management/CellarBundleMBean.java | 47 +++++++-
.../cellar/management/CellarConfigMBean.java | 55 ++++++++-
.../cellar/management/CellarFeaturesMBean.java | 87 +++++++++++++-
.../cellar/management/CellarGroupMBean.java | 37 +++++-
.../karaf/cellar/management/CellarMBean.java | 69 ++++++++++-
.../cellar/management/CellarNodeMBean.java | 15 ++-
.../internal/CellarBundleMBeanImpl.java | 100 ++++++++--------
.../internal/CellarConfigMBeanImpl.java | 94 ++++++++-------
.../internal/CellarFeaturesMBeanImpl.java | 116 ++++++++++---------
.../internal/CellarGroupMBeanImpl.java | 7 +-
.../management/internal/CellarMBeanImpl.java | 12 +-
.../internal/CellarNodeMBeanImpl.java | 8 +-
12 files changed, 489 insertions(+), 158 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/acd39040/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 76379d8..9b009e7 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 for the Cellar Bundles 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, regex, or ID.
+ * @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, regex, or ID.
+ * @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, regex, or ID.
+ * @param version the bundle version.
+ * @throws Exception in case of stop failure.
+ */
void stop(String group, String symbolicName, String version) throws Exception;
-
+
+ /**
+ * Get the list of bundles in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @return the list of bundles.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData getBundles(String group) throws Exception;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/acd39040/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..beb5a3c 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 of the Cellar Config MBean.
*/
public interface CellarConfigMBean {
+ /**
+ * Get the configurations in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @return the list of configurations.
+ * @throws Exception in case of retrieval failure.
+ */
List<String> listConfig(String group) throws Exception;
+
+ /**
+ * Delete a configuration in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @param pid the configuration PID.
+ * @throws Exception in case of delete failure.
+ */
void deleteConfig(String group, String pid) throws Exception;
+
+ /**
+ * Get 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.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData listProperties(String group, String pid) throws Exception;
+
+ /**
+ * Set the value of a property in 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 at the end of a value of a property in 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 value to append at the end of 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 in 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/acd39040/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 8ae335b..807f71f 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 of 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 in 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 feature install 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 feature install 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 in 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 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 uninstall failure.
+ */
void uninstall(String group, String name, String version) throws Exception;
+ /**
+ * Get the list of the features repositories in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @return the list of the features repositories.
+ * @throws Exception in case of retrieval failure.
+ */
List<String> getUrls(String group) throws Exception;
+
+ /**
+ * Get the list of the features in a cluster group.
+ *
+ * @param group the cluster group name.
+ * @return the list of the 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/acd39040/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 73dc338..e56fedc 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,15 +16,50 @@ package org.apache.karaf.cellar.management;
import javax.management.openmbean.TabularData;
/**
- * Cellar group MBean to manipulate Cellar cluster group.
+ * Describe the operations and attributes of the Cellar Group MBean.
*/
public interface CellarGroupMBean {
+ /**
+ * 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;
+ /**
+ * Get the list the 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/acd39040/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 2b3aebb..1b66b11 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 nodes.
+ *
+ * @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/acd39040/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 78d8840..5612bc5 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,12 +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 of the Cellar Node MBean.
*/
public interface CellarNodeMBean {
+ /**
+ * Ping a node.
+ *
+ * @param nodeId the node ID.
+ * @return the ping time (in milliseconds).
+ * @throws Exception in case of ping failure.
+ */
long pingNode(String nodeId) throws Exception;
+ /**
+ * Get the list of the nodes in the cluster.
+ *
+ * @return the list of the nodes.
+ * @throws Exception in case of retrieval failure.
+ */
TabularData getNodes() throws Exception;
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/acd39040/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..69004f5 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);
@@ -89,7 +90,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
// 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 bundle location is allowed
@@ -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,22 +112,23 @@ 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);
}
- // broadcast the event
+ // broadcast the cluster event
ClusterBundleEvent event = new ClusterBundleEvent(name, version, location, BundleEvent.INSTALLED);
event.setSourceGroup(group);
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);
@@ -136,25 +138,25 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
// 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");
}
- // 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,21 +168,22 @@ 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);
}
- // broadcast the event
+ // broadcast the cluster event
String[] split = key.split("/");
ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleEvent.UNINSTALLED);
event.setSourceGroup(group);
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);
@@ -190,26 +193,26 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
// 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");
}
- // 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);
+ throw new IllegalStateException("Bundle " + key + " is 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);
+ throw new IllegalStateException("Bundle " + key + " is not found in cluster group " + groupName);
}
location = state.getLocation();
@@ -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);
@@ -244,26 +248,26 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
// 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");
}
- // 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);
+ throw new IllegalStateException("Bundle " + key + " is 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);
+ throw new IllegalStateException("Bundle " + key + " is not found in cluster group " + groupName);
}
location = state.getLocation();
@@ -273,37 +277,38 @@ 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.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"},
new String[]{"ID of the bundle", "Name of the bundle", "Version of the bundle", "Current status of the bundle", "Location of the bundle"},
new OpenType[]{SimpleType.INTEGER, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING});
- TabularType tableType = new TabularType("Bundles", "Table of all KarafCellar bundles", compositeType,
+ TabularType tableType = new TabularType("Bundles", "Table of all Karaf Cellar bundles", compositeType,
new String[]{"name", "version"});
TabularData table = new TabularDataSupport(tableType);
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 bundles in a cluster group.
* @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/acd39040/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 8175c81..88a4f8b 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
+ clusterConfigurations.remove(pid);
// broadcast the cluster event
ClusterConfigurationEvent event = new ClusterConfigurationEvent(pid);
@@ -91,10 +93,11 @@ 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);
}
}
+ @Override
public TabularData listProperties(String group, String pid) throws Exception {
CompositeType compositeType = new CompositeType("Property", "Karaf Cellar Config property",
new String[]{"key", "value"},
@@ -104,8 +107,8 @@ 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);
+ Map<String, Properties> clusterConfigurations = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + group);
+ Properties properties = clusterConfigurations.get(pid);
if (properties != null) {
Enumeration propertyNames = properties.propertyNames();
while (propertyNames.hasMoreElements()) {
@@ -120,6 +123,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);
@@ -138,28 +142,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);
@@ -169,7 +174,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
@@ -178,35 +183,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);
@@ -216,7 +222,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
@@ -225,23 +231,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/acd39040/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 b79b792..5eefa93 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 Cellar features MBean 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 cluster 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,22 @@ 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 features in the cluster group
+ clusterFeatures.put(feature, true);
try {
- // update the distributed bundles map
+ // update the bundles in the cluster group
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 +167,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 cluster group exists
Group group = groupManager.findGroupByName(groupName);
@@ -188,7 +192,7 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
// check if 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 +201,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 +229,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 compositeType = new CompositeType("Feature", "Karaf Cellar feature",
new String[]{"name", "version", "installed"},
@@ -257,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(compositeType,
new String[]{"name", "version", "installed"},
new Object[]{feature.getName(), feature.getVersion(), installed});
@@ -273,6 +280,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);
@@ -281,16 +289,17 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
}
// get the distributed URLs list
- List<String> urls = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
+ List<String> clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
List<String> result = new ArrayList<String>();
- for (String url : urls) {
+ for (String url : clusterRepositories) {
result.add(url);
}
return result;
}
+ @Override
public void addUrl(String groupName, String url) throws Exception {
// check if the group exists
Group group = groupManager.findGroupByName(groupName);
@@ -306,14 +315,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;
@@ -335,7 +344,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()) {
@@ -348,16 +357,16 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
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));
@@ -366,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);
@@ -385,14 +395,14 @@ 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) {
+ for (String repository : clusterRepositories) {
if (repository.equals(url)) {
found = true;
break;
@@ -414,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()) {
@@ -427,16 +437,16 @@ public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeat
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));
@@ -445,7 +455,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");
}
}
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/acd39040/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 550b749..834b08b 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
@@ -31,7 +31,7 @@ import java.util.List;
import java.util.Set;
/**
- * Implementation of the Cellar group MBean.
+ * Implementation of the Cellar Group MBean.
*/
public class CellarGroupMBeanImpl extends StandardMBean implements CellarGroupMBean {
@@ -67,6 +67,7 @@ public class CellarGroupMBeanImpl extends StandardMBean implements CellarGroupMB
this.groupManager = groupManager;
}
+ @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/acd39040/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 3e5f370..a7c34b5 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
@@ -41,7 +41,7 @@ import javax.management.openmbean.*;
import java.util.*;
/**
- * Implementation of the Cellar core MBean.
+ * Implementation of the Cellar Core MBean.
*/
public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
@@ -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());
command.setDestination(clusterManager.listNodes());
@@ -142,6 +144,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());
@@ -158,6 +161,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());
@@ -174,6 +178,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);
@@ -200,6 +205,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
return table;
}
+ @Override
public void consumerStart(String nodeId) throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
@@ -216,6 +222,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());
@@ -232,6 +239,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);
@@ -258,6 +266,7 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
return table;
}
+ @Override
public void producerStop(String nodeId) throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
@@ -274,6 +283,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/acd39040/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 4b26b09..b9f95ea 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;
@@ -27,11 +24,10 @@ import javax.management.StandardMBean;
import javax.management.openmbean.*;
import java.util.Arrays;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
/**
- * Implementation of the Cellar node MBean.
+ * Implementation of the Cellar Node MBean.
*/
public class CellarNodeMBeanImpl extends StandardMBean implements CellarNodeMBean {
@@ -58,6 +54,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) {
@@ -71,6 +68,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",