aboutsummaryrefslogtreecommitdiff
path: root/weed-fs/src/pkg
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2012-09-03 19:18:02 -0700
committerChris Lu <chris.lu@gmail.com>2012-09-03 19:18:02 -0700
commitfbe828e48648df0c0adeca240853d110bb04f4d8 (patch)
tree8fb7e1806ed28b2fee54b52ac95257ca4acdd1f1 /weed-fs/src/pkg
parent09542d82b422242216c7f717f22aaf2b73d65b72 (diff)
downloadseaweedfs-fbe828e48648df0c0adeca240853d110bb04f4d8.tar.xz
seaweedfs-fbe828e48648df0c0adeca240853d110bb04f4d8.zip
reformatting
Diffstat (limited to 'weed-fs/src/pkg')
-rw-r--r--weed-fs/src/pkg/directory/volume_mapping.go23
1 files changed, 8 insertions, 15 deletions
diff --git a/weed-fs/src/pkg/directory/volume_mapping.go b/weed-fs/src/pkg/directory/volume_mapping.go
index 9d58a1e77..b40ab51eb 100644
--- a/weed-fs/src/pkg/directory/volume_mapping.go
+++ b/weed-fs/src/pkg/directory/volume_mapping.go
@@ -10,17 +10,10 @@ import (
"sync"
)
-const (
- FileIdSaveInterval = 10000
-)
-
-type MachineInfo struct {
- Url string //<server name/ip>[:port]
- PublicUrl string
-}
type Machine struct {
- Server MachineInfo
Volumes []storage.VolumeInfo
+ Url string //<server name/ip>[:port]
+ PublicUrl string
}
type Mapper struct {
@@ -35,7 +28,7 @@ type Mapper struct {
}
func NewMachine(server, publicUrl string, volumes []storage.VolumeInfo) *Machine {
- return &Machine{Server: MachineInfo{Url: server, PublicUrl: publicUrl}, Volumes: volumes}
+ return &Machine{Url: server, PublicUrl: publicUrl, Volumes: volumes}
}
func NewMapper(dirname string, filename string, volumeSizeLimit uint64) (m *Mapper) {
@@ -49,7 +42,7 @@ func NewMapper(dirname string, filename string, volumeSizeLimit uint64) (m *Mapp
return
}
-func (m *Mapper) PickForWrite(c string) (string, int, *MachineInfo, error) {
+func (m *Mapper) PickForWrite(c string) (string, int, *Machine, error) {
len_writers := len(m.Writers)
if len_writers <= 0 {
log.Println("No more writable volumes!")
@@ -61,11 +54,11 @@ func (m *Mapper) PickForWrite(c string) (string, int, *MachineInfo, error) {
machine := m.Machines[machine_id-1]
fileId, count := m.sequence.NextFileId(util.ParseInt(c, 1))
if count == 0 {
- return "", 0, &m.Machines[rand.Intn(len(m.Machines))].Server, errors.New("Strange count:" + c)
+ return "", 0, m.Machines[rand.Intn(len(m.Machines))], errors.New("Strange count:" + c)
}
- return NewFileId(vid, fileId, rand.Uint32()).String(), count, &machine.Server, nil
+ return NewFileId(vid, fileId, rand.Uint32()).String(), count, machine, nil
}
- return "", 0, &m.Machines[rand.Intn(len(m.Machines))].Server, errors.New("Strangely vid " + vid.String() + " is on no machine!")
+ return "", 0, m.Machines[rand.Intn(len(m.Machines))], errors.New("Strangely vid " + vid.String() + " is on no machine!")
}
func (m *Mapper) Get(vid storage.VolumeId) (*Machine, error) {
machineId := m.vid2machineId[vid]
@@ -80,7 +73,7 @@ func (m *Mapper) Add(machine Machine) {
m.volumeLock.Lock()
foundExistingMachineId := -1
for index, entry := range m.Machines {
- if machine.Server.Url == entry.Server.Url {
+ if machine.Url == entry.Url {
foundExistingMachineId = index
break
}