-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinside_options.go
165 lines (140 loc) · 2.93 KB
/
inside_options.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package gopaxos
import (
"github.com/docker/docker/pkg/random"
"sync"
)
var oneInsideOptions sync.Once
var dfInsideOptions *insideOptions
func getInsideOptionsInstance() *insideOptions {
oneInsideOptions.Do(initInsideOptions)
return dfInsideOptions
}
func initInsideOptions() {
dfInsideOptions = &insideOptions{
isLargeBufferMode: false,
isFollower: false,
groupCount: 1,
}
}
type insideOptions struct {
isLargeBufferMode bool
isFollower bool
groupCount int
}
func (i *insideOptions) setAsLargeBufferMode() {
i.isLargeBufferMode = true
}
func (i *insideOptions) setAsFollower() {
i.isFollower = true
}
func (i *insideOptions) setGroupCount(groupCount int) {
i.groupCount = groupCount
}
func (i *insideOptions) getMaxBufferSize() int {
if i.isLargeBufferMode {
return 52428800
}
return 10485760
}
func (i *insideOptions) getStartPrepareTimeoutMs() int {
if i.isLargeBufferMode {
return 15000
}
return 2000
}
func (i *insideOptions) getStartAcceptTimeoutMs() int {
if i.isLargeBufferMode {
return 15000
}
return 1000
}
func (i *insideOptions) getMaxPrepareTimeoutMs() int {
if i.isLargeBufferMode {
return 90000
}
return 8000
}
func (i *insideOptions) getMaxAcceptTimeoutMs() int {
if i.isLargeBufferMode {
return 90000
}
return 8000
}
func (i *insideOptions) getMaxIOLoopQueueLen() int {
if i.isLargeBufferMode {
return 1024/i.groupCount + 100
}
return 10240/i.groupCount + 1000
}
func (i *insideOptions) getMaxQueueLen() int {
if i.isLargeBufferMode {
return 1024
}
return 10240
}
func (i *insideOptions) getAskforLearnInterval() int {
if !i.isFollower {
if i.isLargeBufferMode {
return 50000 + random.Rand.Int()%10000
}
return 2500 + random.Rand.Int()%500
}
if i.isLargeBufferMode {
return 30000 + random.Rand.Int()%15000
}
return 2000 + random.Rand.Int()%1000
}
func (i *insideOptions) getLearnerReceiverAckLead() int {
if i.isLargeBufferMode {
return 2
}
return 4
}
func (i *insideOptions) getLearnerSenderPrepareTimeoutMs() int {
if i.isLargeBufferMode {
return 6000
}
return 5000
}
func (i *insideOptions) getLearnerSenderAckTimeoutMs() int {
if i.isLargeBufferMode {
return 60000
}
return 5000
}
func (i *insideOptions) getLearnerSenderAckLead() int {
if i.isLargeBufferMode {
return 5
}
return 21
}
func (i *insideOptions) getTcpOutQueueDropTimeMs() int {
if i.isLargeBufferMode {
return 20000
}
return 5000
}
func (i *insideOptions) getLogFileMaxSize() int {
if i.isLargeBufferMode {
return 524288000
}
return 104857600
}
func (i *insideOptions) getTcpConnectionNonActiveTimeout() int {
if i.isLargeBufferMode {
return 600000
}
return 60000
}
func (i *insideOptions) getLearnerSenderSendQps() int {
if i.isLargeBufferMode {
return 10000 / i.groupCount
}
return 100000 / i.groupCount
}
func (i *insideOptions) getCleanerDeleteQps() int {
if i.isLargeBufferMode {
return 30000 / i.groupCount
}
return 300000 / i.groupCount
}