From e7c594b6e07eeca7ed2f2226debf1e129ff5d344 Mon Sep 17 00:00:00 2001 From: chulin <316014408@qq.com> Date: Wed, 30 Nov 2016 13:58:52 +0800 Subject: [PATCH] . --- weed/filer/cassandra_store/cassandra_store.go | 15 +++++++++------ weed/server/volume_server_handlers_read.go | 2 +- weed/topology/topology_vacuum.go | 7 +++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/weed/filer/cassandra_store/cassandra_store.go b/weed/filer/cassandra_store/cassandra_store.go index 50a792a65..b58c7779b 100644 --- a/weed/filer/cassandra_store/cassandra_store.go +++ b/weed/filer/cassandra_store/cassandra_store.go @@ -2,6 +2,7 @@ package cassandra_store import ( "fmt" + "strings" "github.com/chrislusf/seaweedfs/weed/filer" "github.com/chrislusf/seaweedfs/weed/glog" @@ -10,29 +11,31 @@ import ( ) /* - Basically you need a table just like this: - CREATE TABLE seaweed_files ( path varchar, fids list, PRIMARY KEY (path) ); - Need to match flat_namespace.FlatNamespaceStore interface Put(fullFileName string, fid string) (err error) Get(fullFileName string) (fid string, err error) Delete(fullFileName string) (fid string, err error) - */ type CassandraStore struct { cluster *gocql.ClusterConfig 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 Recommended! 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() diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.go index 05631a515..49027a135 100644 --- a/weed/server/volume_server_handlers_read.go +++ b/weed/server/volume_server_handlers_read.go @@ -112,7 +112,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request) mtype = mt } } - + ext = strings.ToLower(ext) // 后缀先转小写,防止匹配不上大写的后缀 if ext != ".gz" { if n.IsGzipped() { if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { diff --git a/weed/topology/topology_vacuum.go b/weed/topology/topology_vacuum.go index 3a6fcbae2..a7ef52336 100644 --- a/weed/topology/topology_vacuum.go +++ b/weed/topology/topology_vacuum.go @@ -86,7 +86,14 @@ func (t *Topology) Vacuum(garbageThreshold string) int { for _, vl := range c.storageType2VolumeLayout.Items() { if vl != nil { volumeLayout := vl.(*VolumeLayout) + writableSet := make(map[storage.VolumeId]bool) + for _, id := range volumeLayout.writables { + writableSet[id] = true + } for vid, locationlist := range volumeLayout.vid2location { + if _, isWritable := writableSet[vid]; !isWritable { + continue + } glog.V(0).Infof("check vacuum on collection:%s volume:%d", c.Name, vid) if batchVacuumVolumeCheck(volumeLayout, vid, locationlist, garbageThreshold) { if batchVacuumVolumeCompact(volumeLayout, vid, locationlist) {