Adjustments to firewall rules generation/initializations for running multiple benchmarks
[iot2.git] / iotjava / iotruntime / master / IoTMaster.java
index 3ce672d7c07f7eb3bda5e24df11b46bf18723c18..2d5b44f799ff6e01856df452d81fc59e37acf2a2 100644 (file)
@@ -1377,6 +1377,8 @@ public final class IoTMaster {
        private void setRouterBasicPolicies(String strRouter) {
 
                String strMonitorHost = routerConfig.getIPFromMACAddress(STR_MONITORING_HOST);
+           routerConfig.initMainPolicy(strRouter);
+           routerConfig.combineRouterPolicies(strRouter);
                routerConfig.configureRouterICMPPolicies(strRouter, strMonitorHost);
                routerConfig.configureRouterDHCPPolicies(strRouter);
                routerConfig.configureRouterDNSPolicies(strRouter);
@@ -1393,6 +1395,8 @@ public final class IoTMaster {
        private void setHostBasicPolicies(String strHost) {
 
                String strMonitorHost = routerConfig.getIPFromMACAddress(STR_MONITORING_HOST);
+           routerConfig.initMainPolicy(strHost);
+           routerConfig.combineRouterPolicies(strHost);
                routerConfig.configureHostDHCPPolicies(strHost);
                routerConfig.configureHostDNSPolicies(strHost);
                if (strHost.equals(strMonitorHost)) {
@@ -1990,13 +1994,14 @@ public final class IoTMaster {
                try {
                        // Extract hostname for this IoTMaster from MySQL DB
                        strIoTMasterHostAdd = routerConfig.getIPFromMACAddress(STR_MASTER_MAC_ADD);
+                   // Assign a new list of PrintWriter objects
+           routerConfig.renewPrintWriter();
                        // Loop as we can still find controller/device classes
                        for(int i=0; i<strObjectNames.length; i++) {
                                // PROFILING
                                start = System.currentTimeMillis();
-
-                               // Assign a new list of PrintWriter objects
-                               routerConfig.renewPrintWriter();
+                       // Assign a new list of main PrintWriter objects
+               routerConfig.renewMainPrintWriter();
                                // Get controller names one by one
                                String strObjControllerName = strObjectNames[i];
                                // Use LoadBalancer to assign a host address
@@ -2111,6 +2116,11 @@ public final class IoTMaster {
                                        // SetInstrumenter vs. RelationInstrumenter
                                        String strFieldName = map.getKey();
                                        String strClassName = map.getValue().getClass().getName();
+
+                           System.out.println("\n\nDEBUG: Instrumenting IoTSet and IoTRelation objects!!!");
+                           System.out.println("DEBUG: Field name: " + strFieldName);
+                           System.out.println("DEBUG: Class name: " + strFieldName + "\n\n");
+
                                        if(strClassName.equals(STR_SET_INSTRUMENTER_CLS)) {
                                                SetInstrumenter setInstrumenter = (SetInstrumenter) map.getValue();
                                                if(setInstrumenter.getObjTableName().equals(STR_IOT_DEV_ADD_CLS)) { 
@@ -2146,18 +2156,14 @@ public final class IoTMaster {
                                // PROFILING
                                start = System.currentTimeMillis();
 
-                               // ROUTING POLICY: Deploy basic policies if this is the last controller
-                               if (i == strObjectNames.length-1) {
-                                       // ROUTING POLICY: implement basic policies to reject all other irrelevant traffics
-                                       for(String s: commHan.getHosts()) {
-                                               setHostBasicPolicies(s);
-                                       }
-                                       // We retain all the basic policies for router, 
-                                       // but we delete the initial allowance policies for internal all TCP and UDP communications
-                                       setRouterBasicPolicies(STR_ROUTER_ADD);
+                               // ROUTING POLICY: implement basic policies to reject all other irrelevant traffics
+                               for(String s: commHan.getHosts()) {
+                                       setHostBasicPolicies(s);
                                }
-                               // Close access to policy files and deploy policies
-                               routerConfig.close();
+                               // We retain all the basic policies for router, 
+                               // but we delete the initial allowance policies for internal all TCP and UDP communications
+                               setRouterBasicPolicies(STR_ROUTER_ADD);
+                               routerConfig.closeMain();
                                // Deploy the policy
                                HashSet<String> setAddresses = new HashSet<String>(commHan.getHosts());
                                setAddresses.add(strIoTMasterHostAdd);
@@ -2204,11 +2210,15 @@ public final class IoTMaster {
                                inStream.close();
                                socket.close();
                                serverSocket.close();
+                               objInitHand.clearObjectInitHandler();
                                commHan.printLists();
+                               commHan.clearCommunicationHandler();
                                lbIoT.printHostInfo();
                                if (STR_ACTIVATE_SANDBOXING.equals("Yes"))
                                        createMACPolicyThreads(setAddresses);
                        }
+                       // Close access to policy files and deploy policies
+                       routerConfig.close();
 
                } catch (IOException          |
                                 InterruptedException |