SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
removing set volume location display version number add default replication type
Chris Lue340fbee828f
diff --git a/weed-fs/src/cmd/weed/master.go b/weed-fs/src/cmd/weed/master.goindex 46833db5c7..d359152f7e 100644--- a/weed-fs/src/cmd/weed/master.go+++ b/weed-fs/src/cmd/weed/master.go@@ -33,6 +33,7 @@ var (volumeSizeLimitMB = cmdMaster.Flag.Uint("volumeSizeLimitMB", 32*1024, "Default Volume Size in MegaBytes")mpulse = cmdMaster.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats")confFile = cmdMaster.Flag.String("conf", "/etc/weed.conf", "xml configuration file")+ defaultRepType = cmdMaster.Flag.String("defaultReplicationType", "00", "Default replication type if not specified."))var topo *topology.Topology@@ -57,11 +58,15 @@ func dirLookupHandler(w http.ResponseWriter, r *http.Request) {writeJson(w, r, map[string]string{"error": "volume id " + volumeId.String() + " not found. "})}}+func dirAssignHandler(w http.ResponseWriter, r *http.Request) {- c, _ := strconv.Atoi(r.FormValue("count"))+ c, e := strconv.Atoi(r.FormValue("count"))+ if e != nil {+ c = 1+ }repType := r.FormValue("replication")- if repType == ""{- repType = "00"+ if repType == "" {+ repType = *defaultRepType}rt, err := storage.NewReplicationType(repType)if err != nil {@@ -82,6 +87,7 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {writeJson(w, r, map[string]string{"error": err.Error()})}}+func dirJoinHandler(w http.ResponseWriter, r *http.Request) {ip := r.RemoteAddr[0:strings.Index(r.RemoteAddr, ":")]port, _ := strconv.Atoi(r.FormValue("port"))@@ -93,13 +99,13 @@ func dirJoinHandler(w http.ResponseWriter, r *http.Request) {if *IsDebug {log.Println(s, "volumes", r.FormValue("volumes"))}-- //new waystopo.RegisterVolumes(*volumes, ip, port, publicUrl, maxVolumeCount)}+func dirStatusHandler(w http.ResponseWriter, r *http.Request) {writeJson(w, r, topo.ToMap())}+func volumeGrowHandler(w http.ResponseWriter, r *http.Request) {count := 0rt, err := storage.NewReplicationType(r.FormValue("replication"))@@ -120,7 +126,7 @@ func volumeGrowHandler(w http.ResponseWriter, r *http.Request) {}func runMaster(cmd *Command, args []string) bool {- topo = topology.NewTopology("topo", *confFile, *metaFolder, "toposequence", uint64(*volumeSizeLimitMB)*1024*1024, *mpulse)+ topo = topology.NewTopology("topo", *confFile, *metaFolder, "weed", uint64(*volumeSizeLimitMB)*1024*1024, *mpulse)vg = replication.NewDefaultVolumeGrowth()log.Println("Volume Size Limit is", *volumeSizeLimitMB, "MB")http.HandleFunc("/dir/assign", dirAssignHandler)@@ -131,7 +137,7 @@ func runMaster(cmd *Command, args []string) bool {topo.StartRefreshWritableVolumes()- log.Println("Start directory service at http://127.0.0.1:" + strconv.Itoa(*mport))+ log.Println("Start Weed Master", VERSION, "at port", strconv.Itoa(*mport))e := http.ListenAndServe(":"+strconv.Itoa(*mport), nil)if e != nil {log.Fatal("Fail to start:", e)diff --git a/weed-fs/src/cmd/weed/version.go b/weed-fs/src/cmd/weed/version.goindex aa31912371..158d074b9a 100644--- a/weed-fs/src/cmd/weed/version.go+++ b/weed-fs/src/cmd/weed/version.go@@ -5,6 +5,10 @@ import ("runtime")+const (+ VERSION = "0.18"+)+var cmdVersion = &Command{Run: runVersion,UsageLine: "version",@@ -12,11 +16,11 @@ var cmdVersion = &Command{Long: `Version prints the Weed File System version`,}-func runVersion(cmd *Command, args []string) bool{+func runVersion(cmd *Command, args []string) bool {if len(args) != 0 {cmd.Usage()}- fmt.Printf("version 0.18 %s %s\n",runtime.GOOS, runtime.GOARCH)+ fmt.Printf("version %s %s %s\n", VERSION, runtime.GOOS, runtime.GOARCH)return true}diff --git a/weed-fs/src/cmd/weed/volume.go b/weed-fs/src/cmd/weed/volume.goindex e5b83da105..9c83026292 100644--- a/weed-fs/src/cmd/weed/volume.go+++ b/weed-fs/src/cmd/weed/volume.go@@ -2,7 +2,6 @@ package mainimport ("bytes"- "encoding/json""log""math/rand""mime"@@ -53,21 +52,6 @@ func assignVolumeHandler(w http.ResponseWriter, r *http.Request) {log.Println("volume =", r.FormValue("volume"), ", replicationType =", r.FormValue("replicationType"), ", error =", err)}}-func setVolumeLocationsHandler(w http.ResponseWriter, r *http.Request) {- if *IsDebug {- log.Println("volumeLocationsList =", r.FormValue("volumeLocationsList"))- }- volumeLocationsList := new([]storage.VolumeLocations)- err := json.Unmarshal([]byte(r.FormValue("volumeLocationsList")), volumeLocationsList)- if err == nil {- err = store.SetVolumeLocations(*volumeLocationsList)- }- if err == nil {- writeJson(w, r, map[string]string{"error": ""})- } else {- writeJson(w, r, map[string]string{"error": err.Error()})- }-}func storeHandler(w http.ResponseWriter, r *http.Request) {switch r.Method {case "GET":@@ -239,7 +223,6 @@ func runVolume(cmd *Command, args []string) bool {http.HandleFunc("/", storeHandler)http.HandleFunc("/status", statusHandler)http.HandleFunc("/admin/assign_volume", assignVolumeHandler)- http.HandleFunc("/admin/set_volume_locations_list", setVolumeLocationsHandler)go func() {for {diff --git a/weed-fs/src/pkg/admin/storage.go b/weed-fs/src/pkg/admin/storage.godeleted file mode 100644index 8d9e8a1038..0000000000--- a/weed-fs/src/pkg/admin/storage.go+++ /dev/null@@ -1,22 +0,0 @@-package admin--import (- "pkg/storage"- "pkg/topology"-)--func SendVolumeLocationsList(t *topology.Topology, vid storage.VolumeId) error{-// values := make(url.Values)-// values.Add("volumeLocationsList", vid.String())-// volumeLocations:= []map[string]string{}-// list := t.GetVolumeLocations(vid)-// m := make(map[string]interface{})-// m["Vid"] = vid.String()-// for _, dn := range list {-// m["Locations"] = append(m["Locations"], dn)-// }-// for _, dn := range list {-// util.Post("http://"+dn.Ip+":"+strconv.Itoa(dn.Port)+"/admin/set_volume_locations_list", values)-// }- return nil-}diff --git a/weed-fs/src/pkg/storage/store.go b/weed-fs/src/pkg/storage/store.goindex bea6f8633e..9e7bed1929 100644--- a/weed-fs/src/pkg/storage/store.go+++ b/weed-fs/src/pkg/storage/store.go@@ -140,18 +140,3 @@ func (s *Store) HasVolume(i VolumeId) bool {_, ok := s.volumes[i]return ok}--type VolumeLocations struct {- Vid VolumeId- Locations []string-}--func (s *Store) SetVolumeLocations(volumeLocationList []VolumeLocations) error {- for _, volumeLocations := range volumeLocationList {- vid := volumeLocations.Vid- if v := s.volumes[vid]; v != nil {- v.locations = volumeLocations.Locations- }- }- return nil-}diff --git a/weed-fs/src/pkg/storage/volume.go b/weed-fs/src/pkg/storage/volume.goindex fd68d2bc37..c75fa5195a 100644--- a/weed-fs/src/pkg/storage/volume.go+++ b/weed-fs/src/pkg/storage/volume.go@@ -22,8 +22,6 @@ type Volume struct {accessLock sync.Mutex- //transient- locations []string}func NewVolume(dirname string, id VolumeId, replicationType ReplicationType) (v *Volume) {diff --git a/weed-fs/src/pkg/topology/topology.go b/weed-fs/src/pkg/topology/topology.goindex 9cef512492..28340233c6 100644--- a/weed-fs/src/pkg/topology/topology.go+++ b/weed-fs/src/pkg/topology/topology.go@@ -2,11 +2,11 @@ package topologyimport ("errors"+ "io/ioutil""math/rand""pkg/directory""pkg/sequence""pkg/storage"- "io/ioutil")type Topology struct {@@ -24,11 +24,11 @@ type Topology struct {chanDeadDataNodes chan *DataNodechanRecoveredDataNodes chan *DataNodechanFullVolumes chan *storage.VolumeInfo-+configuration *Configuration}-func NewTopology(id string, confFile string, dirname string, filename string, volumeSizeLimit uint64, pulse int) *Topology {+func NewTopology(id string, confFile string, dirname string, sequenceFilename string, volumeSizeLimit uint64, pulse int) *Topology {t := &Topology{}t.id = NodeId(id)t.nodeType = "Topology"@@ -38,32 +38,34 @@ func NewTopology(id string, confFile string, dirname string, filename string, vot.pulse = int64(pulse)t.volumeSizeLimit = volumeSizeLimit- t.sequence = sequence.NewSequencer(dirname, filename)+ t.sequence = sequence.NewSequencer(dirname, sequenceFilename)t.chanDeadDataNodes = make(chan *DataNode)t.chanRecoveredDataNodes = make(chan *DataNode)t.chanFullVolumes = make(chan *storage.VolumeInfo)- t.loadConfiguration(confFile)-+ t.loadConfiguration(confFile)+return t}-func (t *Topology) loadConfiguration(configurationFile string)error{- b, e := ioutil.ReadFile(configurationFile);- if e ==nil{- t.configuration, e = NewConfiguration(b)- }- return e+func (t *Topology) loadConfiguration(configurationFile string) error {+ b, e := ioutil.ReadFile(configurationFile)+ if e == nil {+ t.configuration, e = NewConfiguration(b)+ }+ return e}-func (t *Topology) Lookup(vid storage.VolumeId) (*[]*DataNode) {- for _, vl := range t.replicaType2VolumeLayout {- if list := vl.Lookup(vid); list!=nil {- return list- }- }- return nil+func (t *Topology) Lookup(vid storage.VolumeId) *[]*DataNode {+ for _, vl := range t.replicaType2VolumeLayout {+ if vl != nil {+ if list := vl.Lookup(vid); list != nil {+ return list+ }+ }+ }+ return nil}func (t *Topology) RandomlyReserveOneVolume() (bool, *DataNode, *storage.VolumeId) {@@ -119,7 +121,7 @@ func (t *Topology) RegisterVolumeLayout(v *storage.VolumeInfo, dn *DataNode) {}func (t *Topology) RegisterVolumes(volumeInfos []storage.VolumeInfo, ip string, port int, publicUrl string, maxVolumeCount int) {- dcName, rackName := t.configuration.Locate(ip)+ dcName, rackName := t.configuration.Locate(ip)dc := t.GetOrCreateDataCenter(dcName)rack := dc.GetOrCreateRack(rackName)dn := rack.GetOrCreateDataNode(ip, port, publicUrl, maxVolumeCount)@@ -143,7 +145,7 @@ func (t *Topology) GetOrCreateDataCenter(dcName string) *DataCenter {func (t *Topology) ToMap() interface{} {m := make(map[string]interface{})- m["Max"] = t.GetMaxVolumeCount()+ m["Max"] = t.GetMaxVolumeCount()m["Free"] = t.FreeSpace()var dcs []interface{}for _, c := range t.Children() {