aboutsummaryrefslogtreecommitdiff
path: root/weed-fs/src/pkg
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2012-08-23 23:14:54 -0700
committerChris Lu <chris.lu@gmail.com>2012-08-23 23:14:54 -0700
commit0c32e2e965107ce71423e1f6efb6efe82feac2a0 (patch)
tree9ae1e52bf07b9447b6f576a9d03369c32a5ee48b /weed-fs/src/pkg
parent868e47f9945f302466056f03cd219dd4b83285cc (diff)
downloadseaweedfs-0c32e2e965107ce71423e1f6efb6efe82feac2a0.tar.xz
seaweedfs-0c32e2e965107ce71423e1f6efb6efe82feac2a0.zip
simplify volume id printing
Diffstat (limited to 'weed-fs/src/pkg')
-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
3 files changed, 6 insertions, 7 deletions
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)