Exemplo n.º 1
0
            void processFindSuccessorForFixFingers(IAsyncResult result)
            {
                Console.WriteLine("Chord::ChordRealNode::Engine processFindSuccessorForFixFingers ENTER");
                ChordCommon.IChordNode_Object iNode_Object = (ChordCommon.IChordNode_Object)(result.AsyncState);

                Tashjik.Common.AsyncCallback_Object thisAppState = (Tashjik.Common.AsyncCallback_Object)(iNode_Object.obj);
                ObjectInt fingerState = (ObjectInt)(thisAppState.obj);

                finger[fingerState.i] = iNode_Object.node;

                AsyncCallback callBack     = thisAppState.callBack;
                Object        origAppState = fingerState.appState;

                if (!(callBack == null))
                {
                    IAsyncResult res = new Tashjik.Common.ObjectAsyncResult(origAppState, true, true);
                    callBack(res);
                }
            }
Exemplo n.º 2
0
            public void beginFixFingers(AsyncCallback beginStabilizeCallBack, Object appState)
            {
                Console.WriteLine("Chord::Engine::beginFixFingers ENTER");
                //static int next = -1;
                fingerNext++;
                if (fingerNext >= 160)
                {
                    fingerNext = 0;
                }
                //bit wise addition is required
                //will require some effort

                byte[] byteVal = getByteArrayOfValue(fingerNext);

                /*		byte[] C = new byte[20];
                 *
                 *
                 *              int bitPos = Int32.MaxValue;
                 *              int bytePos = Math.DivRem(fingerNext - 1,8, out bitPos);
                 *
                 *              C[19-bytePos] = (byte) (1 << bitPos);
                 */

                ObjectInt fingerState = new ObjectInt();

                fingerState.appState = appState;
                fingerState.i        = fingerNext;

                Tashjik.Common.AsyncCallback_Object thisAppState = new Tashjik.Common.AsyncCallback_Object();
                thisAppState.callBack = beginStabilizeCallBack;
                thisAppState.obj      = fingerState;



                AsyncCallback findSuccessorCallBack = new AsyncCallback(processFindSuccessorForFixFingers);

                beginFindSuccessor(Tashjik.Common.UtilityMethod.moduloAdd1(selfNodeBasic.getHashedIP(), byteVal), null, findSuccessorCallBack, thisAppState, new Guid("00000000-0000-0000-0000-000000000000"));
            }
Exemplo n.º 3
0
            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"));
                    }
                }
            }
Exemplo n.º 4
0
            public void beginFixFingers(AsyncCallback beginStabilizeCallBack, Object appState)
            {
                Console.WriteLine("Chord::Engine::beginFixFingers ENTER");
                    //static int next = -1;
                    fingerNext ++;
                    if (fingerNext>=160)
                        fingerNext = 0;
                    //bit wise addition is required
                    //will require some effort

                    byte[] byteVal = getByteArrayOfValue(fingerNext);

                /*		byte[] C = new byte[20];

                    int bitPos = Int32.MaxValue;
                    int bytePos = Math.DivRem(fingerNext - 1,8, out bitPos);

                    C[19-bytePos] = (byte) (1 << bitPos);
                */

                    ObjectInt fingerState = new ObjectInt();
                    fingerState.appState = appState;
                    fingerState.i = fingerNext;

                    Tashjik.Common.AsyncCallback_Object thisAppState = new Tashjik.Common.AsyncCallback_Object();
                    thisAppState.callBack = beginStabilizeCallBack;
                    thisAppState.obj = fingerState;

                    AsyncCallback findSuccessorCallBack = new AsyncCallback(processFindSuccessorForFixFingers);
                    beginFindSuccessor(Tashjik.Common.UtilityMethod.moduloAdd1(selfNodeBasic.getHashedIP(), byteVal), null, findSuccessorCallBack, thisAppState, new Guid("00000000-0000-0000-0000-000000000000"));
            }
Exemplo n.º 5
0
            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"));
                        }

                    }
            }