// Take the current method from the queue and wake up the correct thread
retValueBytes = returnQueue.poll();
if (retValueBytes != null) { // If there is method bytes
- //System.out.println("retValBytes in wake up thread: " + Arrays.toString(retValueBytes));
int objectId = getObjectId(retValueBytes);
int methodId = getMethodId(retValueBytes);
String strKey = objectId + "-" + methodId;
AtomicBoolean retRecv = mapStubId.get(strKey);
- //System.out.println("boolean status: " + retRecv + " with key: " + strKey);
didGetReturnBytes.set(false);
while(!retRecv.compareAndSet(false, true));
- //System.out.println("boolean status: " + retRecv + " - map has: " + mapStubId.size());
while(!didGetReturnBytes.get()); // While skeleton is still processing
}
}
public synchronized void registerStub(int objectId, int methodId, AtomicBoolean retValueReceived) {
String strKey = objectId + "-" + methodId;
- //System.out.println("Key exist? " + mapStubId.containsKey(strKey));
mapStubId.put(strKey, retValueReceived);
- //System.out.println("\n\nAdding keyBytes: " + strKey + " now size: " + mapStubId.size() + "\n\n");
}
System.arraycopy(packetBytes, IoTRMIUtil.OBJECT_ID_LEN, methodIdBytes, 0, IoTRMIUtil.METHOD_ID_LEN);
// Get method Id
int methodId = IoTRMIUtil.byteArrayToInt(methodIdBytes);
- // Get method Id
return methodId;
}
// Receive return value and return it to caller
// Now just strip off the object ID and method ID
int headerLen = IoTRMIUtil.OBJECT_ID_LEN + IoTRMIUtil.METHOD_ID_LEN + IoTRMIUtil.PACKET_TYPE_LEN;
- //if (retValueBytes == null)
- // System.out.println("retValueBytes is null!");
-
int valByteLen = retValueBytes.length - headerLen;
byte[] retValBytes = new byte[valByteLen];
// Method Id is positioned after object Id in the byte array
-
- //System.out.println("Val byte len: " + valByteLen);
- //System.out.println("Length retValBytes: " + retValBytes.length);
-
- //System.arraycopy(retValueBytes, headerLen, retValBytes, 0, valByteLen);
- //Object retObj = IoTRMIUtil.getParamObject(retType, retGenTypeVal, retValBytes);
Object retObj = null;
if (valByteLen != 0) {
System.arraycopy(retValueBytes, headerLen, retValBytes, 0, valByteLen);