From 5385bf9555f32adefe25457c025b2e895d94ac7c Mon Sep 17 00:00:00 2001 From: eshujiushiwo <378013446@qq.com> Date: Mon, 28 Nov 2016 11:27:40 +0800 Subject: [PATCH 1/7] update cassandra connections update cassandra connections --- weed/filer/cassandra_store/cassandra_store.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/weed/filer/cassandra_store/cassandra_store.go b/weed/filer/cassandra_store/cassandra_store.go index 50a792a65..e9e1d9222 100644 --- a/weed/filer/cassandra_store/cassandra_store.go +++ b/weed/filer/cassandra_store/cassandra_store.go @@ -32,7 +32,12 @@ type CassandraStore struct { 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 { + c.cluster = gocql.NewCluster(hosts...) + } else if len(s) > 1 { + c.cluster = gocql.NewCluster(s[0], s[1]) + } c.cluster.Keyspace = keyspace c.cluster.Consistency = gocql.Quorum c.session, err = c.cluster.CreateSession() From 89ccb6be05a82631377ddbdbe117df51958bbbf1 Mon Sep 17 00:00:00 2001 From: eshujiushiwo <378013446@qq.com> Date: Mon, 28 Nov 2016 12:16:51 +0800 Subject: [PATCH 2/7] Update cassandra_store.go --- weed/filer/cassandra_store/cassandra_store.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/weed/filer/cassandra_store/cassandra_store.go b/weed/filer/cassandra_store/cassandra_store.go index e9e1d9222..3005fead9 100644 --- a/weed/filer/cassandra_store/cassandra_store.go +++ b/weed/filer/cassandra_store/cassandra_store.go @@ -34,8 +34,11 @@ func NewCassandraStore(keyspace string, hosts ...string) (c *CassandraStore, err c = &CassandraStore{} s := strings.Split(hosts, ",") if len(s) == 1 { + fmt.Println("000") c.cluster = gocql.NewCluster(hosts...) } else if len(s) > 1 { + fmt.Println("111",s[0]) + fmt.Println("222",s[1]) c.cluster = gocql.NewCluster(s[0], s[1]) } c.cluster.Keyspace = keyspace From 809aa028ec7be5c6f19945d81d3b3456780b2bc2 Mon Sep 17 00:00:00 2001 From: eshujiushiwo <378013446@qq.com> Date: Mon, 28 Nov 2016 15:01:04 +0800 Subject: [PATCH 3/7] fix the connection of cassandra fix the connection of cassandra ,let filer can connect to multi cassandra nodes which are in the one cluster --- weed/filer/cassandra_store/cassandra_store.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/weed/filer/cassandra_store/cassandra_store.go b/weed/filer/cassandra_store/cassandra_store.go index 3005fead9..0431872fa 100644 --- a/weed/filer/cassandra_store/cassandra_store.go +++ b/weed/filer/cassandra_store/cassandra_store.go @@ -2,7 +2,7 @@ package cassandra_store import ( "fmt" - + "strings" "github.com/chrislusf/seaweedfs/weed/filer" "github.com/chrislusf/seaweedfs/weed/glog" @@ -34,11 +34,8 @@ func NewCassandraStore(keyspace string, hosts ...string) (c *CassandraStore, err c = &CassandraStore{} s := strings.Split(hosts, ",") if len(s) == 1 { - fmt.Println("000") c.cluster = gocql.NewCluster(hosts...) } else if len(s) > 1 { - fmt.Println("111",s[0]) - fmt.Println("222",s[1]) c.cluster = gocql.NewCluster(s[0], s[1]) } c.cluster.Keyspace = keyspace From 3e29d0f75b974294718c5050ef5adabcbbab2e51 Mon Sep 17 00:00:00 2001 From: eshujiushiwo <378013446@qq.com> Date: Mon, 28 Nov 2016 15:14:19 +0800 Subject: [PATCH 4/7] Update cassandra_store.go --- weed/filer/cassandra_store/cassandra_store.go | 1 + 1 file changed, 1 insertion(+) diff --git a/weed/filer/cassandra_store/cassandra_store.go b/weed/filer/cassandra_store/cassandra_store.go index 0431872fa..f4ff5ef3e 100644 --- a/weed/filer/cassandra_store/cassandra_store.go +++ b/weed/filer/cassandra_store/cassandra_store.go @@ -34,6 +34,7 @@ func NewCassandraStore(keyspace string, hosts ...string) (c *CassandraStore, err c = &CassandraStore{} s := strings.Split(hosts, ",") if len(s) == 1 { + glog.V(0).Infof("Only one cassandra node to connect!A Cluster is Proposed" ) c.cluster = gocql.NewCluster(hosts...) } else if len(s) > 1 { c.cluster = gocql.NewCluster(s[0], s[1]) From 3450eff2886f38594154bee4b1b389787c0be575 Mon Sep 17 00:00:00 2001 From: eshujiushiwo <378013446@qq.com> Date: Mon, 28 Nov 2016 15:32:16 +0800 Subject: [PATCH 5/7] fix info log fix info log --- weed/filer/cassandra_store/cassandra_store.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weed/filer/cassandra_store/cassandra_store.go b/weed/filer/cassandra_store/cassandra_store.go index f4ff5ef3e..6b7779bb6 100644 --- a/weed/filer/cassandra_store/cassandra_store.go +++ b/weed/filer/cassandra_store/cassandra_store.go @@ -34,7 +34,8 @@ func NewCassandraStore(keyspace string, hosts ...string) (c *CassandraStore, err c = &CassandraStore{} s := strings.Split(hosts, ",") if len(s) == 1 { - glog.V(0).Infof("Only one cassandra node to connect!A Cluster is Proposed" ) + + 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[0], s[1]) From 5ee7fdc0cc424b508bec85fccab671285359dd2e Mon Sep 17 00:00:00 2001 From: eshujiushiwo <378013446@qq.com> Date: Mon, 28 Nov 2016 16:03:39 +0800 Subject: [PATCH 6/7] fix hosts strings fix hosts strings --- weed/filer/cassandra_store/cassandra_store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weed/filer/cassandra_store/cassandra_store.go b/weed/filer/cassandra_store/cassandra_store.go index 6b7779bb6..35221d7ee 100644 --- a/weed/filer/cassandra_store/cassandra_store.go +++ b/weed/filer/cassandra_store/cassandra_store.go @@ -30,13 +30,13 @@ 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{} 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...) + c.cluster = gocql.NewCluster(hosts) } else if len(s) > 1 { c.cluster = gocql.NewCluster(s[0], s[1]) } From e025fc00a49db8eebb6df8e83a3c890f55ca5c14 Mon Sep 17 00:00:00 2001 From: eshujiushiwo <378013446@qq.com> Date: Mon, 28 Nov 2016 18:23:39 +0800 Subject: [PATCH 7/7] let filer use all cassandra server let filer use all cassandra server --- weed/filer/cassandra_store/cassandra_store.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/weed/filer/cassandra_store/cassandra_store.go b/weed/filer/cassandra_store/cassandra_store.go index 35221d7ee..c9ea88735 100644 --- a/weed/filer/cassandra_store/cassandra_store.go +++ b/weed/filer/cassandra_store/cassandra_store.go @@ -34,11 +34,10 @@ func NewCassandraStore(keyspace string, hosts string) (c *CassandraStore, err er c = &CassandraStore{} 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[0], s[1]) + c.cluster = gocql.NewCluster(s...) } c.cluster.Keyspace = keyspace c.cluster.Consistency = gocql.Quorum