Documentation ¶
Index ¶
- Constants
- Variables
- func TransLimit(rateLimit int) int
- type BaseProperties
- type Config
- func (c *Config) GetSuperCID(taskID string) string
- func (c *Config) GetSuperPID() string
- func (c *Config) IsSuperCID(clientID string) bool
- func (c *Config) IsSuperPID(peerID string) bool
- func (c *Config) Load(path string) error
- func (c *Config) SetCIDPrefix(ip string)
- func (c *Config) SetSuperPID(pid string)
- func (c *Config) String() string
- type PluginProperties
- type PluginType
Constants ¶
const ( // DefaultSupernodeConfigFilePath the default supernode config path. DefaultSupernodeConfigFilePath = "/etc/dragonfly/supernode.yml" // SuperNodeCIdPrefix is a string as the prefix of the supernode. SuperNodeCIdPrefix = "cdnnode:" )
const ( PieceSEMISUC = -3 PieceWAITING = -1 PieceRUNNING = 0 PieceSUCCESS = 1 PieceFAILED = 2 )
PieceStatus code
const ( // FailCountLimit indicates the limit of fail count as a client. FailCountLimit = 5 // EliminationLimit indicates limit of fail count as a server. EliminationLimit = 5 // PeerUpLimit indicates the limit of the load count as a server. PeerUpLimit = 5 // PeerDownLimit indicates the limit of the download task count as a client. PeerDownLimit = 4 )
const ( // DefaultPieceSize 4M DefaultPieceSize = 4 * 1024 * 1024 // DefaultPieceSizeLimit 15M DefaultPieceSizeLimit = 15 * 1024 * 1024 // PieceHeadSize 4 bytes PieceHeadSize = 4 // PieceWrapSize 4 bytes head and 1 byte tail PieceWrapSize = PieceHeadSize + 1 // PieceTailChar the value of piece tail PieceTailChar = byte(0x7f) )
const ( // StoragePlugin the storage plugin type. StoragePlugin = PluginType("storage") // SchedulerPlugin the scheduler plugin type. SchedulerPlugin = PluginType("scheduler") )
const (
// CDNWriterRoutineLimit 4
CDNWriterRoutineLimit = 4
)
Variables ¶
var ( // DownloadHome is the parent directory where the downloaded files are stored // which is a relative path. DownloadHome = "download" )
var PluginTypes = []PluginType{ StoragePlugin, SchedulerPlugin, }
PluginTypes explicitly stores all available plugin types.
Functions ¶
func TransLimit ¶ added in v0.4.0
TransLimit trans rateLimit from MB/s to B/s.
Types ¶
type BaseProperties ¶ added in v0.4.0
type BaseProperties struct { // ListenPort is the port supernode server listens on. // default: 8002 ListenPort int `yaml:"listenPort"` // DownloadPort is the port for download files from supernode. // default: 8001 DownloadPort int `yaml:"downloadPort"` // HomeDir is working directory of supernode. // default: /home/admin/supernode HomeDir string `yaml:"homeDir"` // the core pool size of ScheduledExecutorService. // When a request to start a download task, supernode will construct a thread concurrent pool // to download pieces of source file and write to specified storage. // Note: source file downloading is into pieces via range attribute set in HTTP header. // default: 10 SchedulerCorePoolSize int `yaml:"schedulerCorePoolSize"` // DownloadPath specifies the path where to store downloaded files from source address. // This path can be set beyond BaseDir, such as taking advantage of a different disk from BaseDir's. // default: $BaseDir/downloads DownloadPath string `yaml:"downloadPath"` // PeerUpLimit is the upload limit of a peer. When dfget starts to play a role of peer, // it can only stand PeerUpLimit upload tasks from other peers. // default: 5 PeerUpLimit int `yaml:"peerUpLimit"` // PeerDownLimit is the download limit of a peer. When a peer starts to download a file/image, // it will download file/image in the form of pieces. PeerDownLimit mean that a peer can only // stand starting PeerDownLimit concurrent downloading tasks. // default: 4 PeerDownLimit int `yaml:"peerDownLimit"` // When dfget node starts to play a role of peer, it will provide services for other peers // to pull pieces. If it runs into an issue when providing services for a peer, its self failure // increases by 1. When the failure limit reaches EliminationLimit, the peer will isolate itself // as a unhealthy state. Then this dfget will be no longer called by other peers. // default: 5 EliminationLimit int `yaml:"eliminationLimit"` // FailureCountLimit is the failure count limit set in supernode for dfget client. // When a dfget client takes part in the peer network constructed by supernode, // supernode will command the peer to start distribution task. // When dfget client fails to finish distribution task, the failure count of client // increases by 1. When failure count of client reaches to FailureCountLimit(default 5), // dfget client will be moved to blacklist of supernode to stop playing as a peer. // default: 5 FailureCountLimit int `yaml:"failureCountLimit"` // LinkLimit is set for supernode to limit every piece download network speed (unit: MB/s). // default: 20 LinkLimit int `yaml:"linkLimit"` // SystemReservedBandwidth is the network bandwidth reserved for system software. // unit: MB/s // default: 20 SystemReservedBandwidth int `yaml:"systemReservedBandwidth"` // MaxBandwidth is the network bandwidth that supernode can use. // unit: MB/s // default: 200 MaxBandwidth int `yaml:"maxBandwidth"` // Whether to enable profiler // default: false EnableProfiler bool `yaml:"enableProfiler"` // Whether to open DEBUG level // default: false Debug bool `yaml:"debug"` // AdvertiseIP is used to set the ip that we advertise to other peer in the p2p-network. // By default, the first non-loop address is advertised. AdvertiseIP string `yaml:"advertiseIP"` // contains filtered or unexported fields }
BaseProperties contains all basic properties of supernode.
func NewBaseProperties ¶ added in v0.4.0
func NewBaseProperties() *BaseProperties
NewBaseProperties create a instant with default values.
type Config ¶
type Config struct { *BaseProperties `yaml:"base"` Plugins map[PluginType][]*PluginProperties `yaml:"plugins"` Storages map[string]interface{} `yaml:"storages"` }
Config contains all configuration of supernode.
func NewConfig ¶ added in v0.4.0
func NewConfig() *Config
NewConfig create a instant with default values.
func (*Config) GetSuperCID ¶ added in v0.4.0
GetSuperCID returns the cid string for taskID.
func (*Config) GetSuperPID ¶ added in v0.4.0
GetSuperPID returns the pid string for supernode.
func (*Config) IsSuperCID ¶ added in v0.4.0
IsSuperCID returns whether the clientID represents supernode.
func (*Config) IsSuperPID ¶ added in v0.4.0
IsSuperPID returns whether the peerID represents supernode.
func (*Config) SetCIDPrefix ¶ added in v0.4.0
SetCIDPrefix sets a string as the prefix for supernode CID which used to distinguish from the other peer nodes.
func (*Config) SetSuperPID ¶ added in v0.4.0
SetSuperPID sets the value of supernode PID.
type PluginProperties ¶ added in v0.4.0
type PluginProperties struct { Name string `yaml:"name"` Enabled bool `yaml:"enabled"` Config string `yaml:"config"` }
PluginProperties the properties of a plugin.