aboutsummaryrefslogtreecommitdiff
path: root/go/storage
diff options
context:
space:
mode:
Diffstat (limited to 'go/storage')
-rw-r--r--go/storage/cdb_map.go5
-rw-r--r--go/storage/cdb_map_test.go3
-rw-r--r--go/storage/compact_map.go2
-rw-r--r--go/storage/compact_map_perf_test.go5
-rw-r--r--go/storage/compress.go3
-rw-r--r--go/storage/crc.go3
-rw-r--r--go/storage/file_id.go5
-rw-r--r--go/storage/needle.go7
-rw-r--r--go/storage/needle_map.go5
-rw-r--r--go/storage/needle_read_write.go5
-rw-r--r--go/storage/store.go9
-rw-r--r--go/storage/store_vacuum.go3
-rw-r--r--go/storage/volume.go26
-rw-r--r--go/storage/volume_super_block.go3
-rw-r--r--go/storage/volume_vacuum.go3
-rw-r--r--go/storage/volume_version.go2
16 files changed, 50 insertions, 39 deletions
diff --git a/go/storage/cdb_map.go b/go/storage/cdb_map.go
index 1869a563e..fbb59e9c0 100644
--- a/go/storage/cdb_map.go
+++ b/go/storage/cdb_map.go
@@ -1,13 +1,14 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/util"
"encoding/json"
"errors"
"fmt"
- "github.com/tgulacsi/go-cdb"
"os"
"path/filepath"
+
+ "github.com/chrislusf/weed-fs/go/util"
+ "github.com/tgulacsi/go-cdb"
)
// CDB-backed read-only needle map
diff --git a/go/storage/cdb_map_test.go b/go/storage/cdb_map_test.go
index cff7dfa61..ed690f44f 100644
--- a/go/storage/cdb_map_test.go
+++ b/go/storage/cdb_map_test.go
@@ -1,11 +1,12 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/glog"
"math/rand"
"os"
"runtime"
"testing"
+
+ "github.com/chrislusf/weed-fs/go/glog"
)
var testIndexFilename string = "../../test/sample.idx"
diff --git a/go/storage/compact_map.go b/go/storage/compact_map.go
index 9cfc3e8f7..6ac18b012 100644
--- a/go/storage/compact_map.go
+++ b/go/storage/compact_map.go
@@ -1,7 +1,5 @@
package storage
-import ()
-
type NeedleValue struct {
Key Key
Offset uint32 `comment:"Volume offset"` //since aligned to 8 bytes, range is 4G*8=32G
diff --git a/go/storage/compact_map_perf_test.go b/go/storage/compact_map_perf_test.go
index ef43de25b..f74684225 100644
--- a/go/storage/compact_map_perf_test.go
+++ b/go/storage/compact_map_perf_test.go
@@ -1,11 +1,12 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/glog"
- "github.com/chrislusf/weed-fs/go/util"
"log"
"os"
"testing"
+
+ "github.com/chrislusf/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/util"
)
func TestMemoryUsage(t *testing.T) {
diff --git a/go/storage/compress.go b/go/storage/compress.go
index a353c9d3a..5efc9e1f1 100644
--- a/go/storage/compress.go
+++ b/go/storage/compress.go
@@ -2,11 +2,12 @@ package storage
import (
"bytes"
- "github.com/chrislusf/weed-fs/go/glog"
"compress/flate"
"compress/gzip"
"io/ioutil"
"strings"
+
+ "github.com/chrislusf/weed-fs/go/glog"
)
/*
diff --git a/go/storage/crc.go b/go/storage/crc.go
index 7aa400959..af25b9e53 100644
--- a/go/storage/crc.go
+++ b/go/storage/crc.go
@@ -1,9 +1,10 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/util"
"fmt"
"hash/crc32"
+
+ "github.com/chrislusf/weed-fs/go/util"
)
var table = crc32.MakeTable(crc32.Castagnoli)
diff --git a/go/storage/file_id.go b/go/storage/file_id.go
index ec566826c..f6e36a98c 100644
--- a/go/storage/file_id.go
+++ b/go/storage/file_id.go
@@ -1,11 +1,12 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/glog"
- "github.com/chrislusf/weed-fs/go/util"
"encoding/hex"
"errors"
"strings"
+
+ "github.com/chrislusf/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/util"
)
type FileId struct {
diff --git a/go/storage/needle.go b/go/storage/needle.go
index daede321b..aa3206920 100644
--- a/go/storage/needle.go
+++ b/go/storage/needle.go
@@ -1,9 +1,6 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/glog"
- "github.com/chrislusf/weed-fs/go/images"
- "github.com/chrislusf/weed-fs/go/util"
"encoding/hex"
"errors"
"io/ioutil"
@@ -13,6 +10,10 @@ import (
"strconv"
"strings"
"time"
+
+ "github.com/chrislusf/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/images"
+ "github.com/chrislusf/weed-fs/go/util"
)
const (
diff --git a/go/storage/needle_map.go b/go/storage/needle_map.go
index dca2e6c5d..504ca1552 100644
--- a/go/storage/needle_map.go
+++ b/go/storage/needle_map.go
@@ -1,11 +1,12 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/glog"
- "github.com/chrislusf/weed-fs/go/util"
"fmt"
"io"
"os"
+
+ "github.com/chrislusf/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/util"
)
type NeedleMapper interface {
diff --git a/go/storage/needle_read_write.go b/go/storage/needle_read_write.go
index bf452ba37..663b5abbd 100644
--- a/go/storage/needle_read_write.go
+++ b/go/storage/needle_read_write.go
@@ -1,12 +1,13 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/glog"
- "github.com/chrislusf/weed-fs/go/util"
"errors"
"fmt"
"io"
"os"
+
+ "github.com/chrislusf/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/util"
)
const (
diff --git a/go/storage/store.go b/go/storage/store.go
index e7a9dac94..80d8a30b8 100644
--- a/go/storage/store.go
+++ b/go/storage/store.go
@@ -1,10 +1,6 @@
package storage
import (
- proto "code.google.com/p/goprotobuf/proto"
- "github.com/chrislusf/weed-fs/go/glog"
- "github.com/chrislusf/weed-fs/go/operation"
- "github.com/chrislusf/weed-fs/go/util"
"encoding/json"
"errors"
"fmt"
@@ -12,6 +8,11 @@ import (
"math/rand"
"strconv"
"strings"
+
+ proto "code.google.com/p/goprotobuf/proto"
+ "github.com/chrislusf/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/operation"
+ "github.com/chrislusf/weed-fs/go/util"
)
const (
diff --git a/go/storage/store_vacuum.go b/go/storage/store_vacuum.go
index 3527e4f59..209e3b4b3 100644
--- a/go/storage/store_vacuum.go
+++ b/go/storage/store_vacuum.go
@@ -1,9 +1,10 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/glog"
"fmt"
"strconv"
+
+ "github.com/chrislusf/weed-fs/go/glog"
)
func (s *Store) CheckCompactVolume(volumeIdString string, garbageThresholdString string) (error, bool) {
diff --git a/go/storage/volume.go b/go/storage/volume.go
index de79e9107..5b0a83605 100644
--- a/go/storage/volume.go
+++ b/go/storage/volume.go
@@ -2,7 +2,6 @@ package storage
import (
"bytes"
- "github.com/chrislusf/weed-fs/go/glog"
"errors"
"fmt"
"io"
@@ -10,6 +9,8 @@ import (
"path"
"sync"
"time"
+
+ "github.com/chrislusf/weed-fs/go/glog"
)
type Volume struct {
@@ -72,7 +73,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool) error {
if e != nil {
if !os.IsPermission(e) {
- return fmt.Errorf("cannot load Volume Data %s.dat: %s", fileName, e.Error())
+ return fmt.Errorf("cannot load Volume Data %s.dat: %v", fileName, e)
}
}
@@ -92,12 +93,12 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool) error {
if v.readOnly {
glog.V(1).Infoln("open to read file", fileName+".idx")
if indexFile, e = os.OpenFile(fileName+".idx", os.O_RDONLY, 0644); e != nil {
- return fmt.Errorf("cannot read Volume Index %s.idx: %s", fileName, e.Error())
+ return fmt.Errorf("cannot read Volume Index %s.idx: %v", fileName, e)
}
} else {
glog.V(1).Infoln("open to write file", fileName+".idx")
if indexFile, e = os.OpenFile(fileName+".idx", os.O_RDWR|os.O_CREATE, 0644); e != nil {
- return fmt.Errorf("cannot write Volume Index %s.idx: %s", fileName, e.Error())
+ return fmt.Errorf("cannot write Volume Index %s.idx: %v", fileName, e)
}
}
glog.V(0).Infoln("loading file", fileName+".idx", "readonly", v.readOnly)
@@ -115,7 +116,7 @@ func (v *Volume) Size() int64 {
if e == nil {
return stat.Size()
}
- glog.V(0).Infof("Failed to read file size %s %s", v.dataFile.Name(), e.Error())
+ glog.V(0).Infof("Failed to read file size %s %v", v.dataFile.Name(), e)
return -1
}
func (v *Volume) Close() {
@@ -170,6 +171,7 @@ func (v *Volume) write(n *Needle) (size uint32, err error) {
}
var offset int64
if offset, err = v.dataFile.Seek(0, 2); err != nil {
+ glog.V(0).Infof("faile to seek the end of file: %v", err)
return
}
@@ -177,21 +179,21 @@ func (v *Volume) write(n *Needle) (size uint32, err error) {
if offset%NeedlePaddingSize != 0 {
offset = offset + (NeedlePaddingSize - offset%NeedlePaddingSize)
if offset, err = v.dataFile.Seek(offset, 0); err != nil {
- glog.V(4).Infof("failed to align in datafile %s: %s", v.dataFile.Name(), err.Error())
+ glog.V(0).Infof("failed to align in datafile %s: %v", v.dataFile.Name(), err)
return
}
}
if size, err = n.Append(v.dataFile, v.Version()); err != nil {
if e := v.dataFile.Truncate(offset); e != nil {
- err = fmt.Errorf("%s\ncannot truncate %s: %s", err, v.dataFile.Name(), e.Error())
+ err = fmt.Errorf("%s\ncannot truncate %s: %v", err, v.dataFile.Name(), e)
}
return
}
nv, ok := v.nm.Get(n.Id)
if !ok || int64(nv.Offset)*NeedlePaddingSize < offset {
if _, err = v.nm.Put(n.Id, uint32(offset/NeedlePaddingSize), n.Size); err != nil {
- glog.V(4).Infof("failed to save in needle map %d: %s", n.Id, err.Error())
+ glog.V(4).Infof("failed to save in needle map %d: %v", n.Id, err)
}
}
if v.lastModifiedTime < n.LastModified {
@@ -292,13 +294,13 @@ func ScanVolumeFile(dirname string, collection string, id VolumeId,
offset := int64(SuperBlockSize)
n, rest, e := ReadNeedleHeader(v.dataFile, version, offset)
if e != nil {
- err = fmt.Errorf("cannot read needle header: %s", e)
+ err = fmt.Errorf("cannot read needle header: %v", e)
return
}
for n != nil {
if readNeedleBody {
if err = n.ReadNeedleBody(v.dataFile, version, offset+int64(NeedleHeaderSize), rest); err != nil {
- err = fmt.Errorf("cannot read needle body: %s", err)
+ err = fmt.Errorf("cannot read needle body: %v", err)
return
}
}
@@ -310,7 +312,7 @@ func ScanVolumeFile(dirname string, collection string, id VolumeId,
if err == io.EOF {
return nil
}
- return fmt.Errorf("cannot read needle header: %s", err)
+ return fmt.Errorf("cannot read needle header: %v", err)
}
}
@@ -360,7 +362,7 @@ func (v *Volume) ensureConvertIdxToCdb(fileName string) (cdbCanRead bool) {
defer indexFile.Close()
glog.V(0).Infof("converting %s.idx to %s.cdb", fileName, fileName)
if e = ConvertIndexToCdb(fileName+".cdb", indexFile); e != nil {
- glog.V(0).Infof("error converting %s.idx to %s.cdb: %s", fileName, fileName, e.Error())
+ glog.V(0).Infof("error converting %s.idx to %s.cdb: %v", fileName, fileName, e)
return false
}
return true
diff --git a/go/storage/volume_super_block.go b/go/storage/volume_super_block.go
index a7e86b1c3..57e0deea9 100644
--- a/go/storage/volume_super_block.go
+++ b/go/storage/volume_super_block.go
@@ -1,9 +1,10 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/glog"
"fmt"
"os"
+
+ "github.com/chrislusf/weed-fs/go/glog"
)
const (
diff --git a/go/storage/volume_vacuum.go b/go/storage/volume_vacuum.go
index b348434d2..7e026a61d 100644
--- a/go/storage/volume_vacuum.go
+++ b/go/storage/volume_vacuum.go
@@ -1,10 +1,11 @@
package storage
import (
- "github.com/chrislusf/weed-fs/go/glog"
"fmt"
"os"
"time"
+
+ "github.com/chrislusf/weed-fs/go/glog"
)
func (v *Volume) garbageLevel() float64 {
diff --git a/go/storage/volume_version.go b/go/storage/volume_version.go
index 9702ae904..2e9f58aa2 100644
--- a/go/storage/volume_version.go
+++ b/go/storage/volume_version.go
@@ -1,7 +1,5 @@
package storage
-import ()
-
type Version uint8
const (