/*public void stabilize() * { * AsyncCallback getPredecessorCallBack = new AsyncCallback(processGetPredecessorForStabilize); * successor.beginGetPredecessor(getPredecessorCallBack); * //if(((Node)self<x) && ((Node)x<successor)) * // successor = x; * //successor.notify(self); * }*/ public void beginStabilize(AsyncCallback beginStabilizeCallBack, Object appState) { Console.WriteLine("Chord::Engine::beginStabilize ENTER"); lock (successorLock) { if (successor == self) { if (beginStabilizeCallBack != null) { IAsyncResult res = new Tashjik.Common.ObjectAsyncResult(appState, true, true); beginStabilizeCallBack(res); } else { return; } } } Tashjik.Common.AsyncCallback_Object thisAppState = new Tashjik.Common.AsyncCallback_Object(); thisAppState.callBack = beginStabilizeCallBack; thisAppState.obj = appState; Console.WriteLine("Chord::Engine::beginStabilize successor != self"); AsyncCallback getPredecessorCallBack = new AsyncCallback(processGetPredecessorForStabilize); lock (successorLock) { successor.beginGetPredecessor(getPredecessorCallBack, thisAppState); } Console.WriteLine("Chord::Engine::beginStabilize EXIT"); }
public void beginPutData(byte[] key, byte[] data, int offset, int size, AsyncCallback putDataCallBack, Object appState) { Console.WriteLine("ChordRealNode::beginPutData ENTER"); //once DataStore gets complex, this operation should not complete on the same synchronous thread dataStore.putData(key, data, offset, size); IAsyncResult putDataResult = new Tashjik.Common.ObjectAsyncResult(appState, true, true); putDataCallBack(putDataResult); }
/* public void notify(Node possiblePred) * { * engine.notify(possiblePred); * * } * * private void beginJoin(IChordNode joinNode, AsyncCallback joinCallBack, Object appState) * { * engine.beginJoin(joinNode, joinCallBack, appState); * } */ public void beginPredecessorNotify(IChordNode possiblePred, AsyncCallback notifyCallBack, Object appState) { engine.notify(possiblePred); if (!(notifyCallBack == null)) { IAsyncResult res = new Tashjik.Common.ObjectAsyncResult(appState, true, true); notifyCallBack(res); } }
void processFindSuccessorForJoin(IAsyncResult result) { Console.WriteLine("ChordRealNode::Engine::processFindSuccessorForJoin ENTER"); ChordCommon.IChordNode_Object iNode_Object = (ChordCommon.IChordNode_Object)(result.AsyncState); Tashjik.Common.AsyncCallback_Object thisAppState = (Tashjik.Common.AsyncCallback_Object)(iNode_Object.obj); lock (successorLock) { successor = iNode_Object.node; } Console.WriteLine("ChordRealNode::Engine::processFindSuccessorForJoin successor has been set"); lock (successorLock) { successor.beginGetFingerTable(new AsyncCallback(processGetFingerTableForJoin), thisAppState); } //we have found the successor, and a request has been made for its finger table //once the finger table comes in, a findSiccessor call will be made to each of them //do we need to wait till all of them respond? wat if a few of them go down // we can't hang forever... better to return back, and allow the client to query // if the queries happen immediately, tey will fail because the finger table is still empty // as the finger table starts filling up, the queries will get answered better // // other possible solutions: wait for some time (and not indefinitely), and then allow // the client to query. But how long should we wait? In the literature do we have any such // approximate times by which quesries will come back? totally unpredictable I feel... depends // on whether the n/w is the intyernet or a LAN, etc,. // // maybe we could wait till a certain number of entries inthe finger table get filled up ... // maybe 60% .... but how do we decide on this number ... perhaps ChordCylinder will have // data on Churn rates and can set this. Will require significant chanes to the architecture, // because here the client is deciding on how long we should wait AsyncCallback callBack = thisAppState.callBack; Object appState1 = thisAppState.obj; if (!(callBack == null)) { IAsyncResult res = new Tashjik.Common.ObjectAsyncResult(appState1, true, true); callBack(res); } }
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); } }
void processPingForCheckPredecessor(IAsyncResult result) { Console.WriteLine("Chord::ChordRealNode::Engine processPingForCheckPredecessor ENTER"); Tashjik.Common.Bool_Object thisAppState = (Tashjik.Common.Bool_Object)(result.AsyncState); Tashjik.Common.AsyncCallback_Object checkPredecessorAppState = (Tashjik.Common.AsyncCallback_Object)(thisAppState.obj); if (!(thisAppState.b)) { predecessor = null; } //AsyncCallback callBack = ((Tashjik.Common.AsyncCallback_Object)appState).callBack; //Object appState1 = ((Tashjik.Common.AsyncCallback_Object)appState).obj; if (!(checkPredecessorAppState.callBack == null)) { Console.WriteLine("Chord::ChordRealNode::Engine processPingForCheckPredecessor callBack!=null"); IAsyncResult res = new Tashjik.Common.ObjectAsyncResult(checkPredecessorAppState.obj, true, true); checkPredecessorAppState.callBack(res); } }
public void beginCheckPredecessor(AsyncCallback checkPredecesorCallBack, Object appState) { Console.WriteLine("Chord::ChordRealNode::Engine beginCheckPredecessor ENTER"); if (predecessor == null) { if (checkPredecesorCallBack != null) { IAsyncResult res = new Tashjik.Common.ObjectAsyncResult(appState, true, true); checkPredecesorCallBack(res); } else { return; } } Tashjik.Common.AsyncCallback_Object thisAppState = new Tashjik.Common.AsyncCallback_Object(); thisAppState.callBack = checkPredecesorCallBack; thisAppState.obj = appState; AsyncCallback pingCallBack = new AsyncCallback(processPingForCheckPredecessor); predecessor.beginPing(pingCallBack, thisAppState); }
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); } }
/*public void stabilize() { AsyncCallback getPredecessorCallBack = new AsyncCallback(processGetPredecessorForStabilize); successor.beginGetPredecessor(getPredecessorCallBack); //if(((Node)self<x) && ((Node)x<successor)) // successor = x; //successor.notify(self); }*/ public void beginStabilize(AsyncCallback beginStabilizeCallBack, Object appState) { Console.WriteLine("Chord::Engine::beginStabilize ENTER"); lock (successorLock) { if (successor == self) { if (beginStabilizeCallBack != null) { IAsyncResult res = new Tashjik.Common.ObjectAsyncResult(appState, true, true); beginStabilizeCallBack(res); } else return; } } Tashjik.Common.AsyncCallback_Object thisAppState = new Tashjik.Common.AsyncCallback_Object(); thisAppState.callBack = beginStabilizeCallBack; thisAppState.obj = appState; Console.WriteLine("Chord::Engine::beginStabilize successor != self"); AsyncCallback getPredecessorCallBack = new AsyncCallback(processGetPredecessorForStabilize); lock (successorLock) { successor.beginGetPredecessor(getPredecessorCallBack, thisAppState); } Console.WriteLine("Chord::Engine::beginStabilize EXIT"); }
public void beginCheckPredecessor(AsyncCallback checkPredecesorCallBack, Object appState) { Console.WriteLine("Chord::ChordRealNode::Engine beginCheckPredecessor ENTER"); if(predecessor==null) { if(checkPredecesorCallBack!=null) { IAsyncResult res = new Tashjik.Common.ObjectAsyncResult(appState, true, true); checkPredecesorCallBack(res); } else return; } Tashjik.Common.AsyncCallback_Object thisAppState = new Tashjik.Common.AsyncCallback_Object(); thisAppState.callBack = checkPredecesorCallBack; thisAppState.obj = appState; AsyncCallback pingCallBack = new AsyncCallback(processPingForCheckPredecessor); predecessor.beginPing(pingCallBack, thisAppState); }
/* public void notify(Node possiblePred) { engine.notify(possiblePred); } private void beginJoin(IChordNode joinNode, AsyncCallback joinCallBack, Object appState) { engine.beginJoin(joinNode, joinCallBack, appState); } */ public void beginPredecessorNotify(IChordNode possiblePred, AsyncCallback notifyCallBack, Object appState) { engine.notify(possiblePred); if(!(notifyCallBack==null)) { IAsyncResult res = new Tashjik.Common.ObjectAsyncResult(appState, true, true); notifyCallBack(res); } }
void processPingForCheckPredecessor(IAsyncResult result) { Console.WriteLine("Chord::ChordRealNode::Engine processPingForCheckPredecessor ENTER"); Tashjik.Common.Bool_Object thisAppState = (Tashjik.Common.Bool_Object)(result.AsyncState); Tashjik.Common.AsyncCallback_Object checkPredecessorAppState = (Tashjik.Common.AsyncCallback_Object)(thisAppState.obj); if(!(thisAppState.b)) predecessor = null; //AsyncCallback callBack = ((Tashjik.Common.AsyncCallback_Object)appState).callBack; //Object appState1 = ((Tashjik.Common.AsyncCallback_Object)appState).obj; if(!(checkPredecessorAppState.callBack==null)) { Console.WriteLine("Chord::ChordRealNode::Engine processPingForCheckPredecessor callBack!=null"); IAsyncResult res = new Tashjik.Common.ObjectAsyncResult(checkPredecessorAppState.obj, true, true); checkPredecessorAppState.callBack(res); } }