|
@ -264,10 +264,10 @@ func (s *Store) SetRack(rack string) { |
|
|
func (s *Store) SetBootstrapMaster(bootstrapMaster string) { |
|
|
func (s *Store) SetBootstrapMaster(bootstrapMaster string) { |
|
|
s.masterNodes = NewMasterNodes(bootstrapMaster) |
|
|
s.masterNodes = NewMasterNodes(bootstrapMaster) |
|
|
} |
|
|
} |
|
|
func (s *Store) Join() error { |
|
|
|
|
|
masterNode, e := s.masterNodes.findMaster() |
|
|
|
|
|
|
|
|
func (s *Store) Join() (masterNode string, e error) { |
|
|
|
|
|
masterNode, e = s.masterNodes.findMaster() |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
return e |
|
|
|
|
|
|
|
|
return |
|
|
} |
|
|
} |
|
|
stats := new([]*VolumeInfo) |
|
|
stats := new([]*VolumeInfo) |
|
|
maxVolumeCount := 0 |
|
|
maxVolumeCount := 0 |
|
@ -305,18 +305,18 @@ func (s *Store) Join() error { |
|
|
jsonBlob, err := util.Post("http://"+masterNode+"/dir/join", values) |
|
|
jsonBlob, err := util.Post("http://"+masterNode+"/dir/join", values) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
s.masterNodes.reset() |
|
|
s.masterNodes.reset() |
|
|
return err |
|
|
|
|
|
|
|
|
return "", err |
|
|
} |
|
|
} |
|
|
var ret operation.JoinResult |
|
|
var ret operation.JoinResult |
|
|
if err := json.Unmarshal(jsonBlob, &ret); err != nil { |
|
|
if err := json.Unmarshal(jsonBlob, &ret); err != nil { |
|
|
return err |
|
|
|
|
|
|
|
|
return masterNode, err |
|
|
} |
|
|
} |
|
|
if ret.Error != "" { |
|
|
if ret.Error != "" { |
|
|
return errors.New(ret.Error) |
|
|
|
|
|
|
|
|
return masterNode, errors.New(ret.Error) |
|
|
} |
|
|
} |
|
|
s.volumeSizeLimit = ret.VolumeSizeLimit |
|
|
s.volumeSizeLimit = ret.VolumeSizeLimit |
|
|
s.connected = true |
|
|
s.connected = true |
|
|
return nil |
|
|
|
|
|
|
|
|
return |
|
|
} |
|
|
} |
|
|
func (s *Store) Close() { |
|
|
func (s *Store) Close() { |
|
|
for _, location := range s.Locations { |
|
|
for _, location := range s.Locations { |
|
@ -338,7 +338,7 @@ func (s *Store) Write(i VolumeId, n *Needle) (size uint32, err error) { |
|
|
} |
|
|
} |
|
|
if s.volumeSizeLimit < v.ContentSize()+3*uint64(size) { |
|
|
if s.volumeSizeLimit < v.ContentSize()+3*uint64(size) { |
|
|
glog.V(0).Infoln("volume", i, "size", v.ContentSize(), "will exceed limit", s.volumeSizeLimit) |
|
|
glog.V(0).Infoln("volume", i, "size", v.ContentSize(), "will exceed limit", s.volumeSizeLimit) |
|
|
if e := s.Join(); e != nil { |
|
|
|
|
|
|
|
|
if _, e := s.Join(); e != nil { |
|
|
glog.V(0).Infoln("error when reporting size:", e) |
|
|
glog.V(0).Infoln("error when reporting size:", e) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|