MCPcopy Create free account
hub / github.com/Super-long/ChubbyGo / InitRoot

Function InitRoot

BaseServer/fileSystem.go:403–431  ·  view source on GitHub ↗

* * @brief: 用于初始化每个Cell内的根目录 * @return: 返回根目录的实体 */

()

Source from the content-addressed store, hash-verified

401 * @return: 返回根目录的实体
402 */
403func InitRoot() *FileSystemNode {
404 root := &FileSystemNode{}
405
406 root.fileType = Directory
407 // TODO 访问控制如何调整 就是一系列的ACLs 这个显然需要读取配置文件了
408
409 // 想来想去,如果把Chubby Cell的名字改成与leaderID,后面切主会比较麻烦,对于外界来说也不好调用
410 // 因为理想的调用方法是有一个DNS服务器,客户端可以使用名称来得到这个Cell的地址
411 // 此时直接取名就方便的多,TODO 后面这里还是要读一手配置文件
412 //root.fileName = "ChubbyCell_" + strconv.Itoa(int(leaderID))
413 root.fileName = "ChubbyCell_" + "lizhaolong"
414
415 // instanceseq与tokenseq的初始值是2,零设定为无效值,1为delete通知的成功值
416 root.instanceSeq = 2
417 root.tokenSeq = 2
418 root.aCLsSeq = 0
419 root.checksum = root.makeCheckSum()
420
421 root.nowLockType = NotLock
422 root.readLockReferenceCount = 0
423 root.nowPath = "/ls/" + root.fileName // 所有Cell的根均为ls(lock server),这是一个虚拟的根
424 root.next = make(map[string]*FileSystemNode)
425 root.nextNameCache = make(map[string]uint64)
426
427 /* log.Printf("目前的路径名 : %s\n", root.nowPath)
428 RootFileOperation.pathToFileSystemNodePointer[root.nowPath] = root*/
429
430 return root
431}
432
433func (Fsn *FileSystemNode) CheckToken(token uint64, filename string) error{
434 Node, IsExist := Fsn.next[filename]

Callers 1

InitFileOperationFunction · 0.85

Calls 1

makeCheckSumMethod · 0.95

Tested by

no test coverage detected