Basic query[edit]
The core usage of the Chord protocol is to query a key from a client (generally a node as well), i.e. to find {displaystyle successor(k)} successor(k). The basic approach is to pass the query to a node's successor, if it cannot find the key locally. This will lead to a {displaystyle O(N)} O(N) query time.
Finger table[edit]
To avoid the linear search above, Chord implements a faster search method by requiring each node to keep a finger table containing up to {displaystyle m} m entries. The {displaystyle i^{th}} i^{th} entry of node {displaystyle n} n will contain {displaystyle successor((n+2^{i-1}),{mod {,}}2^{m})} successor((n+2^{i-1}),mod,2^m). The first entry of finger table is actually the node's immediate successor (and therefore an extra successor field is not needed). Every time a node wants to look up a key {displaystyle k} k, it will pass the query to the closest successor or predecessor (depending on the finger table) of {displaystyle k} k in its finger table (the "largest" one on the circle whose ID is smaller than {displaystyle k} k), until a node finds out the key is stored in its immediate successor.
With such a finger table, the number of nodes that must be contacted to find a successor in an N-node network is {displaystyle O(log N)} O(log N). (See proof below.)
Node join[edit]
Whenever a new node joins, three invariants should be maintained (the first two ensure correctness and the last one keeps querying fast):
Each node's successor points to its immediate successor correctly.
Each key is stored in {displaystyle successor(k)} successor(k).
Each node's finger table should be correct.
To satisfy these invariants, a predecessor field is maintained for each node. As the successor is the first entry of the finger table, we do not need to maintain this field separately any more. The following tasks should be done for a newly joined node {displaystyle n} n:
Initialize node {displaystyle n} n (the predecessor and the finger table).
Notify other nodes to update their predecessors and finger tables.
The new node takes over its responsible keys from its successor.
The predecessor of {displaystyle n} n can be easily obtained from the predecessor of {displaystyle successor(n)} successor(n) (in the previous circle). As for its finger table, there are various initialization methods. The simplest one is to execute find successor queries for all {displaystyle m} m entries, resulting in {displaystyle O(Mlog N)} O(Mlog N) initialization time. A better method is to check whether {displaystyle i^{th}} i^{th} entry in the finger table is still correct for the {displaystyle (i+1)^{th}} (i+1)^{th} entry. This will lead to {displaystyle O(log ^{2}N)} O(log^2 N). The best method is to initialize the finger table from its immediate neighbours and make some updates, which is {displaystyle O(log N)} O(log N).
Stabilization[edit]
To ensure correct lookups, all successor pointers must be up to date. => stabilization protocol running periodically in the background. Updates finger tables and successor pointers. Stabilization protocol: Stabilize(): n asks its successor for its predecessor p and decides whether p should be n‘s successor instead (this is the case if p recently joined the system). Notify(): notifies n‘s successor of its existence, so it can change its predecessor to n Fix_fingers(): updates finger tables
Failures and replication[edit]
สอบถามพื้นฐาน [แก้]การใช้งานหลักของโพรโทคอคอร์ดเป็น การสอบถามจากไคลเอนต์ (โดยทั่วไปโหนดเช่น) เช่น การค้นหา successor(k) {displaystyle successor(k) } วิธีพื้นฐานคือการ ผ่านแบบสอบถามไปยังโหนสืบ หากไม่พบคีย์ในท้องถิ่น นี้จะนำไปสู่เวลาสอบถาม O(N) {displaystyle O(N) }ตารางนิ้ว [แก้]เพื่อหลีกเลี่ยงการค้นหาเชิงเส้นข้าง คอร์ดใช้วิธีการค้นหาได้เร็วขึ้น โดยให้แต่ละโหนเก็บตารางนิ้วที่ประกอบด้วยถึงรายการ m {displaystyle m } ของ { displaystyle ฉัน ^ {th } } ผม ^ {th } รายการของโหน {displaystyle n } n จะประกอบด้วย {สืบ displaystyle ((n + 2 ^ { i-1 }) , {mod {,}}2^{m }) } successor((n+2^{i-1}),mod,2^m) รายการแรกของตารางนิ้วเป็นจริงของโหนดที่ทำต่อทันที (และดังนั้น ฟิลด์สืบพิเศษไม่จำเป็นต้อง) ทุกครั้งที่โหนดที่ต้องการค้นหาคีย์ {displaystyle k } k จะส่งแบบสอบถามสืบที่ใกล้เคียงหรือรุ่นก่อนหน้า (ขึ้นอยู่กับตารางนิ้ว) ของ k {displaystyle k } ในตารางนิ้ว (หนึ่ง "ที่ใหญ่ที่สุด" ในวงกลมที่มีหมายเลขที่มีขนาดเล็กกว่า k {displaystyle k }) จนกว่าจะพบโหน คีย์ถูกเก็บไว้ในทำการต่อได้ทันทีเช่นนิ้วตาราง หมายเลขของโหนที่ต้องติดต่อเพื่อค้นหาทายาทในเครือข่ายที่มี N โหน เป็น {displaystyle O(log N) } O (log N) (ดูหลักฐานด้านล่าง)เข้าร่วมโหน [แก้]เมื่อโหนใหม่รวม ควรรักษาสาม invariants (สองคนแรกตรวจความถูกต้อง และสุดท้ายช่วยทำแบบสอบถามอย่างรวดเร็ว):แต่ละโหนสืบไปทดทันทีอย่างถูกต้องแต่ละคีย์ถูกเก็บไว้ใน successor(k) {displaystyle successor(k) }แต่ละโหนตารางนิ้วควรถูกต้องการตอบสนองเหล่านี้ invariants เขตข้อมูลก่อนหน้าถูกรักษาไว้สำหรับแต่ละโหน สืบต่อเป็น รายการแรกของตารางนิ้ว เราไม่จำเป็นต้องรักษาฟิลด์นี้แยกต่างหากใด ๆ เพิ่มเติม ควรทำงานต่อไป n:โหนใหม่รวม {displaystyle n }เริ่มต้นโหน {displaystyle n } n (บรรพบุรุษและตารางนิ้ว)แจ้งโหนอื่น ๆ การปรับปรุงรุ่นก่อนและตารางนิ้วโหนดใหม่จะกว่าคีย์ความรับผิดชอบจากผู้สืบบรรพบุรุษของ {displaystyle n } n สามารถได้รับจากบรรพบุรุษของ {displaystyle successor(n) } successor(n) (ในวงกลมก่อนหน้านี้)ได้อย่างง่ายดาย สำหรับตารางนิ้ว มีหลายวิธี ง่ายที่สุดคือการดำเนินการหาผู้สืบทอดแบบสอบถามสำหรับรายการทั้งหมด {displaystyle m } m ในเวลาเริ่มต้นของ {displaystyle O(Mlog N) } O (Mlog N) วิธีดีคือการ ตรวจสอบว่า { displaystyle ฉัน ^ {th } } ผม ^ {th } รายการในตารางนิ้วจะยังคงถูกต้องสำหรับการ { displaystyle (ผม + 1) ^ {th } } (ผม + 1) ^ {th } รายการ นี้จะนำไปสู่ {displaystyle O(log ^{2}N) } O (log^2 N) วิธีที่ดีที่สุดคือการ เตรียมใช้งานตารางนิ้วจากของเพื่อนบ้านได้ทันที และทำการปรับปรุงบางอย่าง ซึ่งเป็น {displaystyle O(log N) } O (log N)Stabilization[edit]To ensure correct lookups, all successor pointers must be up to date. => stabilization protocol running periodically in the background. Updates finger tables and successor pointers. Stabilization protocol: Stabilize(): n asks its successor for its predecessor p and decides whether p should be n‘s successor instead (this is the case if p recently joined the system). Notify(): notifies n‘s successor of its existence, so it can change its predecessor to n Fix_fingers(): updates finger tablesFailures and replication[edit]
การแปล กรุณารอสักครู่..
