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:50 UTC
[15/50] [abbrv] git commit: Code cleanup
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 {