split into server and clients

git-svn-id: https://weed-fs.googlecode.com/svn/trunk@9 282b0af5-e82d-9cf1-ede4-77906d7719d0
This commit is contained in:
chris.lu@gmail.com
2011-12-16 14:51:26 +00:00
parent 02f4e7b82c
commit 23ecd7bb33
9 changed files with 466 additions and 154 deletions

View File

@@ -6,13 +6,19 @@ import (
"path"
"rand"
"log"
"store"
"storage"
)
type Machine struct {
Server string //<server name/ip>[:port]
PublicServer string
}
type Mapper struct {
dir string
FileName string
Id2Machine map[uint32][]*Machine
LastId uint32
}
func NewMachine(server, publicServer string) (m *Machine) {
m = new(Machine)
@@ -20,13 +26,6 @@ func NewMachine(server, publicServer string) (m *Machine) {
return
}
type Mapper struct {
dir string
FileName string
Id2Machine map[uint32][]*Machine
LastId uint32
}
func NewMapper(dirname string, filename string) (m *Mapper) {
m = new(Mapper)
m.dir = dirname
@@ -51,7 +50,7 @@ func (m *Mapper) PickForWrite() []*Machine {
func (m *Mapper) Get(vid uint32) []*Machine {
return m.Id2Machine[vid]
}
func (m *Mapper) Add(machine *Machine, volumes []store.VolumeStat) {
func (m *Mapper) Add(machine *Machine, volumes []storage.VolumeStat) {
log.Println("Adding store node", machine.Server)
for _, v := range volumes {
existing := m.Id2Machine[uint32(v.Id)]