config

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// DefaultSupernodeConfigFilePath the default supernode config path.
	DefaultSupernodeConfigFilePath = "/etc/dragonfly/supernode.yml"

	// SuperNodeCIdPrefix is a string as the prefix of the supernode.
	SuperNodeCIdPrefix = "cdnnode:"
)
View Source
const (
	PieceSEMISUC = -3
	PieceWAITING = -1
	PieceRUNNING = 0
	PieceSUCCESS = 1
	PieceFAILED  = 2
)

PieceStatus code

View Source
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
)
View Source
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)
)
View Source
const (
	// StoragePlugin the storage plugin type.
	StoragePlugin = PluginType("storage")

	// SchedulerPlugin the scheduler plugin type.
	SchedulerPlugin = PluginType("scheduler")
)
View Source
const (
	// CDNWriterRoutineLimit 4
	CDNWriterRoutineLimit = 4
)

Variables

View Source
var (
	// DownloadHome is the parent directory where the downloaded files are stored
	// which is a relative path.
	DownloadHome = "download"
)

PluginTypes explicitly stores all available plugin types.

Functions

func TransLimit added in v0.4.0

func TransLimit(rateLimit int) int

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

func (c *Config) GetSuperCID(taskID string) string

GetSuperCID returns the cid string for taskID.

func (*Config) GetSuperPID added in v0.4.0

func (c *Config) GetSuperPID() string

GetSuperPID returns the pid string for supernode.

func (*Config) IsSuperCID added in v0.4.0

func (c *Config) IsSuperCID(clientID string) bool

IsSuperCID returns whether the clientID represents supernode.

func (*Config) IsSuperPID added in v0.4.0

func (c *Config) IsSuperPID(peerID string) bool

IsSuperPID returns whether the peerID represents supernode.

func (*Config) Load added in v0.4.0

func (c *Config) Load(path string) error

Load loads config properties from the giving file.

func (*Config) SetCIDPrefix added in v0.4.0

func (c *Config) SetCIDPrefix(ip string)

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

func (c *Config) SetSuperPID(pid string)

SetSuperPID sets the value of supernode PID.

func (*Config) String added in v0.4.0

func (c *Config) String() string

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.

type PluginType added in v0.4.0

type PluginType string

PluginType defines the type of plugin.

Jump to

Keyboard shortcuts

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