private Map<Integer, Integer> hmRMIRegPort;
private Map<Integer, Integer> hmRMIStubPort;
private Set<Integer> hsDevicePort;
+ private Set<Integer> hsAllPorts;
private Map<Integer, Integer> hmAdditionalPort;
private int iNumOfObjects;
private int iNumOfHosts;
hmRMIRegPort = new HashMap<Integer, Integer>();
hmRMIStubPort = new HashMap<Integer, Integer>();
hsDevicePort = new HashSet<Integer>();
+ hsAllPorts = new HashSet<Integer>();
hmAdditionalPort = new HashMap<Integer, Integer>();
iNumOfObjects = 0;
iNumOfHosts = 0;
bVerbose = _bVerbose;
RuntimeOutput.print("CommunicationHandler: Creating a new CommunicationHandler object!", bVerbose);
}
+
+ /**
+ * Method clearCommunicationHandler()
+ * <p>
+ * Clear the data structure
+ *
+ * @return void
+ */
+ public void clearCommunicationHandler() {
+
+ listActiveControllerObj.clear();
+ listFieldObjectID.clear();
+ listObjCrtInfo.clear();
+ listArrFieldValues.clear();
+ listArrFieldClasses.clear();
+ hmActiveObj.clear();
+ hmHostAdd.clear();
+ hmHostList.clear();
+ hmComPort.clear();
+ hmRMIRegPort.clear();
+ hmRMIStubPort.clear();
+ hsDevicePort.clear();
+ hmAdditionalPort.clear();
+ iNumOfObjects = 0;
+ iNumOfHosts = 0;
+ RuntimeOutput.print("CommunicationHandler: Clearing CommunicationHandler object's data structure!", bVerbose);
+ }
/**
* Method addPortConnection()
// Check port existence in HashMap
} while (portIsAvailable(iComPort) == false);
hmComPort.put(iNumOfObjects, iComPort);
+ // hsAllPorts tracks all the existing and used port numbers
+ hsAllPorts.add(iComPort);
int iRMIRegPort = 0;
do {
// Check port existence in HashMap
} while (portIsAvailable(iRMIRegPort) == false);
hmRMIRegPort.put(iNumOfObjects, iRMIRegPort);
+ hsAllPorts.add(iRMIRegPort);
int iRMIStubPort = 0;
do {
// Check port existence in HashMap
} while (portIsAvailable(iRMIStubPort) == false);
hmRMIStubPort.put(iNumOfObjects, iRMIStubPort);
+ hsAllPorts.add(iRMIStubPort);
iNumOfObjects++;
}
public void addDevicePort(int iDevPort) {
hsDevicePort.add(iDevPort);
-
+ // Track this port number
+ hsAllPorts.add(iDevPort);
}
/**
// Check port existence in HashMap
} while (portIsAvailable(iAdditionalPort) == false);
hmAdditionalPort.put(iNumOfObjects, iAdditionalPort);
+ // Track this port number
+ hsAllPorts.add(iAdditionalPort);
iNumOfObjects++;
*/
public boolean portIsAvailable(int iPortNumber) {
- if (hmComPort.containsValue(iPortNumber) == true) {
+ /*if (hmComPort.containsValue(iPortNumber) == true) {
return false;
} else if (hmRMIRegPort.containsValue(iPortNumber) == true) {
return false;
return false;
} else {
return true;
+ }*/
+ if (hsAllPorts.contains(iPortNumber)) {
+ return false;
+ } else {
+ return true;
}
}