chord_impl.h
来自「基于DHT的对等协议」· C头文件 代码 · 共 100 行
H
100 行
#ifndef _CHORD_IMPL_H_#define _CHORD_IMPL_H_/* * * Copyright (C) 2000 Frans Kaashoek (kaashoek@lcs.mit.edu) * Copyright (C) 2001 Frans Kaashoek (kaashoek@lcs.mit.edu) and * Frank Dabek (fdabek@lcs.mit.edu). * Copyright (C) 2003 Emil Sit (sit@mit.edu). * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */#include "chord.h"#include "route.h"#include "transport_prot.h"#include "coord.h"extern long outbytes;class stabilize_manager;class succ_list;class pred_list;class rpc_manager;// ================ VIRTUAL NODE ================struct dispatch_record { unsigned long progno; cbdispatch_t cb; ihash_entry<dispatch_record> hlink; dispatch_record (int p, cbdispatch_t c) : progno (p), cb (c) {};};struct upcall_record { int progno; cbupcall_t cb; ihash_entry<upcall_record> hlink; upcall_record (int p, cbupcall_t c) : progno (p), cb (c) {};};class vnode_impl : public vnode { protected: ptr<location> me_; ptr<rpc_manager> rpcm; ptr<succ_list> successors; ptr<pred_list> predecessors; ptr<stabilize_manager> stabilizer; virtual void dispatch (user_args *a); void doroute (user_args *sbp, chord_testandfindarg *fa); void do_upcall (int upcall_prog, int upcall_proc, void *uc_args, int uc_args_len, cbupcalldone_t app_cb); void upcall_done (chord_testandfindarg *fa, chord_testandfindres *res, user_args *sbp, bool stop); private: int myindex; //每个节点有一个整型标志自己 int checkdead_int; // ??? 需要确认的可能down掉的节点标识 ihash<unsigned long, dispatch_record, &dispatch_record::progno, &dispatch_record::hlink > dispatch_table; ihash<int, upcall_record, &upcall_record::progno, &upcall_record::hlink> upcall_table;//==========有关前驱后继信息====================== u_long ngetsuccessor; //第n 个后继 u_long ngetpredecessor; //第n个前驱 u_long ngetsucclist; //n个后继list u_long nfindsuccessor; //要寻找第n个后继
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?