/
defaults.go
74 lines (58 loc) · 2.57 KB
/
defaults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2019 DxChain, All rights reserved.
// Use of this source code is governed by an Apache
// License 2.0 that can be found in the LICENSE file.
package storageclient
import (
"time"
)
// Files and directories related constant
const (
PersistDirectory = "storageclient"
PersistFilename = "storageclient.json"
PersistStorageClientVersion = "1.0"
DxPathRoot = "dxfiles"
)
// StorageClient Settings, where 0 means unlimited
const (
DefaultMaxDownloadSpeed = 0
DefaultMaxUploadSpeed = 0
DefaultPacketSize = 4 * 4096
// frequency to check whether storage client is online
OnlineCheckFrequency = time.Second * 10
// the amount of time that can pass for processing activating worker pool
WorkerActivateTimeout = time.Minute * 5
// how long to wait for a worker after a worker failed to perform a download task.
DownloadFailureCooldown = time.Second * 3
// how many times a bad host's timeout/cool down can be doubled before a maximum cool down is reached.
MaxConsecutivePenalty = 10
)
const (
// DefaultMaxMemory available
DefaultMaxMemory = uint64(3 * 1 << 28)
extraRatio = 0.02
)
// Default params about upload/download process
var (
// healthCheckInterval defines the maximum amount of time that should pass
// in between checking the health of a file or directory.
HealthCheckInterval = 30 * time.Minute
// MaxConsecutiveSegmentUploads is the maximum number of segment before rebuilding the heap.
MaxConsecutiveSegmentUploads = 100
// repairStuckChunkInterval defines how long the storage client sleeps between
// trying to repair a stuck chunk. The uploadHeap prioritizes stuck chunks
// so this interval is to allow time for unstuck chunks to be repaired.
// Ideally the uploadHeap is spending 95% of its time repairing unstuck
// chunks.
RepairStuckSegmentInterval = 10 * time.Minute
// uploadAndRepairErrorSleepDuration indicates how long a upload process
// should sleep before retrying if there is an error fetching the metadata
// of the root directory of the storage client's filesystem.
UploadAndRepairErrorSleepDuration = 15 * time.Minute
// RemoteRepairDownloadThreshold indicates the threshold in percent under
// which the storage client starts repairing a file that is not available on disk
RemoteRepairDownloadThreshold = 0.125
// UploadFailureCoolDown is the initial time of punishment while upload consecutive fails
// the punishment time shows exponential growth
UploadFailureCoolDown = 3 * time.Second
)
var keys = []string{"fund", "hosts", "period", "violation", "uploadspeed", "downloadspeed"}