Skip to content

Commit

Permalink
🔧 Revise backup/meta Cassandra default values (#336)
Browse files Browse the repository at this point in the history
* 🔧 Revise default values of Cassandra configs

Signed-off-by: Rintaro Okamura <[email protected]>

* 🔧 Fix write-coalesce-wait-time

Signed-off-by: Rintaro Okamura <[email protected]>

* ♻️ Refactor default values

Signed-off-by: Rintaro Okamura <[email protected]>

* 🤖 Update license headers and formatting go codes

Signed-off-by: vdaas-ci <[email protected]>

Co-authored-by: vdaas-ci <[email protected]>
  • Loading branch information
rinx and vdaas-ci authored Apr 20, 2020
1 parent 6b0baa2 commit bb36f8a
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 66 deletions.
24 changes: 12 additions & 12 deletions charts/vald/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ backupManager:
# backupManager.cassandra.config.timeout -- timeout
timeout: 600ms
# backupManager.cassandra.config.connect_timeout -- connect timeout
connect_timeout: 600ms
connect_timeout: 3s
# backupManager.cassandra.config.port -- cassandra port
port: 9042
# backupManager.cassandra.config.keyspace -- cassandra keyspace
Expand All @@ -1263,14 +1263,14 @@ backupManager:
# backupManager.cassandra.config.retry_policy.num_retries -- number of retries
num_retries: 3
# backupManager.cassandra.config.retry_policy.min_duration -- minimum duration to retry
min_duration: 1s
min_duration: 10ms
# backupManager.cassandra.config.retry_policy.max_duration -- maximum duration to retry
max_duration: 30s
max_duration: 1s
reconnection_policy:
# backupManager.cassandra.config.reconnection_policy.max_retries -- maximum number of retries to reconnect
max_retries: 3
# backupManager.cassandra.config.reconnection_policy.initial_interval -- initial interval to reconnect
initial_interval: 1m
initial_interval: 100ms
# backupManager.cassandra.config.socket_keepalive -- socket keep alive time
socket_keepalive: 0s
# backupManager.cassandra.config.max_prepared_stmts -- maximum number of prepared statements
Expand Down Expand Up @@ -1308,7 +1308,7 @@ backupManager:
# backupManager.cassandra.config.default_timestamp -- default timestamp enabled
default_timestamp: true
# backupManager.cassandra.config.reconnect_interval -- interval of reconnection
reconnect_interval: 1m
reconnect_interval: 100ms
# backupManager.cassandra.config.max_wait_schema_agreement -- maximum duration to wait for schema agreement
max_wait_schema_agreement: 1m
# backupManager.cassandra.config.ignore_peer_addr -- ignore peer addresses
Expand All @@ -1324,7 +1324,7 @@ backupManager:
# backupManager.cassandra.config.default_idempotence -- default idempotence enabled
default_idempotence: false
# backupManager.cassandra.config.write_coalesce_wait_time -- write coalesce wait time
write_coalesce_wait_time: 200ms
write_coalesce_wait_time: 200µs
# backupManager.cassandra.config.meta_table -- table name of backup
meta_table: meta_vector
pool_config:
Expand Down Expand Up @@ -1748,7 +1748,7 @@ meta:
# meta.cassandra.config.timeout -- timeout
timeout: 600ms
# meta.cassandra.config.connect_timeout -- connect timeout
connect_timeout: 600ms
connect_timeout: 3s
# meta.cassandra.config.port -- cassandra port
port: 9042
# meta.cassandra.config.keyspace -- cassandra keyspace
Expand All @@ -1765,14 +1765,14 @@ meta:
# meta.cassandra.config.retry_policy.num_retries -- number of retries
num_retries: 3
# meta.cassandra.config.retry_policy.min_duration -- minimum duration to retry
min_duration: 1s
min_duration: 10ms
# meta.cassandra.config.retry_policy.max_duration -- maximum duration to retry
max_duration: 30s
max_duration: 1s
reconnection_policy:
# meta.cassandra.config.reconnection_policy.max_retries -- maximum number of retries to reconnect
max_retries: 3
# meta.cassandra.config.reconnection_policy.initial_interval -- initial interval to reconnect
initial_interval: 1m
initial_interval: 100ms
# meta.cassandra.config.socket_keepalive -- socket keep alive time
socket_keepalive: 0s
# meta.cassandra.config.max_prepared_stmts -- maximum number of prepared statements
Expand Down Expand Up @@ -1810,7 +1810,7 @@ meta:
# meta.cassandra.config.default_timestamp -- default timestamp enabled
default_timestamp: true
# meta.cassandra.config.reconnect_interval -- interval of reconnection
reconnect_interval: 1m
reconnect_interval: 100ms
# meta.cassandra.config.max_wait_schema_agreement -- maximum duration to wait for schema agreement
max_wait_schema_agreement: 1m
# meta.cassandra.config.ignore_peer_addr -- ignore peer addresses
Expand All @@ -1826,7 +1826,7 @@ meta:
# meta.cassandra.config.default_idempotence -- default idempotence enabled
default_idempotence: false
# meta.cassandra.config.write_coalesce_wait_time -- write coalesce wait time
write_coalesce_wait_time: 200ms
write_coalesce_wait_time: 200µs
# meta.cassandra.config.meta_table -- table name of backup
meta_table: meta_vector
pool_config:
Expand Down
17 changes: 7 additions & 10 deletions internal/config/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,13 @@ func (cfg *Cassandra) Opts() (opts []cassandra.Option, err error) {
}

if cfg.PoolConfig != nil {
opts = append(opts, cassandra.WithDC(cfg.PoolConfig.DataCenter))
if cfg.PoolConfig.DCAwareRouting {
opts = append(opts, cassandra.WithEnableDCAwareRouting())
}
if cfg.PoolConfig.NonLocalReplicasFallback {
opts = append(opts, cassandra.WithEnableNonLocalReplicasFallback())
}
if cfg.PoolConfig.ShuffleReplicas {
opts = append(opts, cassandra.WithEnableShuffleReplicas())
}
opts = append(
opts,
cassandra.WithDC(cfg.PoolConfig.DataCenter),
cassandra.WithDCAwareRouting(cfg.PoolConfig.DCAwareRouting),
cassandra.WithNonLocalReplicasFallback(cfg.PoolConfig.NonLocalReplicasFallback),
cassandra.WithShuffleReplicas(cfg.PoolConfig.ShuffleReplicas),
)
}

if cfg.TCP != nil {
Expand Down
60 changes: 30 additions & 30 deletions internal/db/nosql/cassandra/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,30 @@ type Option func(*client) error

var (
defaultOpts = []Option{
WithDisableDCAwareRouting(),
WithDisableNonLocalReplicasFallback(),
WithDisableShuffleReplicas(),
WithCQLVersion("3.0.0"),
WithProtoVersion(0),
WithTimeout("600ms"),
WithConnectTimeout("600ms"),
WithPort(9042),
WithNumConns(2),
WithConsistency("quorum"),
WithMaxPreparedStmts(1000),
WithMaxRoutingKeyInfo(1000),
WithPageSize(5000),
WithEnableHostVerification(false),
WithDefaultTimestamp(true),
WithReconnectInterval("1m"),
WithMaxWaitSchemaAgreement("1m"),
WithIgnorePeerAddr(false),
WithDisableInitialHostLookup(false),
WithDisableNodeStatusEvents(false),
WithDisableTopologyEvents(false),
WithDisableSkipMetadata(false),
WithDefaultIdempotence(false),
WithWriteCoalesceWaitTime("200µs"),
WithDCAwareRouting(false),
WithNonLocalReplicasFallback(false),
WithShuffleReplicas(false),
}
)

Expand Down Expand Up @@ -309,44 +330,23 @@ func WithDC(name string) Option {
}
}

func WithEnableDCAwareRouting() Option {
func WithDCAwareRouting(dc_aware_routing bool) Option {
return func(c *client) error {
c.poolConfig.enableDCAwareRouting = true
c.poolConfig.enableDCAwareRouting = dc_aware_routing
return nil
}
}

func WithDisableDCAwareRouting() Option {
func WithNonLocalReplicasFallback(non_local_replicas_fallback bool) Option {
return func(c *client) error {
c.poolConfig.enableDCAwareRouting = false
c.poolConfig.enableNonLocalReplicasFallback = non_local_replicas_fallback
return nil
}
}

func WithEnableNonLocalReplicasFallback() Option {
func WithShuffleReplicas(shuffle_replicas bool) Option {
return func(c *client) error {
c.poolConfig.enableNonLocalReplicasFallback = true
return nil
}
}

func WithDisableNonLocalReplicasFallback() Option {
return func(c *client) error {
c.poolConfig.enableNonLocalReplicasFallback = false
return nil
}
}

func WithEnableShuffleReplicas() Option {
return func(c *client) error {
c.poolConfig.enableShuffleReplicas = true
return nil
}
}

func WithDisableShuffleReplicas() Option {
return func(c *client) error {
c.poolConfig.enableShuffleReplicas = false
c.poolConfig.enableShuffleReplicas = shuffle_replicas
return nil
}
}
Expand Down
8 changes: 4 additions & 4 deletions k8s/agent/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ spec:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- vald-agent-ngt
- key: app
operator: In
values:
- vald-agent-ngt
topologyKey: kubernetes.io/hostname
weight: 100
requiredDuringSchedulingIgnoredDuringExecution: []
Expand Down
8 changes: 4 additions & 4 deletions k8s/discoverer/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ spec:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- vald-discoverer
- key: app
operator: In
values:
- vald-discoverer
topologyKey: kubernetes.io/hostname
weight: 100
requiredDuringSchedulingIgnoredDuringExecution: []
Expand Down
8 changes: 4 additions & 4 deletions k8s/gateway/vald/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ spec:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- vald-gateway
- key: app
operator: In
values:
- vald-gateway
topologyKey: kubernetes.io/hostname
weight: 100
requiredDuringSchedulingIgnoredDuringExecution: []
Expand Down
3 changes: 1 addition & 2 deletions k8s/operator/helm/valdrelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ metadata:
name: vald-cluster
namespace: default
# the values of Helm chart for Vald can be placed under the `spec` field.
spec:
{}
spec: {}

0 comments on commit bb36f8a

Please sign in to comment.