aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2
diff options
context:
space:
mode:
Diffstat (limited to 'weed/filer2')
-rw-r--r--weed/filer2/abstract_sql/abstract_sql_store.go2
-rw-r--r--weed/filer2/cassandra/cassandra_store.go2
-rw-r--r--weed/filer2/configuration.go20
-rw-r--r--weed/filer2/entry.go2
-rw-r--r--weed/filer2/entry_codec.go4
-rw-r--r--weed/filer2/filechunks.go2
-rw-r--r--weed/filer2/filechunks_test.go30
-rw-r--r--weed/filer2/filer.go26
-rw-r--r--weed/filer2/filerstore.go4
-rw-r--r--weed/filer2/fullpath.go2
-rw-r--r--weed/filer2/leveldb/leveldb_store.go10
-rw-r--r--weed/filer2/leveldb/leveldb_store_test.go2
-rw-r--r--weed/filer2/memdb/memdb_store.go4
-rw-r--r--weed/filer2/memdb/memdb_store_test.go2
-rw-r--r--weed/filer2/mysql/mysql_store.go6
-rw-r--r--weed/filer2/postgres/postgres_store.go6
-rw-r--r--weed/filer2/redis/redis_store.go2
17 files changed, 62 insertions, 64 deletions
diff --git a/weed/filer2/abstract_sql/abstract_sql_store.go b/weed/filer2/abstract_sql/abstract_sql_store.go
index e924fa16a..aa3b82c5b 100644
--- a/weed/filer2/abstract_sql/abstract_sql_store.go
+++ b/weed/filer2/abstract_sql/abstract_sql_store.go
@@ -1,8 +1,8 @@
package abstract_sql
import (
- "fmt"
"database/sql"
+ "fmt"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
diff --git a/weed/filer2/cassandra/cassandra_store.go b/weed/filer2/cassandra/cassandra_store.go
index 316b6cce0..a1e63b87d 100644
--- a/weed/filer2/cassandra/cassandra_store.go
+++ b/weed/filer2/cassandra/cassandra_store.go
@@ -2,9 +2,9 @@ package cassandra
import (
"fmt"
- "github.com/gocql/gocql"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
+ "github.com/gocql/gocql"
"github.com/spf13/viper"
)
diff --git a/weed/filer2/configuration.go b/weed/filer2/configuration.go
index 16c0f3fd0..46ed9e056 100644
--- a/weed/filer2/configuration.go
+++ b/weed/filer2/configuration.go
@@ -3,8 +3,8 @@ package filer2
import (
"os"
- "github.com/spf13/viper"
"github.com/chrislusf/seaweedfs/weed/glog"
+ "github.com/spf13/viper"
)
const (
@@ -20,12 +20,11 @@ enabled = false
enabled = false
dir = "." # directory to store level db files
-[mysql]
+####################################################
# multiple filers on shared storage, fairly scalable
-#
-# need to choose or create a database.
-# need to manually create a table "filemeta".
-#
+####################################################
+
+[mysql]
# CREATE TABLE IF NOT EXISTS filemeta (
# dirhash BIGINT COMMENT 'first 64 bits of MD5 hash value of directory field',
# name VARCHAR(1000) COMMENT 'directory or file name',
@@ -33,7 +32,6 @@ dir = "." # directory to store level db files
# meta BLOB,
# PRIMARY KEY (dirhash, name)
# ) DEFAULT CHARSET=utf8;
-#
enabled = true
hostname = "localhost"
port = 3306
@@ -90,10 +88,10 @@ var (
func (f *Filer) LoadConfiguration() {
// find a filer store
- viper.SetConfigName("filer") // name of config file (without extension)
- viper.AddConfigPath(".") // optionally look for config in the working directory
- viper.AddConfigPath("$HOME/.seaweedfs") // call multiple times to add many search paths
- viper.AddConfigPath("/etc/seaweedfs/") // path to look for the config file in
+ viper.SetConfigName("filer") // name of config file (without extension)
+ viper.AddConfigPath(".") // optionally look for config in the working directory
+ viper.AddConfigPath("$HOME/.seaweedfs") // call multiple times to add many search paths
+ viper.AddConfigPath("/etc/seaweedfs/") // path to look for the config file in
if err := viper.ReadInConfig(); err != nil { // Handle errors reading the config file
glog.Fatalf("Failed to load filer.toml file from current directory, or $HOME/.seaweedfs/, or /etc/seaweedfs/" +
"\n\nPlease follow this example and add a filer.toml file to " +
diff --git a/weed/filer2/entry.go b/weed/filer2/entry.go
index f741d4bb3..cf7ad08aa 100644
--- a/weed/filer2/entry.go
+++ b/weed/filer2/entry.go
@@ -15,7 +15,7 @@ type Attr struct {
Gid uint32 // group gid
}
-func (attr Attr) IsDirectory() (bool) {
+func (attr Attr) IsDirectory() bool {
return attr.Mode&os.ModeDir > 0
}
diff --git a/weed/filer2/entry_codec.go b/weed/filer2/entry_codec.go
index 7fafea3e3..8019b2193 100644
--- a/weed/filer2/entry_codec.go
+++ b/weed/filer2/entry_codec.go
@@ -4,9 +4,9 @@ import (
"os"
"time"
+ "fmt"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/gogo/protobuf/proto"
- "fmt"
)
func (entry *Entry) EncodeAttributesAndChunks() ([]byte, error) {
@@ -23,7 +23,7 @@ func (entry *Entry) EncodeAttributesAndChunks() ([]byte, error) {
return proto.Marshal(message)
}
-func (entry *Entry) DecodeAttributesAndChunks(blob []byte) (error) {
+func (entry *Entry) DecodeAttributesAndChunks(blob []byte) error {
message := &filer_pb.Entry{}
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go
index 5877f2f71..86b1a85b5 100644
--- a/weed/filer2/filechunks.go
+++ b/weed/filer2/filechunks.go
@@ -1,9 +1,9 @@
package filer2
import (
- "sort"
"log"
"math"
+ "sort"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
)
diff --git a/weed/filer2/filechunks_test.go b/weed/filer2/filechunks_test.go
index 033e66b1e..134bb9c19 100644
--- a/weed/filer2/filechunks_test.go
+++ b/weed/filer2/filechunks_test.go
@@ -1,8 +1,8 @@
package filer2
import (
- "testing"
"log"
+ "testing"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
)
@@ -163,9 +163,9 @@ func TestChunksReading(t *testing.T) {
Offset: 0,
Size: 250,
Expected: []*ChunkView{
- {Offset: 0, Size: 100, FileId: "abc", LogicOffset:0},
- {Offset: 0, Size: 100, FileId: "asdf", LogicOffset:100},
- {Offset: 0, Size: 50, FileId: "fsad", LogicOffset:200},
+ {Offset: 0, Size: 100, FileId: "abc", LogicOffset: 0},
+ {Offset: 0, Size: 100, FileId: "asdf", LogicOffset: 100},
+ {Offset: 0, Size: 50, FileId: "fsad", LogicOffset: 200},
},
},
// case 1: updates overwrite full chunks
@@ -177,7 +177,7 @@ func TestChunksReading(t *testing.T) {
Offset: 50,
Size: 100,
Expected: []*ChunkView{
- {Offset: 50, Size: 100, FileId: "asdf", LogicOffset:50},
+ {Offset: 50, Size: 100, FileId: "asdf", LogicOffset: 50},
},
},
// case 2: updates overwrite part of previous chunks
@@ -189,8 +189,8 @@ func TestChunksReading(t *testing.T) {
Offset: 25,
Size: 50,
Expected: []*ChunkView{
- {Offset: 25, Size: 25, FileId: "asdf", LogicOffset:25},
- {Offset: 0, Size: 25, FileId: "abc", LogicOffset:50},
+ {Offset: 25, Size: 25, FileId: "asdf", LogicOffset: 25},
+ {Offset: 0, Size: 25, FileId: "abc", LogicOffset: 50},
},
},
// case 3: updates overwrite full chunks
@@ -203,8 +203,8 @@ func TestChunksReading(t *testing.T) {
Offset: 0,
Size: 200,
Expected: []*ChunkView{
- {Offset: 0, Size: 50, FileId: "asdf", LogicOffset:0},
- {Offset: 0, Size: 150, FileId: "xxxx", LogicOffset:50},
+ {Offset: 0, Size: 50, FileId: "asdf", LogicOffset: 0},
+ {Offset: 0, Size: 150, FileId: "xxxx", LogicOffset: 50},
},
},
// case 4: updates far away from prev chunks
@@ -217,7 +217,7 @@ func TestChunksReading(t *testing.T) {
Offset: 0,
Size: 400,
Expected: []*ChunkView{
- {Offset: 0, Size: 200, FileId: "asdf", LogicOffset:0},
+ {Offset: 0, Size: 200, FileId: "asdf", LogicOffset: 0},
// {Offset: 0, Size: 150, FileId: "xxxx"}, // missing intervals should not happen
},
},
@@ -232,8 +232,8 @@ func TestChunksReading(t *testing.T) {
Offset: 0,
Size: 220,
Expected: []*ChunkView{
- {Offset: 0, Size: 200, FileId: "asdf", LogicOffset:0},
- {Offset: 0, Size: 20, FileId: "abc", LogicOffset:200},
+ {Offset: 0, Size: 200, FileId: "asdf", LogicOffset: 0},
+ {Offset: 0, Size: 20, FileId: "abc", LogicOffset: 200},
},
},
// case 6: same updates
@@ -246,7 +246,7 @@ func TestChunksReading(t *testing.T) {
Offset: 0,
Size: 100,
Expected: []*ChunkView{
- {Offset: 0, Size: 100, FileId: "abc", LogicOffset:0},
+ {Offset: 0, Size: 100, FileId: "abc", LogicOffset: 0},
},
},
// case 7: edge cases
@@ -259,8 +259,8 @@ func TestChunksReading(t *testing.T) {
Offset: 0,
Size: 200,
Expected: []*ChunkView{
- {Offset: 0, Size: 100, FileId: "abc", LogicOffset:0},
- {Offset: 0, Size: 100, FileId: "asdf", LogicOffset:100},
+ {Offset: 0, Size: 100, FileId: "abc", LogicOffset: 0},
+ {Offset: 0, Size: 100, FileId: "asdf", LogicOffset: 100},
},
},
}
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go
index 35d69b32e..f182adb13 100644
--- a/weed/filer2/filer.go
+++ b/weed/filer2/filer.go
@@ -3,12 +3,12 @@ package filer2
import (
"fmt"
+ "github.com/chrislusf/seaweedfs/weed/glog"
"github.com/karlseguin/ccache"
- "strings"
+ "os"
"path/filepath"
+ "strings"
"time"
- "os"
- "github.com/chrislusf/seaweedfs/weed/glog"
)
type Filer struct {
@@ -24,15 +24,15 @@ func NewFiler(master string) *Filer {
}
}
-func (f *Filer) SetStore(store FilerStore) () {
+func (f *Filer) SetStore(store FilerStore) {
f.store = store
}
-func (f *Filer) DisableDirectoryCache() () {
+func (f *Filer) DisableDirectoryCache() {
f.directoryCache = nil
}
-func (f *Filer) CreateEntry(entry *Entry) (error) {
+func (f *Filer) CreateEntry(entry *Entry) error {
dirParts := strings.Split(string(entry.FullPath), "/")
@@ -94,11 +94,11 @@ func (f *Filer) CreateEntry(entry *Entry) (error) {
}
/*
- if !hasWritePermission(lastDirectoryEntry, entry) {
- glog.V(0).Infof("directory %s: %v, entry: uid=%d gid=%d",
- lastDirectoryEntry.FullPath, lastDirectoryEntry.Attr, entry.Uid, entry.Gid)
- return fmt.Errorf("no write permission in folder %v", lastDirectoryEntry.FullPath)
- }
+ if !hasWritePermission(lastDirectoryEntry, entry) {
+ glog.V(0).Infof("directory %s: %v, entry: uid=%d gid=%d",
+ lastDirectoryEntry.FullPath, lastDirectoryEntry.Attr, entry.Uid, entry.Gid)
+ return fmt.Errorf("no write permission in folder %v", lastDirectoryEntry.FullPath)
+ }
*/
if err := f.store.InsertEntry(entry); err != nil {
@@ -135,12 +135,12 @@ func (f *Filer) DeleteEntry(p FullPath) (fileEntry *Entry, err error) {
func (f *Filer) ListDirectoryEntries(p FullPath, startFileName string, inclusive bool, limit int) ([]*Entry, error) {
if strings.HasSuffix(string(p), "/") && len(p) > 1 {
- p = p[0:len(p)-1]
+ p = p[0 : len(p)-1]
}
return f.store.ListDirectoryEntries(p, startFileName, inclusive, limit)
}
-func (f *Filer) cacheGetDirectory(dirpath string) (*Entry) {
+func (f *Filer) cacheGetDirectory(dirpath string) *Entry {
if f.directoryCache == nil {
return nil
}
diff --git a/weed/filer2/filerstore.go b/weed/filer2/filerstore.go
index b9f7d1198..a5cd3352e 100644
--- a/weed/filer2/filerstore.go
+++ b/weed/filer2/filerstore.go
@@ -7,8 +7,8 @@ import (
type FilerStore interface {
GetName() string
- Initialize(viper *viper.Viper) (error)
- InsertEntry(*Entry) (error)
+ Initialize(viper *viper.Viper) error
+ InsertEntry(*Entry) error
UpdateEntry(*Entry) (err error)
FindEntry(FullPath) (entry *Entry, err error)
DeleteEntry(FullPath) (fileEntry *Entry, err error)
diff --git a/weed/filer2/fullpath.go b/weed/filer2/fullpath.go
index 20e42e9b9..be6e34431 100644
--- a/weed/filer2/fullpath.go
+++ b/weed/filer2/fullpath.go
@@ -25,7 +25,7 @@ func (fp FullPath) DirAndName() (string, string) {
return dir[:len(dir)-1], name
}
-func (fp FullPath) Name() (string) {
+func (fp FullPath) Name() string {
_, name := filepath.Split(string(fp))
return name
}
diff --git a/weed/filer2/leveldb/leveldb_store.go b/weed/filer2/leveldb/leveldb_store.go
index 8b2df93ac..a3125e923 100644
--- a/weed/filer2/leveldb/leveldb_store.go
+++ b/weed/filer2/leveldb/leveldb_store.go
@@ -1,15 +1,15 @@
package leveldb
import (
- "fmt"
"bytes"
+ "fmt"
- "github.com/syndtr/goleveldb/leveldb"
"github.com/chrislusf/seaweedfs/weed/filer2"
- leveldb_util "github.com/syndtr/goleveldb/leveldb/util"
"github.com/chrislusf/seaweedfs/weed/glog"
- "github.com/spf13/viper"
weed_util "github.com/chrislusf/seaweedfs/weed/util"
+ "github.com/spf13/viper"
+ "github.com/syndtr/goleveldb/leveldb"
+ leveldb_util "github.com/syndtr/goleveldb/leveldb/util"
)
const (
@@ -162,7 +162,7 @@ func genDirectoryKeyPrefix(fullpath filer2.FullPath, startFileName string) (keyP
return keyPrefix
}
-func getNameFromKey(key []byte) (string) {
+func getNameFromKey(key []byte) string {
sepIndex := len(key) - 1
for sepIndex >= 0 && key[sepIndex] != DIR_FILE_SEPARATOR {
diff --git a/weed/filer2/leveldb/leveldb_store_test.go b/weed/filer2/leveldb/leveldb_store_test.go
index 87f77d138..896dabdc3 100644
--- a/weed/filer2/leveldb/leveldb_store_test.go
+++ b/weed/filer2/leveldb/leveldb_store_test.go
@@ -1,10 +1,10 @@
package leveldb
import (
- "testing"
"github.com/chrislusf/seaweedfs/weed/filer2"
"io/ioutil"
"os"
+ "testing"
)
func TestCreateAndFind(t *testing.T) {
diff --git a/weed/filer2/memdb/memdb_store.go b/weed/filer2/memdb/memdb_store.go
index 452e4970c..098ed5dce 100644
--- a/weed/filer2/memdb/memdb_store.go
+++ b/weed/filer2/memdb/memdb_store.go
@@ -1,11 +1,11 @@
package memdb
import (
+ "fmt"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/google/btree"
- "strings"
- "fmt"
"github.com/spf13/viper"
+ "strings"
)
func init() {
diff --git a/weed/filer2/memdb/memdb_store_test.go b/weed/filer2/memdb/memdb_store_test.go
index a8631f969..bd1cdfdc0 100644
--- a/weed/filer2/memdb/memdb_store_test.go
+++ b/weed/filer2/memdb/memdb_store_test.go
@@ -1,8 +1,8 @@
package memdb
import (
- "testing"
"github.com/chrislusf/seaweedfs/weed/filer2"
+ "testing"
)
func TestCreateAndFind(t *testing.T) {
diff --git a/weed/filer2/mysql/mysql_store.go b/weed/filer2/mysql/mysql_store.go
index e56b961bb..475e4a642 100644
--- a/weed/filer2/mysql/mysql_store.go
+++ b/weed/filer2/mysql/mysql_store.go
@@ -1,13 +1,13 @@
package mysql
import (
- "fmt"
"database/sql"
+ "fmt"
"github.com/chrislusf/seaweedfs/weed/filer2"
- "github.com/spf13/viper"
- _ "github.com/go-sql-driver/mysql"
"github.com/chrislusf/seaweedfs/weed/filer2/abstract_sql"
+ _ "github.com/go-sql-driver/mysql"
+ "github.com/spf13/viper"
)
const (
diff --git a/weed/filer2/postgres/postgres_store.go b/weed/filer2/postgres/postgres_store.go
index 19d97b443..3bec55def 100644
--- a/weed/filer2/postgres/postgres_store.go
+++ b/weed/filer2/postgres/postgres_store.go
@@ -1,13 +1,13 @@
package postgres
import (
- "fmt"
"database/sql"
+ "fmt"
"github.com/chrislusf/seaweedfs/weed/filer2"
- "github.com/spf13/viper"
- _ "github.com/lib/pq"
"github.com/chrislusf/seaweedfs/weed/filer2/abstract_sql"
+ _ "github.com/lib/pq"
+ "github.com/spf13/viper"
)
const (
diff --git a/weed/filer2/redis/redis_store.go b/weed/filer2/redis/redis_store.go
index cb8381bf5..5d1f51812 100644
--- a/weed/filer2/redis/redis_store.go
+++ b/weed/filer2/redis/redis_store.go
@@ -4,8 +4,8 @@ import (
"fmt"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
- "github.com/spf13/viper"
"github.com/go-redis/redis"
+ "github.com/spf13/viper"
"sort"
"strings"
)