public IChordNodeArray_ObjectAsyncResult(IChordNodeArray_Object n, bool compSync, bool isComp) { AsyncState = (Object)n; AsyncWaitHandle = null; // CompletedSynchronously = compSync; // IsCompleted = isComp; }
public void beginGetFingerTable(AsyncCallback getFingerTableCallBack, Object appState) { Console.WriteLine("ChordRealNode::beginGetFingerTable ENTER"); ChordCommon.IChordNodeArray_Object iNodeArray_Object = new ChordCommon.IChordNodeArray_Object(); iNodeArray_Object.nodeArray = engine.getFingerTable(); iNodeArray_Object.obj = appState; if (!(getFingerTableCallBack == null)) { IAsyncResult res = new ChordCommon.IChordNodeArray_ObjectAsyncResult(iNodeArray_Object, false, true); getFingerTableCallBack(res); } }
void processGetFingerTableForJoin(IAsyncResult result) { Console.WriteLine("ChordRealNode::Engine::processFindFingerTableForJoin ENTER"); ChordCommon.IChordNodeArray_Object iNodeArray_Object = (ChordCommon.IChordNodeArray_Object)(result.AsyncState); Tashjik.Common.AsyncCallback_Object thisAppState = (Tashjik.Common.AsyncCallback_Object)(iNodeArray_Object.obj); IChordNode[] successorFingerTable = iNodeArray_Object.nodeArray; for (int i = 0; i < successorFingerTable.Length; i++) { IChordNode chordNode = successorFingerTable[i]; if (chordNode != null) { ObjectInt fingerState = new ObjectInt(); fingerState.appState = thisAppState; fingerState.i = i; byte[] jumpVal = getByteArrayOfValue(i); successorFingerTable[i].beginFindSuccessor(Common.UtilityMethod.moduloAdd1(self.getHashedIP(), jumpVal), self, new AsyncCallback(processFingerTableFindSuccessorForJoin), fingerState, new Guid("00000000-0000-0000-0000-000000000000")); } } }
public override void notifyTwoWayReplyReceived(IPAddress fromIP, byte[] buffer, int offset, int size, AsyncCallback originalRequestCallBack, Object originalAppState) { Console.WriteLine("ChordProxyNode::notifyTwoWayReplyReceived ENTER"); String[] split = splitMsgBuffer(buffer, offset, size); if(String.Compare(split[0], "FIND_SUCCESSOR_REPLY") == 0) { Console.WriteLine("ChordProxyNode::notifyTwoWayReplyReceived FIND_SUCCESSOR_RECEIVED"); String strSuccessorIP = split[1]; Console.Write("ChordProxyNode::notifyTwoWayReplyReceived SuccessorIP = "); Console.WriteLine(strSuccessorIP); IPAddress successorIP = UtilityMethod.convertStrToIP(strSuccessorIP); ChordCommon.IChordNode_Object iNode_Object = new ChordCommon.IChordNode_Object(); iNode_Object.node = (IChordNode)(proxyController.getProxyNode(successorIP)); iNode_Object.obj = originalAppState; Tashjik.Common.ObjectAsyncResult objectAsyncResult = new Tashjik.Common.ObjectAsyncResult(iNode_Object, false, false); if(originalRequestCallBack != null) originalRequestCallBack(objectAsyncResult); } else if(String.Compare(split[0], "GET_PREDECESSOR_REPLY")==0) { Console.WriteLine("ChordProxyNode::notifyTwoWayReplyReceived GET_PREDECESSOR_RECEIVED"); String strPredecessorIP = split[1]; ChordCommon.IChordNode_Object iNode_Object = new ChordCommon.IChordNode_Object(); if(String.Compare(strPredecessorIP, "UNKNOWN_PREDECESSOR")==0) { Console.Write("ChordProxyNode::notifyTwoWayReplyReceived PREDECESSOR_UNKNOWN"); iNode_Object.node = null; } else { Console.Write("ChordProxyNode::notifyTwoWayReplyReceived PredecessorIP = "); Console.WriteLine(strPredecessorIP); IPAddress predecessorIP = UtilityMethod.convertStrToIP(strPredecessorIP); iNode_Object.node = (IChordNode)(proxyController.getProxyNode(predecessorIP)); } iNode_Object.obj = originalAppState; Tashjik.Common.ObjectAsyncResult objectAsyncResult = new Tashjik.Common.ObjectAsyncResult(iNode_Object, false, false); if(originalRequestCallBack != null) originalRequestCallBack(objectAsyncResult); } else if (String.Compare(split[0], "GET_FINGERTABLE_REPLY") == 0) { Console.WriteLine("ChordProxyNode::notifyTwoWayReplyReceived GET_FINGERTABLE_RECEIVED"); String strPredecessorIP = split[1]; IChordNode[] fingerTable = new IChordNode[split.Length - 1]; for (int i = 1; i < 161; i++) { if (split[i] == "NULL") fingerTable[i - 1] = null; else fingerTable[i - 1] = (IChordNode)(proxyController.getProxyNode(UtilityMethod.convertStrToIP(split[i].ToString()))); } ChordCommon.IChordNodeArray_Object iNodeArray_Object = new ChordCommon.IChordNodeArray_Object(); iNodeArray_Object.nodeArray = fingerTable; iNodeArray_Object.obj = originalAppState; Tashjik.Common.ObjectAsyncResult objectAsyncResult = new Tashjik.Common.ObjectAsyncResult(iNodeArray_Object, false, false); if (originalRequestCallBack != null) originalRequestCallBack(objectAsyncResult); } }
public override void notifyTwoWayReplyReceived(IPAddress fromIP, byte[] buffer, int offset, int size, AsyncCallback originalRequestCallBack, Object originalAppState) { Console.WriteLine("ChordProxyNode::notifyTwoWayReplyReceived ENTER"); String[] split = splitMsgBuffer(buffer, offset, size); if (String.Compare(split[0], "FIND_SUCCESSOR_REPLY") == 0) { Console.WriteLine("ChordProxyNode::notifyTwoWayReplyReceived FIND_SUCCESSOR_RECEIVED"); String strSuccessorIP = split[1]; Console.Write("ChordProxyNode::notifyTwoWayReplyReceived SuccessorIP = "); Console.WriteLine(strSuccessorIP); IPAddress successorIP = UtilityMethod.convertStrToIP(strSuccessorIP); ChordCommon.IChordNode_Object iNode_Object = new ChordCommon.IChordNode_Object(); iNode_Object.node = (IChordNode)(proxyController.getProxyNode(successorIP)); iNode_Object.obj = originalAppState; Tashjik.Common.ObjectAsyncResult objectAsyncResult = new Tashjik.Common.ObjectAsyncResult(iNode_Object, false, false); if (originalRequestCallBack != null) { originalRequestCallBack(objectAsyncResult); } } else if (String.Compare(split[0], "GET_PREDECESSOR_REPLY") == 0) { Console.WriteLine("ChordProxyNode::notifyTwoWayReplyReceived GET_PREDECESSOR_RECEIVED"); String strPredecessorIP = split[1]; ChordCommon.IChordNode_Object iNode_Object = new ChordCommon.IChordNode_Object(); if (String.Compare(strPredecessorIP, "UNKNOWN_PREDECESSOR") == 0) { Console.Write("ChordProxyNode::notifyTwoWayReplyReceived PREDECESSOR_UNKNOWN"); iNode_Object.node = null; } else { Console.Write("ChordProxyNode::notifyTwoWayReplyReceived PredecessorIP = "); Console.WriteLine(strPredecessorIP); IPAddress predecessorIP = UtilityMethod.convertStrToIP(strPredecessorIP); iNode_Object.node = (IChordNode)(proxyController.getProxyNode(predecessorIP)); } iNode_Object.obj = originalAppState; Tashjik.Common.ObjectAsyncResult objectAsyncResult = new Tashjik.Common.ObjectAsyncResult(iNode_Object, false, false); if (originalRequestCallBack != null) { originalRequestCallBack(objectAsyncResult); } } else if (String.Compare(split[0], "GET_FINGERTABLE_REPLY") == 0) { Console.WriteLine("ChordProxyNode::notifyTwoWayReplyReceived GET_FINGERTABLE_RECEIVED"); String strPredecessorIP = split[1]; IChordNode[] fingerTable = new IChordNode[split.Length - 1]; for (int i = 1; i < 161; i++) { if (split[i] == "NULL") { fingerTable[i - 1] = null; } else { fingerTable[i - 1] = (IChordNode)(proxyController.getProxyNode(UtilityMethod.convertStrToIP(split[i].ToString()))); } } ChordCommon.IChordNodeArray_Object iNodeArray_Object = new ChordCommon.IChordNodeArray_Object(); iNodeArray_Object.nodeArray = fingerTable; iNodeArray_Object.obj = originalAppState; Tashjik.Common.ObjectAsyncResult objectAsyncResult = new Tashjik.Common.ObjectAsyncResult(iNodeArray_Object, false, false); if (originalRequestCallBack != null) { originalRequestCallBack(objectAsyncResult); } } }