02.06.2013 Views

Implementing a Distributed Peer to Peer File Sharing System ... - Umbc

Implementing a Distributed Peer to Peer File Sharing System ... - Umbc

Implementing a Distributed Peer to Peer File Sharing System ... - Umbc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHEWBACCA Baker, Fink, Trimm, Whisman<br />

}<br />

/**<br />

* Lock the cloud - if local node has the <strong>to</strong>ken, then<br />

* locking proceeds; else it is queried for<br />

*/<br />

public void lock_cloud() {<br />

}<br />

if (<strong>to</strong>ken==null)<br />

pass_<strong>to</strong>ken(this);<br />

is_locked=true;<br />

public void unlock_cloud() {<br />

}<br />

/**<br />

is_locked=false;<br />

is_locked.notify // wake any waiting threads<br />

* Updates forward fingers <strong>to</strong> notify them that "nhid"<br />

* is the new holder of the <strong>to</strong>ken. Forward fingers are<br />

* updated <strong>to</strong> maintain the set CN of correct nodes;<br />

* by fixing the forward fingers, it ensures that any<br />

* node querying for a <strong>to</strong>ken will eventually land on the<br />

* proper path <strong>to</strong>ward the <strong>to</strong>ken.<br />

*/<br />

public void update_forward_<strong>to</strong>ken_fingers(int nhid) {<br />

// recursively update forward fingers<br />

<strong>to</strong>ken_finger = closest_preceding_finger_index(nhid);<br />

if (<strong>to</strong>ken_finger>0)<br />

finger[<strong>to</strong>ken_finger].node.update_forward_<strong>to</strong>ken_fingers(nhid);<br />

}<br />

/**<br />

29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!