Configure the right jvm heap size to support more than 3 cluster instances of ONOS in cord-tester.

Change-Id: I1484c3f9d8012b33f31320d0ded480f71697966a
diff --git a/src/test/utils/CordContainer.py b/src/test/utils/CordContainer.py
index 3b62f68..d98bbe0 100644
--- a/src/test/utils/CordContainer.py
+++ b/src/test/utils/CordContainer.py
@@ -403,7 +403,7 @@
 
     def __init__(self, name = NAME, image = IMAGE, prefix = PREFIX, tag = TAG,
                  boot_delay = 20, restart = False, network_cfg = None,
-                 cluster = False, data_volume = None, async = False, quagga_config = None):
+                 cluster = False, data_volume = None, async = False, quagga_config = None, max_instances=1):
         if restart is True:
             ##Find the right image to restart
             running_image = filter(lambda c: c['Names'][0] == '/{}'.format(name), self.dckr.containers())
@@ -417,11 +417,18 @@
         if quagga_config is not None:
             self.quagga_config = quagga_config
         super(Onos, self).__init__(name, image, prefix = prefix, tag = tag, quagga_config = self.quagga_config)
+        self.max_instances = max_instances
         self.boot_delay = boot_delay
         self.data_map = None
         if cluster is True:
             self.ports = []
-            self.env['JAVA_OPTS'] = self.JAVA_OPTS_CLUSTER
+            if self.max_instances <= 3:
+                java_opts = self.JAVA_OPTS_CLUSTER
+            else:
+                instance_memory = (get_mem(instances=self.max_instances),) * 2
+                java_opts = '-Xms{} -Xmx{} -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode'.format(*instance_memory)
+
+            self.env['JAVA_OPTS'] = java_opts
             if data_volume is not None:
                 self.data_map = self.get_data_map(data_volume, self.guest_data_dir)
                 self.host_guest_map = self.host_guest_map + self.data_map