|
From: Kalman G. <gr...@ko...> - 2008-06-19 11:54:57
|
Hi everybody,
I already talked to Yue, here is the answer I gave him:
You cannot actively wait until e.g. a result arrives and to continue at
that specific point in your code.
Waiting has to be implemented using the callback functionality.
Basically, in a method you can either send a request or react on in.
Typically you have an Operation like in the example
CheckLivenessOperation. When this Operation is actived you should send a
message to the peer to be pinged. Further you should define which method
to call if a result arrives. That's it for the momemt.
When the reply comes, its corresponding listener is called and you can
perform the tasks needed to be done. E.g. updating the status of the
contacted peer.
best regards,
Kalman
> -----Ursprüngliche Nachricht-----
> Von: pee...@li... [mailto:pee...@li...] Im Auftrag von Kalman Graffi
> Gesendet: Dienstag, 10. Juni 2008 14:50
> An: pee...@li...
> Betreff: [Peerfactsim-developer] Fwd: Problem with Waiting the result ofoperation
>
> Forwarded email from Yue Sheng:
>
> Hello everybody,
> I'm implementing the chord overlay for the simulator following the
> document "How to create an overlay in PeerfactSim.KOM" and I have a
> problem implementing the action of waiting.
> For example:
> I defined a simple operation called CheckLivenessOperation in my overlay
> node, which checks if another overlay node is active or not. The
> operation sends a request message via transport layer to the target node
> and wait for a time, if it gets a reply in that time, then
> operationFinished(true) will be call, else operationFinished(false) will
> be called.
>
> My problem is: For the caller of this operation, namely the overlay
> node, after it calls CheckLivenessOperation.scheduleImmediately(), it
> has to wait until the operation is finished, after that it can tell if
> the target node is active or not. And I'm not sure how to let the node
> wait. Until now I use the following way to wait for the result of an
> operation:
>
> Method in my overlay node:
>
> public boolean checkLiveness(ChordContact target) {
> ping = new CheckLivenessOperation(this, target, opListener);
> ping.scheduleImmediately();
> while( ! ping.isFinished() ) {
> // busy waiting
> }
> return ping.isSuccessful();
> }
>
> Although I think the while() statement is not correct, but I have no
> other idea at the moment.
> Any help will be appreciated.
> thanks!!!
> Yue Sheng
>
>
--
_________ Dipl.Math., Dipl.Inf. Kalman Graffi ___________
Peer-to-Peer Networking Group
Multimedia Communications Lab (KOM)
http:\\www.kom.tu-darmstadt.de
Technische Universitaet Darmstadt
Dept. of Electrical Engineering & Information Technology
tel: +49 (0) 6151 16-4959 fax: +49 (0) 6151 16-6152
postal address: TU Darmstadt, FB 18, KOM, Merckstr. 25,
D-64283 Darmstadt, Germany
__________________________________________________________
|