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
go fmt
Chris Lu3575d41009e4
diff --git a/weed/command/backup.go b/weed/command/backup.goindex b9973c6a98..207df770b5 100644--- a/weed/command/backup.go+++ b/weed/command/backup.go@@ -72,7 +72,7 @@ func runBackup(cmd *Command, args []string) bool {vid := needle.VolumeId(*s.volumeId)// find volume location, replication, ttl info- lookup, err := operation.Lookup(func()string{return *s.master}, vid.String())+ lookup, err := operation.Lookup(func() string { return *s.master }, vid.String())if err != nil {fmt.Printf("Error looking up volume %d: %v\n", vid, err)return truediff --git a/weed/command/download.go b/weed/command/download.goindex 5da1f57d9e..7bbff94487 100644--- a/weed/command/download.go+++ b/weed/command/download.go@@ -44,7 +44,7 @@ var cmdDownload = &Command{func runDownload(cmd *Command, args []string) bool {for _, fid := range args {- if e := downloadToFile(func()string{return *d.server}, fid, util.ResolvePath(*d.dir)); e != nil {+ if e := downloadToFile(func() string { return *d.server }, fid, util.ResolvePath(*d.dir)); e != nil {fmt.Println("Download Error: ", fid, e)}}diff --git a/weed/command/upload.go b/weed/command/upload.goindex effcf8836b..149d71241a 100644--- a/weed/command/upload.go+++ b/weed/command/upload.go@@ -96,7 +96,7 @@ func runUpload(cmd *Command, args []string) bool {if e != nil {return e}- results, e := operation.SubmitFiles(func()string {return *upload.master}, grpcDialOption, parts, *upload.replication, *upload.collection, *upload.dataCenter, *upload.ttl, *upload.diskType, *upload.maxMB, *upload.usePublicUrl)+ results, e := operation.SubmitFiles(func() string { return *upload.master }, grpcDialOption, parts, *upload.replication, *upload.collection, *upload.dataCenter, *upload.ttl, *upload.diskType, *upload.maxMB, *upload.usePublicUrl)bytes, _ := json.Marshal(results)fmt.Println(string(bytes))if e != nil {@@ -113,7 +113,7 @@ func runUpload(cmd *Command, args []string) bool {if e != nil {fmt.Println(e.Error())}- results, _ := operation.SubmitFiles(func()string {return *upload.master}, grpcDialOption, parts, *upload.replication, *upload.collection, *upload.dataCenter, *upload.ttl, *upload.diskType, *upload.maxMB, *upload.usePublicUrl)+ results, _ := operation.SubmitFiles(func() string { return *upload.master }, grpcDialOption, parts, *upload.replication, *upload.collection, *upload.dataCenter, *upload.ttl, *upload.diskType, *upload.maxMB, *upload.usePublicUrl)bytes, _ := json.Marshal(results)fmt.Println(string(bytes))}diff --git a/weed/filer/mysql/mysql_store.go b/weed/filer/mysql/mysql_store.goindex 022a8d72df..501ab1d39a 100644--- a/weed/filer/mysql/mysql_store.go+++ b/weed/filer/mysql/mysql_store.go@@ -47,7 +47,7 @@ func (store *MysqlStore) initialize(user, password, hostname string, port int, dstore.SupportBucketTable = falsestore.SqlGenerator = &SqlGenMysql{CreateTableSqlTemplate: "",- DropTableSqlTemplate: "drop table `%s`",+ DropTableSqlTemplate: "drop table `%s`",}sqlUrl := fmt.Sprintf(CONNECTION_URL_PATTERN, user, password, hostname, port, database)diff --git a/weed/filer/postgres/postgres_sql_gen.go b/weed/filer/postgres/postgres_sql_gen.goindex 480f433ef0..e13070c3d8 100644--- a/weed/filer/postgres/postgres_sql_gen.go+++ b/weed/filer/postgres/postgres_sql_gen.go@@ -1,10 +1,10 @@package postgresimport (- `fmt`+ "fmt"- `github.com/chrislusf/seaweedfs/weed/filer/abstract_sql`- _ `github.com/lib/pq`+ "github.com/chrislusf/seaweedfs/weed/filer/abstract_sql"+ _ "github.com/lib/pq")type SqlGenPostgres struct {diff --git a/weed/filer/postgres2/postgres2_store.go b/weed/filer/postgres2/postgres2_store.goindex 4b5fbc8cf0..92893bf7aa 100644--- a/weed/filer/postgres2/postgres2_store.go+++ b/weed/filer/postgres2/postgres2_store.go@@ -50,7 +50,7 @@ func (store *PostgresStore2) initialize(createTable, user, password, hostname ststore.SupportBucketTable = truestore.SqlGenerator = &postgres.SqlGenPostgres{CreateTableSqlTemplate: createTable,- DropTableSqlTemplate: `drop table "%s"`,+ DropTableSqlTemplate: `drop table "%s"`,}sqlUrl := fmt.Sprintf(CONNECTION_URL_PATTERN, hostname, port, sslmode)diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.goindex b24514cda0..0d5cfd29cf 100644--- a/weed/operation/upload_content.go+++ b/weed/operation/upload_content.go@@ -100,7 +100,7 @@ func retriedUploadData(uploadUrl string, filename string, cipher bool, data []by} else {glog.Warningf("uploading to %s: %v", uploadUrl, err)}- time.Sleep(time.Millisecond * time.Duration(237 * (i+1)))+ time.Sleep(time.Millisecond * time.Duration(237*(i+1)))}return}diff --git a/weed/server/master_server_handlers_admin.go b/weed/server/master_server_handlers_admin.goindex 4a77d24b58..f24d4e9245 100644--- a/weed/server/master_server_handlers_admin.go+++ b/weed/server/master_server_handlers_admin.go@@ -125,13 +125,13 @@ func (ms *MasterServer) selfUrl(r *http.Request) string {}func (ms *MasterServer) submitFromMasterServerHandler(w http.ResponseWriter, r *http.Request) {if ms.Topo.IsLeader() {- submitForClientHandler(w, r, func()string{return ms.selfUrl(r)}, ms.grpcDialOption)+ submitForClientHandler(w, r, func() string { return ms.selfUrl(r) }, ms.grpcDialOption)} else {masterUrl, err := ms.Topo.Leader()if err != nil {writeJsonError(w, r, http.StatusInternalServerError, err)} else {- submitForClientHandler(w, r, func()string{return masterUrl}, ms.grpcDialOption)+ submitForClientHandler(w, r, func() string { return masterUrl }, ms.grpcDialOption)}}}diff --git a/weed/server/volume_grpc_client_to_master.go b/weed/server/volume_grpc_client_to_master.goindex 323667d2ed..f8875169f8 100644--- a/weed/server/volume_grpc_client_to_master.go+++ b/weed/server/volume_grpc_client_to_master.go@@ -219,14 +219,14 @@ func (vs *VolumeServer) doHeartbeat(masterNode, masterGrpcAddress string, grpcDicase <-vs.stopChan:var volumeMessages []*master_pb.VolumeInformationMessageemptyBeat := &master_pb.Heartbeat{- Ip: vs.store.Ip,- Port: uint32(vs.store.Port),- PublicUrl: vs.store.PublicUrl,- MaxFileKey: uint64(0),- DataCenter: vs.store.GetDataCenter(),- Rack: vs.store.GetRack(),- Volumes: volumeMessages,- HasNoVolumes: len(volumeMessages) == 0,+ Ip: vs.store.Ip,+ Port: uint32(vs.store.Port),+ PublicUrl: vs.store.PublicUrl,+ MaxFileKey: uint64(0),+ DataCenter: vs.store.GetDataCenter(),+ Rack: vs.store.GetRack(),+ Volumes: volumeMessages,+ HasNoVolumes: len(volumeMessages) == 0,}glog.V(1).Infof("volume server %s:%d stops and deletes all volumes", vs.store.Ip, vs.store.Port)if err = stream.Send(emptyBeat); err != nil {diff --git a/weed/shell/command_ec_test.go b/weed/shell/command_ec_test.goindex 14235d5655..a1226adbb9 100644--- a/weed/shell/command_ec_test.go+++ b/weed/shell/command_ec_test.go@@ -126,7 +126,7 @@ func TestCommandEcBalanceVolumeEvenButRackUneven(t *testing.T) {func newEcNode(dc string, rack string, dataNodeId string, freeEcSlot int) *EcNode {return &EcNode{info: &master_pb.DataNodeInfo{- Id: dataNodeId,+ Id: dataNodeId,DiskInfos: make(map[string]*master_pb.DiskInfo),},dc: dc,diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.goindex 677f388564..f9dcf3b5fb 100644--- a/weed/shell/command_volume_fsck.go+++ b/weed/shell/command_volume_fsck.go@@ -285,7 +285,7 @@ func (c *commandVolumeFsck) collectVolumeIds(verbose bool, writer io.Writer) (vo}eachDataNode(resp.TopologyInfo, func(dc string, rack RackId, t *master_pb.DataNodeInfo) {- for _, diskInfo := range t.DiskInfos{+ for _, diskInfo := range t.DiskInfos {for _, vi := range diskInfo.VolumeInfos {volumeIdToServer[vi.Id] = VInfo{server: t.Id,diff --git a/weed/storage/store.go b/weed/storage/store.goindex 92f1db2bcf..47829666af 100644--- a/weed/storage/store.go+++ b/weed/storage/store.go@@ -285,15 +285,15 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {}return &master_pb.Heartbeat{- Ip: s.Ip,- Port: uint32(s.Port),- PublicUrl: s.PublicUrl,- MaxVolumeCounts: maxVolumeCounts,- MaxFileKey: NeedleIdToUint64(maxFileKey),- DataCenter: s.dataCenter,- Rack: s.rack,- Volumes: volumeMessages,- HasNoVolumes: len(volumeMessages) == 0,+ Ip: s.Ip,+ Port: uint32(s.Port),+ PublicUrl: s.PublicUrl,+ MaxVolumeCounts: maxVolumeCounts,+ MaxFileKey: NeedleIdToUint64(maxFileKey),+ DataCenter: s.dataCenter,+ Rack: s.rack,+ Volumes: volumeMessages,+ HasNoVolumes: len(volumeMessages) == 0,}}diff --git a/weed/storage/types/volume_disk_type.go b/weed/storage/types/volume_disk_type.goindex 0e199a6264..25056ee105 100644--- a/weed/storage/types/volume_disk_type.go+++ b/weed/storage/types/volume_disk_type.go@@ -25,7 +25,7 @@ func ToDiskType(vt string) (diskType DiskType) {return}-func (diskType DiskType) String() string{+func (diskType DiskType) String() string {if diskType == "" {return ""}diff --git a/weed/topology/disk.go b/weed/topology/disk.goindex c159c4cca6..37d5e1272e 100644--- a/weed/topology/disk.go+++ b/weed/topology/disk.go@@ -48,11 +48,11 @@ func (d *DiskUsages) negative() *DiskUsages {t := newDiskUsages()for diskType, b := range d.usages {a := t.getOrCreateDisk(diskType)- a.volumeCount = - b.volumeCount- a.remoteVolumeCount = - b.remoteVolumeCount- a.activeVolumeCount = - b.activeVolumeCount- a.ecShardCount = - b.ecShardCount- a.maxVolumeCount = - b.maxVolumeCount+ a.volumeCount = -b.volumeCount+ a.remoteVolumeCount = -b.remoteVolumeCount+ a.activeVolumeCount = -b.activeVolumeCount+ a.ecShardCount = -b.ecShardCount+ a.maxVolumeCount = -b.maxVolumeCount}return t@@ -68,7 +68,7 @@ func (d *DiskUsages) ToMap() interface{} {return ret}-func (d *DiskUsages) ToDiskInfo() (map[string]*master_pb.DiskInfo) {+func (d *DiskUsages) ToDiskInfo() map[string]*master_pb.DiskInfo {ret := make(map[string]*master_pb.DiskInfo)for diskType, diskUsageCounts := range d.usages {m := &master_pb.DiskInfo{diff --git a/weed/topology/node.go b/weed/topology/node.goindex f9ac890ef0..95d63972e6 100644--- a/weed/topology/node.go+++ b/weed/topology/node.go@@ -39,7 +39,7 @@ type NodeImpl struct {diskUsages *DiskUsagesid NodeIdparent Node- sync.RWMutex // lock children+ sync.RWMutex // lock childrenchildren map[NodeId]NodemaxVolumeId needle.VolumeId