X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=iotjava%2Fiotruntime%2Fmaster%2FIoTMaster.java;h=70ae6b876c9e8cd849b266a2a5032cf6dd2753ae;hb=7e8c0cabb7057ad561adbb8b6cc2a0fd5c41bbf4;hp=03a365227e43a7d9381739d78f6a5815fc6c70e1;hpb=8e565033fd19c4696f67862ade27f0ebbacf5682;p=iot2.git diff --git a/iotjava/iotruntime/master/IoTMaster.java b/iotjava/iotruntime/master/IoTMaster.java index 03a3652..70ae6b8 100644 --- a/iotjava/iotruntime/master/IoTMaster.java +++ b/iotjava/iotruntime/master/IoTMaster.java @@ -140,8 +140,8 @@ public final class IoTMaster { private static final String STR_SHELL_HEADER = "#!/bin/sh"; private static final String STR_JAVA_PATH = "/usr/bin/java"; private static final String STR_MAC_POL_PATH = "tomoyo/"; - private static final String STR_TMP = "tmp"; - private static final String STR_ARP = "arp"; + private static final String STR_TMP = "tmp"; + private static final String STR_ARP = "arp"; private static int INT_SIZE = 4; // send length in the size of integer (4 bytes) private static final int INT_DNS_PORT = 53; @@ -229,7 +229,6 @@ public final class IoTMaster { else throw new Error("IoTMaster: Unknown value for STR_MAC_TO_IP_TRANSLATION: " + STR_MAC_TO_IP_TRANSLATION); processJailConfig = new ProcessJailConfig(); - //processJailConfig.setAddressListObject(routerConfig.getAddressListObject()); objInitHand = new ObjectInitHandler(BOOL_VERBOSE); objAddInitHand = new ObjectAddressInitHandler(BOOL_VERBOSE); mapClassNameToCrim = new HashMap(); @@ -346,9 +345,9 @@ public final class IoTMaster { System.out.println("IoTMaster: Error reading config file: " + strCfgFileName); ex.printStackTrace(); } - System.out.println("IoTMaster: Reading " + strCfgField + + RuntimeOutput.print("IoTMaster: Reading " + strCfgField + " from config file: " + strCfgFileName + " with value: " + - prop.getProperty(strCfgField, null)); + prop.getProperty(strCfgField, null), BOOL_VERBOSE); // NULL is returned if the property isn't found return prop.getProperty(strCfgField, null); } @@ -423,7 +422,7 @@ public final class IoTMaster { * @params strFieldName String field name * @params strIoTSlaveObjectHostAdd String slave host address * @params inStream ObjectInputStream communication - * @params inStream ObjectOutputStream communication + * @params outStream ObjectOutputStream communication * @params strLanguage String language * @return void */ @@ -468,12 +467,6 @@ public final class IoTMaster { if (commHan.getComPort(strDeviceAddressKey) == null) { commHan.addPortConnection(strIoTSlaveObjectHostAdd, strDeviceAddressKey); } - - // TODO: DEBUG!!! - System.out.println("\n\n DEBUG: InstrumentSetDevice: Object Name: " + strObjName); - System.out.println("DEBUG: InstrumentSetDevice: Port number: " + commHan.getComPort(strDeviceAddressKey)); - System.out.println("DEBUG: InstrumentSetDevice: Device address: " + strDeviceAddressKey + "\n\n"); - // Send address one by one if(strLanguage.equals(STR_JAVA)) { Message msgGetIoTSetObj = null; @@ -534,12 +527,6 @@ public final class IoTMaster { } int iRows = setInstrumenter.numberOfRows(); RuntimeOutput.print("IoTMaster: Number of rows for IoTZigbeeAddress: " + iRows, BOOL_VERBOSE); - - // TODO: DEBUG!!! - System.out.println("\n\nDEBUG: InstrumentZigbeeDevice: Object Name: " + strObjName); - System.out.println("DEBUG: InstrumentZigbeeDevice: Port number: " + commHan.getComPort(strZigbeeGWAddressKey)); - System.out.println("DEBUG: InstrumentZigbeeDevice: Device address: " + strZigbeeGWAddress + "\n\n"); - // Transfer the address for(int iRow=0; iRow; // java -cp $CLASSPATH:./*.jar @@ -1040,7 +1012,6 @@ public final class IoTMaster { else throw new Error("IoTMaster: Language specification not recognized: " + strLanguageDriver); RuntimeOutput.print("IoTMaster: Language for " + strObjName + " is " + strLanguageDriver, BOOL_VERBOSE); - RuntimeOutput.print(strSSHCommand, BOOL_VERBOSE); // Start a new thread to start a new JVM createThread(strSSHCommand); @@ -1058,14 +1029,6 @@ public final class IoTMaster { outStream = new BufferedOutputStream(socket.getOutputStream()); recvAck(inStream); } - - // PROFILING - result = System.currentTimeMillis()-start; - System.out.println("\n\n ==> Time needed to start JVM for " + strObjName + ": " + result + "\n\n"); - - // PROFILING - start = System.currentTimeMillis(); - if(strLanguageDriver.equals(STR_JAVA)) { sendFileToJavaSlaveDriver(serverSocket, inStream, outStream, strObjName, strObjClassName, strObjClassInterfaceName, strObjStubClsIntfaceName, @@ -1076,14 +1039,6 @@ public final class IoTMaster { commHan.getRMIRegPort(strObjName), commHan.getRMIStubPort(strObjName), arrFieldValues, arrFieldClasses, outStream, inStream); } - - // PROFILING - result = System.currentTimeMillis()-start; - System.out.println("\n\n ==> Time needed to send JAR file for " + strObjName + ": " + result + "\n\n"); - - // PROFILING - start = System.currentTimeMillis(); - // Instrument the class source code and look for IoTSet for device addresses // e.g. @config private IoTSet lb_addresses; RuntimeOutput.print("IoTMaster: Instantiating for " + strObjClassName + " with objectID " + strFieldObjectID, BOOL_VERBOSE); @@ -1141,11 +1096,6 @@ public final class IoTMaster { createDriverObjectCpp(outStream, inStream); //endSessionCpp(outStream); } - - // PROFILING - result = System.currentTimeMillis()-start; - System.out.println("\n\n ==> Time needed to create object " + strObjName + " and instrument IoTDeviceAddress: " + result + "\n\n"); - // Closing streams outStream.close(); inStream.close(); @@ -1369,7 +1319,6 @@ public final class IoTMaster { reinitializeIoTSetFieldCpp(outStream, inStream); } else if (iotcommMsg == IoTCommCode.CREATE_NEW_IOTRELATION) { // == COMMUNICATION WITH IOTSLAVE CONTROLLER TO CREATE IOTRELATION - // TODO: createNewIoTRelation needs to be created here! createNewIoTRelationCpp(str, outStream, inStream); List listObject = objInitHand.getListObjectInitInfo(str); List listSecondObject = objInitHand.getSecondObjectInitInfo(str); @@ -2075,13 +2024,6 @@ public final class IoTMaster { recvAck(inStream); } RuntimeOutput.print("IoTMaster: Communication established!", BOOL_VERBOSE); - - // PROFILING - result = System.currentTimeMillis()-start; - System.out.println("\n\n ==> From start until after SSH for main controller: " + result); - // PROFILING - start = System.currentTimeMillis(); - // Send files for every controller class // e.g. AcmeProximity.jar and AcmeProximity.zip String strControllerClassName = strObjControllerName + STR_CLS_FILE_EXT; @@ -2112,13 +2054,6 @@ public final class IoTMaster { processJailConfig.combineAdditionalMACPolicy(strContMACCfg, strObjControllerName, strObjControllerName); } } - // PROFILING - result = System.currentTimeMillis()-start; - System.out.println("\n\n ==> From IoTSlave start until main controller object is created: " + result); - System.out.println(" ==> Including file transfer times!\n\n"); - // PROFILING - start = System.currentTimeMillis(); - // == END INITIALIZING CONTROLLER/DEVICE IOTSLAVE == // Instrumenting one file RuntimeOutput.print("IoTMaster: Opening class file: " + strControllerClassName, BOOL_VERBOSE); @@ -2146,11 +2081,6 @@ 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)) { @@ -2177,15 +2107,6 @@ public final class IoTMaster { String strTempFileName = "./" + strObjControllerName + STR_MAC_POLICY_EXT; processJailConfig.combineControllerMACPolicies(strIoTSlaveControllerHostAdd, strObjControllerName, strTempFileName); processJailConfig.flush(); - - // PROFILING - result = System.currentTimeMillis()-start; - System.out.println("\n\n ==> Time needed to instrument device driver objects: " + result + "\n\n"); - System.out.println(" ==> #Objects: " + commHan.getActiveControllerObjectList().size() + "\n\n"); - - // PROFILING - start = System.currentTimeMillis(); - // ROUTING POLICY: implement basic policies to reject all other irrelevant traffics for(String s: commHan.getHosts()) { setHostBasicPolicies(s); @@ -2200,33 +2121,13 @@ public final class IoTMaster { // See if firewall policy is configured to be "on" or "off" if (STR_POLICY_ON.equals(STR_YES)) createPolicyThreads(STR_ROUTER_ADD, setAddresses); - - // PROFILING - result = System.currentTimeMillis()-start; - System.out.println("\n\n ==> Time needed to send policy files and deploy them : " + result + "\n\n"); - - // PROFILING - start = System.currentTimeMillis(); - // Separating object creations and Set/Relation initializations createDriverObjects(); - - // PROFILING - result = System.currentTimeMillis()-start; - System.out.println("\n\n ==> Time needed to instantiate objects: " + result + "\n\n"); - // PROFILING - start = System.currentTimeMillis(); - // Sets and relations initializations if(STR_LANGUAGE_CONTROLLER.equals(STR_JAVA)) initializeSetsAndRelationsJava(inStream, outStream); else initializeSetsAndRelationsCpp(inStream, outStream);; - - // PROFILING - result = System.currentTimeMillis()-start; - System.out.println("\n\n ==> Time needed to initialize sets and relations: " + result + "\n\n"); - if(STR_LANGUAGE_CONTROLLER.equals(STR_JAVA)) // == COMMUNICATION WITH IOTSLAVE CONTROLLER TO EXECUTE INIT METHOD commMasterToSlave(new MessageSimple(IoTCommCode.INVOKE_INIT_METHOD), "Invoke init() method!", inStream, outStream);