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;
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<String,Object>();
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);
}
* @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
*/
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;
}
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<iRows; iRow++) {
arrFieldValues = setInstrumenter.fieldValues(iRow);
// Extract the interface name for RMI
// e.g. ProximitySensorInterface, TempSensorInterface, etc.
-
String strObjCfgFile = STR_IOT_CODE_PATH + strObjClassName + "/" + strObjClassName + STR_CFG_FILE_EXT;
strObjClassInterfaceName = parseConfigFile(strObjCfgFile, STR_INTERFACE_CLS_CFG);
strObjStubClsIntfaceName = parseConfigFile(strObjCfgFile, STR_INT_STUB_CLS_CFG);
} else {
// If this is a new object ... then create one
// Get host address for IoTSlave from LoadBalancer
- //strIoTSlaveObjectHostAdd = lbIoT.selectHost();
strIoTSlaveObjectHostAdd = routerConfig.getIPFromMACAddress(lbIoT.selectHost());
if (strIoTSlaveControllerHostAdd == null)
throw new Error("IoTMaster: Could not translate MAC to IP address! Please check the router's /tmp/dhcp.leases!");
routerConfig.configureHostMainPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveControllerHostAdd,
strIoTSlaveObjectHostAdd, STR_TCP_PROTOCOL);
// Configure MAC policies for objects
- //String strFileName = STR_MAC_POL_PATH + strObjClassName + STR_MAC_POLICY_EXT;
String strFileName = STR_MAC_POL_PATH + STR_JAVA + STR_MAC_POLICY_EXT;
if (STR_ACTIVATE_SANDBOXING.equals("Yes")) {
processJailConfig.configureProcessJailDeviceDriverPolicies(strIoTSlaveObjectHostAdd, strObjName, strObjClassName,
commHan.addAdditionalPort(strUniqueDev);
}
}
-
- // TODO: DEBUG!!!
- System.out.println("\n\n DEBUG: InstrumentPolicySetDevice: Object Name: " + strObjName);
- System.out.println("DEBUG: InstrumentPolicySetDevice: Port number: " + commHan.getComPort(strDeviceAddressKey));
- System.out.println("DEBUG: InstrumentPolicySetDevice: Device address: " + strDeviceAddressKey + "\n\n");
-
// Send routing policy to router for device drivers and devices
// ROUTING POLICY: RMI communication - RMI registry and stub ports
if((iDestDeviceDriverPort == -1) && (!strProtocol.equals(STR_NO_PROTOCOL))) {
// Send the file to the compute node
String strCmdSend = "scp " + shellFile + " " + STR_USERNAME + strIoTSlaveObjectHostAdd + ":" + STR_RUNTIME_DIR;
runCommand(strCmdSend);
- System.out.println("IoTMaster: Sending shell file: " + strCmdSend);
+ RuntimeOutput.print("IoTMaster: Sending shell file: " + strCmdSend, BOOL_VERBOSE);
return STR_SSH + " " + STR_USERNAME + strIoTSlaveObjectHostAdd + " cd " + STR_RUNTIME_DIR + " " + shellFile;
}
strLanguageDriver = parseConfigFile(sCfgFile, STR_LANGUAGE);
if(strLanguageDriver == null) // Check nullness for the second time - report if it is still null
throw new Error("IoTMaster: Language specification missing in config file: " + sCfgFile);
- // PROFILING
- long start = 0;
- long result = 0;
- // PROFILING
- start = System.currentTimeMillis();
-
// Construct ssh command line
// e.g. ssh rtrimana@dw-2.eecs.uci.edu cd <path>;
// java -cp $CLASSPATH:./*.jar
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);
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,
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<IoTDeviceAddress> lb_addresses;
RuntimeOutput.print("IoTMaster: Instantiating for " + strObjClassName + " with objectID " + strFieldObjectID, BOOL_VERBOSE);
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();
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<ObjectInitInfo> listObject = objInitHand.getListObjectInitInfo(str);
List<ObjectInitInfo> listSecondObject = objInitHand.getSecondObjectInitInfo(str);
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;
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);
// 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)) {
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);
// 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);