aboutsummaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2016-04-26 20:10:26 -0700
committerChris Lu <chris.lu@gmail.com>2016-04-26 20:10:26 -0700
commitc9e33d37098dfb86a1d262885060757837468c46 (patch)
treead975c4159e7eb6ff014158246c24508bc1eac4d /go
parentadcfaa5735e1bb7330b35a054e2b061c614cbcb3 (diff)
downloadseaweedfs-c9e33d37098dfb86a1d262885060757837468c46.tar.xz
seaweedfs-c9e33d37098dfb86a1d262885060757837468c46.zip
separate into 2 files, no logic change
Diffstat (limited to 'go')
-rw-r--r--go/storage/disk_location.go44
-rw-r--r--go/storage/store.go36
2 files changed, 44 insertions, 36 deletions
diff --git a/go/storage/disk_location.go b/go/storage/disk_location.go
new file mode 100644
index 000000000..146e53ed6
--- /dev/null
+++ b/go/storage/disk_location.go
@@ -0,0 +1,44 @@
+package storage
+
+import (
+ "io/ioutil"
+ "strings"
+
+ "github.com/chrislusf/seaweedfs/go/glog"
+)
+
+type DiskLocation struct {
+ Directory string
+ MaxVolumeCount int
+ volumes map[VolumeId]*Volume
+}
+
+func (mn *DiskLocation) reset() {
+}
+
+func (l *DiskLocation) loadExistingVolumes(needleMapKind NeedleMapType) {
+ if dirs, err := ioutil.ReadDir(l.Directory); err == nil {
+ for _, dir := range dirs {
+ name := dir.Name()
+ if !dir.IsDir() && strings.HasSuffix(name, ".dat") {
+ collection := ""
+ base := name[:len(name)-len(".dat")]
+ i := strings.LastIndex(base, "_")
+ if i > 0 {
+ collection, base = base[0:i], base[i+1:]
+ }
+ if vid, err := NewVolumeId(base); err == nil {
+ if l.volumes[vid] == nil {
+ if v, e := NewVolume(l.Directory, collection, vid, needleMapKind, nil, nil); e == nil {
+ l.volumes[vid] = v
+ glog.V(0).Infof("data file %s, replicaPlacement=%s v=%d size=%d ttl=%s", l.Directory+"/"+name, v.ReplicaPlacement, v.Version(), v.Size(), v.Ttl.String())
+ } else {
+ glog.V(0).Infof("new volume %s error %s", name, e)
+ }
+ }
+ }
+ }
+ }
+ }
+ glog.V(0).Infoln("Store started on dir:", l.Directory, "with", len(l.volumes), "volumes", "max", l.MaxVolumeCount)
+}
diff --git a/go/storage/store.go b/go/storage/store.go
index ebf01d09f..386d53f09 100644
--- a/go/storage/store.go
+++ b/go/storage/store.go
@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
- "io/ioutil"
"math/rand"
"strconv"
"strings"
@@ -20,15 +19,6 @@ const (
MAX_TTL_VOLUME_REMOVAL_DELAY = 10 // 10 minutes
)
-type DiskLocation struct {
- Directory string
- MaxVolumeCount int
- volumes map[VolumeId]*Volume
-}
-
-func (mn *DiskLocation) reset() {
-}
-
type MasterNodes struct {
nodes []string
lastNode int
@@ -200,32 +190,6 @@ func (s *Store) addVolume(vid VolumeId, collection string, needleMapKind NeedleM
return fmt.Errorf("No more free space left")
}
-func (l *DiskLocation) loadExistingVolumes(needleMapKind NeedleMapType) {
- if dirs, err := ioutil.ReadDir(l.Directory); err == nil {
- for _, dir := range dirs {
- name := dir.Name()
- if !dir.IsDir() && strings.HasSuffix(name, ".dat") {
- collection := ""
- base := name[:len(name)-len(".dat")]
- i := strings.LastIndex(base, "_")
- if i > 0 {
- collection, base = base[0:i], base[i+1:]
- }
- if vid, err := NewVolumeId(base); err == nil {
- if l.volumes[vid] == nil {
- if v, e := NewVolume(l.Directory, collection, vid, needleMapKind, nil, nil); e == nil {
- l.volumes[vid] = v
- glog.V(0).Infof("data file %s, replicaPlacement=%s v=%d size=%d ttl=%s", l.Directory+"/"+name, v.ReplicaPlacement, v.Version(), v.Size(), v.Ttl.String())
- } else {
- glog.V(0).Infof("new volume %s error %s", name, e)
- }
- }
- }
- }
- }
- }
- glog.V(0).Infoln("Store started on dir:", l.Directory, "with", len(l.volumes), "volumes", "max", l.MaxVolumeCount)
-}
func (s *Store) Status() []*VolumeInfo {
var stats []*VolumeInfo
for _, location := range s.Locations {