Browse Source

be lenient when writing, but report right away when volume size limit is

exceeded
pull/2/head
Chris Lu 11 years ago
parent
commit
2a8c60f71b
  1. 7
      go/storage/needle.go
  2. 10
      go/storage/store.go
  3. 2
      go/weed/master.go

7
go/storage/needle.go

@ -15,9 +15,10 @@ import (
) )
const ( const (
NeedleHeaderSize = 16 //should never change this
NeedlePaddingSize = 8
NeedleChecksumSize = 4
NeedleHeaderSize = 16 //should never change this
NeedlePaddingSize = 8
NeedleChecksumSize = 4
MaxPossibleVolumeSize = 4 * 1024 * 1024 * 1024 * 8
) )
/* /*

10
go/storage/store.go

@ -262,15 +262,15 @@ func (s *Store) Write(i VolumeId, n *Needle) (size uint32, err error) {
err = fmt.Errorf("Volume %s is read only!", i) err = fmt.Errorf("Volume %s is read only!", i)
return return
} else { } else {
if s.volumeSizeLimit >= v.ContentSize()+uint64(size) {
if MaxPossibleVolumeSize >= v.ContentSize()+uint64(size) {
size, err = v.write(n) size, err = v.write(n)
} else { } else {
err = fmt.Errorf("Volume Size Limit %d Exceeded! Current size is %d", s.volumeSizeLimit, v.ContentSize()) err = fmt.Errorf("Volume Size Limit %d Exceeded! Current size is %d", s.volumeSizeLimit, v.ContentSize())
} }
if err != nil && s.volumeSizeLimit < v.ContentSize()+uint64(size) && s.volumeSizeLimit >= v.ContentSize() {
glog.V(0).Infoln("volume", i, "size is", v.ContentSize(), "close to", s.volumeSizeLimit)
if err = s.Join(); err != nil {
glog.V(0).Infoln("error with Join:", err)
if s.volumeSizeLimit < v.ContentSize()+uint64(size) {
glog.V(0).Infoln("volume", i, "size", v.ContentSize(), "will exceed limit", s.volumeSizeLimit)
if e = s.Join(); e != nil {
glog.V(0).Infoln("error when reporting size:", e)
} }
} }
} }

2
go/weed/master.go

@ -30,7 +30,7 @@ var (
mport = cmdMaster.Flag.Int("port", 9333, "http listen port") mport = cmdMaster.Flag.Int("port", 9333, "http listen port")
mip = cmdMaster.Flag.String("ip", "localhost", "http listen port") mip = cmdMaster.Flag.String("ip", "localhost", "http listen port")
metaFolder = cmdMaster.Flag.String("mdir", os.TempDir(), "data directory to store meta data") metaFolder = cmdMaster.Flag.String("mdir", os.TempDir(), "data directory to store meta data")
volumeSizeLimitMB = cmdMaster.Flag.Uint("volumeSizeLimitMB", 32*1024, "Default Volume Size in MegaBytes")
volumeSizeLimitMB = cmdMaster.Flag.Uint("volumeSizeLimitMB", 32*1000, "Default Volume Size in MegaBytes")
mpulse = cmdMaster.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats") mpulse = cmdMaster.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats")
confFile = cmdMaster.Flag.String("conf", "/etc/weedfs/weedfs.conf", "xml configuration file") confFile = cmdMaster.Flag.String("conf", "/etc/weedfs/weedfs.conf", "xml configuration file")
defaultRepType = cmdMaster.Flag.String("defaultReplicationType", "000", "Default replication type if not specified.") defaultRepType = cmdMaster.Flag.String("defaultReplicationType", "000", "Default replication type if not specified.")

Loading…
Cancel
Save