Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 8ab79df

Browse files
committed
change cassandra timeout to duration var
1 parent 095aaa4 commit 8ab79df

File tree

15 files changed

+32
-31
lines changed

15 files changed

+32
-31
lines changed

cmd/mt-split-metrics-by-ttl/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func main() {
2323
flag.StringVar(&storeConfig.Keyspace, "cassandra-keyspace", storeConfig.Keyspace, "cassandra keyspace to use for storing the metric data table")
2424
flag.StringVar(&storeConfig.Consistency, "cassandra-consistency", storeConfig.Consistency, "write consistency (any|one|two|three|quorum|all|local_quorum|each_quorum|local_one")
2525
flag.StringVar(&storeConfig.HostSelectionPolicy, "cassandra-host-selection-policy", storeConfig.HostSelectionPolicy, "")
26-
flag.IntVar(&storeConfig.Timeout, "cassandra-timeout", storeConfig.Timeout, "cassandra timeout in milliseconds")
26+
flag.DurationVar(&storeConfig.Timeout, "cassandra-timeout", storeConfig.Timeout, "cassandra timeout")
2727
flag.IntVar(&storeConfig.Retries, "cassandra-retries", storeConfig.Retries, "how many times to retry a query before failing it")
2828
flag.IntVar(&storeConfig.CqlProtocolVersion, "cql-protocol-version", storeConfig.CqlProtocolVersion, "cql protocol version to use")
2929
flag.BoolVar(&storeConfig.DisableInitialHostLookup, "cassandra-disable-initial-host-lookup", storeConfig.DisableInitialHostLookup, "instruct the driver to not attempt to get host info from the system.peers table")

cmd/mt-store-cat/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func main() {
4545
flag.StringVar(&storeConfig.Keyspace, "cassandra-keyspace", storeConfig.Keyspace, "cassandra keyspace to use for storing the metric data table")
4646
flag.StringVar(&storeConfig.Consistency, "cassandra-consistency", storeConfig.Consistency, "write consistency (any|one|two|three|quorum|all|local_quorum|each_quorum|local_one")
4747
flag.StringVar(&storeConfig.HostSelectionPolicy, "cassandra-host-selection-policy", storeConfig.HostSelectionPolicy, "")
48-
flag.IntVar(&storeConfig.Timeout, "cassandra-timeout", storeConfig.Timeout, "cassandra timeout in milliseconds")
48+
flag.DurationVar(&storeConfig.Timeout, "cassandra-timeout", storeConfig.Timeout, "cassandra timeout")
4949
flag.IntVar(&storeConfig.ReadConcurrency, "cassandra-read-concurrency", storeConfig.ReadConcurrency, "max number of concurrent reads to cassandra.")
5050
//flag.IntVar(&storeConfig.WriteConcurrency, "write-concurrency", storeConfig.WriteConcurrency, "max number of concurrent writes to cassandra.")
5151
flag.IntVar(&storeConfig.ReadQueueSize, "cassandra-read-queue-size", storeConfig.ReadQueueSize, "max number of outstanding reads before reads will be dropped. This is important if you run queries that result in many reads in parallel.")

cmd/mt-update-ttl/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var (
2323
cassandraKeyspace = flag.String("cassandra-keyspace", "metrictank", "cassandra keyspace to use for storing the metric data table")
2424
cassandraConsistency = flag.String("cassandra-consistency", "one", "write consistency (any|one|two|three|quorum|all|local_quorum|each_quorum|local_one")
2525
cassandraHostSelectionPolicy = flag.String("cassandra-host-selection-policy", "tokenaware,hostpool-epsilon-greedy", "")
26-
cassandraTimeout = flag.Int("cassandra-timeout", 1000, "cassandra timeout in milliseconds")
26+
cassandraTimeout = flag.Duration("cassandra-timeout", time.Second, "cassandra timeout")
2727
cassandraConcurrency = flag.Int("cassandra-concurrency", 20, "max number of concurrent reads to cassandra.")
2828
cassandraRetries = flag.Int("cassandra-retries", 0, "how many times to retry a query before failing it")
2929
cqlProtocolVersion = flag.Int("cql-protocol-version", 4, "cql protocol version to use")

cmd/mt-whisper-importer-writer/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func main() {
8989
globalFlags.StringVar(&storeConfig.Keyspace, "cassandra-keyspace", storeConfig.Keyspace, "cassandra keyspace to use for storing the metric data table")
9090
globalFlags.StringVar(&storeConfig.Consistency, "cassandra-consistency", storeConfig.Consistency, "write consistency (any|one|two|three|quorum|all|local_quorum|each_quorum|local_one")
9191
globalFlags.StringVar(&storeConfig.HostSelectionPolicy, "cassandra-host-selection-policy", storeConfig.HostSelectionPolicy, "")
92-
globalFlags.IntVar(&storeConfig.Timeout, "cassandra-timeout", storeConfig.Timeout, "cassandra timeout in milliseconds")
92+
globalFlags.DurationVar(&storeConfig.Timeout, "cassandra-timeout", storeConfig.Timeout, "cassandra timeout")
9393
globalFlags.IntVar(&storeConfig.ReadConcurrency, "cassandra-read-concurrency", storeConfig.ReadConcurrency, "max number of concurrent reads to cassandra.")
9494
globalFlags.IntVar(&storeConfig.WriteConcurrency, "cassandra-write-concurrency", storeConfig.WriteConcurrency, "max number of concurrent writes to cassandra.")
9595
globalFlags.IntVar(&storeConfig.ReadQueueSize, "cassandra-read-queue-size", storeConfig.ReadQueueSize, "max number of outstanding reads before reads will be dropped. This is important if you run queries that result in many reads in parallel.")

docker/docker-chaos/metrictank.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ consistency = one
7070
# tokenaware,hostpool-simple : prefer host that has the needed data, fallback to hostpool-simple.
7171
# tokenaware,hostpool-epsilon-greedy : prefer host that has the needed data, fallback to hostpool-epsilon-greedy.
7272
host-selection-policy = tokenaware,hostpool-epsilon-greedy
73-
# cassandra timeout in milliseconds
74-
timeout = 4000
73+
# cassandra timeout
74+
timeout = 4s
7575
# max number of concurrent reads to cassandra
7676
read-concurrency = 500
7777
# max number of concurrent writes to cassandra

docker/docker-cluster/metrictank.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ consistency = one
7070
# tokenaware,hostpool-simple : prefer host that has the needed data, fallback to hostpool-simple.
7171
# tokenaware,hostpool-epsilon-greedy : prefer host that has the needed data, fallback to hostpool-epsilon-greedy.
7272
host-selection-policy = tokenaware,hostpool-epsilon-greedy
73-
# cassandra timeout in milliseconds
74-
timeout = 4000
73+
# cassandra timeout
74+
timeout = 4s
7575
# max number of concurrent reads to cassandra
7676
read-concurrency = 500
7777
# max number of concurrent writes to cassandra

docker/docker-cosmosdb/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ services:
1717
WAIT_TIMEOUT: 60
1818
MT_STATS_ADDR: graphite:2003
1919
MT_CASSANDRA_ADDRS: <addr>
20-
MT_CASSANDRA_TIMEOUT: 30000
20+
MT_CASSANDRA_TIMEOUT: 30s
2121
MT_CASSANDRA_SSL: "true"
2222
MT_CASSANDRA_CA_PATH: ""
2323
MT_CASSANDRA_HOST_VERIFICATION: "false"

docker/docker-dev-custom-cfg-kafka/metrictank.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ consistency = one
7070
# tokenaware,hostpool-simple : prefer host that has the needed data, fallback to hostpool-simple.
7171
# tokenaware,hostpool-epsilon-greedy : prefer host that has the needed data, fallback to hostpool-epsilon-greedy.
7272
host-selection-policy = tokenaware,hostpool-epsilon-greedy
73-
# cassandra timeout in milliseconds
74-
timeout = 1000
73+
# cassandra timeout
74+
timeout = 1s
7575
# max number of concurrent reads to cassandra
7676
read-concurrency = 20
7777
# max number of concurrent writes to cassandra

docs/config.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ consistency = one
9999
# tokenaware,hostpool-simple : prefer host that has the needed data, fallback to hostpool-simple.
100100
# tokenaware,hostpool-epsilon-greedy : prefer host that has the needed data, fallback to hostpool-epsilon-greedy.
101101
host-selection-policy = tokenaware,hostpool-epsilon-greedy
102-
# cassandra timeout in milliseconds
103-
timeout = 1000
102+
# cassandra timeout
103+
timeout = 1s
104104
# max number of concurrent reads to cassandra
105105
read-concurrency = 20
106106
# max number of concurrent writes to cassandra

docs/tools.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ Flags:
298298
how many times to retry a query before failing it
299299
-cassandra-ssl
300300
enable SSL connection to cassandra
301-
-cassandra-timeout int
302-
cassandra timeout in milliseconds (default 1000)
301+
-cassandra-timeout duration (default 1s)
302+
cassandra timeout
303303
-cassandra-username string
304304
username for authentication (default "cassandra")
305305
-cql-protocol-version int
@@ -364,8 +364,8 @@ Flags:
364364
File containing the needed schemas in case database needs initializing (default "/etc/metrictank/schema-store-cassandra.toml")
365365
-cassandra-ssl
366366
enable SSL connection to cassandra
367-
-cassandra-timeout int
368-
cassandra timeout in milliseconds (default 1000)
367+
-cassandra-timeout duration (default 1s)
368+
cassandra timeout
369369
-cassandra-username string
370370
username for authentication (default "cassandra")
371371
-config string
@@ -432,8 +432,8 @@ Flags:
432432
how many times to retry a query before failing it
433433
-cassandra-ssl
434434
enable SSL connection to cassandra
435-
-cassandra-timeout int
436-
cassandra timeout in milliseconds (default 1000)
435+
-cassandra-timeout duration (default 1s)
436+
cassandra timeout
437437
-cassandra-username string
438438
username for authentication (default "cassandra")
439439
-cql-protocol-version int
@@ -544,8 +544,8 @@ global config flags:
544544
File containing the needed schemas in case database needs initializing (default "/etc/metrictank/schema-store-cassandra.toml")
545545
-cassandra-ssl
546546
enable SSL connection to cassandra
547-
-cassandra-timeout int
548-
cassandra timeout in milliseconds (default 1000)
547+
-cassandra-timeout duration (default 1s)
548+
cassandra timeout
549549
-cassandra-username string
550550
username for authentication (default "cassandra")
551551
-cassandra-window-factor int

metrictank-sample.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ consistency = one
7373
# tokenaware,hostpool-simple : prefer host that has the needed data, fallback to hostpool-simple.
7474
# tokenaware,hostpool-epsilon-greedy : prefer host that has the needed data, fallback to hostpool-epsilon-greedy.
7575
host-selection-policy = tokenaware,hostpool-epsilon-greedy
76-
# cassandra timeout in milliseconds
77-
timeout = 1000
76+
# cassandra timeout
77+
timeout = 1s
7878
# max number of concurrent reads to cassandra
7979
read-concurrency = 20
8080
# max number of concurrent writes to cassandra

scripts/config/metrictank-docker.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ consistency = one
7070
# tokenaware,hostpool-simple : prefer host that has the needed data, fallback to hostpool-simple.
7171
# tokenaware,hostpool-epsilon-greedy : prefer host that has the needed data, fallback to hostpool-epsilon-greedy.
7272
host-selection-policy = tokenaware,hostpool-epsilon-greedy
73-
# cassandra timeout in milliseconds
74-
timeout = 10000
73+
# cassandra timeout
74+
timeout = 10s
7575
# max number of concurrent reads to cassandra
7676
read-concurrency = 20
7777
# max number of concurrent writes to cassandra

scripts/config/metrictank-package.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ consistency = one
7070
# tokenaware,hostpool-simple : prefer host that has the needed data, fallback to hostpool-simple.
7171
# tokenaware,hostpool-epsilon-greedy : prefer host that has the needed data, fallback to hostpool-epsilon-greedy.
7272
host-selection-policy = tokenaware,hostpool-epsilon-greedy
73-
# cassandra timeout in milliseconds
74-
timeout = 1000
73+
# cassandra timeout
74+
timeout = 1s
7575
# max number of concurrent reads to cassandra
7676
read-concurrency = 20
7777
# max number of concurrent writes to cassandra

store/cassandra/cassandra.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func NewCassandraStore(config *StoreConfig, ttls []uint32) (*CassandraStore, err
127127
}
128128
}
129129
cluster.Consistency = gocql.ParseConsistency(config.Consistency)
130-
cluster.Timeout = time.Duration(config.Timeout) * time.Millisecond
130+
cluster.Timeout = config.Timeout
131131
cluster.ConnectTimeout = cluster.Timeout
132132
cluster.NumConns = config.WriteConcurrency
133133
cluster.ProtoVersion = config.CqlProtocolVersion

store/cassandra/config.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cassandra
22

33
import (
44
"flag"
5+
"time"
56

67
"github.com/rakyll/globalconf"
78
)
@@ -11,7 +12,7 @@ type StoreConfig struct {
1112
Keyspace string
1213
Consistency string
1314
HostSelectionPolicy string
14-
Timeout int
15+
Timeout time.Duration
1516
ReadConcurrency int
1617
WriteConcurrency int
1718
ReadQueueSize int
@@ -38,7 +39,7 @@ func NewStoreConfig() *StoreConfig {
3839
Keyspace: "metrictank",
3940
Consistency: "one",
4041
HostSelectionPolicy: "tokenaware,hostpool-epsilon-greedy",
41-
Timeout: 1000,
42+
Timeout: time.Second,
4243
ReadConcurrency: 20,
4344
WriteConcurrency: 10,
4445
ReadQueueSize: 200000,
@@ -67,7 +68,7 @@ func ConfigSetup() *flag.FlagSet {
6768
cas.StringVar(&CliConfig.Keyspace, "keyspace", CliConfig.Keyspace, "cassandra keyspace to use for storing the metric data table")
6869
cas.StringVar(&CliConfig.Consistency, "consistency", CliConfig.Consistency, "write consistency (any|one|two|three|quorum|all|local_quorum|each_quorum|local_one")
6970
cas.StringVar(&CliConfig.HostSelectionPolicy, "host-selection-policy", CliConfig.HostSelectionPolicy, "")
70-
cas.IntVar(&CliConfig.Timeout, "timeout", CliConfig.Timeout, "cassandra timeout in milliseconds")
71+
cas.DurationVar(&CliConfig.Timeout, "timeout", CliConfig.Timeout, "cassandra timeout")
7172
cas.IntVar(&CliConfig.ReadConcurrency, "read-concurrency", CliConfig.ReadConcurrency, "max number of concurrent reads to cassandra.")
7273
cas.IntVar(&CliConfig.WriteConcurrency, "write-concurrency", CliConfig.WriteConcurrency, "max number of concurrent writes to cassandra.")
7374
cas.IntVar(&CliConfig.ReadQueueSize, "read-queue-size", CliConfig.ReadQueueSize, "max number of outstanding reads before reads will be dropped. This is important if you run queries that result in many reads in parallel.")

0 commit comments

Comments
 (0)