aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weed-fs/src/cmd/weed/master.go6
-rw-r--r--weed-fs/src/pkg/directory/file_id.go7
-rw-r--r--weed-fs/src/pkg/directory/volume_mapping.go4
-rw-r--r--weed-fs/src/pkg/storage/volume.go2
4 files changed, 9 insertions, 10 deletions
diff --git a/weed-fs/src/cmd/weed/master.go b/weed-fs/src/cmd/weed/master.go
index 37d3b2295..ef416a83c 100644
--- a/weed-fs/src/cmd/weed/master.go
+++ b/weed-fs/src/cmd/weed/master.go
@@ -38,13 +38,13 @@ func dirLookupHandler(w http.ResponseWriter, r *http.Request) {
if commaSep > 0 {
vid = vid[0:commaSep]
}
- volumeId, _ := strconv.ParseUint(vid, 10, 64)
- machine, e := mapper.Get(storage.VolumeId(volumeId))
+ volumeId, _ := storage.NewVolumeId(vid)
+ machine, e := mapper.Get(volumeId)
if e == nil {
writeJson(w, r, machine.Server)
} else {
log.Println("Invalid volume id", volumeId)
- writeJson(w, r, map[string]string{"error": "volume id " + strconv.FormatUint(volumeId, 10) + " not found"})
+ writeJson(w, r, map[string]string{"error": "volume id " + volumeId.String() + " not found"})
}
}
func dirAssignHandler(w http.ResponseWriter, r *http.Request) {
diff --git a/weed-fs/src/pkg/directory/file_id.go b/weed-fs/src/pkg/directory/file_id.go
index 723d94276..62fc354bf 100644
--- a/weed-fs/src/pkg/directory/file_id.go
+++ b/weed-fs/src/pkg/directory/file_id.go
@@ -4,7 +4,6 @@ import (
"encoding/hex"
"log"
"pkg/storage"
- "strconv"
"strings"
"pkg/util"
)
@@ -25,9 +24,9 @@ func ParseFileId(fid string) *FileId{
return nil
}
vid_string, key_hash_string := a[0], a[1]
- vid, _ := strconv.ParseUint(vid_string, 10, 64)
+ volumeId, _ := storage.NewVolumeId(vid_string)
key, hash := storage.ParseKeyHash(key_hash_string)
- return &FileId{VolumeId: storage.VolumeId(vid), Key: key, Hashcode: hash}
+ return &FileId{VolumeId: volumeId, Key: key, Hashcode: hash}
}
func (n *FileId) String() string {
bytes := make([]byte, 12)
@@ -36,5 +35,5 @@ func (n *FileId) String() string {
nonzero_index := 0
for ; bytes[nonzero_index] == 0; nonzero_index++ {
}
- return strconv.FormatUint(uint64(n.VolumeId), 10) + "," + hex.EncodeToString(bytes[nonzero_index:])
+ return n.VolumeId.String() + "," + hex.EncodeToString(bytes[nonzero_index:])
}
diff --git a/weed-fs/src/pkg/directory/volume_mapping.go b/weed-fs/src/pkg/directory/volume_mapping.go
index a6748f5c6..445179bc3 100644
--- a/weed-fs/src/pkg/directory/volume_mapping.go
+++ b/weed-fs/src/pkg/directory/volume_mapping.go
@@ -82,7 +82,7 @@ func (m *Mapper) PickForWrite(c string) (string, int, MachineInfo, error) {
}
return NewFileId(vid, fileId, rand.Uint32()).String(), count, machine.Server, nil
}
- return "", 0, m.Machines[rand.Intn(len(m.Machines))].Server, errors.New("Strangely vid " + strconv.FormatUint(uint64(vid), 10) + " is on no machine!")
+ return "", 0, m.Machines[rand.Intn(len(m.Machines))].Server, errors.New("Strangely vid " + vid.String() + " is on no machine!")
}
func (m *Mapper) NextFileId(c string) (uint64,int) {
count, parseError := strconv.ParseUint(c,10,64)
@@ -105,7 +105,7 @@ func (m *Mapper) NextFileId(c string) (uint64,int) {
func (m *Mapper) Get(vid storage.VolumeId) (*Machine, error) {
machineId := m.vid2machineId[vid]
if machineId <= 0 {
- return nil, errors.New("invalid volume id " + strconv.FormatUint(uint64(vid), 10))
+ return nil, errors.New("invalid volume id " + vid.String())
}
return m.Machines[machineId-1], nil
}
diff --git a/weed-fs/src/pkg/storage/volume.go b/weed-fs/src/pkg/storage/volume.go
index 2f156a13b..519ebab4d 100644
--- a/weed-fs/src/pkg/storage/volume.go
+++ b/weed-fs/src/pkg/storage/volume.go
@@ -37,7 +37,7 @@ type Volume struct {
func NewVolume(dirname string, id VolumeId) (v *Volume) {
var e error
v = &Volume{dir: dirname, Id: id}
- fileName := strconv.FormatUint(uint64(v.Id), 10)
+ fileName := id.String()
v.dataFile, e = os.OpenFile(path.Join(v.dir, fileName+".dat"), os.O_RDWR|os.O_CREATE, 0644)
if e != nil {
log.Fatalf("New Volume [ERROR] %s\n", e)