master

package
v0.0.0-...-f617e85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2016 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortBlockByFunc

func SortBlockByFunc(f func(*BlockHeader) int, list []*BlockHeader) sort.Interface

func SortNodeByFunc

func SortNodeByFunc(f func(NodeID) int, list []NodeID) sort.Interface

Types

type BlockManager

type BlockManager struct {
	// contains filtered or unexported fields
}

func NewBlockManager

func NewBlockManager() *BlockManager

func (*BlockManager) AddBlock

func (b *BlockManager) AddBlock(id FileID, block *BlockHeader)

func (*BlockManager) AddFile

func (b *BlockManager) AddFile(file *File)

func (*BlockManager) DeleteBlock

func (b *BlockManager) DeleteBlock(id FileID, blockID BlockID)

func (*BlockManager) DeleteFile

func (b *BlockManager) DeleteFile(id FileID)

func (*BlockManager) GetBlock

func (b *BlockManager) GetBlock(blockID BlockID) *BlockHeader

func (*BlockManager) GetFile

func (b *BlockManager) GetFile(id FileID) *File

func (*BlockManager) HasBlock

func (b *BlockManager) HasBlock(blockID BlockID) bool

func (*BlockManager) ListFile

func (b *BlockManager) ListFile() []*File

func (*BlockManager) UpdateFileStatus

func (b *BlockManager) UpdateFileStatus(id FileID, status FileStatus)

type BlockSort

type BlockSort struct {
	Func func(*BlockHeader) int
	// contains filtered or unexported fields
}

func (BlockSort) Len

func (n BlockSort) Len() int

func (BlockSort) Less

func (n BlockSort) Less(i, j int) bool

func (BlockSort) Swap

func (n BlockSort) Swap(i, j int)

type HTTPServer

type HTTPServer struct {
	Host string
	Port int
	// contains filtered or unexported fields
}

func NewHTTPServer

func NewHTTPServer(host string, port int, blockManager *BlockManager, nodeManager *NodeManager) *HTTPServer

func (*HTTPServer) Addr

func (server *HTTPServer) Addr() string

func (*HTTPServer) AddrWithScheme

func (server *HTTPServer) AddrWithScheme() string

func (*HTTPServer) ListenAndServe

func (server *HTTPServer) ListenAndServe()

type Master

type Master struct {
	RPCPort int
	// contains filtered or unexported fields
}

Master node controllers all metadata of the whole cluster.

func NewMaster

func NewMaster(config *Config) *Master

NewMaster returns a master.

func (*Master) ListenRPC

func (m *Master) ListenRPC()

ListenRPC setup a RPC server on master node.

func (*Master) Monitor

func (m *Master) Monitor()

func (*Master) Run

func (master *Master) Run()

Run method setup all necessary goroutines.

type MasterRPC

type MasterRPC struct {
	// contains filtered or unexported fields
}

func NewMasterRPC

func NewMasterRPC(nodeManager *NodeManager, blockManager *BlockManager, replicationController *ReplicationController) *MasterRPC

func (*MasterRPC) Heartbeat

func (c *MasterRPC) Heartbeat(message comm.HeartbeatMessage, reply *comm.HeartbeatResponse) error

func (*MasterRPC) Register

func (c *MasterRPC) Register(message comm.RegistrationMessage, reply *NodeID) error

func (*MasterRPC) SyncDone

func (c *MasterRPC) SyncDone(block *BlockHeader, reply *comm.SyncDoneResponse) error

type NodeManager

type NodeManager struct {
	// contains filtered or unexported fields
}

func NewNodeManager

func NewNodeManager() *NodeManager

func (*NodeManager) AddNode

func (n *NodeManager) AddNode(node *Node)

func (*NodeManager) DeleteNode

func (n *NodeManager) DeleteNode(nodeID NodeID)

func (*NodeManager) GetNode

func (n *NodeManager) GetNode(id NodeID) *Node

func (*NodeManager) LeastBlocksNodes

func (n *NodeManager) LeastBlocksNodes() []NodeID

func (*NodeManager) LeastConnectionNodes

func (n *NodeManager) LeastConnectionNodes() []NodeID

func (*NodeManager) ListNode

func (n *NodeManager) ListNode() []*Node

func (*NodeManager) LostNode

func (n *NodeManager) LostNode(node *Node, blockManager *BlockManager)

LostNode wipe a node from healthy node.

func (*NodeManager) ReRegisterChunkNode

func (n *NodeManager) ReRegisterChunkNode(addr string, id NodeID)

ReRegisterChunkNode re-register a lost node to node manager.

func (*NodeManager) RegisterChunkNode

func (n *NodeManager) RegisterChunkNode(addr string) NodeID

RegisterChunkNode generate universal unique id for a chunk node and register this node. to master's map.

func (*NodeManager) UpdateNode

func (n *NodeManager) UpdateNode(node *Node)

func (*NodeManager) UpdateNodeWithHeartbeat

func (n *NodeManager) UpdateNodeWithHeartbeat(message comm.HeartbeatMessage)

UpdateNodeWithHeartbeat update node information with heartbeat message.

type NodeSort

type NodeSort struct {
	Func func(NodeID) int
	// contains filtered or unexported fields
}

func (NodeSort) Len

func (n NodeSort) Len() int

func (NodeSort) Less

func (n NodeSort) Less(i, j int) bool

func (NodeSort) Swap

func (n NodeSort) Swap(i, j int)

type ReplicationController

type ReplicationController struct {
	// contains filtered or unexported fields
}

func NewReplicationController

func NewReplicationController(defaultReplication int) *ReplicationController

func (*ReplicationController) Replicate

func (rc *ReplicationController) Replicate(blockManager *BlockManager, nodeManager *NodeManager, blocks []BlockID) []*SyncBlock

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL