config

package
v2.1.16 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSeedPeerConcurrentUploadLimit is default number for seed peer concurrent upload limit.
	DefaultSeedPeerConcurrentUploadLimit = 300

	// DefaultPeerConcurrentUploadLimit is default number for peer concurrent upload limit.
	DefaultPeerConcurrentUploadLimit = 50

	// DefaultPeerConcurrentPieceCount is default number for pieces to concurrent downloading.
	DefaultPeerConcurrentPieceCount = 4

	// DefaultSchedulerCandidateParentLimit is default limit the number of candidate parent.
	DefaultSchedulerCandidateParentLimit = 4

	// DefaultSchedulerFilterParentLimit is default limit the number for filter parent.
	DefaultSchedulerFilterParentLimit = 40
)
View Source
const (
	// DefaultServerPort is default port for server.
	DefaultServerPort = 8002

	// DefaultServerAdvertisePort is default advertise port for server.
	DefaultServerAdvertisePort = 8002
)
View Source
const (
	// DefaultRedisBrokerDB is default db for redis broker.
	DefaultRedisBrokerDB = 1

	// DefaultRedisBackendDB is default db for redis backend.
	DefaultRedisBackendDB = 2

	// DefaultNetworkTopologyDB is default db for network topology.
	DefaultNetworkTopologyDB = 3
)
View Source
const (
	// DefaultSchedulerAlgorithm is default algorithm for scheduler.
	DefaultSchedulerAlgorithm = "default"

	// DefaultSchedulerBackToSourceCount is default back-to-source count for scheduler.
	DefaultSchedulerBackToSourceCount = 3

	// DefaultSchedulerRetryBackToSourceLimit is default retry back-to-source limit for scheduler.
	DefaultSchedulerRetryBackToSourceLimit = 5

	// DefaultSchedulerRetryLimit is default retry limit for scheduler.
	DefaultSchedulerRetryLimit = 10

	// DefaultSchedulerRetryInterval is default retry interval for scheduler.
	DefaultSchedulerRetryInterval = 50 * time.Millisecond

	// DefaultSchedulerPieceDownloadTimeout is default timeout of downloading piece.
	DefaultSchedulerPieceDownloadTimeout = 30 * time.Minute

	// DefaultSchedulerPeerGCInterval is default interval for peer gc.
	DefaultSchedulerPeerGCInterval = 10 * time.Second

	// DefaultSchedulerPeerTTL is default ttl for peer.
	DefaultSchedulerPeerTTL = 24 * time.Hour

	// DefaultSchedulerTaskGCInterval is default interval for task gc.
	DefaultSchedulerTaskGCInterval = 30 * time.Minute

	// DefaultSchedulerHostGCInterval is default interval for host gc.
	DefaultSchedulerHostGCInterval = 6 * time.Hour

	// DefaultSchedulerHostTTL is default ttl for host.
	DefaultSchedulerHostTTL = 1 * time.Hour

	// DefaultRefreshModelInterval is model refresh interval.
	DefaultRefreshModelInterval = 168 * time.Hour

	// DefaultCPU is default cpu usage.
	DefaultCPU = 1
)
View Source
const (
	// DefaultResourceTaskDownloadTinyScheme is default scheme of downloading tiny task.
	DefaultResourceTaskDownloadTinyScheme = "http"

	// DefaultResourceTaskDownloadTinyTimeout is default timeout of downloading tiny task.
	DefaultResourceTaskDownloadTinyTimeout = 1 * time.Minute
)
View Source
const (
	// DefaultManagerSchedulerClusterID is default id for scheduler cluster.
	DefaultManagerSchedulerClusterID = 1

	// DefaultManagerKeepAliveInterval is default interval for keepalive.
	DefaultManagerKeepAliveInterval = 5 * time.Second
)
View Source
const (
	// DefaultJobGlobalWorkerNum is default global worker number for job.
	DefaultJobGlobalWorkerNum = 500

	// DefaultJobSchedulerWorkerNum is default scheduler worker number for job.
	DefaultJobSchedulerWorkerNum = 500

	// DefaultJobGlobalWorkerNum is default local worker number for job.
	DefaultJobLocalWorkerNum = 1000

	// DefaultJobRedisBrokerDB is default db for redis broker.
	DefaultJobRedisBrokerDB = 1

	// DefaultJobRedisBackendDB is default db for redis backend.
	DefaultJobRedisBackendDB = 2
)
View Source
const (
	// DefaultStorageMaxSize is the default maximum size of record file.
	DefaultStorageMaxSize = 100

	// DefaultStorageMaxBackups is the default maximum count of backup.
	DefaultStorageMaxBackups = 10

	// DefaultStorageBufferSize is the default size of buffer container.
	DefaultStorageBufferSize = 100
)
View Source
const (
	// DefaultNetworkTopologyCollectInterval is the default interval of collecting network topology.
	DefaultNetworkTopologyCollectInterval = 2 * time.Hour

	// DefaultProbeQueueLength is the default length of probe queue.
	DefaultProbeQueueLength = 5

	// DefaultProbeCount is the default number of probing hosts.
	DefaultProbeCount = 5
)
View Source
const (
	// DefaultTrainerAddr is the default address of trainer.
	DefaultTrainerAddr = "127.0.0.1:9090"

	// DefaultTrainerInterval is the default interval of training.
	DefaultTrainerInterval = 7 * 24 * time.Hour

	// DefaultTrainerUploadTimeout is the default timeout of uploading dataset to trainer.
	DefaultTrainerUploadTimeout = 1 * time.Hour
)
View Source
const (
	// DefaultDynConfigRefreshInterval is default refresh interval for dynamic configuration.
	DefaultDynConfigRefreshInterval = 1 * time.Minute
)
View Source
const (
	// DefaultMetricsAddr is default address for metrics server.
	DefaultMetricsAddr = ":8000"
)

Variables

View Source
var (
	// DefaultCertIPAddresses is default ip addresses of certificate.
	DefaultCertIPAddresses = []net.IP{ip.IPv4, ip.IPv6}

	// DefaultCertDNSNames is default dns names of certificate.
	DefaultCertDNSNames = []string{"dragonfly-scheduler", "dragonfly-scheduler.dragonfly-system.svc", "dragonfly-scheduler.dragonfly-system.svc.cluster.local"}

	// DefaultCertValidityPeriod is default validity period of certificate.
	DefaultCertValidityPeriod = 180 * 24 * time.Hour
)
View Source
var (
	// DefaultNetworkEnableIPv6 is default value of enableIPv6.
	DefaultNetworkEnableIPv6 = false
)

Functions

func GetSeedPeerClusterConfigBySeedPeer added in v2.0.9

func GetSeedPeerClusterConfigBySeedPeer(seedPeer *managerv2.SeedPeer) (types.SeedPeerClusterConfig, error)

GetSeedPeerClusterConfigBySeedPeer returns the seed peer cluster config by seed peer.

Types

type CertSpec added in v2.0.6

type CertSpec struct {
	// DNSNames is a list of dns names be set on the certificate.
	DNSNames []string `mapstructure:"dnsNames" yaml:"dnsNames"`

	// IPAddresses is a list of ip addresses be set on the certificate.
	IPAddresses []net.IP `mapstructure:"ipAddresses" yaml:"ipAddresses"`

	// ValidityPeriod is the validity period of certificate.
	ValidityPeriod time.Duration `mapstructure:"validityPeriod" yaml:"validityPeriod"`
}

type Config

type Config struct {
	// Base options.
	base.Options `yaml:",inline" mapstructure:",squash"`

	// Server configuration.
	Server ServerConfig `yaml:"server" mapstructure:"server"`

	// Scheduler configuration.
	Scheduler SchedulerConfig `yaml:"scheduler" mapstructure:"scheduler"`

	// Database configuration.
	Database DatabaseConfig `yaml:"database" mapstructure:"database"`

	// Resource configuration.
	Resource ResourceConfig `yaml:"resource" mapstructure:"resource"`

	// Dynconfig configuration.
	DynConfig DynConfig `yaml:"dynConfig" mapstructure:"dynConfig"`

	// Manager configuration.
	Manager ManagerConfig `yaml:"manager" mapstructure:"manager"`

	// SeedPeer configuration.
	SeedPeer SeedPeerConfig `yaml:"seedPeer" mapstructure:"seedPeer"`

	// Host configuration.
	Host HostConfig `yaml:"host" mapstructure:"host"`

	// Job configuration.
	Job JobConfig `yaml:"job" mapstructure:"job"`

	// Storage configuration.
	Storage StorageConfig `yaml:"storage" mapstructure:"storage"`

	// Metrics configuration.
	Metrics MetricsConfig `yaml:"metrics" mapstructure:"metrics"`

	// Security configuration.
	Security SecurityConfig `yaml:"security" mapstructure:"security"`

	// Network configuration.
	Network NetworkConfig `yaml:"network" mapstructure:"network"`

	// NetworkTopology configuration.
	NetworkTopology NetworkTopologyConfig `yaml:"networkTopology" mapstructure:"networkTopology"`

	// Trainer configuration.
	Trainer TrainerConfig `yaml:"trainer" mapstructure:"trainer"`
}

func New

func New() *Config

New default configuration.

func (*Config) Convert

func (cfg *Config) Convert() error

func (*Config) Validate

func (cfg *Config) Validate() error

Validate config parameters.

type DatabaseConfig added in v2.0.30

type DatabaseConfig struct {
	// Redis configuration.
	Redis RedisConfig `yaml:"redis" mapstructure:"redis"`
}

type DownloadTinyConfig added in v2.0.30

type DownloadTinyConfig struct {
	// Scheme is download tiny task scheme.
	Scheme string `yaml:"scheme" mapstructure:"scheme"`

	// Timeout is http request timeout.
	Timeout time.Duration `yaml:"timeout" mapstructure:"timeout"`

	// TLS is download tiny task TLS configuration.
	TLS DownloadTinyTLSClientConfig `yaml:"tls" mapstructure:"tls"`
}

type DownloadTinyTLSClientConfig added in v2.0.30

type DownloadTinyTLSClientConfig struct {
	// InsecureSkipVerify controls whether a client verifies the
	// server's certificate chain and host name.
	InsecureSkipVerify bool `yaml:"insecureSkipVerify" mapstructure:"insecureSkipVerify"`
}

type DynConfig

type DynConfig struct {
	// RefreshInterval is refresh interval for manager cache.
	RefreshInterval time.Duration `yaml:"refreshInterval" mapstructure:"refreshInterval"`
}

type DynconfigData

type DynconfigData struct {
	Scheduler    *managerv2.Scheduler
	Applications []*managerv2.Application
}

type DynconfigInterface

type DynconfigInterface interface {
	// GetResolveSeedPeerAddrs returns the dynamic schedulers resolve addrs.
	GetResolveSeedPeerAddrs() ([]resolver.Address, error)

	// GetScheduler returns the scheduler config from manager.
	GetScheduler() (*managerv2.Scheduler, error)

	// GetApplications returns the applications config from manager.
	GetApplications() ([]*managerv2.Application, error)

	// GetSeedPeers returns the dynamic seed peers config from manager.
	GetSeedPeers() ([]*managerv2.SeedPeer, error)

	// GetSchedulerCluster returns the the scheduler cluster config from manager.
	GetSchedulerCluster() (*managerv2.SchedulerCluster, error)

	// GetSchedulerClusterConfig returns the scheduler cluster config.
	GetSchedulerClusterConfig() (types.SchedulerClusterConfig, error)

	// GetSchedulerClusterClientConfig returns the client config.
	GetSchedulerClusterClientConfig() (types.SchedulerClusterClientConfig, error)

	// Get returns the dynamic config from manager.
	Get() (*DynconfigData, error)

	// Refresh refreshes dynconfig in cache.
	Refresh() error

	// Register allows an instance to register itself to listen/observe events.
	Register(Observer)

	// Deregister allows an instance to remove itself from the collection of observers/listeners.
	Deregister(Observer)

	// Notify publishes new events to listeners.
	Notify() error

	// Serve the dynconfig listening service.
	Serve() error

	// Stop the dynconfig listening service.
	Stop() error
}

func NewDynconfig

func NewDynconfig(rawManagerClient managerclient.V2, cacheDir string, cfg *Config, options ...DynconfigOption) (DynconfigInterface, error)

NewDynconfig returns a new dynconfig instence.

type DynconfigOption added in v2.0.9

type DynconfigOption func(d *dynconfig) error

DynconfigOption is a functional option for configuring the dynconfig.

func WithTransportCredentials added in v2.0.9

func WithTransportCredentials(creds credentials.TransportCredentials) DynconfigOption

WithTransportCredentials returns a DialOption which configures a connection level security credentials (e.g., TLS/SSL).

type GCConfig

type GCConfig struct {
	// PieceDownloadTimeout is timeout of downloading piece.
	PieceDownloadTimeout time.Duration `yaml:"pieceDownloadTimeout" mapstructure:"pieceDownloadTimeout"`

	// PeerGCInterval is interval of peer gc.
	PeerGCInterval time.Duration `yaml:"peerGCInterval" mapstructure:"peerGCInterval"`

	// PeerTTL is time to live of peer. If the peer has been downloaded by other peers,
	// then PeerTTL will be reset.
	PeerTTL time.Duration `yaml:"peerTTL" mapstructure:"peerTTL"`

	// TaskGCInterval is interval of task gc. If all the peers have been reclaimed in the task,
	// then the task will also be reclaimed.
	TaskGCInterval time.Duration `yaml:"taskGCInterval" mapstructure:"taskGCInterval"`

	// HostGCInterval is interval of host gc.
	HostGCInterval time.Duration `yaml:"hostGCInterval" mapstructure:"hostGCInterval"`

	// HostTTL is time to live of host. If host announces message to scheduler,
	// then HostTTl will be reset.
	HostTTL time.Duration `yaml:"hostTTL" mapstructure:"hostTTL"`
}

type HostConfig

type HostConfig struct {
	// IDC for scheduler.
	IDC string `mapstructure:"idc" yaml:"idc"`

	// Location for scheduler.
	Location string `mapstructure:"location" yaml:"location"`
}

type JobConfig

type JobConfig struct {
	// Enable job service.
	Enable bool `yaml:"enable" mapstructure:"enable"`

	// Number of workers in global queue.
	GlobalWorkerNum uint `yaml:"globalWorkerNum" mapstructure:"globalWorkerNum"`

	// Number of workers in scheduler queue.
	SchedulerWorkerNum uint `yaml:"schedulerWorkerNum" mapstructure:"schedulerWorkerNum"`

	// Number of workers in local queue.
	LocalWorkerNum uint `yaml:"localWorkerNum" mapstructure:"localWorkerNum"`

	// DEPRECATED: Please use the `database.redis` field instead.
	Redis RedisConfig `yaml:"redis" mapstructure:"redis"`
}

type KeepAliveConfig

type KeepAliveConfig struct {
	// Keep alive interval.
	Interval time.Duration `yaml:"interval" mapstructure:"interval"`
}

type ManagerConfig

type ManagerConfig struct {
	// Addr is manager address.
	Addr string `yaml:"addr" mapstructure:"addr"`

	// SchedulerClusterID is scheduler cluster id.
	SchedulerClusterID uint `yaml:"schedulerClusterID" mapstructure:"schedulerClusterID"`

	// KeepAlive configuration.
	KeepAlive KeepAliveConfig `yaml:"keepAlive" mapstructure:"keepAlive"`
}

type MetricsConfig added in v2.0.1

type MetricsConfig struct {
	// Enable metrics service.
	Enable bool `yaml:"enable" mapstructure:"enable"`

	// Metrics service address.
	Addr string `yaml:"addr" mapstructure:"addr"`

	// Enable host metrics.
	EnableHost bool `yaml:"enableHost" mapstructure:"enableHost"`
}

type NetworkConfig added in v2.0.7

type NetworkConfig struct {
	// EnableIPv6 enables ipv6 for server.
	EnableIPv6 bool `mapstructure:"enableIPv6" yaml:"enableIPv6"`
}

type NetworkTopologyConfig added in v2.0.9

type NetworkTopologyConfig struct {
	// Enable network topology service, including probe, network topology collection.
	Enable bool `yaml:"enable" mapstructure:"enable"`

	// CollectInterval is the interval of collecting network topology.
	CollectInterval time.Duration `mapstructure:"collectInterval" yaml:"collectInterval"`

	// Probe is the configuration of probe.
	Probe ProbeConfig `yaml:"probe" mapstructure:"probe"`
}

type Observer

type Observer interface {
	// OnNotify allows an event to be published to interface implementations.
	OnNotify(*DynconfigData)
}

type ProbeConfig added in v2.0.9

type ProbeConfig struct {
	// QueueLength is the length of probe queue.
	QueueLength int `mapstructure:"queueLength" yaml:"queueLength"`

	// Count is the number of probing hosts.
	Count int `mapstructure:"count" yaml:"count"`
}

type RedisConfig

type RedisConfig struct {
	// DEPRECATED: Please use the `addrs` field instead.
	Host string `yaml:"host" mapstructure:"host"`

	// DEPRECATED: Please use the `addrs` field instead.
	Port int `yaml:"port" mapstructure:"port"`

	// Addrs is server addresses.
	Addrs []string `yaml:"addrs" mapstructure:"addrs"`

	// MasterName is the sentinel master name.
	MasterName string `yaml:"masterName" mapstructure:"masterName"`

	// Username is server username.
	Username string `yaml:"username" mapstructure:"username"`

	// Password is server password.
	Password string `yaml:"password" mapstructure:"password"`

	// BrokerDB is broker database name.
	BrokerDB int `yaml:"brokerDB" mapstructure:"brokerDB"`

	// BackendDB is backend database name.
	BackendDB int `yaml:"backendDB" mapstructure:"backendDB"`

	// NetworkTopologyDB is network topology database name.
	NetworkTopologyDB int `yaml:"networkTopologyDB" mapstructure:"networkTopologyDB"`
}

type ResourceConfig added in v2.0.30

type ResourceConfig struct {
	// Task resource configuration.
	Task TaskConfig `yaml:"task" mapstructure:"task"`
}

type SchedulerConfig

type SchedulerConfig struct {
	// Algorithm is scheduling algorithm used by the scheduler.
	Algorithm string `yaml:"algorithm" mapstructure:"algorithm"`

	// BackToSourceCount is single task allows the peer to back-to-source count.
	BackToSourceCount int `yaml:"backToSourceCount" mapstructure:"backToSourceCount"`

	// RetryBackToSourceLimit reaches the limit, then the peer back-to-source.
	RetryBackToSourceLimit int `yaml:"retryBackToSourceLimit" mapstructure:"retryBackToSourceLimit"`

	// RetryLimit reaches the limit, then scheduler returns scheduling failed.
	RetryLimit int `yaml:"retryLimit" mapstructure:"retryLimit"`

	// RetryInterval is scheduling interval.
	RetryInterval time.Duration `yaml:"retryInterval" mapstructure:"retryInterval"`

	// GC configuration.
	GC GCConfig `yaml:"gc" mapstructure:"gc"`
}

type SecurityConfig added in v2.0.6

type SecurityConfig struct {
	// AutoIssueCert indicates to issue client certificates for all grpc call
	// if AutoIssueCert is false, any other option in Security will be ignored.
	AutoIssueCert bool `mapstructure:"autoIssueCert" yaml:"autoIssueCert"`

	// CACert is the root CA certificate for all grpc tls handshake, it can be path or PEM format string.
	CACert types.PEMContent `mapstructure:"caCert" yaml:"caCert"`

	// TLSVerify indicates to verify client certificates.
	TLSVerify bool `mapstructure:"tlsVerify" yaml:"tlsVerify"`

	// TLSPolicy controls the grpc shandshake behaviors:
	// force: both ClientHandshake and ServerHandshake are only support tls.
	// prefer: ServerHandshake supports tls and insecure (non-tls), ClientHandshake will only support tls.
	// default: ServerHandshake supports tls and insecure (non-tls), ClientHandshake will only support insecure (non-tls).
	TLSPolicy string `mapstructure:"tlsPolicy" yaml:"tlsPolicy"`

	// CertSpec is the desired state of certificate.
	CertSpec CertSpec `mapstructure:"certSpec" yaml:"certSpec"`
}

type SeedPeerConfig added in v2.0.3

type SeedPeerConfig struct {
	// Enable is to enable seed peer as P2P peer.
	Enable bool `yaml:"enable" mapstructure:"enable"`
}

type ServerConfig

type ServerConfig struct {
	// AdvertiseIP is advertise ip.
	AdvertiseIP net.IP `yaml:"advertiseIP" mapstructure:"advertiseIP"`

	// AdvertisePort is advertise port.
	AdvertisePort int `yaml:"advertisePort" mapstructure:"advertisePort"`

	// ListenIP is listen ip, like: 0.0.0.0, 192.168.0.1.
	ListenIP net.IP `yaml:"listenIP" mapstructure:"listenIP"`

	// Server port.
	Port int `yaml:"port" mapstructure:"port"`

	// Server hostname.
	Host string `yaml:"host" mapstructure:"host"`

	// Server work directory.
	WorkHome string `yaml:"workHome" mapstructure:"workHome"`

	// Server dynamic config cache directory.
	CacheDir string `yaml:"cacheDir" mapstructure:"cacheDir"`

	// Server log directory.
	LogDir string `yaml:"logDir" mapstructure:"logDir"`

	// Server plugin directory.
	PluginDir string `yaml:"pluginDir" mapstructure:"pluginDir"`

	// Server storage data directory.
	DataDir string `yaml:"dataDir" mapstructure:"dataDir"`
}

type StorageConfig added in v2.0.3

type StorageConfig struct {
	// MaxSize sets the maximum size in megabytes of storage file.
	MaxSize int `yaml:"maxSize" mapstructure:"maxSize"`

	// MaxBackups sets the maximum number of storage files to retain.
	MaxBackups int `yaml:"maxBackups" mapstructure:"maxBackups"`

	// BufferSize sets the size of buffer container,
	// if the buffer is full, write all the records in the buffer to the file.
	BufferSize int `yaml:"bufferSize" mapstructure:"bufferSize"`
}

type TaskConfig added in v2.0.30

type TaskConfig struct {
	// Download tiny task configuration.
	DownloadTiny DownloadTinyConfig `yaml:"downloadTiny" mapstructure:"downloadTiny"`
}

type TrainerConfig added in v2.0.10

type TrainerConfig struct {
	// Enable trainer service.
	Enable bool `yaml:"enable" mapstructure:"enable"`

	// Addr is trainer service address.
	Addr string `yaml:"addr" mapstructure:"addr"`

	// Interval is the interval of training.
	Interval time.Duration `yaml:"interval" mapstructure:"interval"`

	// UploadTimeout is the timeout of uploading dataset to trainer.
	UploadTimeout time.Duration `yaml:"uploadTimeout" mapstructure:"uploadTimeout"`
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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