diff options
| author | thibauth <thibauth@30fcff6e-8de6-41c7-acce-77ff6d1dd07b> | 2011-09-06 16:07:17 +0000 |
|---|---|---|
| committer | thibauth <thibauth@30fcff6e-8de6-41c7-acce-77ff6d1dd07b> | 2011-09-06 16:07:17 +0000 |
| commit | fa3a9f2a4d5db1723112cac9492eca662e0d8478 (patch) | |
| tree | 0a32d24d0f36198febe30e114b6e210a12a27f96 | |
| parent | 89f1f90f64aa8da3c2e18b3ba3bea5336dcd9c2b (diff) | |
| download | pacemaker-fa3a9f2a4d5db1723112cac9492eca662e0d8478.tar.gz | |
Chord
git-svn-id: https://scm.gforge.inria.fr/svn/pacemaker@80 30fcff6e-8de6-41c7-acce-77ff6d1dd07b
| -rw-r--r-- | sources/thibaut/chord.ml | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sources/thibaut/chord.ml b/sources/thibaut/chord.ml new file mode 100644 index 0000000..cb3ad2a --- /dev/null +++ b/sources/thibaut/chord.ml @@ -0,0 +1,27 @@ +open Globals +open SlotArray + + +let do_peer root peer = + + let aux = function + | Ask p -> ask_peer peer p + | _ -> failwith "Big problem" + in + + SlotArray.filter_peers is_active peer.slots; + SlotArray.iter_asks aux peer.slots; + let free_slots = SlotArray.capacity peer.slots - SlotArray.length peer.slots + - SlotArray.asks peer.slots in + if free_slots > 2 then + let (a,b) = ask_root root peer in + if a then begin + SlotArray.accept (Peer root) peer.slots; + SlotArray.append_asks b peer.slots + end + else + SlotArray.append_asks b peer.slots + +let do_server root = + SlotArray.filter_peers is_active root.slots + |
