This repository has been archived by the owner on Sep 18, 2021. It is now read-only.
/
development.scala
175 lines (148 loc) · 4.12 KB
/
development.scala
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
166
167
168
169
170
171
172
173
174
175
import com.twitter.flockdb.config._
import com.twitter.gizzard.config._
import com.twitter.querulous.config._
import com.twitter.querulous.StatsCollector
import com.twitter.util.TimeConversions._
import com.twitter.flockdb.shards.QueryClass
import com.twitter.flockdb.Priority
trait Credentials extends Connection {
val username = "root"
val password = ""
}
class ProductionQueryEvaluator extends QueryEvaluator {
autoDisable = new AutoDisablingQueryEvaluator {
val errorCount = 100
val interval = 60.seconds
}
database.memoize = true
database.pool = new ApachePoolingDatabase {
sizeMin = 40
sizeMax = 40
maxWait = 100.millis
minEvictableIdle = 60.seconds
testIdle = 1.second
testOnBorrow = false
}
database.timeout = new TimingOutDatabase {
open = 50.millis
poolSize = 10
queueSize = 10000
}
}
class ProductionNameServerReplica(host: String) extends Mysql {
val connection = new Connection with Credentials {
val hostnames = Seq(host)
val database = "flock_edges_production"
}
queryEvaluator = new ProductionQueryEvaluator {
database.pool.foreach { p =>
p.sizeMin = 1
p.sizeMax = 1
p.maxWait = 1.second
}
database.timeout.foreach { t =>
t.open = 1.second
}
query.timeouts = Map(
QueryClass.Select -> QueryTimeout(1.second),
QueryClass.Execute -> QueryTimeout(1.second),
QueryClass.SelectCopy -> QueryTimeout(15.seconds),
QueryClass.SelectModify -> QueryTimeout(3.seconds)
)
}
}
new FlockDB {
aggregateJobsPageSize = 500
val server = new FlockDBServer with THsHaServer {
timeout = 100.millis
idleTimeout = 60.seconds
threadPool.minThreads = 250
threadPool.maxThreads = 250
}
val nameServer = new com.twitter.gizzard.config.NameServer {
mappingFunction = ByteSwapper
jobRelay = NoJobRelay
val replicas = Seq(
new ProductionNameServerReplica("flockdb001.twitter.com"),
new ProductionNameServerReplica("flockdb002.twitter.com")
)
}
jobInjector.timeout = 100.millis
jobInjector.idleTimeout = 60.seconds
jobInjector.threadPool.minThreads = 30
val replicationFuture = new Future {
poolSize = 100
maxPoolSize = 100
keepAlive = 5.seconds
timeout = 6.seconds
}
val readFuture = new Future {
poolSize = 100
maxPoolSize = 100
keepAlive = 5.seconds
timeout = 6.seconds
}
val databaseConnection = new Credentials {
val hostnames = Seq("localhost")
val database = "edges_test"
urlOptions = Map("rewriteBatchedStatements" -> "true")
}
val edgesQueryEvaluator = new ProductionQueryEvaluator
val materializingQueryEvaluator = new ProductionQueryEvaluator {
database.pool.foreach { p =>
p.sizeMin = 1
p.sizeMax = 1
p.maxWait = 1.second
}
}
class ProductionScheduler(val name: String) extends Scheduler {
jobQueueName = name + "_jobs"
val schedulerType = new KestrelScheduler { path = "/var/spool/kestrel" }
errorLimit = 100
errorRetryDelay = 15.minutes
errorStrobeInterval = 1.second
perFlushItemLimit = 100
jitterRate = 0
}
val jobQueues = Map(
Priority.High.id -> new ProductionScheduler("edges") { threads = 32 },
Priority.Medium.id -> new ProductionScheduler("copy") { threads = 12; errorRetryDelay = 60.seconds },
Priority.Low.id -> new ProductionScheduler("edges_slow") { threads = 2 }
)
val adminConfig = new AdminConfig {
val textPort = 9991
val httpPort = 9990
}
logging = new LogConfigString("""
log {
filename = "/var/log/flock/production.log"
level = "info"
roll = "hourly"
throttle_period_msec = 60000
throttle_rate = 10
truncate_stack_traces = 100
w3c {
node = "w3c"
use_parents = false
filename = "/var/log/flock/w3c.log"
level = "info"
roll = "hourly"
}
stats {
node = "stats"
use_parents = false
level = "info"
scribe_category = "flock-stats"
scribe_server = "localhost"
scribe_max_packet_size = 100
}
bad_jobs {
node = "bad_jobs"
use_parents = false
filename = "/var/log/flock/bad_jobs.log"
level = "info"
roll = "never"
}
}
""")
}