Added initial framework for using Hazelcast-3.0.2 within ONOS.
diff --git a/conf/hazelcast.xml b/conf/hazelcast.xml
new file mode 100644
index 0000000..267cd58
--- /dev/null
+++ b/conf/hazelcast.xml
@@ -0,0 +1,102 @@
+<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config
+ http://www.hazelcast.com/schema/config/hazelcast-config-3.0.xsd"
+ xmlns="http://www.hazelcast.com/schema/config"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <map name="*">
+
+ <!--
+ Number of sync-backups. If 1 is set as the backup-count for example,
+ then all entries of the map will be copied to another JVM for
+ ail-safety. Valid numbers are 0 (no backup), 1, 2, 3.
+ -->
+ <backup-count>0</backup-count>
+
+ <!--
+ Number of async-backups. If 1 is set as the backup-count for example,
+ then all entries of the map will be copied to another JVM for
+ fail-safety. Valid numbers are 0 (no backup), 1, 2, 3.
+ -->
+ <async-backup-count>3</async-backup-count>
+
+ <!--
+ Can we read the local backup entries? Default value is false for
+ strong consistency. Being able to read backup data will give you
+ greater performance.
+ -->
+ <read-backup-data>true</read-backup-data>
+
+ <near-cache>
+ <!--
+ Maximum size of the near cache. When max size is reached,
+ cache is evicted based on the policy defined.
+ Any integer between 0 and Integer.MAX_VALUE. 0 means
+ Integer.MAX_VALUE. Default is 0.
+ -->
+ <max-size>0</max-size>
+ <!--
+ Maximum number of seconds for each entry to stay in the near cache.
+ Entries that are older than <time-to-live-seconds> will get
+ automatically evicted from the near cache.
+ Any integer between 0 and Integer.MAX_VALUE. 0 means infinite.
+ Default is 0.
+ -->
+ <time-to-live-seconds>0</time-to-live-seconds>
+
+ <!--
+ Maximum number of seconds each entry can stay in the near cache as
+ untouched (not-read).
+ Entries that are not read (touched) more than <max-idle-seconds>
+ value will get removed from the near cache.
+ Any integer between 0 and Integer.MAX_VALUE. 0 means
+ Integer.MAX_VALUE. Default is 0.
+ -->
+ <max-idle-seconds>0</max-idle-seconds>
+
+ <!--
+ Valid values are:
+ NONE (no extra eviction, <time-to-live-seconds> may still apply),
+ LRU (Least Recently Used),
+ LFU (Least Frequently Used).
+ LRU is the default.
+ Regardless of the eviction policy used, <time-to-live-seconds> will
+ still apply.
+ -->
+ <eviction-policy>NONE</eviction-policy>
+
+ <!--
+ Should the cached entries get evicted if the entries are changed
+ (updated or removed).
+ true of false. Default is true.
+ -->
+ <invalidate-on-change>true</invalidate-on-change>
+
+ </near-cache>
+ </map>
+
+ <topic name="*">
+ <global-ordering-enabled>false</global-ordering-enabled>
+ </topic>
+
+ <network>
+ <port auto-increment="true">5701</port>
+ <join>
+ <multicast enabled="true">
+ <multicast-group>224.2.2.3</multicast-group>
+ <multicast-port>54327</multicast-port>
+ </multicast>
+ <!--
+ <tcp-ip enabled="false">
+ <member>machine1</member>
+ <member>machine2</member>
+ <member>machine3:5799</member>
+ <member>192.168.1.0-7</member>
+ <member>192.168.1.21</member>
+ </tcp-ip>
+ -->
+ <aws enabled="false">
+ </aws>
+ </join>
+ </network>
+
+</hazelcast>
diff --git a/conf/onos-embedded.properties b/conf/onos-embedded.properties
index ed85223..5e09059 100644
--- a/conf/onos-embedded.properties
+++ b/conf/onos-embedded.properties
@@ -7,6 +7,7 @@
net.floodlightcontroller.counter.CounterStore,\
net.floodlightcontroller.perfmon.PktInProcessingTime,\
net.floodlightcontroller.ui.web.StaticWebRoutable,\
+net.onrc.onos.datagrid.HazelcastDatagrid,\
net.onrc.onos.registry.controller.ZookeeperRegistry
net.floodlightcontroller.restserver.RestApiServer.port = 8080
net.floodlightcontroller.core.FloodlightProvider.openflowport = 6633
@@ -14,4 +15,5 @@
net.floodlightcontroller.forwarding.Forwarding.idletimeout = 5
net.floodlightcontroller.forwarding.Forwarding.hardtimeout = 0
net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher.dbconf = conf/titan-embedded.properties
+net.onrc.onos.datagrid.HazelcastDatagrid.datagridConfig = conf/hazelcast.xml
diff --git a/conf/onos.properties b/conf/onos.properties
index 283203a..4920744 100644
--- a/conf/onos.properties
+++ b/conf/onos.properties
@@ -14,4 +14,4 @@
net.floodlightcontroller.forwarding.Forwarding.idletimeout = 5
net.floodlightcontroller.forwarding.Forwarding.hardtimeout = 0
net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher.dbconf = /tmp/cassandra.titan
-
+net.onrc.onos.datagrid.HazelcastDatagrid.datagridConfig = conf/hazelcast.xml
diff --git a/pom.xml b/pom.xml
index 943133d..871ca57 100644
--- a/pom.xml
+++ b/pom.xml
@@ -240,6 +240,11 @@
</dependency>
-->
<dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast</artifactId>
+ <version>3.0.2</version>
+ </dependency>
+ <dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
diff --git a/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java b/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
new file mode 100644
index 0000000..7736880
--- /dev/null
+++ b/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
@@ -0,0 +1,150 @@
+package net.onrc.onos.datagrid;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.floodlightcontroller.core.IFloodlightProviderService;
+import net.floodlightcontroller.core.module.FloodlightModuleContext;
+import net.floodlightcontroller.core.module.FloodlightModuleException;
+import net.floodlightcontroller.core.module.IFloodlightModule;
+import net.floodlightcontroller.core.module.IFloodlightService;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.hazelcast.config.Config;
+import com.hazelcast.config.FileSystemXmlConfig;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+import com.hazelcast.instance.GroupProperties;
+
+/**
+ * A datagrid service that uses Hazelcast as a datagrid.
+ * The relevant data is stored in the Hazelcast datagrid and shared as
+ * appropriate in a multi-node cluster.
+ */
+public class HazelcastDatagrid implements IFloodlightModule, IDatagridService {
+ protected static Logger log =
+ LoggerFactory.getLogger(HazelcastDatagrid.class);
+
+ protected IFloodlightProviderService floodlightProvider;
+
+ protected static final String HazelcastConfigFile = "datagridConfig";
+ private HazelcastInstance hazelcast = null;
+ private Config hazelcastConfig = null;
+
+ /**
+ * Initialize the Hazelcast Datagrid operation.
+ *
+ * @param conf the configuration filename.
+ */
+ public void init(String configFilename) {
+ /*
+ System.setProperty("hazelcast.socket.receive.buffer.size", "32");
+ System.setProperty("hazelcast.socket.send.buffer.size", "32");
+ */
+ // System.setProperty("hazelcast.heartbeat.interval.seconds", "100");
+
+ // Init from configuration file
+ try {
+ hazelcastConfig = new FileSystemXmlConfig(configFilename);
+ } catch (FileNotFoundException e) {
+ log.error("Error opening Hazelcast XML configuration. File not found: " + configFilename, e);
+ }
+ /*
+ hazelcastConfig.setProperty(GroupProperties.PROP_IO_THREAD_COUNT, "1");
+ hazelcastConfig.setProperty(GroupProperties.PROP_OPERATION_THREAD_COUNT, "1");
+ hazelcastConfig.setProperty(GroupProperties.PROP_EVENT_THREAD_COUNT, "1");
+ */
+ //
+ hazelcastConfig.setProperty(GroupProperties.PROP_EVENT_QUEUE_CAPACITY, "4000000");
+ hazelcastConfig.setProperty(GroupProperties.PROP_SOCKET_RECEIVE_BUFFER_SIZE, "4096");
+ hazelcastConfig.setProperty(GroupProperties.PROP_SOCKET_SEND_BUFFER_SIZE, "4096");
+ }
+
+ /**
+ * Shutdown the Hazelcast Datagrid operation.
+ */
+ public void finalize() {
+ close();
+ }
+
+ /**
+ * Shutdown the Hazelcast Datagrid operation.
+ */
+ public void close() {
+ Hazelcast.shutdownAll();
+ }
+
+ /**
+ * Get the collection of offered module services.
+ *
+ * @return the collection of offered module services.
+ */
+ @Override
+ public Collection<Class<? extends IFloodlightService>> getModuleServices() {
+ Collection<Class<? extends IFloodlightService>> l =
+ new ArrayList<Class<? extends IFloodlightService>>();
+ l.add(IDatagridService.class);
+ return l;
+ }
+
+ /**
+ * Get the collection of implemented services.
+ *
+ * @return the collection of implemented services.
+ */
+ @Override
+ public Map<Class<? extends IFloodlightService>, IFloodlightService>
+ getServiceImpls() {
+ Map<Class<? extends IFloodlightService>,
+ IFloodlightService> m =
+ new HashMap<Class<? extends IFloodlightService>,
+ IFloodlightService>();
+ m.put(IDatagridService.class, this);
+ return m;
+ }
+
+ /**
+ * Get the collection of modules this module depends on.
+ *
+ * @return the collection of modules this module depends on.
+ */
+ @Override
+ public Collection<Class<? extends IFloodlightService>>
+ getModuleDependencies() {
+ Collection<Class<? extends IFloodlightService>> l =
+ new ArrayList<Class<? extends IFloodlightService>>();
+ l.add(IFloodlightProviderService.class);
+ return l;
+ }
+
+ /**
+ * Initialize the module.
+ *
+ * @param context the module context to use for the initialization.
+ */
+ @Override
+ public void init(FloodlightModuleContext context)
+ throws FloodlightModuleException {
+ floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
+
+ // Get the configuration file name and configure the Datagrid
+ Map<String, String> configMap = context.getConfigParams(this);
+ String configFilename = configMap.get(HazelcastConfigFile);
+ this.init(configFilename);
+ }
+
+ /**
+ * Startup module operation.
+ *
+ * @param context the module context to use for the startup.
+ */
+ @Override
+ public void startUp(FloodlightModuleContext context) {
+ hazelcast = Hazelcast.newHazelcastInstance(hazelcastConfig);
+ }
+}
diff --git a/src/main/java/net/onrc/onos/datagrid/IDatagridService.java b/src/main/java/net/onrc/onos/datagrid/IDatagridService.java
new file mode 100644
index 0000000..1c7f3ab
--- /dev/null
+++ b/src/main/java/net/onrc/onos/datagrid/IDatagridService.java
@@ -0,0 +1,10 @@
+package net.onrc.onos.datagrid;
+
+import net.floodlightcontroller.core.module.IFloodlightService;
+
+/**
+ * Interface for providing Datagrid Service to other modules.
+ */
+public interface IDatagridService extends IFloodlightService {
+ // TODO
+}
diff --git a/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule b/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
index f552de5..d3508ff 100644
--- a/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
+++ b/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
@@ -18,6 +18,7 @@
net.floodlightcontroller.devicemanager.test.MockDeviceManager
net.floodlightcontroller.core.test.MockFloodlightProvider
net.floodlightcontroller.core.test.MockThreadPoolService
+net.onrc.onos.datagrid.HazelcastDatagrid
net.onrc.onos.ofcontroller.flowmanager.FlowManager
net.onrc.onos.ofcontroller.routing.TopoRouteService
net.onrc.onos.ofcontroller.bgproute.BgpRoute