Documentation ¶
Index ¶
- func AddFileShare()
- func CheckPukAddr(addr nodeStore.AddressNet, index uint64, addrEx AddressNetExtend) bool
- type AddressNetExtend
- func AddressFromB58String(str string) AddressNetExtend
- func BuildAddrNetExtend(addr nodeStore.AddressNet, index uint64) AddressNetExtend
- func GetNodeNetworkNum(level uint, id AddressNetExtend) []*AddressNetExtend
- func GetQuarterLogicAddrNetByAddrNetExtend(id *AddressNetExtend) (logicIds []*AddressNetExtend)
- type AutonomyFinish
- type FindVnodeVO
- type Vnode
- func (this *Vnode) AddLogicVnodeinfos(vnodes *[]Vnodeinfo) (change bool)
- func (this *Vnode) AddLogicVnodeinfosCheckChange(vnodes *[]Vnodeinfo) (change bool)
- func (this *Vnode) CheckAutonomyFinish() bool
- func (this *Vnode) CheckVnodeinfoExistByNid(nid nodeStore.AddressNet) bool
- func (this *Vnode) DeleteNid(nid nodeStore.AddressNet) bool
- func (this *Vnode) DeleteVid(vnodeInfo *Vnodeinfo) bool
- func (this *Vnode) Destroy()
- func (this *Vnode) EqualLogicNodes(oldNodeinfo []Vnodeinfo) bool
- func (this *Vnode) FindVnodeinfo(vid AddressNetExtend) *Vnodeinfo
- func (this *Vnode) GetDownVnodeInfo() []VnodeinfoS
- func (this *Vnode) GetOnebyoneVnodeInfo() []VnodeinfoS
- func (this *Vnode) GetSelfVnodeinfo() Vnodeinfo
- func (this *Vnode) GetSortAddressNetExtend(ss []VnodeinfoS, self AddressNetExtend) ([]VnodeinfoS, int)
- func (this *Vnode) GetUpVnodeInfo() []VnodeinfoS
- func (this *Vnode) GetVnodeinfoAllNotSelf() []Vnodeinfo
- func (this *Vnode) Run()
- func (this *Vnode) SearchAVnodeByOnebyone(an *[]VnodeinfoS, rr nodeStore.AddressNet) (*nodeStore.AddressNet, *nodeStore.AddressNet, bool)
- func (this *Vnode) SearchVnode()
- func (this *Vnode) SetAutonomyFinish()
- func (this *Vnode) VnodeDelAddr(delV AddressNetExtend)
- func (this *Vnode) WaitAutonomyFinish()
- type VnodeManager
- func (this *VnodeManager) AddClientVnodeinfo(vnode Vnodeinfo)
- func (this *VnodeManager) AddLogicVnodeinfo(vnodes ...Vnodeinfo) bool
- func (this *VnodeManager) AddLogicVnodeinfos(nodeVid AddressNetExtend, vnodes *[]Vnodeinfo) (change bool)
- func (this *VnodeManager) AddVnode() Vnodeinfo
- func (this *VnodeManager) AddVnodeByIndex(index uint64) *Vnodeinfo
- func (this *VnodeManager) CheckNodeinfoExistInSelf(nid nodeStore.AddressNet) bool
- func (this *VnodeManager) Close()
- func (this *VnodeManager) DelClientVnodeinfo(nid nodeStore.AddressNet)
- func (this *VnodeManager) DelSelfVnodeByAddr(vid nodeStore.AddressNet)
- func (this *VnodeManager) DelUpdownVnodeByAddr(vid AddressNetExtend)
- func (this *VnodeManager) DelVnode() (vnodeinfo *Vnodeinfo)
- func (this *VnodeManager) DelVnodeByIndex(index uint64)
- func (this *VnodeManager) FindInVnodeSelf(id AddressNetExtend) bool
- func (this *VnodeManager) FindInVnodeinfoSelf(id AddressNetExtend) *Vnodeinfo
- func (this *VnodeManager) FindLogicInVnodeSelf(id AddressNetExtend) []Vnodeinfo
- func (this *VnodeManager) FindNearVnodeInSelf(nodeId *AddressNetExtend) *AddressNetExtend
- func (this *VnodeManager) FindNearVnodeInSelfAppIndex0(nodeId *AddressNetExtend, includeIndex0 bool) AddressNetExtend
- func (this *VnodeManager) FindNearVnodeP2P(nodeId, outId *AddressNetExtend, includeSelf bool, blockAddr map[string]int) AddressNetExtend
- func (this *VnodeManager) FindNearVnodeSearchVnode(nodeId, outId *AddressNetExtend, includeSelf, includeIndex0 bool, ...) AddressNetExtend
- func (this *VnodeManager) FindNearVnodesSearchVnode(nodeId, outId *AddressNetExtend, includeSelf, includeIndex0 bool) (res []AddressNetExtend)
- func (this *VnodeManager) FindVnodeInAllSelf(id nodeStore.AddressNet) *Vnode
- func (this *VnodeManager) FindVnodeInSelf(nodeVid AddressNetExtend) *Vnode
- func (this *VnodeManager) FindVnodeinfo(vid AddressNetExtend) *Vnodeinfo
- func (this *VnodeManager) GetClientVnodeinfo() []*Vnodeinfo
- func (this *VnodeManager) GetCloseVnodeChan() chan *Vnodeinfo
- func (this *VnodeManager) GetFindVnodeChan() chan *[]*FindVnodeVO
- func (this *VnodeManager) GetVnodeAll() map[string]Vnodeinfo
- func (this *VnodeManager) GetVnodeDiscover() (discoverVnode *Vnode)
- func (this *VnodeManager) GetVnodeIdByIndex(index uint64) *AddressNetExtend
- func (this *VnodeManager) GetVnodeNumber() []Vnodeinfo
- func (this *VnodeManager) GetVnodeSelf() []Vnodeinfo
- func (this *VnodeManager) IsClose()
- func (this *VnodeManager) IsOpen()
- func (this *VnodeManager) IsSelfVnodeNeed(nid nodeStore.AddressNet) bool
- func (this *VnodeManager) RLock()
- func (this *VnodeManager) RUnlock()
- func (this *VnodeManager) SetupVnodeNumber(n uint64)
- func (this *VnodeManager) WaitAutonomyFinish()
- type Vnodeinfo
- type VnodeinfoS
- type VnodeinfoTimeout
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPukAddr ¶
func CheckPukAddr(addr nodeStore.AddressNet, index uint64, addrEx AddressNetExtend) bool
检查公钥生成的地址是否一样 @return bool 是否一样 true=相同;false=不相同;
Types ¶
type AddressNetExtend ¶
type AddressNetExtend nodeStore.AddressNet
扩展地址
func AddressFromB58String ¶
func AddressFromB58String(str string) AddressNetExtend
func BuildAddrNetExtend ¶
func BuildAddrNetExtend(addr nodeStore.AddressNet, index uint64) AddressNetExtend
通过公钥生成网络节点地址,将公钥两次hash得到网络节点地址 @version []byte 版本号(如比特币主网版本号“0x00")
func GetNodeNetworkNum ¶
func GetNodeNetworkNum(level uint, id AddressNetExtend) []*AddressNetExtend
得到每个节点网络的网络号,不包括本节点 @id *utils.Multihash 要计算的id @level int 深度
func GetQuarterLogicAddrNetByAddrNetExtend ¶
func GetQuarterLogicAddrNetByAddrNetExtend(id *AddressNetExtend) (logicIds []*AddressNetExtend)
得到保存数据的逻辑节点 @idStr id十六进制字符串 @return 4分之一节点
func (AddressNetExtend) B58String ¶
func (this AddressNetExtend) B58String() string
type AutonomyFinish ¶
type AutonomyFinish interface {
WaitAutonomyFinish()
}
type FindVnodeVO ¶
查找虚拟节点
func ParseFindVnodeVO ¶
func ParseFindVnodeVO(bs []byte) (*FindVnodeVO, error)
func (*FindVnodeVO) Proto ¶
func (this *FindVnodeVO) Proto() ([]byte, error)
type Vnode ¶
type Vnode struct { Vnode Vnodeinfo //自己的虚拟节点 LogicalNode *sync.Map //逻辑节点 key:string=AddressNetExtend;value:Vnodeinfo=; LogicalNodeIndexNID *sync.Map //逻辑节点 key:string=AddressNet;value:map[AddressNetExtend]Vnodeinfo=; UpVnodeInfo *sync.Map //虚拟节点连接的大于自己的节点信息 DownVnodeInfo *sync.Map //虚拟节点连接的小于自己的节点信息 HeadTail bool Lock *sync.RWMutex //调整up down // contains filtered or unexported fields }
虚拟节点
func NewVnode ¶
func NewVnode(index uint64, addrNet nodeStore.AddressNet, findNearVnodeChan chan *[]*FindVnodeVO, c context.Context, af AutonomyFinish, closeVnodeChan chan *Vnodeinfo) *Vnode
创建一个虚拟节点
func (*Vnode) AddLogicVnodeinfos ¶
添加一个完整的Vnodes集合,可以判断此节点是否自治完成 @return bool 是否有改变true=有改变;false=无改变。
func (*Vnode) AddLogicVnodeinfosCheckChange ¶
添加一个完整的Vnodes集合,可以判断此节点是否自治完成 @return bool 是否有改变true=有改变;false=无改变。
func (*Vnode) CheckVnodeinfoExistByNid ¶
func (this *Vnode) CheckVnodeinfoExistByNid(nid nodeStore.AddressNet) bool
* 检查是否包含指定真实的节点信息 * @param nid 真实节点地址 * @return bool 是否包含标识
func (*Vnode) DeleteNid ¶
func (this *Vnode) DeleteNid(nid nodeStore.AddressNet) bool
当一个节点下线,删除一个节点 查找一个节点是否包含在本虚拟节点的逻辑节点中 @return bool 是否存在
func (*Vnode) DeleteVid ¶
* 当一个虚拟节点下线,删除对应记录信息 * 查找一个节点是否包含在本虚拟节点的逻辑节点中 * @param nid 虚拟节点的真实id * @param vid 虚拟节点的虚拟id
func (*Vnode) EqualLogicNodes ¶
对比逻辑节点是否有变化
func (*Vnode) FindVnodeinfo ¶
func (this *Vnode) FindVnodeinfo(vid AddressNetExtend) *Vnodeinfo
查找Vnodeinfo
func (*Vnode) GetDownVnodeInfo ¶
func (this *Vnode) GetDownVnodeInfo() []VnodeinfoS
* 锁内使用 * 不锁Vnode获取vnode的downVnode排序信息
func (*Vnode) GetOnebyoneVnodeInfo ¶
func (this *Vnode) GetOnebyoneVnodeInfo() []VnodeinfoS
* 加读锁,获取本Vnode存的up down所有Vnodeinfo以及本vnode
func (*Vnode) GetSortAddressNetExtend ¶
func (this *Vnode) GetSortAddressNetExtend(ss []VnodeinfoS, self AddressNetExtend) ([]VnodeinfoS, int)
* 虚拟节点地址按10进制从大到小排序
func (*Vnode) GetUpVnodeInfo ¶
func (this *Vnode) GetUpVnodeInfo() []VnodeinfoS
* 锁内使用 * 不锁Vnode获取vnode的upVnode排序信息
func (*Vnode) GetVnodeinfoAllNotSelf ¶
获得自己节点的所有逻辑节点,不包括自己节点
func (*Vnode) SearchAVnodeByOnebyone ¶
func (this *Vnode) SearchAVnodeByOnebyone(an *[]VnodeinfoS, rr nodeStore.AddressNet) (*nodeStore.AddressNet, *nodeStore.AddressNet, bool)
* 通过地址搜索返回本Vnode中合适的地址
func (*Vnode) VnodeDelAddr ¶
func (this *Vnode) VnodeDelAddr(delV AddressNetExtend)
* 加锁,删除本Vnode中的某个虚拟地址所有信息
type VnodeManager ¶
type VnodeManager struct { DiscoverVnodes *Vnode //每个节点启动一个发现者虚拟节点,用于保存逻辑节点 VnodeMap map[uint64]*Vnode //保存自己的虚拟节点key:uint64=index;value:*Vnode=自己的虚拟节点。 // contains filtered or unexported fields }
func NewVnodeManager ¶
func NewVnodeManager(nodeManager *nodeStore.NodeManager, c context.Context, af AutonomyFinish) *VnodeManager
func (*VnodeManager) AddClientVnodeinfo ¶
func (this *VnodeManager) AddClientVnodeinfo(vnode Vnodeinfo)
添加被连接的虚拟节点
func (*VnodeManager) AddLogicVnodeinfo ¶
func (this *VnodeManager) AddLogicVnodeinfo(vnodes ...Vnodeinfo) bool
添加虚拟节点的逻辑节点 @return bool 是否有改变true=有改变;false=无改变。
func (*VnodeManager) AddLogicVnodeinfos ¶
func (this *VnodeManager) AddLogicVnodeinfos(nodeVid AddressNetExtend, vnodes *[]Vnodeinfo) (change bool)
添加虚拟节点的多个逻辑节点
func (*VnodeManager) AddVnodeByIndex ¶
func (this *VnodeManager) AddVnodeByIndex(index uint64) *Vnodeinfo
添加一个指定下标的虚拟节点
func (*VnodeManager) CheckNodeinfoExistInSelf ¶
func (this *VnodeManager) CheckNodeinfoExistInSelf(nid nodeStore.AddressNet) bool
* 检查是否包含指定的真实节点信息
func (*VnodeManager) DelClientVnodeinfo ¶
func (this *VnodeManager) DelClientVnodeinfo(nid nodeStore.AddressNet)
* 根据真实节点删除客户端连接信息
func (*VnodeManager) DelSelfVnodeByAddr ¶
func (this *VnodeManager) DelSelfVnodeByAddr(vid nodeStore.AddressNet)
* 指定删除一个自己创建的虚拟地址 * 同时删除本节点其他vnode中存此地址的信息
func (*VnodeManager) DelUpdownVnodeByAddr ¶
func (this *VnodeManager) DelUpdownVnodeByAddr(vid AddressNetExtend)
* 指定删除一个在up down排序中的别人的虚拟地址
func (*VnodeManager) DelVnode ¶
func (this *VnodeManager) DelVnode() (vnodeinfo *Vnodeinfo)
删除一个虚拟节点
func (*VnodeManager) DelVnodeByIndex ¶
func (this *VnodeManager) DelVnodeByIndex(index uint64)
删除一个指定下标的虚拟节点
func (*VnodeManager) FindInVnodeSelf ¶
func (this *VnodeManager) FindInVnodeSelf(id AddressNetExtend) bool
查找节点id是否是自己的节点 @return bool 是否在
func (*VnodeManager) FindInVnodeinfoSelf ¶
func (this *VnodeManager) FindInVnodeinfoSelf(id AddressNetExtend) *Vnodeinfo
查找节点id是否是自己的节点 @return bool 是否在
func (*VnodeManager) FindLogicInVnodeSelf ¶
func (this *VnodeManager) FindLogicInVnodeSelf(id AddressNetExtend) []Vnodeinfo
查找自己一个虚拟节点的逻辑节点
func (*VnodeManager) FindNearVnodeInSelf ¶
func (this *VnodeManager) FindNearVnodeInSelf(nodeId *AddressNetExtend) *AddressNetExtend
在自己的虚拟节点中找到最近的虚拟节点 @nodeId 要查找的节点
func (*VnodeManager) FindNearVnodeInSelfAppIndex0 ¶
func (this *VnodeManager) FindNearVnodeInSelfAppIndex0(nodeId *AddressNetExtend, includeIndex0 bool) AddressNetExtend
* 在自己的虚拟节点中找到最近的虚拟节点,指定是否查找index为0的节点信息 * @nodeId 要查找的节点 * @includeIndex0 是否要包含index为0的节点进行查询标识
func (*VnodeManager) FindNearVnodeP2P ¶
func (this *VnodeManager) FindNearVnodeP2P(nodeId, outId *AddressNetExtend, includeSelf bool, blockAddr map[string]int) AddressNetExtend
找到最近的虚拟节点 @nodeId 要查找的节点 @outId 排除一个节点 @includeSelf 是否包括自己 @return 查找到的节点id,可能为空
func (*VnodeManager) FindNearVnodeSearchVnode ¶
func (this *VnodeManager) FindNearVnodeSearchVnode(nodeId, outId *AddressNetExtend, includeSelf, includeIndex0 bool, blockAddr map[string]int) AddressNetExtend
找到最近的虚拟节点 这是给搜索磁力节点提供的方法,排除了Index为0的节点地址。 @nodeId *AddressNetExtend 要查找的节点 @outId *AddressNetExtend 排除一个节点 @includeSelf bool 是否包括自己 @includeIndex0 bool 是否包含index为0(即发现节点)的节点信息 @blockAddr []*nodeStore.AddressNet 黑名单地址 @return 查找到的节点id,可能为空
func (*VnodeManager) FindNearVnodesSearchVnode ¶
func (this *VnodeManager) FindNearVnodesSearchVnode(nodeId, outId *AddressNetExtend, includeSelf, includeIndex0 bool) (res []AddressNetExtend)
* 根据目标节点,返回排序后的虚拟节点地址列表 * @nodeId 要查找的节点 * @outId 排除一个节点 * @includeSelf 是否包括自己 * @includeIndex0 是否包含index为0(即发现节点)的节点信息 * @return 查找到的节点id,可能为空
func (*VnodeManager) FindVnodeInAllSelf ¶
func (this *VnodeManager) FindVnodeInAllSelf(id nodeStore.AddressNet) *Vnode
查找节点id是否是自己的节点 @return bool 是否在
func (*VnodeManager) FindVnodeInSelf ¶
func (this *VnodeManager) FindVnodeInSelf(nodeVid AddressNetExtend) *Vnode
获得自己管理的节点
func (*VnodeManager) FindVnodeinfo ¶
func (this *VnodeManager) FindVnodeinfo(vid AddressNetExtend) *Vnodeinfo
在逻辑节点中查找Vnodeinfo
func (*VnodeManager) GetClientVnodeinfo ¶
func (this *VnodeManager) GetClientVnodeinfo() []*Vnodeinfo
添加被连接的虚拟节点
func (*VnodeManager) GetCloseVnodeChan ¶
func (this *VnodeManager) GetCloseVnodeChan() chan *Vnodeinfo
获取关闭vnode管道
func (*VnodeManager) GetFindVnodeChan ¶
func (this *VnodeManager) GetFindVnodeChan() chan *[]*FindVnodeVO
获取查询vnode管道
func (*VnodeManager) GetVnodeAll ¶
func (this *VnodeManager) GetVnodeAll() map[string]Vnodeinfo
获得所有节点,包括自己节点
func (*VnodeManager) GetVnodeDiscover ¶
func (this *VnodeManager) GetVnodeDiscover() (discoverVnode *Vnode)
添加一个发现者虚拟节点,用于发现其他虚拟节点,以及保存逻辑节点
func (*VnodeManager) GetVnodeIdByIndex ¶
func (this *VnodeManager) GetVnodeIdByIndex(index uint64) *AddressNetExtend
* 通过一个指定下标获取虚拟节点地址 * * @param index uint64 下标 * @return vid AddressNetExtend 节点地址
func (*VnodeManager) GetVnodeNumber ¶
func (this *VnodeManager) GetVnodeNumber() []Vnodeinfo
查询扩展的虚拟节点数量
func (*VnodeManager) GetVnodeSelf ¶
func (this *VnodeManager) GetVnodeSelf() []Vnodeinfo
获得自己管理的节点info
func (*VnodeManager) IsSelfVnodeNeed ¶
func (this *VnodeManager) IsSelfVnodeNeed(nid nodeStore.AddressNet) bool
* 检查是否是逻辑节点,虚拟节点,自己虚拟节点up down中是否包含
func (*VnodeManager) SetupVnodeNumber ¶
func (this *VnodeManager) SetupVnodeNumber(n uint64)
调整云存储大小,多了的就减少,少了的就增加。
func (*VnodeManager) WaitAutonomyFinish ¶
func (this *VnodeManager) WaitAutonomyFinish()
等待虚拟节点网络自治完成
type Vnodeinfo ¶
type Vnodeinfo struct { Nid nodeStore.AddressNet `json:"nid"` //节点真实网络地址 Index uint64 `json:"index"` //节点第几个空间,从1开始,下标为0的节点为实际节点。 Vid AddressNetExtend `json:"vid"` //vid,虚拟节点网络地址 }
func BuildNodeinfo ¶
func BuildNodeinfo(index uint64, addrNet nodeStore.AddressNet) *Vnodeinfo
type VnodeinfoS ¶
type VnodeinfoS struct { Nid nodeStore.AddressNet `json:"nid"` //节点真实网络地址 Index uint64 `json:"index"` //节点第几个空间,从1开始,下标为0的节点为实际节点。 Vid AddressNetExtend `json:"vid"` //vid,虚拟节点网络地址 // lastContactTimestamp time.Time //最后检查的时间戳 Addr string `json:"addr"` //真实节点IP地址 TcpPort uint64 `json:"tcpport"` //真实节点tcp端口 QuicPort uint64 `json:"quicport"` //真实节点quic端口 }
type VnodeinfoTimeout ¶
type VnodeinfoTimeout struct { Vnodeinfo // contains filtered or unexported fields }
带超时的vnodeinfo
func CreateVnodeinfoTimeout ¶
func CreateVnodeinfoTimeout(vnodeinfo *Vnodeinfo) *VnodeinfoTimeout
创建一个带超时的Vnodeinfo
func (*VnodeinfoTimeout) CheckTimeout ¶
func (this *VnodeinfoTimeout) CheckTimeout(outtime time.Duration) bool
检查时间是否过期 @return bool 是否过期。true=过期了;false=未过期。