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 />

10 Appendix: Enhanced Chord Algorithm<br />

The following algorithm includes enhancements for cloud locking as discussed<br />

elsewhere. This is actual Java, augmented <strong>to</strong> resemble the algorithmic notations in the<br />

original paper.<br />

/**<br />

* Augmented Pro<strong>to</strong>col Methods - Token-based Mutex<br />

*/<br />

/**<br />

* This method returns an index of a finger, not the finger<br />

* itself.<br />

*/<br />

public int closest_preceding_finger_index(int id) {<br />

}<br />

for (int i=_m; i>=1; i--) {<br />

}<br />

if (on_range(finger[i].node._id, this._id+1, id-1))<br />

return i;<br />

return 0; // 0 means "this" is closest prec finger<br />

public ChordNode closest_preceding_finger(int id) {<br />

}<br />

/**<br />

int cpf = closest_preceding_finger_index(id);<br />

if (cpf>0)<br />

return finger[cpf].node;<br />

else<br />

return this;<br />

* Creates a <strong>to</strong>ken on the local node<br />

*/<br />

public void put_<strong>to</strong>ken(int sn) {<br />

<strong>to</strong>ken = new Integer(sn);<br />

28

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

Saved successfully!

Ooh no, something went wrong!