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 2012/04/30 10:35:04 UTC
svn commit: r1332111 - in /karaf/cellar/trunk:
bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/
bundle/src/main/resources/OSGI-INF/blueprint/
core/src/main/java/org/apache/karaf/cellar/core/control/
core/src/main/java/org/apache/karaf/cellar/...
Author: jbonofre
Date: Mon Apr 30 08:35:03 2012
New Revision: 1332111
URL: http://svn.apache.org/viewvc?rev=1332111&view=rev
Log:
[KARAF-1239] Use the local node event producer and check the producer status
Modified:
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java
karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml
karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java
karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java
karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
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/UninstallFeatureCommand.java
karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml
karaf/cellar/trunk/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarFeaturesMBeanImpl.java
karaf/cellar/trunk/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml
karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java
karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java
karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java
karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java
karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java
karaf/cellar/trunk/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
Modified: karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java (original)
+++ karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java Mon Apr 30 08:35:03 2012
@@ -18,6 +18,7 @@ import org.apache.karaf.cellar.bundle.Co
import org.apache.karaf.cellar.bundle.RemoteBundleEvent;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
import org.apache.karaf.shell.commands.Argument;
@@ -38,13 +39,23 @@ public class InstallBundleCommand extend
@Argument(index = 1, name = "location", description = "The bundle location.", required = true, multiValued = false)
String location;
+ private EventProducer eventProducer;
+
@Override
protected Object doExecute() throws Exception {
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ System.err.println("Cluster event producer is OFF for this node");
+ return null;
+ }
+
// get the name and version in the location MANIFEST
JarInputStream jarInputStream = new JarInputStream(new URL(location).openStream());
Manifest manifest = jarInputStream.getManifest();
@@ -60,12 +71,19 @@ public class InstallBundleCommand extend
bundles.put(name + "/" + version, state);
// broadcast the event
- EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
RemoteBundleEvent event = new RemoteBundleEvent(name, version, location, BundleEvent.INSTALLED);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
return null;
}
+ public EventProducer getEventProducer() {
+ return eventProducer;
+ }
+
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
+ }
+
}
Modified: karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java (original)
+++ karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java Mon Apr 30 08:35:03 2012
@@ -18,6 +18,7 @@ import org.apache.karaf.cellar.bundle.Co
import org.apache.karaf.cellar.bundle.RemoteBundleEvent;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
import org.apache.karaf.shell.commands.Argument;
@@ -38,13 +39,23 @@ public class StartBundleCommand extends
@Argument(index = 2, name = "version", description = "The bundle version.", required = true, multiValued = false)
String version;
+ private EventProducer eventProducer;
+
@Override
protected Object doExecute() throws Exception {
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ System.err.println("Cluster event producer is OFF for this node");
+ return null;
+ }
+
// update the distributed map
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -64,12 +75,19 @@ public class StartBundleCommand extends
}
// broadcast the event
- EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
RemoteBundleEvent event = new RemoteBundleEvent(name, version, location, BundleEvent.STARTED);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
return null;
}
+ public EventProducer getEventProducer() {
+ return eventProducer;
+ }
+
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
+ }
+
}
Modified: karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java (original)
+++ karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java Mon Apr 30 08:35:03 2012
@@ -18,6 +18,7 @@ import org.apache.karaf.cellar.bundle.Co
import org.apache.karaf.cellar.bundle.RemoteBundleEvent;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
import org.apache.karaf.shell.commands.Argument;
@@ -38,13 +39,23 @@ public class StopBundleCommand extends C
@Argument(index = 2, name = "version", description = "The bundle version.", required = true, multiValued = false)
String version;
+ private EventProducer eventProducer;
+
@Override
protected Object doExecute() throws Exception {
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ System.err.println("Cluster event producer is OFF for this node");
+ return null;
+ }
+
// update the cluster map
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -64,12 +75,19 @@ public class StopBundleCommand extends C
}
// broadcast the event
- EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
RemoteBundleEvent event = new RemoteBundleEvent(name, version, location, BundleEvent.STOPPED);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
return null;
}
+ public EventProducer getEventProducer() {
+ return eventProducer;
+ }
+
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
+ }
+
}
Modified: karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java (original)
+++ karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java Mon Apr 30 08:35:03 2012
@@ -18,6 +18,7 @@ import org.apache.karaf.cellar.bundle.Co
import org.apache.karaf.cellar.bundle.RemoteBundleEvent;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.shell.CellarCommandSupport;
import org.apache.karaf.shell.commands.Argument;
@@ -38,13 +39,23 @@ public class UninstallBundleCommand exte
@Argument(index = 2, name = "version", description = "The bundle version.", required = true, multiValued = false)
String version;
+ private EventProducer eventProducer;
+
@Override
protected Object doExecute() throws Exception {
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ System.err.println("Cluster event producer is OFF for this node");
+ return null;
+ }
+
// update the cluster map
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -63,12 +74,19 @@ public class UninstallBundleCommand exte
}
// broadcast the event
- EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
RemoteBundleEvent event = new RemoteBundleEvent(name, version, location, BundleEvent.UNINSTALLED);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
return null;
}
+ public EventProducer getEventProducer() {
+ return eventProducer;
+ }
+
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
+ }
+
}
Modified: karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml (original)
+++ karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml Mon Apr 30 08:35:03 2012
@@ -19,7 +19,6 @@
<action class="org.apache.karaf.cellar.bundle.shell.ListBundleCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
</action>
<completers>
<ref component-id="allGroupCompleter"/>
@@ -29,7 +28,7 @@
<action class="org.apache.karaf.cellar.bundle.shell.InstallBundleCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
+ <property name="eventProducer" ref="eventProducer"/>
</action>
<completers>
<ref component-id="allGroupCompleter"/>
@@ -39,7 +38,7 @@
<action class="org.apache.karaf.cellar.bundle.shell.UninstallBundleCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
+ <property name="eventProducer" ref="eventProducer"/>
</action>
<completers>
<ref component-id="allGroupCompleter"/>
@@ -51,7 +50,7 @@
<action class="org.apache.karaf.cellar.bundle.shell.StartBundleCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
+ <property name="eventProducer" ref="eventProducer"/>
</action>
<completers>
<ref component-id="allGroupCompleter"/>
@@ -63,7 +62,7 @@
<action class="org.apache.karaf.cellar.bundle.shell.StopBundleCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
+ <property name="eventProducer" ref="eventProducer"/>
</action>
<completers>
<ref component-id="allGroupCompleter"/>
Modified: karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java (original)
+++ karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/control/ProducerSwitchCommandHandler.java Mon Apr 30 08:35:03 2012
@@ -39,7 +39,7 @@ public class ProducerSwitchCommandHandle
producer.getSwitch().turnOn();
return new ProducerSwitchResult(command.getId(), Boolean.TRUE, Boolean.TRUE);
}
- //Turn on the switch
+ //Turn off the switch
else if (command.getStatus().equals(SwitchStatus.OFF)) {
producer.getSwitch().turnOff();
return new ProducerSwitchResult(command.getId(), Boolean.TRUE, Boolean.FALSE);
Modified: karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java (original)
+++ karaf/cellar/trunk/core/src/main/java/org/apache/karaf/cellar/core/shell/CellarCommandSupport.java Mon Apr 30 08:35:03 2012
@@ -25,7 +25,6 @@ public abstract class CellarCommandSuppo
protected ClusterManager clusterManager;
protected GroupManager groupManager;
- protected EventTransportFactory eventTransportFactory;
public ClusterManager getClusterManager() {
return clusterManager;
@@ -43,11 +42,4 @@ public abstract class CellarCommandSuppo
this.groupManager = groupManager;
}
- public EventTransportFactory getEventTransportFactory() {
- return eventTransportFactory;
- }
-
- public void setEventTransportFactory(EventTransportFactory eventTransportFactory) {
- this.eventTransportFactory = eventTransportFactory;
- }
}
Modified: karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml (original)
+++ karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml Mon Apr 30 08:35:03 2012
@@ -19,7 +19,6 @@
<command name="cluster/service-list">
<action class="org.apache.karaf.cellar.dosgi.shell.ListDistributedServicesCommand">
<property name="clusterManager" ref="clusterManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
</action>
</command>
</command-bundle>
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=1332111&r1=1332110&r2=1332111&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 Mon Apr 30 08:35:03 2012
@@ -14,6 +14,7 @@
package org.apache.karaf.cellar.features.shell;
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.features.RemoteFeaturesEvent;
import org.apache.karaf.features.FeatureEvent;
@@ -32,20 +33,40 @@ public class InstallFeatureCommand exten
@Argument(index = 2, name = "version", description = "The feature version.", required = false, multiValued = false)
String version;
+ private EventProducer eventProducer;
+
@Override
protected Object doExecute() throws Exception {
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
- EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ System.err.println("Cluster event producer is OFF for this node");
+ return null;
+ }
+
+ // update the distributed map
+ updateFeatureStatus(groupName, feature, version, true);
+
+ // broadcast the cluster event
RemoteFeaturesEvent event = new RemoteFeaturesEvent(feature, version, FeatureEvent.EventType.FeatureInstalled);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
- updateFeatureStatus(groupName, feature, version, true);
return null;
}
+ public EventProducer getEventProducer() {
+ return eventProducer;
+ }
+
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
+ }
+
}
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=1332111&r1=1332110&r2=1332111&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 Mon Apr 30 08:35:03 2012
@@ -14,6 +14,7 @@
package org.apache.karaf.cellar.features.shell;
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.features.RemoteFeaturesEvent;
import org.apache.karaf.features.FeatureEvent;
@@ -32,21 +33,41 @@ public class UninstallFeatureCommand ext
@Argument(index = 2, name = "version", description = "The feature version.", required = false, multiValued = false)
String version;
+ private EventProducer eventProducer;
+
@Override
protected Object doExecute() throws Exception {
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
- EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ System.err.println("Cluster event producer is OFF for this node");
+ return null;
+ }
+
+ // update the distributed map
+ updateFeatureStatus(groupName, feature, version, true);
+
+ // broadcast the cluster event
RemoteFeaturesEvent event = new RemoteFeaturesEvent(feature, version, FeatureEvent.EventType.FeatureUninstalled);
event.setForce(true);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
- updateFeatureStatus(groupName, feature, version, true);
return null;
}
+ public EventProducer getEventProducer() {
+ return eventProducer;
+ }
+
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
+ }
+
}
Modified: karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml (original)
+++ karaf/cellar/trunk/features/src/main/resources/OSGI-INF/blueprint/shell-features.xml Mon Apr 30 08:35:03 2012
@@ -20,8 +20,8 @@
<action class="org.apache.karaf.cellar.features.shell.InstallFeatureCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
<property name="featuresService" ref="featuresService"/>
+ <property name="eventProducer" ref="eventProducer"/>
</action>
<completers>
<ref component-id="allGroupCompleter"/>
@@ -32,8 +32,8 @@
<action class="org.apache.karaf.cellar.features.shell.UninstallFeatureCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
<property name="featuresService" ref="featuresService"/>
+ <property name="eventProducer" ref="eventProducer"/>
</action>
<completers>
<ref component-id="allGroupCompleter"/>
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=1332111&r1=1332110&r2=1332111&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 Mon Apr 30 08:35:03 2012
@@ -17,6 +17,7 @@ import org.apache.karaf.cellar.core.Clus
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.GroupManager;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.event.EventTransportFactory;
import org.apache.karaf.cellar.features.Constants;
@@ -36,8 +37,8 @@ import java.util.Map;
public class CellarFeaturesMBeanImpl extends StandardMBean implements CellarFeaturesMBean {
private ClusterManager clusterManager;
- private EventTransportFactory eventTransportFactory;
private GroupManager groupManager;
+ private EventProducer eventProducer;
public ClusterManager getClusterManager() {
return this.clusterManager;
@@ -55,12 +56,12 @@ public class CellarFeaturesMBeanImpl ext
this.groupManager = groupManager;
}
- public EventTransportFactory getEventTransportFactory() {
- return eventTransportFactory;
+ public EventProducer getEventProducer() {
+ return eventProducer;
}
- public void setEventTransportFactory(EventTransportFactory eventTransportFactory) {
- this.eventTransportFactory = eventTransportFactory;
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
}
public CellarFeaturesMBeanImpl() throws NotCompliantMBeanException {
@@ -68,11 +69,20 @@ public class CellarFeaturesMBeanImpl ext
}
public void install(String groupName, String name, String version) throws Exception {
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
- EventProducer producer = eventTransportFactory.getEventProducer(groupName,true);
+ if (group == null) {
+ throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
+ }
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ throw new IllegalStateException("Cluster event producer is OFF for this node");
+ }
+
RemoteFeaturesEvent event = new RemoteFeaturesEvent(name, version, FeatureEvent.EventType.FeatureInstalled);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
}
public void install(String groupName, String name) throws Exception {
@@ -80,11 +90,20 @@ public class CellarFeaturesMBeanImpl ext
}
public void uninstall(String groupName, String name, String version) throws Exception {
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
- EventProducer producer = eventTransportFactory.getEventProducer(groupName,true);
+ if (group == null) {
+ throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
+ }
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ throw new IllegalStateException("Cluster event producer is OFF for this node");
+ }
+
RemoteFeaturesEvent event = new RemoteFeaturesEvent(name, version, FeatureEvent.EventType.FeatureUninstalled);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
}
public void uninstall(String groupName, String name) throws Exception {
Modified: karaf/cellar/trunk/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original)
+++ karaf/cellar/trunk/management/src/main/resources/OSGI-INF/blueprint/blueprint.xml Mon Apr 30 08:35:03 2012
@@ -17,8 +17,8 @@
<!-- Reference to the Cellar services -->
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
- <reference id="eventTransportFactory" interface="org.apache.karaf.cellar.core.event.EventTransportFactory"/>
<reference id="executionContext" interface="org.apache.karaf.cellar.core.command.ExecutionContext"/>
+ <reference id="eventProducer" interface="org.apache.karaf.cellar.core.event.EventProducer"/>
<bean id="cellarMBean" class="org.apache.karaf.cellar.management.internal.CellarMBeanImpl">
<property name="clusterManager" ref="clusterManager"/>
@@ -36,7 +36,7 @@
<bean id="cellarFeaturesMBean" class="org.apache.karaf.cellar.management.internal.CellarFeaturesMBeanImpl">
<property name="clusterManager" ref="clusterManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
+ <property name="eventProducer" ref="eventProducer"/>
<property name="groupManager" ref="groupManager"/>
</bean>
Modified: karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java (original)
+++ karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrAddUrlCommand.java Mon Apr 30 08:35:03 2012
@@ -17,6 +17,7 @@ import org.apache.felix.bundlerepository
import org.apache.felix.bundlerepository.Resource;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.obr.Constants;
import org.apache.karaf.cellar.obr.ObrBundleInfo;
@@ -35,11 +36,19 @@ public class ObrAddUrlCommand extends Ob
@Argument(index = 1, name = "url", description = "The repository URL to register in the OBR service.", required = true, multiValued = false)
String url;
+ private EventProducer eventProducer;
+
public Object doExecute() throws Exception {
- // find group for the given name
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
- System.err.println("Cluster group " + groupName + " doesn't exist.");
+ System.err.println("Cluster group " + groupName + " doesn't exist");
+ return null;
+ }
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ System.err.println("Cluster event producer is OFF for this node");
return null;
}
@@ -58,13 +67,20 @@ public class ObrAddUrlCommand extends Ob
obrService.removeRepository(url);
}
- // create an event and produce it
- EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
+ // broadcast the cluster event
ObrUrlEvent event = new ObrUrlEvent(url, Constants.URL_ADD_EVENT_TYPE);
- event.setForce(true);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
+
return null;
}
+ public EventProducer getEventProducer() {
+ return eventProducer;
+ }
+
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
+ }
+
}
Modified: karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java (original)
+++ karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrDeployCommand.java Mon Apr 30 08:35:03 2012
@@ -14,6 +14,7 @@
package org.apache.karaf.cellar.obr.shell;
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.shell.CellarCommandSupport;
import org.apache.karaf.cellar.obr.Constants;
@@ -34,23 +35,39 @@ public class ObrDeployCommand extends Ce
@Option(name = "-s", aliases = { "--start" }, description = "Start the deployed bundles.", required = false, multiValued = false)
boolean start = false;
+ private EventProducer eventProducer;
+
@Override
protected Object doExecute() throws Exception {
- // find the group for the given name
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
- System.err.println("Cluster group " + groupName + " doesn't exist.");
+ System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
- // create an event and produce it
- EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ System.err.println("Cluster event producer is OFF for this node");
+ return null;
+ }
+
+ // broadcast the cluster event
int type = 0;
if (start) type = Constants.BUNDLE_START_EVENT_TYPE;
ObrBundleEvent event = new ObrBundleEvent(bundleId, type);
- event.setForce(true);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
+
return null;
}
+ public EventProducer getEventProducer() {
+ return eventProducer;
+ }
+
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
+ }
+
}
Modified: karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java (original)
+++ karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListCommand.java Mon Apr 30 08:35:03 2012
@@ -30,11 +30,13 @@ public class ObrListCommand extends Cell
String groupName;
public Object doExecute() {
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
- System.err.println("Cluster group " + groupName + " doesn't exist.");
+ System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
+
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
@@ -56,6 +58,7 @@ public class ObrListCommand extends Cell
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
+
return null;
}
Modified: karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java (original)
+++ karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrListUrlCommand.java Mon Apr 30 08:35:03 2012
@@ -29,11 +29,13 @@ public class ObrListUrlCommand extends C
String groupName;
public Object doExecute() throws Exception {
+ // cehck if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
- System.err.println("Cluster group " + groupName + " doesn't exist.");
+ System.err.println("Cluster group " + groupName + " doesn't exist");
return null;
}
+
// get the URLs from the distribution set
Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
if (urls != null) {
@@ -41,6 +43,7 @@ public class ObrListUrlCommand extends C
System.out.println(url);
}
}
+
return null;
}
Modified: karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java (original)
+++ karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/shell/ObrRemoveUrlCommand.java Mon Apr 30 08:35:03 2012
@@ -17,6 +17,7 @@ import org.apache.felix.bundlerepository
import org.apache.felix.bundlerepository.Resource;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.obr.Constants;
import org.apache.karaf.cellar.obr.ObrBundleInfo;
@@ -35,14 +36,22 @@ public class ObrRemoveUrlCommand extends
@Argument(index = 1, name = "url", description = "The repository URL to remove from the OBR service.", required = true, multiValued = false)
String url;
+ private EventProducer eventProducer;
+
public Object doExecute() throws Exception {
- // find the group for the given name
+ // check if the group exists
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
System.err.println("Cluster group " + groupName + " doesn't exist.");
return null;
}
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ System.err.println("Cluster event producer is OFF for this node");
+ return null;
+ }
+
// remove URLS_DISTRIBUTED_SET_NAME from the distributed map
Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName);
urls.remove(url);
@@ -59,12 +68,19 @@ public class ObrRemoveUrlCommand extends
}
// create an event and produce it
- EventProducer producer = eventTransportFactory.getEventProducer(groupName, true);
ObrUrlEvent event = new ObrUrlEvent(url, Constants.URL_REMOVE_EVENT_TYPE);
- event.setForce(true);
event.setSourceGroup(group);
- producer.produce(event);
+ eventProducer.produce(event);
+
return null;
}
+ public EventProducer getEventProducer() {
+ return eventProducer;
+ }
+
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
+ }
+
}
Modified: karaf/cellar/trunk/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml?rev=1332111&r1=1332110&r2=1332111&view=diff
==============================================================================
--- karaf/cellar/trunk/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml (original)
+++ karaf/cellar/trunk/obr/src/main/resources/OSGI-INF/blueprint/shell-commands.xml Mon Apr 30 08:35:03 2012
@@ -20,7 +20,6 @@
<action class="org.apache.karaf.cellar.obr.shell.ObrListCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
</action>
<completers>
<ref component-id="allGroupCompleter"/>
@@ -31,7 +30,7 @@
<action class="org.apache.karaf.cellar.obr.shell.ObrDeployCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
+ <property name="eventProducer" ref="eventProducer"/>
</action>
<completers>
<ref component-id="allGroupCompleter"/>
@@ -42,7 +41,7 @@
<action class="org.apache.karaf.cellar.obr.shell.ObrListUrlCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
+ <property name="eventProducer" ref="eventProducer"/>
</action>
<completers>
<ref component-id="allGroupCompleter"/>
@@ -53,7 +52,7 @@
<action class="org.apache.karaf.cellar.obr.shell.ObrAddUrlCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
+ <property name="eventProducer" ref="eventProducer"/>
<property name="obrService" ref="repositoryAdmin"/>
</action>
<completers>
@@ -65,7 +64,7 @@
<action class="org.apache.karaf.cellar.obr.shell.ObrRemoveUrlCommand">
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="eventTransportFactory" ref="eventTransportFactory"/>
+ <property name="eventProducer" ref="eventProducer"/>
<property name="obrService" ref="repositoryAdmin"/>
</action>
<completers>