karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject karaf-cellar git commit: [KARAF-3628] Improved Hazelcast Discovery Service when starting a new Hazelcast instance
Date Tue, 28 Apr 2015 05:40:51 GMT
Repository: karaf-cellar
Updated Branches:
  refs/heads/cellar-2.3.x d46720614 -> f7fb3f9a4


[KARAF-3628] Improved Hazelcast Discovery Service when starting a new Hazelcast instance


Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/f7fb3f9a
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/f7fb3f9a
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/f7fb3f9a

Branch: refs/heads/cellar-2.3.x
Commit: f7fb3f9a40ca9ba9b41d331b4f85b3de31c54bdd
Parents: d467206
Author: Flávio Ferreira <fferreira@bikeemotion.com>
Authored: Fri Mar 20 17:13:02 2015 +0000
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Tue Apr 28 07:40:38 2015 +0200

----------------------------------------------------------------------
 assembly/src/main/resources/features.xml        |  8 +++++--
 .../factory/HazelcastConfigurationManager.java  | 23 +++++++++++++++++++-
 .../factory/HazelcastServiceFactory.java        |  6 ++++-
 .../resources/OSGI-INF/blueprint/blueprint.xml  |  5 +++++
 .../factory/HazelcastServiceFactoryTest.java    |  1 +
 5 files changed, 39 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f7fb3f9a/assembly/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/features.xml b/assembly/src/main/resources/features.xml
index 9a910f5..b348d31 100644
--- a/assembly/src/main/resources/features.xml
+++ b/assembly/src/main/resources/features.xml
@@ -32,13 +32,17 @@
         <configfile finalname="/etc/hazelcast.xml">
             mvn:org.apache.karaf.cellar/apache-karaf-cellar/${project.version}/xml/hazelcast
         </configfile>
-        <bundle start-level="32">mvn:com.hazelcast/hazelcast/${hazelcast.version}</bundle>
+        <!--
+        <bundle start-level="30" dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
+        <bundle start-level="30" dependency="true">mvn:com.eclipsesource.minimal-json/minimal-json/0.9.2</bundle>
+        -->
+        <bundle start-level="70">mvn:com.hazelcast/hazelcast/${hazelcast.version}</bundle>
     </feature>
 
     <feature name="cellar-hazelcast" description="Cellar implementation based on Hazelcast"
version="${project.version}" resolver="(obr)">
         <feature version="${hazelcast.version}">hazelcast</feature>
         <feature version="${project.version}">cellar-core</feature>
-        <bundle start-level="33">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast/${project.version}</bundle>
+        <bundle start-level="70">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast/${project.version}</bundle>
     </feature>
 
     <feature name="cellar-config" description="ConfigAdmin cluster support" version="${project.version}"
resolver="(obr)">

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f7fb3f9a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
index 43722da..12eecb8 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastConfigurationManager.java
@@ -24,6 +24,13 @@ import org.apache.karaf.cellar.core.utils.CellarUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.List;
+import org.apache.karaf.cellar.core.discovery.DiscoveryService;
+
+/**
+ * Hazelcast configuration manager.
+ * It loads hazelcast.xml configuration file.
+ */
 public class HazelcastConfigurationManager {
 
     private static final transient Logger LOGGER = LoggerFactory.getLogger(HazelcastServiceFactory.class);
@@ -31,6 +38,7 @@ public class HazelcastConfigurationManager {
     private String xmlConfigLocation = System.getProperty("karaf.home") + "/etc/hazelcast.xml";
 
     private Set<String> discoveredMemberSet = new LinkedHashSet<String>();
+    private List<DiscoveryService> discoveryServices;
 
      /**
      * Build a Hazelcast {@link com.hazelcast.config.Config}.
@@ -40,7 +48,16 @@ public class HazelcastConfigurationManager {
     public Config getHazelcastConfig() {
         System.setProperty("hazelcast.config", xmlConfigLocation);
         Config config = new XmlConfigBuilder().build();
-        if (discoveredMemberSet != null) {
+        
+        if (config.getNetworkConfig().getJoin().getTcpIpConfig().isEnabled() && discoveredMemberSet
!= null) {
+            if (discoveryServices != null && !discoveryServices.isEmpty()) {
+                for (DiscoveryService service : discoveryServices) {
+                    service.refresh();
+                    Set<String> discovered = service.discoverMembers();
+                    discoveredMemberSet.addAll(discovered);
+                    LOGGER.trace("HAZELCAST STARTUP DISCOVERY: service {} found members {}",
service, discovered);
+                }
+            }
             TcpIpConfig tcpIpConfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
             tcpIpConfig.getMembers().addAll(discoveredMemberSet);
         }
@@ -67,6 +84,10 @@ public class HazelcastConfigurationManager {
         }
         return updated;
     }
+    
+    public void setDiscoveryServices(List<DiscoveryService> discoveryServices) {
+        this.discoveryServices = discoveryServices;
+    }
 
 	public Set<String> getDiscoveredMemberSet() {
 		return discoveredMemberSet;

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f7fb3f9a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
index 1eeb899..273d867 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
@@ -37,7 +37,7 @@ public class HazelcastServiceFactory  {
 
     private BundleContext bundleContext;
     private CombinedClassLoader combinedClassLoader;
-    private HazelcastConfigurationManager configurationManager = new HazelcastConfigurationManager();
+    private HazelcastConfigurationManager configurationManager;
 
     private CountDownLatch initializationLatch = new CountDownLatch(1);
     private CountDownLatch instanceLatch = new CountDownLatch(1);
@@ -122,5 +122,9 @@ public class HazelcastServiceFactory  {
     public void setCombinedClassLoader(CombinedClassLoader combinedClassLoader) {
         this.combinedClassLoader = combinedClassLoader;
     }
+    
+    public void setConfigurationManager(HazelcastConfigurationManager configurationManager)
{
+        this.configurationManager = configurationManager;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f7fb3f9a/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 2f626d7..d025e56 100644
--- a/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/hazelcast/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -25,10 +25,15 @@
     <bean id="instanceFactory" class="org.apache.karaf.cellar.hazelcast.factory.HazelcastServiceFactory"
           init-method="init" destroy-method="destroy">
         <property name="combinedClassLoader" ref="combinedClassLoader"/>
+        <property name="configurationManager" ref="hazelcastConfigurationManager"/>
         <property name="bundleContext" ref="blueprintBundleContext"/>
         <cm:managed-properties persistent-id="org.apache.karaf.cellar.discovery" update-strategy="component-managed"
                                update-method="update"/>
     </bean>
+    
+    <bean id="hazelcastConfigurationManager" class="org.apache.karaf.cellar.hazelcast.factory.HazelcastConfigurationManager"
>
+        <property name="discoveryServices" ref="discoveryServices"/>
+    </bean>
 
     <!-- Discovery Task -->
     <bean id="discoveryTask" class="org.apache.karaf.cellar.core.discovery.DiscoveryTask"
init-method="init"

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/f7fb3f9a/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java
----------------------------------------------------------------------
diff --git a/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java
b/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java
index b0904ab..0d2bd40 100644
--- a/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java
+++ b/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java
@@ -32,6 +32,7 @@ public class HazelcastServiceFactoryTest {
     	// configuration that disables multicast and enables tcp on 127.0.0.1
         System.setProperty("karaf.home", "src/test/resources");
         HazelcastServiceFactory factory = new HazelcastServiceFactory();
+        factory.setConfigurationManager(new HazelcastConfigurationManager());
         factory.init();
         factory.getInstance();
         HazelcastInstance defaultInstance = Hazelcast.newHazelcastInstance(null);


Mime
View raw message