Share Hazelcast instance when possible.
- Give a name to Hazelcast instance so the instance can be retrived within the same JVM.
- Datastore client now tries to get the instance first to avoid
overhead added by running Hazelcast in client mode.
Change-Id: If8f4b8fec08e3ba81eb0a8a9a23f8a779058db50
diff --git a/src/main/java/net/onrc/onos/core/datagrid/HazelcastDatagrid.java b/src/main/java/net/onrc/onos/core/datagrid/HazelcastDatagrid.java
index 5758b38..8632669 100644
--- a/src/main/java/net/onrc/onos/core/datagrid/HazelcastDatagrid.java
+++ b/src/main/java/net/onrc/onos/core/datagrid/HazelcastDatagrid.java
@@ -30,6 +30,12 @@
*/
public class HazelcastDatagrid implements IFloodlightModule, IDatagridService {
static final Logger log = LoggerFactory.getLogger(HazelcastDatagrid.class);
+
+ /**
+ * The name of Hazelcast instance in this JVM.
+ */
+ public static final String ONOS_HAZELCAST_INSTANCE = "ONOS_HazelcastInstance";
+
private IRestApiService restApi;
static final String HAZELCAST_CONFIG_FILE = "datagridConfig";
@@ -72,6 +78,10 @@
// XXX probably should throw some exception to kill ONOS instead.
}
}
+
+ // set the name of Hazelcast instance in this JVM.
+ hazelcastConfig.setInstanceName(ONOS_HAZELCAST_INSTANCE);
+
/*
hazelcastConfig.setProperty(GroupProperties.PROP_IO_THREAD_COUNT, "1");
hazelcastConfig.setProperty(GroupProperties.PROP_OPERATION_THREAD_COUNT, "1");