Browse Source

.

pull/439/head
chulin 9 years ago
parent
commit
e7c594b6e0
  1. 15
      weed/filer/cassandra_store/cassandra_store.go
  2. 2
      weed/server/volume_server_handlers_read.go
  3. 7
      weed/topology/topology_vacuum.go

15
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<varchar>,
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()

2
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") {

7
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) {

Loading…
Cancel
Save