TFS原始碼解析五

2021-06-25 19:16:31 字數 3951 閱讀 9862

nameserver中

ns_define.h

#ifndef tfs_nameserver_define_h_

#define tfs_nameserver_define_h_

#include 

//訊號量標頭檔案

#include 

//tfs依賴的

tbsys

標頭檔案#include "common/internal.h" 

//基礎資料結構定義標頭檔案

#include "common/func.h" 

//基礎函式標頭檔案

#include "common/lock.h" 

//封裝後的讀寫鎖頭檔案

#include "common/parameter.h" 

//定義各個

server

引數標頭檔案

#include "common/new_client.h" 

//客戶端資訊標頭檔案

#include "common/array_helper.h"

//封裝陣列操作標頭檔案

namespace tfs;

enum nsstatus //nameserver

初始化狀態 ;

enum nsswitchflag //nameserver

主備切換標記 ;

enum reportblockstatus //nameserver

處理block

的狀態 ;

enum handledeleteblockflag //

刪除block

資料和關係標記 ;

enum nskeepalivetype //nameserver

保活型別 ;

enum blockinreplicatequeueflag //block

在複製佇列標記 ;

enum familyinreinstateordissolvequeueflag //family

在恢復佇列標記 ;

enum blockcompareserverflag //block

資訊中比較

server

使用的索引標記 ;

class layoutmanager;

class gcobject//nameserver

中資料的基類,定義最後更新的時間

virtual

~gcobject(){}

virtual

void callback(layoutmanager&){}

inline

void free()

inline time_t get_last_update_time()

const

inline

void update_last_time(

const time_t now = common::func::get_monotonic_time())

inline

bool can_be_clear(

const time_t now)

const

inline

bool can_be_free(

const time_t now)

const

protected:

time_t last_update_time_;

//最後的更新時間 };

//nameserver

統計資訊

struct nsglobalstatisticsinfo :

public common::rwlock;

//nameserver

執行資訊

struct nsruntimeglobalinformation;

//相關最大值定義

static

const int32_t thread_statck_size =16*

1024

*1024;

static

const int32_t max_server_nums =

3000;

static

const int32_t max_process_nums = max_server_nums *12;

//static const int32_t max_block_chunk_nums = 512;

static

const int32_t max_block_chunk_nums =

10240*4

; static

const int32_t max_replication =64;

static

const int32_t max_write_file_count =

256;

static

const uint64_t gb =1*

1024

*1024

*1024;

static

const uint64_t mb =1*

1024

*1024;

static

const

double percentage_min =

0.000001;

static

const

double percentage_max =

1.000000;

static

const

double percentage_magic =

1000000.0;

double calc_capacity_percentage(

const uint64_t capacity,

const uint64_t total_capacity);

static

const int32_t max_pop_server_from_dead_queue_limit =5;

static

const int32_t max_rack_num =

512;

static

const int32_t max_single_rack_server_num =64;

static

const int32_t max_marshlling_queue_element_size =

128;

//編組佇列大小

static

const int32_t max_family_chunk_num =

1024;//

static

const int32_t max_task_reserve_time =5;

class blockcollect;

class servercollect;

extern

int ns_async_callback(common::newclient* client);

extern std::string& print_servers(

const common::arrayhelper&servers,

std::string& result);

extern

void print_servers(

const common::arrayhelper&servers, std::string& result);

extern

void print_servers(

const std::vector& servers,

std::string& result);

extern

void print_blocks(

const std::vector& blocks,

std::string& result); }

/** nameserver **/ }

/** tfs **/

#endif

TFS原始碼解析一

tfs是乙個 分布式檔案系統,集群中主要涉及名字伺服器nameserver,以及資料伺服器dataserver,nameserver提供索引管理,dataserver提供資料儲存及管理。客戶端通過nameserver請求,獲取到dataserver中的資料路徑,然後通過dataserver獲取資料操...

hdl graph slam原始碼解析(五)

hdl graph slam演算法中的回環檢測部分主要是在loop detector.hpp 中定義並實現的,主要分為兩部分,分別是 從歷史關鍵幀中尋找可能的回環 對可能的回環進行點雲配準確定回環。因此,整體的 結構並不複雜 std vector detect const std vector pt...

dubbo原始碼解析 spi 五

之前對dubbo的spi進行了四篇的分享.大家對這個概念有了一些初步的了解.談到程式設計水平如何高階,大家可能都會異口同聲的說出三個字,看原始碼.但是我卻始終認為,程式設計光看,是永遠學不會的.關鍵還是要多動手.但是很多時候,連怎麼看原始碼都無從下手,你叫我寫仿寫原始碼,這不是開玩笑?我們可以回憶一...