master

package
v0.0.0-...-71dd0ca Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinTaskLen         = 30
	TaskWorkerInterval = time.Microsecond * time.Duration(200)
	ForceCloseConnect  = true
	NoCloseConnect     = false
)
View Source
const (
	ColonSplit                  = ":"
	CommaSplit                  = ","
	CfgPeers                    = "peers"
	DataPartitionMissSec        = "dataPartitionMissSec"
	DataPartitionTimeOutSec     = "dataPartitionTimeOutSec"
	EveryLoadDataPartitionCount = "everyLoadDataPartitionCount"
	FileDelayCheckCrc           = "fileDelayCheckCrc"
	ReplicaNum                  = "replicaNum"
)
View Source
const (
	DefaultEveryReleaseDataPartitionCount       = 50
	DefaultReleaseDataPartitionAfterLoadSeconds = 5 * 60
	DefaultReleaseDataPartitionInternalSeconds  = 10
	DefaultCheckHeartbeatIntervalSeconds        = 60
	DefaultCheckDataPartitionIntervalSeconds    = 60
	DefaultFileDelayCheckLackSec                = 5 * DefaultCheckHeartbeatIntervalSeconds
	DefaultFileDelayCheckCrcSec                 = 20 * DefaultCheckHeartbeatIntervalSeconds
	NoHeartBeatTimes                            = 3
	DefaultNodeTimeOutSec                       = NoHeartBeatTimes * DefaultCheckHeartbeatIntervalSeconds
	DefaultDataPartitionTimeOutSec              = 10 * DefaultCheckHeartbeatIntervalSeconds
	DefaultDataPartitionMissSec                 = 24 * 3600
	DefaultDataPartitionWarnInterval            = 60 * 60
	LoadDataPartitionWaitTime                   = 100
	DefaultLoadDataPartitionFrequencyTime       = 60 * 60
	DefaultEveryLoadDataPartitionCount          = 50
	DefaultMetaPartitionTimeOutSec              = 10 * DefaultCheckHeartbeatIntervalSeconds
	//DefaultMetaPartitionMissSec                         = 3600
	DefaultMetaPartitionWarnInterval            = 10 * 60
	DefaultMetaPartitionThreshold       float32 = 0.75
	DefaultMetaPartitionCountOnEachNode         = 100
)
View Source
const (
	ParaNodeAddr          = "addr"
	ParaName              = "name"
	ParaId                = "id"
	ParaCount             = "count"
	ParaReplicas          = "replicas"
	ParaDataPartitionType = "type"
	ParaStart             = "start"
	ParaEnable            = "enable"
	ParaThreshold         = "threshold"
)
View Source
const (
	DeleteExcessReplicationErr     = "DeleteExcessReplicationErr "
	AddLackReplicationErr          = "AddLackReplicationErr "
	CheckDataPartitionDiskErrorErr = "CheckDataPartitionDiskErrorErr  "
	GetAvailDataNodeHostsErr       = "GetAvailDataNodeHostsErr "
	GetAvailMetaNodeHostsErr       = "GetAvailMetaNodeHostsErr "
	GetDataReplicaFileCountInfo    = "GetDataReplicaFileCountInfo "
	DataNodeOfflineInfo            = "dataNodeOfflineInfo"
	HandleDataPartitionOfflineErr  = "HandleDataPartitionOffLineErr "
)
View Source
const (
	DefaultMaxMetaPartitionInodeID  uint64  = 1<<63 - 1
	DefaultMetaPartitionInodeIDStep uint64  = 1 << 24
	DefaultMetaNodeReservedMem      uint64  = 1 << 32
	RuntimeStackBufSize                     = 4096
	NodesAliveRate                  float32 = 0.5
	MinReadWriteDataPartitions              = 200
	SpaceAvailRate                          = 0.95
)
View Source
const (
	OK = iota
	Failed
)
View Source
const (
	VolNormal     uint8 = 0
	VolMarkDelete uint8 = 1
)
View Source
const (
	// Admin APIs
	AdminGetCluster           = "/admin/getCluster"
	AdminGetDataPartition     = "/dataPartition/get"
	AdminLoadDataPartition    = "/dataPartition/load"
	AdminCreateDataPartition  = "/dataPartition/create"
	AdminDataPartitionOffline = "/dataPartition/offline"
	AdminDeleteVol            = "/vol/delete"
	AdminCreateVol            = "/admin/createVol"
	AdminGetIp                = "/admin/getIp"
	AdminCreateMP             = "/metaPartition/create"
	AdminSetCompactStatus     = "/compactStatus/set"
	AdminGetCompactStatus     = "/compactStatus/get"
	AdminSetMetaNodeThreshold = "/threshold/set"

	// Client APIs
	ClientDataPartitions = "/client/dataPartitions"
	ClientVol            = "/client/vol"
	ClientMetaPartition  = "/client/metaPartition"
	ClientVolStat        = "/client/volStat"

	//raft node APIs
	RaftNodeAdd    = "/raftNode/add"
	RaftNodeRemove = "/raftNode/remove"

	// Node APIs
	AddDataNode               = "/dataNode/add"
	DataNodeOffline           = "/dataNode/offline"
	GetDataNode               = "/dataNode/get"
	AddMetaNode               = "/metaNode/add"
	MetaNodeOffline           = "/metaNode/offline"
	GetMetaNode               = "/metaNode/get"
	AdminLoadMetaPartition    = "/metaPartition/load"
	AdminMetaPartitionOffline = "/metaPartition/offline"

	// Operation response
	MetaNodeResponse = "/metaNode/response" // Method: 'POST', ContentType: 'application/json'
	DataNodeResponse = "/dataNode/response" // Method: 'POST', ContentType: 'application/json'
)
View Source
const (
	MaxDataPartitionIDKey = "max_dp_id"
	MaxMetaPartitionIDKey = "max_mp_id"
	MaxMetaNodeIDKey      = "max_metaNode_id"
)
View Source
const (
	OpSyncAddMetaNode          uint32 = 0x01
	OpSyncAddDataNode          uint32 = 0x02
	OpSyncAddDataPartition     uint32 = 0x03
	OpSyncAddVol               uint32 = 0x04
	OpSyncAddMetaPartition     uint32 = 0x05
	OpSyncUpdateDataPartition  uint32 = 0x06
	OpSyncUpdateMetaPartition  uint32 = 0x07
	OpSyncDeleteDataNode       uint32 = 0x08
	OpSyncDeleteMetaNode       uint32 = 0x09
	OpSyncAllocDataPartitionID uint32 = 0x0A
	OpSyncAllocMetaPartitionID uint32 = 0x0B
	OpSyncAllocMetaNodeID      uint32 = 0x0C
	OpSyncPutCluster           uint32 = 0x0D
	OpSyncUpdateVol            uint32 = 0x0E
	OpSyncDeleteVol            uint32 = 0x0F
	OpSyncDeleteDataPartition  uint32 = 0x10
	OpSyncDeleteMetaPartition  uint32 = 0x11
)
View Source
const (
	KeySeparator         = "#"
	MetaNodeAcronym      = "mn"
	DataNodeAcronym      = "dn"
	DataPartitionAcronym = "dp"
	MetaPartitionAcronym = "mp"
	VolAcronym           = "vol"
	ClusterAcronym       = "c"
	MetaNodePrefix       = KeySeparator + MetaNodeAcronym + KeySeparator
	DataNodePrefix       = KeySeparator + DataNodeAcronym + KeySeparator
	DataPartitionPrefix  = KeySeparator + DataPartitionAcronym + KeySeparator
	VolPrefix            = KeySeparator + VolAcronym + KeySeparator
	MetaPartitionPrefix  = KeySeparator + MetaPartitionAcronym + KeySeparator
	ClusterPrefix        = KeySeparator + ClusterAcronym + KeySeparator
)
View Source
const (
	ClusterName       = "clusterName"
	ID                = "id"
	IP                = "ip"
	Port              = "port"
	LogLevel          = "logLevel"
	WalDir            = "walDir"
	StoreDir          = "storeDir"
	GroupId           = 1
	UmpModuleName     = "master"
	CfgRetainLogs     = "retainLogs"
	DefaultRetainLogs = 20000
)

config keys

View Source
const (
	Applied = "applied"
)
View Source
const (
	ReservedVolCount = 1
)
View Source
const (
	UnderlineSeparator = "_"
)

Variables

View Source
var (
	NoAvailDataPartition  = errors.New("no avail data partition")
	DataPartitionNotFound = errors.New("data partition not found")
	RackNotFound          = errors.New("rack not found")
	DataNodeNotFound      = errors.New("data node not found")
	MetaNodeNotFound      = errors.New("meta node not found")
	VolNotFound           = errors.New("vol not found")
	MetaPartitionNotFound = errors.New("meta partition not found")
	DataReplicaNotFound   = errors.New("data replica not found")
	UnMatchPara           = errors.New("para not unmatched")

	DisOrderArrayErr                    = errors.New("dis order array is nil")
	DataReplicaExcessError              = errors.New("data replica Excess error")
	DataReplicaLackError                = errors.New("data replica Lack error")
	DataReplicaHasMissOneError          = errors.New("data replica has miss one ,cannot miss any one")
	NoHaveAnyDataNodeToWrite            = errors.New("No have any data node for create data partition")
	NoHaveAnyMetaNodeToWrite            = errors.New("No have any meta node for create meta partition")
	CannotOffLineErr                    = errors.New("cannot offline because avail data replica <0")
	NoAnyDataNodeForCreateDataPartition = errors.New("no have enough data server for create data partition")
	NoRackForCreateDataPartition        = errors.New("no rack for create data partition")
	NoAnyMetaNodeForCreateMetaPartition = errors.New("no have enough meta server for create meta partition")
	MetaReplicaExcessError              = errors.New("meta partition Replication Excess error")
	NoHaveMajorityReplica               = errors.New("no have majority replica error")
	NoLeader                            = errors.New("no leader")
	ErrBadConfFile                      = errors.New("BadConfFile")
	InvalidDataPartitionType            = errors.New("invalid data partition type. extent or blob")
	ParaEnableNotFound                  = errors.New("para enable not found")
)
View Source
var AddrDatabase = make(map[uint64]string)

AddrDatabase ...

Functions

func HandleError

func HandleError(message string, err error, code int, w http.ResponseWriter)

func UnmarshalTaskResponse

func UnmarshalTaskResponse(task *proto.AdminTask) (err error)

func Warn

func Warn(clusterID, msg string)

func WarnBySpecialUmpKey

func WarnBySpecialUmpKey(umpKey, msg string)

Types

type AdminTaskSender

type AdminTaskSender struct {
	TaskMap map[string]*proto.AdminTask
	sync.Mutex
	// contains filtered or unexported fields
}

func NewAdminTaskSender

func NewAdminTaskSender(targetAddr, clusterID string) (sender *AdminTaskSender)

func (*AdminTaskSender) DelTask

func (sender *AdminTaskSender) DelTask(t *proto.AdminTask)

func (*AdminTaskSender) IsExist

func (sender *AdminTaskSender) IsExist(t *proto.AdminTask) bool

func (*AdminTaskSender) PutTask

func (sender *AdminTaskSender) PutTask(t *proto.AdminTask)

type Cluster

type Cluster struct {
	Name string
	// contains filtered or unexported fields
}

func (*Cluster) ChooseTargetDataHosts

func (c *Cluster) ChooseTargetDataHosts(replicaNum int) (hosts []string, err error)

func (*Cluster) ChooseTargetMetaHosts

func (c *Cluster) ChooseTargetMetaHosts(replicaNum int) (hosts []string, peers []proto.Peer, err error)

func (*Cluster) CreateMetaPartition

func (c *Cluster) CreateMetaPartition(volName string, start, end uint64) (err error)

func (*Cluster) CreateMetaPartitionForManual

func (c *Cluster) CreateMetaPartitionForManual(volName string, start uint64) (err error)

func (*Cluster) DataNodeCount

func (c *Cluster) DataNodeCount() (len int)

func (*Cluster) DisOrderArray

func (c *Cluster) DisOrderArray(oldHosts []string) (newHosts []string, err error)

func (*Cluster) GetAvailCarryMetaNodeTab

func (c *Cluster) GetAvailCarryMetaNodeTab(maxTotal uint64, excludeHosts []string) (nodeTabs NodeTabArrSorterByCarry, availCount int)

func (*Cluster) GetMetaNodeMaxTotal

func (c *Cluster) GetMetaNodeMaxTotal() (maxTotal uint64)

func (*Cluster) UpdateDataNode

func (c *Cluster) UpdateDataNode(dataNode *DataNode, dps []*proto.PartitionReport)

if node report data partition infos,so range data partition infos,then update data partition info

func (*Cluster) UpdateMetaNode

func (c *Cluster) UpdateMetaNode(metaNode *MetaNode, metaPartitions []*proto.MetaPartitionReport, threshold bool)

type ClusterConfig

type ClusterConfig struct {
	FileDelayCheckCrcSec  int64
	FileDelayCheckLackSec int64

	NodeTimeOutSec                    int64
	DataPartitionMissSec              int64
	DataPartitionTimeOutSec           int64
	DataPartitionWarnInterval         int64
	LoadDataPartitionFrequencyTime    int64
	CheckDataPartitionIntervalSeconds int

	MetaNodeThreshold float32
	// contains filtered or unexported fields
}

func NewClusterConfig

func NewClusterConfig() (cfg *ClusterConfig)

type ClusterView

type ClusterView struct {
	Name               string
	LeaderAddr         string
	CompactStatus      bool
	Applied            uint64
	MaxDataPartitionID uint64
	MaxMetaNodeID      uint64
	MaxMetaPartitionID uint64
	Vols               []string
	MetaNodes          []MetaNodeView
	DataNodes          []DataNodeView
}

type DataNode

type DataNode struct {
	MaxDiskAvailWeight        uint64 `json:"MaxDiskAvailWeight"`
	CreatedVolWeights         uint64
	RemainWeightsForCreateVol uint64
	Total                     uint64 `json:"TotalWeight"`
	Used                      uint64 `json:"UsedWeight"`
	Available                 uint64
	RackName                  string `json:"Rack"`
	Addr                      string
	ReportTime                time.Time

	sync.RWMutex
	Ratio       float64
	SelectCount uint64
	Carry       float64
	Sender      *AdminTaskSender

	DataPartitionCount uint32
	// contains filtered or unexported fields
}

func NewDataNode

func NewDataNode(addr, clusterID string) (dataNode *DataNode)

func (*DataNode) IsAvailCarryNode

func (dataNode *DataNode) IsAvailCarryNode() (ok bool)

func (*DataNode) IsWriteAble

func (dataNode *DataNode) IsWriteAble() (ok bool)

func (*DataNode) SelectNodeForWrite

func (dataNode *DataNode) SelectNodeForWrite()

func (*DataNode) SetCarry

func (dataNode *DataNode) SetCarry(carry float64)

func (*DataNode) UpdateNodeMetric

func (dataNode *DataNode) UpdateNodeMetric(resp *proto.DataNodeHeartBeatResponse)

type DataNodeView

type DataNodeView struct {
	Addr   string
	Status bool
}

type DataPartition

type DataPartition struct {
	PartitionID  uint64
	LastLoadTime int64
	ReplicaNum   uint8
	Status       int8

	Replicas         []*DataReplica
	PartitionType    string
	PersistenceHosts []string
	sync.RWMutex

	FileInCoreMap map[string]*FileInCore
	MissNodes     map[string]int64
	VolName       string
	// contains filtered or unexported fields
}

func (*DataPartition) AddMember

func (partition *DataPartition) AddMember(replica *DataReplica)

func (*DataPartition) DeleteReplicaByIndex

func (partition *DataPartition) DeleteReplicaByIndex(index int)

func (*DataPartition) GenerateCreateTasks

func (partition *DataPartition) GenerateCreateTasks() (tasks []*proto.AdminTask)

func (*DataPartition) GenerateDeleteTask

func (partition *DataPartition) GenerateDeleteTask(addr string) (task *proto.AdminTask)

func (*DataPartition) GetAvailableDataReplicas

func (partition *DataPartition) GetAvailableDataReplicas() (replicas []*DataReplica)

获取该副本目前有效的node,即Node在汇报心跳正常,并且该Node不是unavailable

func (*DataPartition) HostsToString

func (partition *DataPartition) HostsToString() (hosts string)

func (*DataPartition) IsInReplicas

func (partition *DataPartition) IsInReplicas(host string) (replica *DataReplica, ok bool)

func (*DataPartition) LoadFile

func (partition *DataPartition) LoadFile(dataNode *DataNode, resp *proto.LoadDataPartitionResponse)

func (*DataPartition) ReleaseDataPartition

func (partition *DataPartition) ReleaseDataPartition()

func (*DataPartition) UpdateMetric

func (partition *DataPartition) UpdateMetric(vr *proto.PartitionReport, dataNode *DataNode)

type DataPartitionMap

type DataPartitionMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewDataPartitionMap

func NewDataPartitionMap(volName string) (dpMap *DataPartitionMap)

func (*DataPartitionMap) GetDataPartitionsView

func (dpMap *DataPartitionMap) GetDataPartitionsView(minPartitionID uint64) (dpResps []*DataPartitionResponse)

type DataPartitionResponse

type DataPartitionResponse struct {
	PartitionID   uint64
	Status        int8
	ReplicaNum    uint8
	PartitionType string
	Hosts         []string
}

type DataPartitionValue

type DataPartitionValue struct {
	PartitionID   uint64
	ReplicaNum    uint8
	Hosts         string
	PartitionType string
}

type DataPartitionsView

type DataPartitionsView struct {
	DataPartitions []*DataPartitionResponse
}

func NewDataPartitionsView

func NewDataPartitionsView() (dataPartitionsView *DataPartitionsView)

type DataReplica

type DataReplica struct {
	Addr string

	ReportTime int64
	FileCount  uint32

	Status                  int8
	LoadPartitionIsResponse bool
	Total                   uint64 `json:"TotalSize"`
	Used                    uint64 `json:"UsedSize"`
	// contains filtered or unexported fields
}

func NewDataReplica

func NewDataReplica(dataNode *DataNode) (replica *DataReplica)

func (*DataReplica) CheckLocIsAvailContainsDiskError

func (replica *DataReplica) CheckLocIsAvailContainsDiskError() (avail bool)

check replica location is avail ,must IsActive=true and replica.Status!=DataReplicaUnavailable

func (*DataReplica) CheckMiss

func (replica *DataReplica) CheckMiss(missSec int64) (isMiss bool)

func (*DataReplica) GetReplicaNode

func (replica *DataReplica) GetReplicaNode() (node *DataNode)

func (*DataReplica) IsActive

func (replica *DataReplica) IsActive(timeOutSec int64) bool

func (*DataReplica) IsLive

func (replica *DataReplica) IsLive(timeOutSec int64) (avail bool)

func (*DataReplica) SetAlive

func (replica *DataReplica) SetAlive()

type FileCrc

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

use struct define File crc and this crc in all File count

func NewFileCrc

func NewFileCrc(volCrc uint32) (fc *FileCrc)

type FileCrcSorterByCount

type FileCrcSorterByCount []*FileCrc

func (FileCrcSorterByCount) Len

func (fileCrcArr FileCrcSorterByCount) Len() (length int)

func (FileCrcSorterByCount) Less

func (fileCrcArr FileCrcSorterByCount) Less(i, j int) bool

func (FileCrcSorterByCount) Swap

func (fileCrcArr FileCrcSorterByCount) Swap(i, j int)

type FileInCore

type FileInCore struct {
	Name       string
	MarkDel    bool
	LastModify int64
	Metas      []*FileMetaOnNode
}

func NewFileInCore

func NewFileInCore(name string) (fc *FileInCore)

type FileMetaOnNode

type FileMetaOnNode struct {
	Crc       uint32
	LocAddr   string
	LocIndex  uint8
	LastObjID uint64
	NeedleCnt int
	Size      uint32
}

this struct define chunk file metadata on dataNode

func NewFileMetaOnNode

func NewFileMetaOnNode(volCrc uint32, volLoc string, volLocIndex int, lastObjID uint64, needleCnt int, size uint32) (fm *FileMetaOnNode)

type IDAllocator

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

type LeaderInfo

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

type Master

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

func NewServer

func NewServer() *Master

func (*Master) ServeHTTP

func (m *Master) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Master) Shutdown

func (m *Master) Shutdown()

func (*Master) Start

func (m *Master) Start(cfg *config.Config) (err error)

func (*Master) Sync

func (m *Master) Sync()

type MetaNode

type MetaNode struct {
	ID                uint64
	Addr              string
	IsActive          bool
	Sender            *AdminTaskSender
	RackName          string `json:"Rack"`
	MaxMemAvailWeight uint64 `json:"MaxMemAvailWeight"`
	Total             uint64 `json:"TotalWeight"`
	Used              uint64 `json:"UsedWeight"`
	Ratio             float64
	SelectCount       uint64
	Carry             float64
	Threshold         float32
	ReportTime        time.Time

	MetaPartitionCount int
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMetaNode

func NewMetaNode(addr, clusterID string) (node *MetaNode)

func (*MetaNode) IsAvailCarryNode

func (metaNode *MetaNode) IsAvailCarryNode() (ok bool)

func (*MetaNode) IsWriteAble

func (metaNode *MetaNode) IsWriteAble() (ok bool)

func (*MetaNode) SelectNodeForWrite

func (metaNode *MetaNode) SelectNodeForWrite()

func (*MetaNode) SetCarry

func (metaNode *MetaNode) SetCarry(carry float64)

type MetaNodeView

type MetaNodeView struct {
	ID     uint64
	Addr   string
	Status bool
}

type MetaPartition

type MetaPartition struct {
	PartitionID uint64
	Start       uint64
	End         uint64
	MaxNodeID   uint64
	Replicas    []*MetaReplica
	ReplicaNum  uint8
	Status      int8

	PersistenceHosts []string
	Peers            []proto.Peer
	MissNodes        map[string]int64
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMetaPartition

func NewMetaPartition(partitionID, start, end uint64, replicaNum uint8, volName string) (mp *MetaPartition)

func (*MetaPartition) GenerateReplicaTask

func (mp *MetaPartition) GenerateReplicaTask(clusterID, volName string) (tasks []*proto.AdminTask)

func (*MetaPartition) UpdateEnd

func (mp *MetaPartition) UpdateEnd(c *Cluster, end uint64)

func (*MetaPartition) UpdateMetaPartition

func (mp *MetaPartition) UpdateMetaPartition(mgr *proto.MetaPartitionReport, metaNode *MetaNode)

type MetaPartitionValue

type MetaPartitionValue struct {
	PartitionID uint64
	ReplicaNum  uint8
	Start       uint64
	End         uint64
	Hosts       string
	Peers       []bsProto.Peer
}

type MetaPartitionView

type MetaPartitionView struct {
	PartitionID uint64
	Start       uint64
	End         uint64
	Members     []string
	LeaderAddr  string
	Status      int8
}

func NewMetaPartitionView

func NewMetaPartitionView(partitionID, start, end uint64, status int8) (mpView *MetaPartitionView)

type MetaReplica

type MetaReplica struct {
	Addr string

	ReportTime int64
	Status     int8
	IsLeader   bool
	// contains filtered or unexported fields
}

func NewMetaReplica

func NewMetaReplica(start, end uint64, metaNode *MetaNode) (mr *MetaReplica)

type Metadata

type Metadata struct {
	Op uint32 `json:"op"`
	K  string `json:"k"`
	V  []byte `json:"v"`
}

func (*Metadata) Marshal

func (m *Metadata) Marshal() ([]byte, error)

func (*Metadata) Unmarshal

func (m *Metadata) Unmarshal(data []byte) (err error)

type MetadataFsm

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

func (*MetadataFsm) Apply

func (mf *MetadataFsm) Apply(command []byte, index uint64) (resp interface{}, err error)

func (*MetadataFsm) ApplyMemberChange

func (mf *MetadataFsm) ApplyMemberChange(confChange *proto.ConfChange, index uint64) (interface{}, error)

func (*MetadataFsm) ApplySnapshot

func (mf *MetadataFsm) ApplySnapshot(peers []proto.Peer, iterator proto.SnapIterator) (err error)

func (*MetadataFsm) BatchPut

func (mf *MetadataFsm) BatchPut(cmdMap map[string][]byte) (err error)

func (*MetadataFsm) Del

func (mf *MetadataFsm) Del(key interface{}) (interface{}, error)

func (*MetadataFsm) DelKeyAndPutIndex

func (mf *MetadataFsm) DelKeyAndPutIndex(key string, cmdMap map[string][]byte) (err error)

func (*MetadataFsm) Get

func (mf *MetadataFsm) Get(key interface{}) (interface{}, error)

func (*MetadataFsm) HandleFatalEvent

func (mf *MetadataFsm) HandleFatalEvent(err *raft.FatalError)

func (*MetadataFsm) HandleLeaderChange

func (mf *MetadataFsm) HandleLeaderChange(leader uint64)

func (*MetadataFsm) Put

func (mf *MetadataFsm) Put(key, val interface{}) (interface{}, error)

func (*MetadataFsm) RegisterApplyHandler

func (mf *MetadataFsm) RegisterApplyHandler(handler RaftCmdApplyHandler)

func (*MetadataFsm) RegisterApplySnapshotHandler

func (mf *MetadataFsm) RegisterApplySnapshotHandler(handler RaftApplySnapshotHandler)

func (*MetadataFsm) RegisterLeaderChangeHandler

func (mf *MetadataFsm) RegisterLeaderChangeHandler(handler RaftLeaderChangeHandler)

func (*MetadataFsm) RegisterPeerChangeHandler

func (mf *MetadataFsm) RegisterPeerChangeHandler(handler RaftPeerChangeHandler)

func (*MetadataFsm) Snapshot

func (mf *MetadataFsm) Snapshot() (proto.Snapshot, error)

type MetadataSnapshot

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

func (*MetadataSnapshot) ApplyIndex

func (ms *MetadataSnapshot) ApplyIndex() uint64

func (*MetadataSnapshot) Close

func (ms *MetadataSnapshot) Close()

func (*MetadataSnapshot) Next

func (ms *MetadataSnapshot) Next() (data []byte, err error)

type Node

type Node interface {
	SetCarry(carry float64)
	SelectNodeForWrite()
}

type NodeTab

type NodeTab struct {
	Carry  float64
	Weight float64
	Ptr    Node
	Id     uint64
}

type NodeTabArrSorterByCarry

type NodeTabArrSorterByCarry []*NodeTab

func (NodeTabArrSorterByCarry) Len

func (nodeTabs NodeTabArrSorterByCarry) Len() int

func (NodeTabArrSorterByCarry) Less

func (nodeTabs NodeTabArrSorterByCarry) Less(i, j int) bool

func (NodeTabArrSorterByCarry) SetNodeTabCarry

func (nodeTabs NodeTabArrSorterByCarry) SetNodeTabCarry(availCarryCount, replicaNum int)

func (NodeTabArrSorterByCarry) Swap

func (nodeTabs NodeTabArrSorterByCarry) Swap(i, j int)

type Rack

type Rack struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRack

func NewRack(name string) (rack *Rack)

func (*Rack) DataNodeCount

func (rack *Rack) DataNodeCount() (len int)

func (*Rack) DisOrderArray

func (rack *Rack) DisOrderArray(oldHosts []string) (newHosts []string, err error)

func (*Rack) GetAvailCarryDataNodeTab

func (rack *Rack) GetAvailCarryDataNodeTab(maxTotal uint64, excludeHosts []string, replicaNum int) (nodeTabs NodeTabArrSorterByCarry, availCount int)

func (*Rack) GetDataNode

func (rack *Rack) GetDataNode(addr string) (dataNode *DataNode, err error)

func (*Rack) GetDataNodeMaxTotal

func (rack *Rack) GetDataNodeMaxTotal() (maxTotal uint64)

func (*Rack) PutDataNode

func (rack *Rack) PutDataNode(dataNode *DataNode)

func (*Rack) RemoveDataNode

func (rack *Rack) RemoveDataNode(addr string)

type RaftApplySnapshotHandler

type RaftApplySnapshotHandler func()

type RaftCmdApplyHandler

type RaftCmdApplyHandler func(cmd *Metadata) (err error)

type RaftLeaderChangeHandler

type RaftLeaderChangeHandler func(leader uint64)

type RaftPeerChangeHandler

type RaftPeerChangeHandler func(confChange *proto.ConfChange) (err error)

type Topology

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

func NewTopology

func NewTopology() (t *Topology)

type Vol

type Vol struct {
	Name    string
	VolType string

	MetaPartitions map[uint64]*MetaPartition

	Status uint8
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewVol

func NewVol(name, volType string, replicaNum uint8) (vol *Vol)

func (*Vol) AddMetaPartition

func (vol *Vol) AddMetaPartition(mp *MetaPartition)

func (*Vol) AddMetaPartitionByRaft

func (vol *Vol) AddMetaPartitionByRaft(mp *MetaPartition)

func (*Vol) LoadDataPartition

func (vol *Vol) LoadDataPartition(c *Cluster)

func (*Vol) ReleaseDataPartitionsAfterLoad

func (vol *Vol) ReleaseDataPartitionsAfterLoad(releaseCount int, afterLoadSeconds int64)

type VolStatInfo

type VolStatInfo struct {
	Name      string
	TotalSize uint64
	UsedSize  uint64
}

type VolValue

type VolValue struct {
	VolType    string
	ReplicaNum uint8
	Status     uint8
}

type VolView

type VolView struct {
	Name           string
	VolType        string
	MetaPartitions []*MetaPartitionView
	DataPartitions []*DataPartitionResponse
}

func NewVolView

func NewVolView(name, volType string) (view *VolView)

Jump to

Keyboard shortcuts

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