diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2022-01-17 23:35:13 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-17 23:35:13 -0800 |
| commit | ec254d8a891386a1d16adc9e0b1e69fd5c307f7c (patch) | |
| tree | a0bde782ddbe72ef1e615bc3a1034b0fcbf23623 | |
| parent | 9274557552e3f3f4b6f7071c47ba8d7aa5c6f64a (diff) | |
| parent | da9540e6660d99fa5cfe55e8a1599fe89e80c562 (diff) | |
| download | seaweedfs-ec254d8a891386a1d16adc9e0b1e69fd5c307f7c.tar.xz seaweedfs-ec254d8a891386a1d16adc9e0b1e69fd5c307f7c.zip | |
Merge pull request #2597 from guol-fnst/gocql_to
add gocql timeout setting
| -rw-r--r-- | weed/command/scaffold/filer.toml | 2 | ||||
| -rw-r--r-- | weed/filer/cassandra/cassandra_store.go | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/weed/command/scaffold/filer.toml b/weed/command/scaffold/filer.toml index a6a45923e..77c6cd58b 100644 --- a/weed/command/scaffold/filer.toml +++ b/weed/command/scaffold/filer.toml @@ -153,6 +153,8 @@ password = "" superLargeDirectories = [] # Name of the datacenter local to this filer, used as host selection fallback. localDC = "" +# Gocql connection timeout, default: 600ms +connection_timeout_millisecond = 600 [hbase] enabled = false diff --git a/weed/filer/cassandra/cassandra_store.go b/weed/filer/cassandra/cassandra_store.go index fc0b52ac7..fb61b0771 100644 --- a/weed/filer/cassandra/cassandra_store.go +++ b/weed/filer/cassandra/cassandra_store.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "github.com/gocql/gocql" + "time" "github.com/chrislusf/seaweedfs/weed/filer" "github.com/chrislusf/seaweedfs/weed/glog" @@ -33,6 +34,7 @@ func (store *CassandraStore) Initialize(configuration util.Configuration, prefix configuration.GetString(prefix+"password"), configuration.GetStringSlice(prefix+"superLargeDirectories"), configuration.GetString(prefix+"localDC"), + configuration.GetInt(prefix+"connection_timeout_millisecond"), ) } @@ -41,12 +43,14 @@ func (store *CassandraStore) isSuperLargeDirectory(dir string) (dirHash string, return } -func (store *CassandraStore) initialize(keyspace string, hosts []string, username string, password string, superLargeDirectories []string, localDC string) (err error) { +func (store *CassandraStore) initialize(keyspace string, hosts []string, username string, password string, superLargeDirectories []string, localDC string, timeout int) (err error) { store.cluster = gocql.NewCluster(hosts...) if username != "" && password != "" { store.cluster.Authenticator = gocql.PasswordAuthenticator{Username: username, Password: password} } store.cluster.Keyspace = keyspace + store.cluster.Timeout = time.Duration(timeout) * time.Millisecond + glog.V(0).Infof("timeout = %d", timeout) fallback := gocql.RoundRobinHostPolicy() if localDC != "" { fallback = gocql.DCAwareRoundRobinPolicy(localDC) |
