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 16:04:53 UTC
svn commit: r1332213 - in /karaf/cellar/trunk:
bundle/src/main/java/org/apache/karaf/cellar/bundle/
bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/
bundle/src/main/resources/OSGI-INF/blueprint/
config/src/main/java/org/apache/karaf/cellar/co...
Author: jbonofre
Date: Mon Apr 30 14:04:52 2012
New Revision: 1332213
URL: http://svn.apache.org/viewvc?rev=1332213&view=rev
Log:
[KARAF-1426] Add check in the handlers
Modified:
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
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/ListBundleCommand.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/blueprint.xml
karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
karaf/cellar/trunk/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
karaf/cellar/trunk/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
karaf/cellar/trunk/event/src/main/java/org/apache/karaf/cellar/event/RemoteEventHandler.java
karaf/cellar/trunk/event/src/main/resources/OSGI-INF/blueprint/blueprint.xml
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/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/resources/OSGI-INF/blueprint/blueprint.xml
karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
karaf/cellar/trunk/obr/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Modified: karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java (original)
+++ karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java Mon Apr 30 14:04:52 2012
@@ -107,7 +107,7 @@ public class BundleSynchronizer extends
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR BUNDLE: cluster event producer is OFF for this node");
+ LOGGER.warn("CELLAR BUNDLE: cluster event producer is OFF");
return;
}
Modified: karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java (original)
+++ karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java Mon Apr 30 14:04:52 2012
@@ -43,7 +43,7 @@ public class LocalBundleListener extends
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- LOGGER.warn("CELLAR BUNDLE: cluster event producer is OFF for this node");
+ LOGGER.warn("CELLAR BUNDLE: cluster event producer is OFF");
return;
}
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=1332213&r1=1332212&r2=1332213&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 14:04:52 2012
@@ -52,7 +52,7 @@ public class InstallBundleCommand extend
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- System.err.println("Cluster event producer is OFF for this node");
+ System.err.println("Cluster event producer is OFF");
return null;
}
Modified: karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java (original)
+++ karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java Mon Apr 30 14:04:52 2012
@@ -34,11 +34,13 @@ public class ListBundleCommand extends C
@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;
}
+
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
try {
@@ -86,6 +88,7 @@ public class ListBundleCommand extends C
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
+
return null;
}
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=1332213&r1=1332212&r2=1332213&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 14:04:52 2012
@@ -52,7 +52,7 @@ public class StartBundleCommand extends
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- System.err.println("Cluster event producer is OFF for this node");
+ System.err.println("Cluster event producer is OFF");
return null;
}
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=1332213&r1=1332212&r2=1332213&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 14:04:52 2012
@@ -52,7 +52,7 @@ public class StopBundleCommand extends C
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- System.err.println("Cluster event producer is OFF for this node");
+ System.err.println("Cluster event producer is OFF");
return null;
}
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=1332213&r1=1332212&r2=1332213&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 14:04:52 2012
@@ -52,7 +52,7 @@ public class UninstallBundleCommand exte
// check if the producer is ON
if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
- System.err.println("Cluster event producer is OFF for this node");
+ System.err.println("Cluster event producer is OFF");
return null;
}
Modified: karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original)
+++ karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml Mon Apr 30 14:04:52 2012
@@ -15,7 +15,7 @@
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <!-- Cluster Configuration Listener -->
+ <!-- Local Bundle Listener -->
<bean id="bundleListener" class="org.apache.karaf.cellar.bundle.LocalBundleListener" init-method="init"
destroy-method="destroy">
<property name="clusterManager" ref="clusterManager"/>
@@ -25,7 +25,7 @@
<property name="eventProducer" ref="eventProducer"/>
</bean>
- <!-- Configuration Synchronizer -->
+ <!-- Bundle Synchronizer -->
<bean id="synchronizer" class="org.apache.karaf.cellar.bundle.BundleSynchronizer"
init-method="init" destroy-method="destroy" depends-on="eventHandler">
<property name="configurationAdmin" ref="configurationAdmin"/>
@@ -34,7 +34,9 @@
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="eventProducer" ref="eventProducer"/>
</bean>
+ <service ref="synchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
+ <!-- Cluster Event Handler -->
<bean id="eventHandler" class="org.apache.karaf.cellar.bundle.BundleEventHandler"
init-method="init" destroy-method="destroy">
<property name="configurationAdmin" ref="configurationAdmin"/>
@@ -42,15 +44,13 @@
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="groupManager" ref="groupManager"/>
</bean>
-
- <!-- OSGi Services & References -->
<service ref="eventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
<service-properties>
<entry key="managed" value="true"/>
</service-properties>
</service>
- <service ref="synchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
+ <!-- Cluster Core Services -->
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
<reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationEventHandler.java Mon Apr 30 14:04:52 2012
@@ -53,11 +53,18 @@ public class ConfigurationEventHandler e
if (event == null || event.getSourceGroup() == null || node == null || node.equals(event.getSourceNode()))
return;
+ // check if the handler is ON
if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
LOGGER.warn("CELLAR CONFIG: {} switch is OFF, cluster event is not handled", SWITCH_ID);
return;
}
+ // check if the group is local
+ if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
+ LOGGER.warn("CELLAR CONFIG: node is not part of the event cluster group");
+ return;
+ }
+
Group group = event.getSourceGroup();
String groupName = group.getName();
Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSynchronizer.java Mon Apr 30 14:04:52 2012
@@ -16,6 +16,7 @@ package org.apache.karaf.cellar.config;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.Synchronizer;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.event.EventType;
import org.osgi.framework.InvalidSyntaxException;
@@ -38,12 +39,13 @@ public class ConfigurationSynchronizer e
private static final transient Logger LOGGER = LoggerFactory.getLogger(ConfigurationSynchronizer.class);
- private List<EventProducer> producerList;
+ private EventProducer eventProducer;
/**
* Constructor
*/
public ConfigurationSynchronizer() {
+
}
/**
@@ -69,7 +71,7 @@ public class ConfigurationSynchronizer e
}
/**
- * Reads the configuration from the remote map.
+ * Gets the configuration from the distributed map.
*/
public void pull(Group group) {
if (group != null) {
@@ -104,9 +106,16 @@ public class ConfigurationSynchronizer e
}
/**
- * Publishes local configuration to the cluster.
+ * Publish local configuration to the cluster.
*/
public void push(Group group) {
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ LOGGER.warn("CELLAR CONFIG: cluster event producer is OFF");
+ return;
+ }
+
if (group != null) {
String groupName = group.getName();
Map<String, Properties> configurationTable = clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + groupName);
@@ -119,7 +128,7 @@ public class ConfigurationSynchronizer e
configs = configurationAdmin.listConfigurations(null);
for (Configuration conf : configs) {
String pid = conf.getPid();
- //Check if the pid is marked as local.
+ // check if the pid is marked as local.
if (isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
Properties source = dictionaryToProperties(preparePush(filterDictionary(conf.getProperties())));
Properties target = configurationTable.get(pid);
@@ -137,23 +146,14 @@ public class ConfigurationSynchronizer e
configurationTable.put(pid, target);
if (requiresUpdate) {
RemoteConfigurationEvent event = new RemoteConfigurationEvent(conf.getPid());
- if (producerList != null && !producerList.isEmpty()) {
- for (EventProducer producer : producerList) {
- producer.produce(event);
- }
- }
-
+ eventProducer.produce(event);
}
LOGGER.debug("CELLAR CONFIG: publishing configuration with PID {} to the distributed map", pid);
}
} else {
RemoteConfigurationEvent event = new RemoteConfigurationEvent(conf.getPid());
configurationTable.put(pid, source);
- if (producerList != null && !producerList.isEmpty()) {
- for (EventProducer producer : producerList) {
- producer.produce(event);
- }
- }
+ eventProducer.produce(event);
LOGGER.debug("CELLAR CONFIG: publishing configuration with PID {} to the distributed map", pid);
}
}
@@ -188,12 +188,12 @@ public class ConfigurationSynchronizer e
return result;
}
- public List<EventProducer> getProducerList() {
- return producerList;
+ public EventProducer getEventProducer() {
+ return eventProducer;
}
- public void setProducerList(List<EventProducer> producerList) {
- this.producerList = producerList;
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
}
}
Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java Mon Apr 30 14:04:52 2012
@@ -16,6 +16,7 @@ package org.apache.karaf.cellar.config;
import org.apache.karaf.cellar.core.Configurations;
import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.event.EventType;
import org.osgi.framework.InvalidSyntaxException;
@@ -38,9 +39,7 @@ public class LocalConfigurationListener
private static final transient Logger LOGGER = LoggerFactory.getLogger(LocalConfigurationListener.class);
- private List<EventProducer> producerList;
-
- private Node node;
+ private EventProducer eventProducer;
/**
* Handle local configuration events.
@@ -49,23 +48,28 @@ public class LocalConfigurationListener
* @param event
*/
public void configurationEvent(ConfigurationEvent event) {
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ LOGGER.warn("CELLAR CONFIG: cluster event producer is OFF");
+ return;
+ }
+
String pid = event.getPid();
Set<Group> groups = groupManager.listLocalGroups();
if (groups != null && !groups.isEmpty()) {
for (Group group : groups) {
- //Check if the pid is allowed for outbound.
+ // check if the pid is allowed for outbound.
if (isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) {
+ // update the distributed map
+ push(pid, group);
+
+ // broadcast the cluster event
RemoteConfigurationEvent configurationEvent = new RemoteConfigurationEvent(pid);
configurationEvent.setSourceGroup(group);
- configurationEvent.setSourceNode(node);
- push(pid, group);
- if (producerList != null && !producerList.isEmpty()) {
- for (EventProducer producer : producerList) {
- producer.produce(configurationEvent);
- }
- }
+ eventProducer.produce(configurationEvent);
} else LOGGER.debug("CELLAR CONFIG: configuration with PID {} is marked as BLOCKED OUTBOUND", pid);
}
}
@@ -98,9 +102,7 @@ public class LocalConfigurationListener
* Initialization Method.
*/
public void init() {
- if (clusterManager != null) {
- node = clusterManager.getNode();
- }
+
}
/**
@@ -110,12 +112,12 @@ public class LocalConfigurationListener
}
- public List<EventProducer> getProducerList() {
- return producerList;
+ public EventProducer getEventProducer() {
+ return eventProducer;
}
- public void setProducerList(List<EventProducer> producerList) {
- this.producerList = producerList;
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
}
}
Modified: karaf/cellar/trunk/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original)
+++ karaf/cellar/trunk/config/src/main/resources/OSGI-INF/blueprint/blueprint.xml Mon Apr 30 14:04:52 2012
@@ -15,14 +15,15 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <!-- Cluster Configuration Listener -->
+ <!-- Local Configuration Listener -->
<bean id="configurationListener" class="org.apache.karaf.cellar.config.LocalConfigurationListener" init-method="init"
destroy-method="destroy">
- <property name="producerList" ref="groupEventProducers"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
+ <property name="eventProducer" ref="eventProducer"/>
</bean>
+ <service ref="configurationListener" interface="org.osgi.service.cm.ConfigurationListener"/>
<!-- Configuration Synchronizer -->
<bean id="synchronizer" class="org.apache.karaf.cellar.config.ConfigurationSynchronizer"
@@ -30,18 +31,16 @@
<property name="configurationAdmin" ref="configurationAdmin"/>
<property name="groupManager" ref="groupManager"/>
<property name="clusterManager" ref="clusterManager"/>
- <property name="producerList" ref="groupEventProducers"/>
+ <property name="eventProducer" ref="eventProducer"/>
</bean>
+ <service ref="synchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
+ <!-- Cluster Event Handler -->
<bean id="eventHandler" class="org.apache.karaf.cellar.config.ConfigurationEventHandler"
init-method="init" destroy-method="destroy">
<property name="configurationAdmin" ref="configurationAdmin"/>
<property name="clusterManager" ref="clusterManager"/>
</bean>
-
- <!-- OSGi Services & References -->
- <service ref="configurationListener" interface="org.osgi.service.cm.ConfigurationListener"/>
- <service ref="synchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
<service ref="eventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
<service-properties>
<entry key="managed" value="true"/>
@@ -51,7 +50,6 @@
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
<reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
- <reference-list id="groupEventProducers" member-type="service-object"
- interface="org.apache.karaf.cellar.core.event.EventProducer" filter="(type=group)"/>
+ <reference id="eventProducer" interface="org.apache.karaf.cellar.core.event.EventProducer"/>
</blueprint>
Modified: karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original)
+++ karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml Mon Apr 30 14:04:52 2012
@@ -22,36 +22,35 @@
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="eventTransportFactory" ref="eventTransportFactory"/>
</bean>
+ <service ref="importListener" interface="org.osgi.framework.hooks.service.ListenerHook"/>
<!-- Export Service Listener -->
- <bean id="exportistener" class="org.apache.karaf.cellar.dosgi.ExportServiceListener" init-method="init" destroy-method="destroy">
+ <bean id="exportListener" class="org.apache.karaf.cellar.dosgi.ExportServiceListener" init-method="init" destroy-method="destroy">
<property name="clusterManager" ref="clusterManager"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="eventTransportFactory" ref="eventTransportFactory"/>
</bean>
- <bean id="remoterServiceCallHandler" class="org.apache.karaf.cellar.dosgi.RemoteServiceCallHandler">
+ <bean id="remoteServiceCallHandler" class="org.apache.karaf.cellar.dosgi.RemoteServiceCallHandler">
<property name="clusterManager" ref="clusterManager"/>
<property name="eventTransportFactory" ref="eventTransportFactory"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
</bean>
+ <service ref="remoteServiceCallHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
+ <service-properties>
+ <entry key="managed" value="true"/>
+ </service-properties>
+ </service>
- <bean id="remoteServiceResultlHandler" class="org.apache.karaf.cellar.dosgi.RemoteServiceResultHandler">
+ <!-- Cluster Event Handler -->
+ <bean id="remoteServiceResultHandler" class="org.apache.karaf.cellar.dosgi.RemoteServiceResultHandler">
<property name="commandStore" ref="commandStore"/>
</bean>
+ <service ref="remoteServiceResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <!-- Service References -->
+ <!-- Cluster Core Services -->
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="eventTransportFactory" interface="org.apache.karaf.cellar.core.event.EventTransportFactory"/>
<reference id="commandStore" interface="org.apache.karaf.cellar.core.command.CommandStore"/>
- <!-- Services -->
- <service ref="importListener" interface="org.osgi.framework.hooks.service.ListenerHook"/>
- <service ref="remoterServiceCallHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
- <service-properties>
- <entry key="managed" value="true"/>
- </service-properties>
- </service>
- <service ref="remoteServiceResultlHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
-
</blueprint>
Modified: karaf/cellar/trunk/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java (original)
+++ karaf/cellar/trunk/event/src/main/java/org/apache/karaf/cellar/event/LocalEventListener.java Mon Apr 30 14:04:52 2012
@@ -15,6 +15,7 @@ package org.apache.karaf.cellar.event;
import org.apache.karaf.cellar.core.Group;
import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.event.EventType;
import org.osgi.service.event.Event;
@@ -31,12 +32,17 @@ public class LocalEventListener extends
private static final transient Logger LOGGER = LoggerFactory.getLogger(LocalEventListener.class);
- private List<EventProducer> producerList;
-
- private Node node;
+ private EventProducer eventProducer;
@Override
public void handleEvent(Event event) {
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ LOGGER.warn("CELLAR EVENT: cluster event producer is OFF");
+ return;
+ }
+
try {
if (event != null && event.getTopic() != null) {
Set<Group> groups = null;
@@ -60,18 +66,10 @@ public class LocalEventListener extends
String topicName = event.getTopic();
Map<String, Serializable> properties = getEventProperties(event);
if (isAllowed(group, Constants.CATEGORY, topicName, EventType.OUTBOUND)) {
+ // broadcast the event
RemoteEvent remoteEvent = new RemoteEvent(topicName, properties);
remoteEvent.setSourceGroup(group);
- remoteEvent.setSourceNode(node);
-
- LOGGER.debug("CELLAR EVENT: broadcast event {}", topicName);
-
- // broadcast the event
- if (producerList != null && !producerList.isEmpty()) {
- for (EventProducer producer : producerList) {
- producer.produce(remoteEvent);
- }
- }
+ eventProducer.produce(remoteEvent);
} else LOGGER.warn("CELLAR EVENT: event {} is marked as BLOCKED OUTBOUND", topicName);
}
}
@@ -85,9 +83,7 @@ public class LocalEventListener extends
* Initialization method.
*/
public void init() {
- if (clusterManager != null) {
- node = clusterManager.getNode();
- }
+
}
/**
@@ -97,12 +93,12 @@ public class LocalEventListener extends
}
- public List<EventProducer> getProducerList() {
- return producerList;
+ public EventProducer getEventProducer() {
+ return eventProducer;
}
- public void setProducerList(List<EventProducer> producerList) {
- this.producerList = producerList;
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
}
}
Modified: karaf/cellar/trunk/event/src/main/java/org/apache/karaf/cellar/event/RemoteEventHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/event/src/main/java/org/apache/karaf/cellar/event/RemoteEventHandler.java?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/event/src/main/java/org/apache/karaf/cellar/event/RemoteEventHandler.java (original)
+++ karaf/cellar/trunk/event/src/main/java/org/apache/karaf/cellar/event/RemoteEventHandler.java Mon Apr 30 14:04:52 2012
@@ -16,6 +16,7 @@ package org.apache.karaf.cellar.event;
import org.apache.karaf.cellar.core.Node;
import org.apache.karaf.cellar.core.control.BasicSwitch;
import org.apache.karaf.cellar.core.control.Switch;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.Event;
import org.apache.karaf.cellar.core.event.EventHandler;
import org.apache.karaf.cellar.core.event.EventType;
@@ -32,11 +33,21 @@ public class RemoteEventHandler extends
public static final String SWITCH_ID = "org.apache.karaf.cellar.event.handler";
private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
- private Node node;
-
public void handle(RemoteEvent event) {
+
+ // check if the handler is ON
+ if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
+ LOGGER.warn("CELLAR EVENT: {} switch is OFF, cluster event is not handled", SWITCH_ID);
+ return;
+ }
+
+ // check if the group is local
+ if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
+ LOGGER.warn("CELLAR EVENT: node is not part of the event cluster group");
+ return;
+ }
+
try {
- // check if the pid is marked as local
if (isAllowed(event.getSourceGroup(), Constants.CATEGORY, event.getTopicName(), EventType.INBOUND)) {
Map<String, Serializable> properties = event.getProperties();
properties.put(Constants.EVENT_PROCESSED_KEY, Constants.EVENT_PROCESSED_VALUE);
@@ -53,9 +64,7 @@ public class RemoteEventHandler extends
* Initialization method.
*/
public void init() {
- if (clusterManager != null) {
- node = clusterManager.getNode();
- }
+
}
/**
Modified: karaf/cellar/trunk/event/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/event/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/event/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original)
+++ karaf/cellar/trunk/event/src/main/resources/OSGI-INF/blueprint/blueprint.xml Mon Apr 30 14:04:52 2012
@@ -15,22 +15,13 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <!-- Cluster Configuration Listener -->
+ <!-- Local Event Listener -->
<bean id="localEventListener" class="org.apache.karaf.cellar.event.LocalEventListener" init-method="init" destroy-method="destroy">
- <property name="producerList" ref="groupEventProducers"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
+ <property name="eventProducer" ref="eventProducer"/>
</bean>
-
- <!-- Event Handler -->
- <bean id="remoteEventHandler" class="org.apache.karaf.cellar.event.RemoteEventHandler" init-method="init" destroy-method="destroy">
- <property name="configurationAdmin" ref="configurationAdmin"/>
- <property name="clusterManager" ref="clusterManager"/>
- <property name="eventAdmin" ref="eventAdmin"/>
- </bean>
-
- <!-- OSGi Service & References -->
<service ref="localEventListener">
<interfaces>
<value>org.osgi.service.event.EventHandler</value>
@@ -44,18 +35,23 @@
</service-properties>
</service>
+ <!-- Cluster Event Handler -->
+ <bean id="remoteEventHandler" class="org.apache.karaf.cellar.event.RemoteEventHandler" init-method="init" destroy-method="destroy">
+ <property name="configurationAdmin" ref="configurationAdmin"/>
+ <property name="clusterManager" ref="clusterManager"/>
+ <property name="eventAdmin" ref="eventAdmin"/>
+ </bean>
<service ref="remoteEventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
<service-properties>
<entry key="managed" value="true"/>
</service-properties>
</service>
+ <!-- Cluster Core Services -->
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
<reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
<reference id="eventAdmin" interface="org.osgi.service.event.EventAdmin" />
<reference id="eventProducer" interface="org.apache.karaf.cellar.core.event.EventProducer"/>
- <reference-list id="groupEventProducers" member-type="service-object"
- interface="org.apache.karaf.cellar.core.event.EventProducer" filter="(type=group)"/>
</blueprint>
\ No newline at end of file
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=1332213&r1=1332212&r2=1332213&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 Mon Apr 30 14:04:52 2012
@@ -49,10 +49,19 @@ public class FeaturesEventHandler extend
* @param event
*/
public void handle(RemoteFeaturesEvent event) {
+
+ // check if the handler is ON
if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
LOGGER.warn("CELLAR FEATURES: {} switch is OFF, cluster event is not handled", SWITCH_ID);
return;
}
+
+ // check if the group is local
+ if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
+ LOGGER.warn("CELLAR FEATURES: node is not part of the event cluster group");
+ return;
+ }
+
String name = event.getName();
String version = event.getVersion();
if (isAllowed(event.getSourceGroup(), Constants.FEATURES_CATEGORY, name, EventType.INBOUND) || event.getForce()) {
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=1332213&r1=1332212&r2=1332213&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 Mon Apr 30 14:04:52 2012
@@ -41,8 +41,6 @@ public class FeaturesSynchronizer extend
private static final transient Logger LOGGER = LoggerFactory.getLogger(FeaturesSynchronizer.class);
- private List<EventProducer> producerList;
-
/**
* Initialization method
*/
@@ -71,7 +69,6 @@ public class FeaturesSynchronizer extend
*/
public void pull(Group group) {
if (group != null) {
- LOGGER.info("CELLAR FEATURES: Pulling features from group {}.",group.getName());
String groupName = group.getName();
List<String> repositories = clusterManager.getList(Constants.REPOSITORIES + Configurations.SEPARATOR + groupName);
Map<FeatureInfo, Boolean> features = clusterManager.getMap(Constants.FEATURES + Configurations.SEPARATOR + groupName);
@@ -93,7 +90,7 @@ public class FeaturesSynchronizer extend
}
}
- //Retrieve remote feautre status.
+ // retrieve remote feature status
if (features != null && !features.isEmpty()) {
for (FeatureInfo info : features.keySet()) {
String name = info.getName();
@@ -129,7 +126,7 @@ public class FeaturesSynchronizer extend
}
/**
- * Pushes features to the cluster.
+ * Push features to the cluster.
*/
public void push(Group group) {
if (group != null) {
@@ -191,15 +188,6 @@ public class FeaturesSynchronizer extend
return result;
}
- public List<EventProducer> getProducerList() {
- return producerList;
- }
-
- public void setProducerList(List<EventProducer> producerList) {
- this.producerList = producerList;
- }
-
-
public ClusterManager getCollectionManager() {
return clusterManager;
}
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=1332213&r1=1332212&r2=1332213&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 Mon Apr 30 14:04:52 2012
@@ -14,6 +14,7 @@
package org.apache.karaf.cellar.features;
import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.event.EventType;
import org.apache.karaf.features.Feature;
@@ -32,7 +33,7 @@ public class LocalFeaturesListener exten
private static final transient Logger LOGGER = LoggerFactory.getLogger(LocalFeaturesListener.class);
- private List<EventProducer> producerList;
+ private EventProducer eventProducer;
@Override
public void init() {
@@ -50,6 +51,13 @@ public class LocalFeaturesListener exten
* @param event
*/
public void featureEvent(FeatureEvent event) {
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ LOGGER.warn("CELLAR FEATURES: cluster event producer is OFF");
+ return;
+ }
+
if (event != null) {
Set<Group> groups = groupManager.listLocalGroups();
@@ -63,22 +71,17 @@ public class LocalFeaturesListener exten
if (isAllowed(group, Constants.FEATURES_CATEGORY, name, EventType.OUTBOUND)) {
FeatureEvent.EventType type = event.getType();
- //Check the event type.
- //This is required because upon reception of the even the feature service considers the feature uninstalled.
+ // update the distributed map
if (FeatureEvent.EventType.FeatureInstalled.equals(event.getType())) {
pushFeature(event.getFeature(), group, true);
} else {
pushFeature(event.getFeature(), group, false);
}
+ // broadcast the event
RemoteFeaturesEvent featureEvent = new RemoteFeaturesEvent(name, version, type);
featureEvent.setSourceGroup(group);
- //TODO: Choose group producer.
- if (producerList != null && !producerList.isEmpty()) {
- for (EventProducer producer : producerList) {
- producer.produce(featureEvent);
- }
- }
+ eventProducer.produce(featureEvent);
} else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED OUTBOUND", name);
}
}
@@ -91,6 +94,13 @@ public class LocalFeaturesListener exten
* @param event
*/
public void repositoryEvent(RepositoryEvent event) {
+
+ // check if the producer is ON
+ if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
+ LOGGER.warn("CELLAR FEATURES: cluster event producer is OFF");
+ return;
+ }
+
if (event != null && event.getRepository() != null) {
Set<Group> groups = groupManager.listLocalGroups();
@@ -100,27 +110,24 @@ public class LocalFeaturesListener exten
repositoryEvent.setSourceGroup(group);
RepositoryEvent.EventType type = event.getType();
- if(RepositoryEvent.EventType.RepositoryAdded.equals(type)){
+ // update the distributed map
+ if (RepositoryEvent.EventType.RepositoryAdded.equals(type)){
pushRepository(event.getRepository(), group);
} else {
removeRepository(event.getRepository(),group);
}
- if (producerList != null && !producerList.isEmpty()) {
- for (EventProducer producer : producerList) {
- producer.produce(repositoryEvent);
- }
- }
+ eventProducer.produce(repositoryEvent);
}
}
}
}
- public List<EventProducer> getProducerList() {
- return producerList;
+ public EventProducer getEventProducer() {
+ return eventProducer;
}
- public void setProducerList(List<EventProducer> producerList) {
- this.producerList = producerList;
+ public void setEventProducer(EventProducer eventProducer) {
+ this.eventProducer = eventProducer;
}
}
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=1332213&r1=1332212&r2=1332213&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 Mon Apr 30 14:04:52 2012
@@ -45,10 +45,19 @@ public class RepositoryEventHandler exte
}
public void handle(RemoteRepositoryEvent event) {
+
+ // check if the handler is ON
if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
LOGGER.warn("CELLAR FEATURES: {} switch is OFF, cluster event is not handled", SWITCH_ID);
return;
}
+
+ // check if the group is local
+ if (groupManager.isLocalGroup(event.getSourceGroup().getName())) {
+ LOGGER.warn("CELLAR FEATURES: node is not part of the event cluster group");
+ return;
+ }
+
String uri = event.getId();
RepositoryEvent.EventType type = event.getType();
try {
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=1332213&r1=1332212&r2=1332213&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 Mon Apr 30 14:04:52 2012
@@ -14,59 +14,53 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <!-- Cluster Configuration Listener -->
+ <!-- Local Features Listener -->
<bean id="featuresListener" class="org.apache.karaf.cellar.features.LocalFeaturesListener" init-method="init"
destroy-method="destroy">
- <property name="featuresService" ref="featuresService"/>
- <property name="producerList" ref="groupEventProducers"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
+ <property name="eventProducer" ref="eventProducer"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
+ <property name="featuresService" ref="featuresService"/>
</bean>
+ <service ref="featuresListener" interface="org.apache.karaf.features.FeaturesListener"/>
<!-- Features/Repositories Synchronizer -->
<bean id="synchronizer" class="org.apache.karaf.cellar.features.FeaturesSynchronizer"
init-method="init" destroy-method="destroy">
- <property name="featuresService" ref="featuresService"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="groupManager" ref="groupManager"/>
- <property name="producerList" ref="groupEventProducers"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
+ <property name="featuresService" ref="featuresService"/>
</bean>
+ <service ref="synchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
- <!-- Features Handler -->
+ <!-- Cluster Event Handler -->
<bean id="featuresHandler" class="org.apache.karaf.cellar.features.FeaturesEventHandler"
init-method="init" destroy-method="destroy">
<property name="featuresService" ref="featuresService"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
+ <service ref="featuresHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
+ <service-properties>
+ <entry key="managed" value="true"/>
+ </service-properties>
+ </service>
- <!-- Repository Handler -->
+ <!-- Cluster Event Handler -->
<bean id="repositoryHandler" class="org.apache.karaf.cellar.features.RepositoryEventHandler"
init-method="init" destroy-method="destroy">
<property name="featuresService" ref="featuresService"/>
<property name="clusterManager" ref="clusterManager"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
-
- <!-- OSGi Services & References -->
- <service ref="featuresListener" interface="org.apache.karaf.features.FeaturesListener"/>
- <service ref="synchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
- <service ref="featuresHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
- <service-properties>
- <entry key="managed" value="true"/>
- </service-properties>
- </service>
-
<service ref="repositoryHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
+
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
- <reference id="eventTransportFactory" interface="org.apache.karaf.cellar.core.event.EventTransportFactory"/>
<reference id="eventProducer" interface="org.apache.karaf.cellar.core.event.EventProducer"/>
<reference id="featuresService" interface="org.apache.karaf.features.FeaturesService"/>
<reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
- <reference-list id="groupEventProducers" member-type="service-object"
- interface="org.apache.karaf.cellar.core.event.EventProducer" filter="(type=group)"/>
</blueprint>
Modified: karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java (original)
+++ karaf/cellar/trunk/obr/src/main/java/org/apache/karaf/cellar/obr/ObrBundleEventHandler.java Mon Apr 30 14:04:52 2012
@@ -18,6 +18,7 @@ import org.apache.felix.bundlerepository
import org.apache.felix.bundlerepository.Resource;
import org.apache.karaf.cellar.core.control.BasicSwitch;
import org.apache.karaf.cellar.core.control.Switch;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventHandler;
import org.apache.karaf.cellar.core.event.EventType;
import org.osgi.framework.Bundle;
@@ -109,6 +110,19 @@ public class ObrBundleEventHandler exten
*/
@Override
public void handle(ObrBundleEvent event) {
+
+ // check if the handler is ON
+ if (eventSwitch.getStatus().equals(SwitchStatus.OFF)) {
+ LOGGER.warn("CELLAR OBR: {} switch is OFF, cluster event is not handled", SWITCH_ID);
+ return;
+ }
+
+ // check if the group is local
+ if (!groupManager.isLocalGroup(event.getSourceGroup().getName())) {
+ LOGGER.warn("CELLAR OBR: node is not part of the event cluster group");
+ return;
+ }
+
String bundleId = event.getBundleId();
try {
if (isAllowed(event.getSourceGroup(), Constants.BUNDLES_CONFIG_CATEGORY, bundleId, EventType.INBOUND)) {
Modified: karaf/cellar/trunk/obr/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/obr/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1332213&r1=1332212&r2=1332213&view=diff
==============================================================================
--- karaf/cellar/trunk/obr/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original)
+++ karaf/cellar/trunk/obr/src/main/resources/OSGI-INF/blueprint/blueprint.xml Mon Apr 30 14:04:52 2012
@@ -22,6 +22,11 @@
<property name="groupManager" ref="groupManager"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
+ <service ref="obrBundleEventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
+ <service-properties>
+ <entry key="managed" value="true"/>
+ </service-properties>
+ </service>
<!-- OBR URLS_DISTRIBUTED_SET_NAME Synchronizer -->
<bean id="obrUrlSynchronizer" class="org.apache.karaf.cellar.obr.ObrUrlSynchronizer"
@@ -32,6 +37,7 @@
<property name="producerList" ref="groupEventProducers"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
+ <service ref="obrUrlSynchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
<!-- OBR URLS_DISTRIBUTED_SET_NAME Event Handler -->
<bean id="obrUrlEventHandler" class="org.apache.karaf.cellar.obr.ObrUrlEventHandler"
@@ -41,16 +47,6 @@
<property name="groupManager" ref="groupManager"/>
<property name="configurationAdmin" ref="configurationAdmin"/>
</bean>
-
- <!-- OBR Bundle Event Handler OSGi service -->
- <service ref="obrBundleEventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
- <service-properties>
- <entry key="managed" value="true"/>
- </service-properties>
- </service>
-
- <!-- OBR OSGi service -->
- <service ref="obrUrlSynchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"/>
<service ref="obrUrlEventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler">
<service-properties>
<entry key="managed" value="true"/>
@@ -62,9 +58,6 @@
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
<reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
- <reference id="eventTransportFactory" interface="org.apache.karaf.cellar.core.event.EventTransportFactory"/>
<reference id="eventProducer" interface="org.apache.karaf.cellar.core.event.EventProducer"/>
- <reference-list id="groupEventProducers" member-type="service-object"
- interface="org.apache.karaf.cellar.core.event.EventProducer" filter="(type=group)"/>
</blueprint>
\ No newline at end of file