Ejemplo n.º 1
0
 public override Tashjik.Tier0.TransportLayerCommunicator.Data notifyTwoWayMsg(IPAddress fromIP, byte[] buffer, int offset, int size)
 {
     Console.WriteLine("ChordProxyNode::notifyTwoWayMsg ENTER");
     String[] split = splitMsgBuffer(buffer, offset, size);
     if (String.Compare(split[0], "GET_PREDECESSOR") == 0)
     {
         byte[]     compositeMsg;
         IChordNode predecessor = thisNode.getPredecessor();
         if (predecessor == null)
         {
             Console.WriteLine("ChordProxyNode::notifyTwoWayMsg  predecessor is unknown");
             compositeMsg = UtilityMethod.convertToTabSeparatedByteArray(true, "GET_PREDECESSOR_REPLY", "UNKNOWN_PREDECESSOR");
         }
         else
         {
             Console.Write("ChordProxyNode::notifyTwoWayMsg predecessor =");
             Console.WriteLine(predecessor.getIP().ToString());
             compositeMsg = UtilityMethod.convertToTabSeparatedByteArray(true, "GET_PREDECESSOR_REPLY", predecessor.getIP().ToString());
         }
         return(new Tashjik.Tier0.TransportLayerCommunicator.Data(compositeMsg, 0, compositeMsg.Length));
     }
     else if (String.Compare(split[0], "GET_FINGERTABLE") == 0)
     {
         byte[]       compositeMsg;
         IChordNode[] fingerTable = thisNode.getFingerTable();
         String[]     str         = new String[fingerTable.Length + 1];
         str[0] = "GET_FINGERTABLE_REPLY";
         int i = 1;
         foreach (IChordNode chordNode in fingerTable)
         {
             Console.WriteLine("ChordProxyNode::notifyTwoWayMsg addong fingertable entry");
             if (chordNode == null)
             {
                 str[i++] = "NULL";
             }
             else
             {
                 str[i++] = chordNode.getIP().ToString();
             }
         }
         Console.WriteLine("ChordProxyNode::notifyTwoWayMsg FingerTable = .... well some other day");
         compositeMsg = UtilityMethod.convertToTabSeparatedByteArray(true, str);
         return(new Tashjik.Tier0.TransportLayerCommunicator.Data(compositeMsg, 0, compositeMsg.Length));
     }
     return(null);
 }
Ejemplo n.º 2
0
        void processFindSuccessorForFindSuccessor(IAsyncResult result)
        {
            Console.WriteLine("ChordServer::processFindSuccessorForFindSuccessor ENTER");

            ChordCommon.IChordNode_Object iNode_Object = (ChordCommon.IChordNode_Object)(result.AsyncState);
            IChordNode successor = iNode_Object.node;
            IPAddress  IP        = successor.getIP();

            Stack <Object> recAppState           = (Stack <Object>)(iNode_Object.obj);
            Object         origAppState          = recAppState.Pop();
            AsyncCallback  findSuccessorCallBack = (AsyncCallback)(recAppState.Pop());

            if (findSuccessorCallBack != null)
            {
                ChordCommon.IP_Object _IP_Object = new ChordCommon.IP_Object();

                _IP_Object.IP  = IP;
                _IP_Object.obj = origAppState;

                IAsyncResult res = new ChordCommon.IP_ObjectAsyncResult(_IP_Object, true, true);
                findSuccessorCallBack(res);
            }
        }
Ejemplo n.º 3
0
        public void beginPredecessorNotify(IChordNode possiblePred, AsyncCallback notifyCallBack, Object appState)
        {
            Console.WriteLine("ChordProxyNode::beginNotify ENTER");

            byte[] compositeMsg = UtilityMethod.convertToTabSeparatedByteArray(true, "PREDECESSOR_NOTIFY", possiblePred.getIP().ToString());

            Console.WriteLine("ChordProxyNode::beginGetPredecessor before sendMsg to proxyController");
            proxyController.sendMsg(this, compositeMsg, 0, compositeMsg.Length, notifyCallBack, appState);
        }
Ejemplo n.º 4
0
        public void beginPredecessorNotify(IChordNode possiblePred, AsyncCallback notifyCallBack, Object appState)
        {
            Console.WriteLine("ChordProxyNode::beginNotify ENTER");

            byte[] compositeMsg = UtilityMethod.convertToTabSeparatedByteArray(true, "PREDECESSOR_NOTIFY", possiblePred.getIP().ToString());

            Console.WriteLine("ChordProxyNode::beginGetPredecessor before sendMsg to proxyController");
            proxyController.sendMsg(this, compositeMsg, 0, compositeMsg.Length, notifyCallBack, appState);
        }
Ejemplo n.º 5
0
        static void processFindSuccessor_notifyTwoWayRelayMsg_callback(IAsyncResult ayncResult)
        {
            ChordCommon.IChordNode_Object iNode_Object = (ChordCommon.IChordNode_Object)(ayncResult.AsyncState);
            IChordNode     successor      = (iNode_Object.node);
            ChordProxyNode chordProxyNode = ((IP_ChordProxyNode)(iNode_Object.obj)).chordProxyNode;
            IPAddress      originalFromIP = ((IP_ChordProxyNode)(iNode_Object.obj)).IP;
            Guid           relayTicket    = ((IP_ChordProxyNode)(iNode_Object.obj)).ticket;

            byte[] compositeMsg = UtilityMethod.convertToTabSeparatedByteArray(true, "FIND_SUCCESSOR_REPLY", successor.getIP().ToString());
            chordProxyNode.proxyController.sendMsgTwoWayRelay(chordProxyNode.proxyController.getProxyNode(originalFromIP), compositeMsg, 0, compositeMsg.Length, null, null, relayTicket);
        }