knodemanager

package
v0.0.0-...-8c384fb Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMetricTTL = 30 * time.Second

Variables

View Source
var CHECK_KNODE_DISCARD = 300 * time.Second
View Source
var CHECK_KNODE_INTERVAL = 60 * time.Second

检查knode健康间隔

View Source
var ErrAlertChannelFull = errors.New("alert channel is full")
View Source
var PeerMaxAlertThreshold = 1

Functions

func CopyCommonRespToIfaces

func CopyCommonRespToIfaces(in []CommonResp) []interface{}

func CopyIpfsIDRespToIfaces

func CopyIpfsIDRespToIfaces(in []IpfsIDResp) []interface{}

func CopyRawIPFSPinInfoToIfaces

func CopyRawIPFSPinInfoToIfaces(in []RawIPFSPinInfo) []interface{}

func CopyStringSliceToIfaces

func CopyStringSliceToIfaces(in [][]string) []interface{}

func CopyStringToIfaces

func CopyStringToIfaces(in []string) []interface{}

Types

type CommonResp

type CommonResp struct {
	Status ErrorCode
}

type Config

type Config struct {
	config.Saver

	// Host/Port for the IPFS daemon.
	NodeAddr []ma.Multiaddr

	// ConnectSwarmsDelay specifies how long to wait after startup before
	// attempting to open connections from this peer's IPFS daemon to the
	// IPFS daemons of other peers.
	ConnectSwarmsDelay time.Duration

	// knode Daemon HTTP Client POST timeout
	KnodeRequestTimeout time.Duration

	// Pin Operation timeout
	PinTimeout time.Duration

	// Unpin Operation timeout
	UnpinTimeout time.Duration

	// RepoGC Operation timeout
	RepoGCTimeout time.Duration

	// How many pin and block/put operations need to happen before we do a
	// special broadcast informer metrics to the network. 0 to disable.
	InformerTriggerInterval int

	// Disables the unpin operation and returns an error.
	UnpinDisable bool

	// Tracing flag used to skip tracing specific paths when not enabled.
	Tracing bool
}

Config is used to initialize a Connector and allows to customize its behavior. It implements the config.ComponentConfig interface.

func DefaultConfig

func DefaultConfig() Config

type ErrorCode

type ErrorCode int
const (
	CODE_SUCCESS ErrorCode = 1
	CODE_FAILD   ErrorCode = 0
	CODE_EXPIRE  ErrorCode = 301

	CODE_INVALID_PARAMETER     ErrorCode = 501
	CODE_INVALID_INTERNALERROR ErrorCode = 502
)

type IpfsIDResp

type IpfsIDResp struct {
	ID        peer.ID  `json:"id,omitempty" codec:"i,omitempty"`
	Addresses []string `json:"addresses" codec:"a,omitempty"`
	Error     string   `json:"error" codec:"e,omitempty"`
}

type Knode

type Knode struct {
	PeerID  peer.ID
	Version string
	Ip      string
	Port    string
	// contains filtered or unexported fields
}

func (*Knode) ConnectPeers

func (k *Knode) ConnectPeers(ctx context.Context, km *KnodeManager, peers []string) error

ConnectPeers connect to knode swarm

type KnodeChecker

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

func NewKnodeChecker

func NewKnodeChecker(ctx context.Context, manager *KnodeManager) *KnodeChecker

func (*KnodeChecker) Alerts

func (kc *KnodeChecker) Alerts() <-chan api.Alert

func (*KnodeChecker) CheckAll

func (kc *KnodeChecker) CheckAll()

func (*KnodeChecker) ResetAlerts

func (kc *KnodeChecker) ResetAlerts(pid peer.ID)

func (*KnodeChecker) Watch

func (kc *KnodeChecker) Watch(ctx context.Context, interval time.Duration)

type KnodeManager

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

func NewKnodeManager

func NewKnodeManager(identity *config.Identity, peerID peer.ID, controllerClient *controllerclient.ControllerConn) *KnodeManager

func (*KnodeManager) Alerts

func (km *KnodeManager) Alerts() <-chan api.Alert

func (*KnodeManager) BlockGet

func (km *KnodeManager) BlockGet(ctx context.Context, cid api.Cid) ([]byte, error)

func (*KnodeManager) BlockStream

func (km *KnodeManager) BlockStream(ctx context.Context, metas <-chan api.NodeWithMeta) error

func (*KnodeManager) ConfigKey

func (km *KnodeManager) ConfigKey(keypath string) (interface{}, error)

func (*KnodeManager) ConnectSwarms

func (km *KnodeManager) ConnectSwarms(ctx context.Context) error

func (*KnodeManager) GetDiscardedMetric

func (km *KnodeManager) GetDiscardedMetric() api.Metric

func (*KnodeManager) GetMetric

func (km *KnodeManager) GetMetric() []api.Metric

func (*KnodeManager) ID

func (km *KnodeManager) ID(ctx context.Context) (api.IPFSID, error)

func (*KnodeManager) Pin

func (km *KnodeManager) Pin(ctx context.Context, pin api.Pin) error

func (*KnodeManager) PinAsync

func (km *KnodeManager) PinAsync(ctx context.Context, pin api.Pin, dests []peer.ID, multiError *MultiError) error

func (*KnodeManager) PinLs

func (km *KnodeManager) PinLs(ctx context.Context, typeFilters []string, out chan<- api.IPFSPinInfo) error

func (*KnodeManager) PinLsCid

func (km *KnodeManager) PinLsCid(ctx context.Context, pin api.Pin) (api.PinDetail, error)

PinLsCid 只检查本RM节点下多个knode的pin状态

func (*KnodeManager) PinLsCidFromAllNode

func (km *KnodeManager) PinLsCidFromAllNode(ctx context.Context, pin api.Pin) ([]peer.ID, error)

PinLsCidFromAllNode 获取所有knode节点的pin 状态

func (*KnodeManager) Ready

func (km *KnodeManager) Ready(ctx context.Context) <-chan struct{}

func (*KnodeManager) RepoGC

func (km *KnodeManager) RepoGC(ctx context.Context) (api.RepoGC, error)

func (*KnodeManager) RepoStat

func (km *KnodeManager) RepoStat(ctx context.Context) (api.IPFSRepoStat, error)

func (*KnodeManager) Resolve

func (km *KnodeManager) Resolve(ctx context.Context, path string) (api.Cid, error)

func (*KnodeManager) SetClient

func (km *KnodeManager) SetClient(client *rpc.Client)

func (*KnodeManager) SetStateTracker

func (km *KnodeManager) SetStateTracker(tracker *stateless.Tracker)

func (*KnodeManager) Shutdown

func (km *KnodeManager) Shutdown(ctx context.Context) error

func (*KnodeManager) SwarmPeers

func (km *KnodeManager) SwarmPeers(ctx context.Context) ([]peer.ID, error)

func (*KnodeManager) Unpin

func (km *KnodeManager) Unpin(ctx context.Context, pin api.Pin) error

type MultiError

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

func NewMultiError

func NewMultiError() MultiError

type NodeStatus

type NodeStatus int
const (
	CONNECTED  NodeStatus = iota //已连接
	REGISTED                     //已注册
	Valid                        //健康可用
	Invalid                      //心跳延迟
	DISCONNECT                   //连接断开
	DISCARDED                    //被丢弃的
)

type PinArgs

type PinArgs struct {
	Operation string
	Cid       string
	Param     url.Values
}

type PinAsyncResp

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

type PinLsArgs

type PinLsArgs struct {
	Operation string
	Param     url.Values
	Cid       string //如果为空就查询所有 pin ls

}

type PinLsResp

type PinLsResp struct {
	Pins []api.IPFSPinInfo
}

type PinResp

type PinResp struct {
	PinStatus api.IPFSPinStatus
	Pins      []api.IPFSPinInfo
}

type RMMetric

type RMMetric struct {
	Name          string
	Peer          peer.ID           //RM节点id
	Group         string            //该RM节点所属分组
	Tag           string            //标签,与分组一样,用于节点分配
	Value         string            //RM管理的所有knode总可用空间
	Expire        int64             //本条信息过期时间
	Valid         bool              //是否可用,既该节点是否可分配
	Weight        int64             //权重
	Partitionable bool              //是否可分区(暂不明白用法)
	ReceivedAt    int64             //时间
	KnodeList     []api.KnodeMetric //  该RM管理下的knode列表)
}

type RMService

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

func (*RMService) PinCallback

func (svc *RMService) PinCallback(ctx context.Context, pin RawIPFSPinInfo, resp *CommonResp) error

func (*RMService) PushMetric

func (svc *RMService) PushMetric(ctx context.Context, m api.KnodeMetric, resp *CommonResp) error

func (*RMService) Regist

func (svc *RMService) Regist(ctx context.Context, args RegisArgs, resp *CommonResp) error

func (*RMService) UploadFile

func (svc *RMService) UploadFile(ctx context.Context, args UploadFileArgs, replyType *CommonResp) error

type RawIPFSPinInfo

type RawIPFSPinInfo struct {
	PeerId  string    `json:"PeerId" codec:"peerId"`
	Cid     string    `json:"Cid" codec:"cid"`
	Type    string    `json:"Type" codec:"type"`
	Message string    `json:"Message" codec:"message"`
	Code    int       `json:"Code" codec:"code"`
	Pins    []string  `json:"Pins" codec:"pins"`
	Status  ErrorCode `json:"Status" codec:"status"`
}

type RegisArgs

type RegisArgs struct {
	PeerID  string
	Version string
	Ip      string
	Port    string
}

type UploadFileArgs

type UploadFileArgs struct {
	PeerID  string //节点id
	OrderID string //controller上传订单号
	Cid     string // cid
	Name    string //file name
	Fid     string //文件id
	Region  string
	Origins string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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