|
@ -19,9 +19,10 @@ type Store struct { |
|
|
PublicUrl string |
|
|
PublicUrl string |
|
|
MaxVolumeCount int |
|
|
MaxVolumeCount int |
|
|
|
|
|
|
|
|
//read from the master
|
|
|
|
|
|
masterNode string |
|
|
masterNode string |
|
|
volumeSizeLimit uint64 |
|
|
|
|
|
|
|
|
connected bool |
|
|
|
|
|
volumeSizeLimit uint64 //read from the master
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func NewStore(port int, ip, publicUrl, dirname string, maxVolumeCount int) (s *Store) { |
|
|
func NewStore(port int, ip, publicUrl, dirname string, maxVolumeCount int) (s *Store) { |
|
@ -108,7 +109,7 @@ func (s *Store) loadExistingVolumes() { |
|
|
if s.volumes[vid] == nil { |
|
|
if s.volumes[vid] == nil { |
|
|
v := NewVolume(s.dir, vid, CopyNil) |
|
|
v := NewVolume(s.dir, vid, CopyNil) |
|
|
s.volumes[vid] = v |
|
|
s.volumes[vid] = v |
|
|
log.Println("In dir", s.dir, "read volume =", vid, "replicationType =", v.replicaType, "version =", v.version,"size =", v.Size()) |
|
|
|
|
|
|
|
|
log.Println("In dir", s.dir, "read volume =", vid, "replicationType =", v.replicaType, "version =", v.version, "size =", v.Size()) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -141,6 +142,9 @@ func (s *Store) Join() error { |
|
|
} |
|
|
} |
|
|
bytes, _ := json.Marshal(stats) |
|
|
bytes, _ := json.Marshal(stats) |
|
|
values := make(url.Values) |
|
|
values := make(url.Values) |
|
|
|
|
|
if !s.connected { |
|
|
|
|
|
values.Add("init", "true") |
|
|
|
|
|
} |
|
|
values.Add("port", strconv.Itoa(s.Port)) |
|
|
values.Add("port", strconv.Itoa(s.Port)) |
|
|
values.Add("ip", s.Ip) |
|
|
values.Add("ip", s.Ip) |
|
|
values.Add("publicUrl", s.PublicUrl) |
|
|
values.Add("publicUrl", s.PublicUrl) |
|
@ -155,6 +159,7 @@ func (s *Store) Join() error { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
s.volumeSizeLimit = ret.VolumeSizeLimit |
|
|
s.volumeSizeLimit = ret.VolumeSizeLimit |
|
|
|
|
|
s.connected = true |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
func (s *Store) Close() { |
|
|
func (s *Store) Close() { |
|
|