Merge pull request #406 from eshujiushiwo/master

Fix the filer connection of cassandra
This commit is contained in:
Chris Lu 2016-11-28 20:05:45 -08:00 committed by GitHub
commit 924f797c58

View file

@ -2,7 +2,7 @@ package cassandra_store
import (
"fmt"
"strings"
"github.com/chrislusf/seaweedfs/weed/filer"
"github.com/chrislusf/seaweedfs/weed/glog"
@ -30,9 +30,15 @@ type CassandraStore struct {
session *gocql.Session
}
func NewCassandraStore(keyspace string, hosts ...string) (c *CassandraStore, err error) {
func NewCassandraStore(keyspace string, hosts string) (c *CassandraStore, err error) {
c = &CassandraStore{}
c.cluster = gocql.NewCluster(hosts...)
s := strings.Split(hosts, ",")
if len(s) == 1 {
glog.V(2).Info("Only one cassandra node to connect!A Cluster is Proposed!Now using:", string(hosts))
c.cluster = gocql.NewCluster(hosts)
} else if len(s) > 1 {
c.cluster = gocql.NewCluster(s...)
}
c.cluster.Keyspace = keyspace
c.cluster.Consistency = gocql.Quorum
c.session, err = c.cluster.CreateSession()