Return-Path: X-Original-To: apmail-karaf-commits-archive@minotaur.apache.org Delivered-To: apmail-karaf-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8E1E4FB29 for ; Wed, 24 Apr 2013 15:36:13 +0000 (UTC) Received: (qmail 37478 invoked by uid 500); 24 Apr 2013 15:36:13 -0000 Delivered-To: apmail-karaf-commits-archive@karaf.apache.org Received: (qmail 37433 invoked by uid 500); 24 Apr 2013 15:36:13 -0000 Mailing-List: contact commits-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@karaf.apache.org Delivered-To: mailing list commits@karaf.apache.org Received: (qmail 37425 invoked by uid 99); 24 Apr 2013 15:36:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Apr 2013 15:36:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Apr 2013 15:36:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 467852388A4A; Wed, 24 Apr 2013 15:35:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1471486 - in /karaf/cellar/trunk: features/src/main/java/org/apache/karaf/cellar/features/ features/src/main/java/org/apache/karaf/cellar/features/shell/ features/src/main/resources/OSGI-INF/blueprint/ management/src/main/java/org/apache/k... Date: Wed, 24 Apr 2013 15:35:48 -0000 To: commits@karaf.apache.org From: jbonofre@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130424153549.467852388A4A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jbonofre Date: Wed Apr 24 15:35:47 2013 New Revision: 1471486 URL: http://svn.apache.org/r1471486 Log: Code cleanup Added: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java - copied, changed from r1471437, karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RemoteFeaturesEvent.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java - copied, changed from r1471437, karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RemoteRepositoryEvent.java Removed: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RemoteFeaturesEvent.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RemoteRepositoryEvent.java Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/Constants.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeatureInfo.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/ListGroupFeatures.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlListCommand.java karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/blueprint.xml karaf/cellar/trunk/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java Copied: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java (from r1471437, karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RemoteFeaturesEvent.java) URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java?p2=karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java&p1=karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RemoteFeaturesEvent.java&r1=1471437&r2=1471486&rev=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RemoteFeaturesEvent.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/ClusterFeaturesEvent.java Wed Apr 24 15:35:47 2013 @@ -17,9 +17,9 @@ import org.apache.karaf.cellar.core.even import org.apache.karaf.features.FeatureEvent.EventType; /** - * Remove features event. + * Cluster features event. */ -public class RemoteFeaturesEvent extends Event { +public class ClusterFeaturesEvent extends Event { private static final String separator = "/"; @@ -29,7 +29,7 @@ public class RemoteFeaturesEvent extends private Boolean noRefresh; private EventType type; - public RemoteFeaturesEvent(String name, String version, EventType type) { + public ClusterFeaturesEvent(String name, String version, EventType type) { super(name + separator + version); this.name = name; this.version = version; @@ -38,7 +38,7 @@ public class RemoteFeaturesEvent extends this.type = type; } - public RemoteFeaturesEvent(String name, String version, Boolean noClean, Boolean noRefresh, EventType type) { + public ClusterFeaturesEvent(String name, String version, Boolean noClean, Boolean noRefresh, EventType type) { super(name + separator + version); this.name = name; this.version = version; Copied: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java (from r1471437, karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RemoteRepositoryEvent.java) URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java?p2=karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java&p1=karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RemoteRepositoryEvent.java&r1=1471437&r2=1471486&rev=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RemoteRepositoryEvent.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/ClusterRepositoryEvent.java Wed Apr 24 15:35:47 2013 @@ -17,17 +17,13 @@ import org.apache.karaf.cellar.core.even import org.apache.karaf.features.RepositoryEvent.EventType; /** - * Remote repository event. + * Cluster features repository event. */ -public class RemoteRepositoryEvent extends Event { +public class ClusterRepositoryEvent extends Event { - /** - * - */ - private static final long serialVersionUID = 1L; private EventType type; - public RemoteRepositoryEvent(String id, EventType type) { + public ClusterRepositoryEvent(String id, EventType type) { super(id); this.type = type; } @@ -36,12 +32,9 @@ public class RemoteRepositoryEvent exten return type; } - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ @Override public String toString() { - return "RemoteRepositoryEvent [type=" + type + ", id=" + id + return "ClusterRepositoryEvent [type=" + type + ", id=" + id + ", sourceNode=" + sourceNode + ", sourceGroup=" + sourceGroup + ", destination=" + destination + ", force=" + force + ", postPublish=" + postPublish + "]"; Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/Constants.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/Constants.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/Constants.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/Constants.java Wed Apr 24 15:35:47 2013 @@ -14,7 +14,7 @@ package org.apache.karaf.cellar.features; /** - * Features constants. + * Features configuration constants. */ public class Constants { Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeatureInfo.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeatureInfo.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeatureInfo.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeatureInfo.java Wed Apr 24 15:35:47 2013 @@ -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 { Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java Wed Apr 24 15:35:47 2013 @@ -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 { +public class FeaturesEventHandler extends FeaturesSupport implements EventHandler { private static final transient Logger LOGGER = LoggerFactory.getLogger(FeaturesSynchronizer.class); @@ -49,11 +49,11 @@ public class FeaturesEventHandler extend } /** - * 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 extend // 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 extend } } } 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 getType() { - return RemoteFeaturesEvent.class; + /** + * Get the event type that this handler is able to handle. + * + * @return the cluster features event type. + */ + @Override + public Class getType() { + return ClusterFeaturesEvent.class; } + /** + * Get the handler switch. + * + * @return the handler switch. + */ + @Override public Switch getSwitch() { // load the switch status from the config try { Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSupport.java Wed Apr 24 15:35:47 2013 @@ -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 Cel } /** - * 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 Cel 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 Cel 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 Cel } /** - * 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(); Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesSynchronizer.java Wed Apr 24 15:35:47 2013 @@ -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 extend private static final transient Logger LOGGER = LoggerFactory.getLogger(FeaturesSynchronizer.class); + @Override public void init() { super.init(); Set groups = groupManager.listLocalGroups(); @@ -48,23 +47,26 @@ public class FeaturesSynchronizer extend 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 clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName); Map clusterFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName); clusterManager.getList(Constants.FEATURES + Configurations.SEPARATOR + groupName); @@ -76,7 +78,7 @@ public class FeaturesSynchronizer extend 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 extend 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 extend } /** - * 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 extend } } + /** + * 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; Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/LocalFeaturesListener.java Wed Apr 24 15:35:47 2013 @@ -24,7 +24,6 @@ import org.apache.karaf.features.Reposit import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; import java.util.Map; import java.util.Set; @@ -48,10 +47,11 @@ public class LocalFeaturesListener exten } /** - * 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 exten 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 exten } // 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 exten 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 distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName()); + // update the features in the cluster group + Map 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 distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + group.getName()); + // update the features in the cluster group + Map 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); } } } Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/RepositoryEventHandler.java Wed Apr 24 15:35:47 2013 @@ -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 { +public class RepositoryEventHandler extends FeaturesSupport implements EventHandler { private static final transient Logger LOGGER = LoggerFactory.getLogger(RepositoryEventHandler.class); @@ -44,7 +44,13 @@ public class RepositoryEventHandler exte 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 exte } } - public Class getType() { - return RemoteRepositoryEvent.class; + @Override + public Class getType() { + return ClusterRepositoryEvent.class; } + @Override public Switch getSwitch() { return eventSwitch; } Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/FeatureCommandSupport.java Wed Apr 24 15:35:47 2013 @@ -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 FeatureCommandSupp 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 FeatureCommandSupp if (group == null || group.getNodes().isEmpty()) { FeatureInfo info = new FeatureInfo(feature, version); - Map features = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName); + Map 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 FeatureCommandSupp } } - // 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 FeatureCommandSupp } 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 FeatureCommandSupp } /** - * 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 distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName); + Map 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 FeatureCommandSupp } } + /** + * 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 FeatureCommandSupp 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; } Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java Wed Apr 24 15:35:47 2013 @@ -17,14 +17,14 @@ import org.apache.karaf.cellar.core.Grou 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 exten @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 exten // 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); Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/ListGroupFeatures.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/ListGroupFeatures.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/ListGroupFeatures.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/ListGroupFeatures.java Wed Apr 24 15:35:47 2013 @@ -23,16 +23,16 @@ import org.apache.karaf.shell.commands.O 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 F try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); - Map features = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName); - if (features != null && !features.isEmpty()) { - System.out.println(String.format("Features for cluster group " + groupName)); + Map 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 F 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); } Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UninstallFeatureCommand.java Wed Apr 24 15:35:47 2013 @@ -17,22 +17,22 @@ import org.apache.karaf.cellar.core.Grou 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 ext // 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); Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlAddCommand.java Wed Apr 24 15:35:47 2013 @@ -19,7 +19,7 @@ import org.apache.karaf.cellar.core.cont 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 urls; private EventProducer eventProducer; @@ -59,15 +59,15 @@ public class UrlAddCommand extends Featu ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); - // get the repositories distributed list - List distributedRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName); - // get the features distributed map - Map distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName); + // get the features repositories in the cluster group + List clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName); + // get the features in the cluster group + Map 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 Featu 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 { Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlListCommand.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlListCommand.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlListCommand.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlListCommand.java Wed Apr 24 15:35:47 2013 @@ -21,7 +21,7 @@ import org.apache.karaf.shell.commands.C 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 Feat return null; } - // get the distributed list - List repositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName); + // get the features repositories in the cluster group + List clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName); - for (String repository : repositories) { + for (String repository : clusterRepositories) { System.out.println(repository); } Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java (original) +++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/shell/UrlRemoveCommand.java Wed Apr 24 15:35:47 2013 @@ -19,7 +19,7 @@ import org.apache.karaf.cellar.core.cont 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 urls; private EventProducer eventProducer; @@ -56,15 +56,15 @@ public class UrlRemoveCommand extends Fe return null; } - // get the distributed list - List distributedRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName); - // get the features distributed map - Map distributedFeatures = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName); + // get the features repositories in the cluster group + List clusterRepositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName); + // get the features in the cluster group + Map 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 Fe 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); } } Modified: karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/blueprint.xml URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original) +++ karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/blueprint.xml Wed Apr 24 15:35:47 2013 @@ -18,7 +18,7 @@ http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> - @@ -26,7 +26,7 @@ - + - - + - + - - + - + Modified: karaf/cellar/trunk/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java?rev=1471486&r1=1471485&r2=1471486&view=diff ============================================================================== --- karaf/cellar/trunk/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java (original) +++ karaf/cellar/trunk/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java Wed Apr 24 15:35:47 2013 @@ -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 ext } // 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 ext 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 ext 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 ext 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 {