Skip to content

Commit

Permalink
refactor: execute gofmt to the whole repo
Browse files Browse the repository at this point in the history
This commit does nothing but execute gofmt to the whole repo using the
following command:

$ find . -type f -name "*.go" | grep -v 'vendor' | xargs gofmt -w

Signed-off-by: Shuoran Liu <[email protected]>
  • Loading branch information
shuoranliu committed Sep 24, 2021
1 parent 9aa807d commit b07bb17
Show file tree
Hide file tree
Showing 30 changed files with 928 additions and 950 deletions.
8 changes: 4 additions & 4 deletions cli/api/metaapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"sync"
"time"

"bufio"
"github.com/chubaofs/chubaofs/metanode"
"github.com/chubaofs/chubaofs/proto"
"github.com/chubaofs/chubaofs/util/log"
"github.com/chubaofs/chubaofs/metanode"
"bufio"
"io"
)

Expand Down Expand Up @@ -231,7 +231,7 @@ func (mc *MetaHttpClient) GetMetaPartition(pid uint64) (cursor uint64, err error
return body.Cursor, nil
}

func (mc *MetaHttpClient) GetAllDentry(pid uint64) (dentryMap map[string]*metanode.Dentry, err error, ) {
func (mc *MetaHttpClient) GetAllDentry(pid uint64) (dentryMap map[string]*metanode.Dentry, err error) {
defer func() {
if err != nil {
log.LogErrorf("action[GetAllDentry],pid:%v,err:%v", pid, err)
Expand Down Expand Up @@ -281,7 +281,7 @@ func parseToken(dec *json.Decoder, expectToken rune) (err error) {
return
}

func (mc *MetaHttpClient) GetAllInodes(pid uint64) (rstMap map[uint64]*Inode, err error, ) {
func (mc *MetaHttpClient) GetAllInodes(pid uint64) (rstMap map[uint64]*Inode, err error) {
defer func() {
if err != nil {
log.LogErrorf("action[GetAllInodes],pid:%v,err:%v", pid, err)
Expand Down
16 changes: 8 additions & 8 deletions cli/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func newClusterStatCmd(client *master.MasterClient) *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
var (
err error
cs *proto.ClusterStatInfo
cs *proto.ClusterStatInfo
)
defer func() {
if err != nil {
Expand All @@ -109,10 +109,10 @@ func newClusterStatCmd(client *master.MasterClient) *cobra.Command {

func newClusterFreezeCmd(client *master.MasterClient) *cobra.Command {
var cmd = &cobra.Command{
Use: CliOpFreeze + " [ENABLE]",
Use: CliOpFreeze + " [ENABLE]",
ValidArgs: []string{"true", "false"},
Short: cmdClusterFreezeShort,
Args: cobra.MinimumNArgs(1),
Short: cmdClusterFreezeShort,
Args: cobra.MinimumNArgs(1),
Long: `Turn on or off the automatic allocation of the data partitions.
If 'freeze=false', ChubaoFS WILL automatically allocate new data partitions for the volume when:
1. the used space is below the max capacity,
Expand All @@ -121,8 +121,8 @@ If 'freeze=false', ChubaoFS WILL automatically allocate new data partitions for
If 'freeze=true', ChubaoFS WILL NOT automatically allocate new data partitions `,
Run: func(cmd *cobra.Command, args []string) {
var (
err error
enable bool
err error
enable bool
)
defer func() {
if err != nil {
Expand Down Expand Up @@ -155,8 +155,8 @@ func newClusterSetThresholdCmd(client *master.MasterClient) *cobra.Command {
If the memory usage reaches this threshold, all the mata partition will be readOnly.`,
Run: func(cmd *cobra.Command, args []string) {
var (
err error
threshold float64
err error
threshold float64
)
defer func() {
if err != nil {
Expand Down
19 changes: 9 additions & 10 deletions cli/cmd/datapartition.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ func newDataPartitionCmd(client *master.MasterClient) *cobra.Command {
}

const (
cmdDataPartitionGetShort = "Display detail information of a data partition"
cmdCheckCorruptDataPartitionShort = "Check and list unhealthy data partitions"
cmdDataPartitionDecommissionShort = "Decommission a replication of the data partition to a new address"
cmdDataPartitionReplicateShort = "Add a replication of the data partition on a new address"
cmdDataPartitionDeleteReplicaShort = "Delete a replication of the data partition on a fixed address"
)
cmdDataPartitionGetShort = "Display detail information of a data partition"
cmdCheckCorruptDataPartitionShort = "Check and list unhealthy data partitions"
cmdDataPartitionDecommissionShort = "Decommission a replication of the data partition to a new address"
cmdDataPartitionReplicateShort = "Add a replication of the data partition on a new address"
cmdDataPartitionDeleteReplicaShort = "Delete a replication of the data partition on a fixed address"
)

func newDataPartitionGetCmd(client *master.MasterClient) *cobra.Command {
var cmd = &cobra.Command{
Expand Down Expand Up @@ -91,9 +91,9 @@ you can use the "reset" command to fix the problem.The "reset" command may lead
The "reset" command will be released in next version`,
Run: func(cmd *cobra.Command, args []string) {
var (
diagnosis *proto.DataPartitionDiagnosis
dataNodes []*proto.DataNodeInfo
err error
diagnosis *proto.DataPartitionDiagnosis
dataNodes []*proto.DataNodeInfo
err error
)
defer func() {
if err != nil {
Expand Down Expand Up @@ -150,7 +150,6 @@ The "reset" command will be released in next version`,
}
}


stdout("\n")
stdout("%v\n", "[Bad data partitions(decommission not completed)]:")
badPartitionTablePattern := "%-8v %-10v\n"
Expand Down
12 changes: 6 additions & 6 deletions cli/cmd/http_service.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package cmd

import (
"github.com/chubaofs/chubaofs/sdk/master"
"github.com/chubaofs/chubaofs/proto"
"github.com/chubaofs/chubaofs/sdk/master"
)

type clientHandler interface {
excuteHttp() (err error)
}

type volumeClient struct {
name string
name string
capacity uint64
opCode MasterOp
client *master.MasterClient
opCode MasterOp
client *master.MasterClient
}

func NewVolumeClient(opCode MasterOp, client *master.MasterClient) (vol *volumeClient){
func NewVolumeClient(opCode MasterOp, client *master.MasterClient) (vol *volumeClient) {
vol = new(volumeClient)
vol.opCode = opCode
vol.opCode = opCode
vol.client = client
return
}
Expand Down
26 changes: 13 additions & 13 deletions cli/cmd/metapartition.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ func newMetaPartitionCmd(client *master.MasterClient) *cobra.Command {
}

const (
cmdMetaPartitionGetShort = "Display detail information of a meta partition"
cmdCheckCorruptMetaPartitionShort = "Check out corrupt meta partitions"
cmdMetaPartitionDecommissionShort = "Decommission a replication of the meta partition to a new address"
cmdMetaPartitionReplicateShort = "Add a replication of the meta partition on a new address"
cmdMetaPartitionDeleteReplicaShort = "Delete a replication of the meta partition on a fixed address"
)
cmdMetaPartitionGetShort = "Display detail information of a meta partition"
cmdCheckCorruptMetaPartitionShort = "Check out corrupt meta partitions"
cmdMetaPartitionDecommissionShort = "Decommission a replication of the meta partition to a new address"
cmdMetaPartitionReplicateShort = "Add a replication of the meta partition on a new address"
cmdMetaPartitionDeleteReplicaShort = "Delete a replication of the meta partition on a fixed address"
)

func newMetaPartitionGetCmd(client *master.MasterClient) *cobra.Command {
var cmd = &cobra.Command{
Expand All @@ -58,9 +58,9 @@ func newMetaPartitionGetCmd(client *master.MasterClient) *cobra.Command {
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
var (
err error
partitionID uint64
partition *proto.MetaPartitionInfo
err error
partitionID uint64
partition *proto.MetaPartitionInfo
)
defer func() {
if err != nil {
Expand Down Expand Up @@ -91,9 +91,9 @@ the corrupt nodes, the few remaining replicas can not reach an agreement with on
"reset" command will be released in next version.`,
Run: func(cmd *cobra.Command, args []string) {
var (
diagnosis *proto.MetaPartitionDiagnosis
metaNodes []*proto.MetaNodeInfo
err error
diagnosis *proto.MetaPartitionDiagnosis
metaNodes []*proto.MetaNodeInfo
err error
)
defer func() {
if err != nil {
Expand Down Expand Up @@ -143,7 +143,7 @@ the corrupt nodes, the few remaining replicas can not reach an agreement with on
})
for _, pid := range diagnosis.LackReplicaMetaPartitionIDs {
var partition *proto.MetaPartitionInfo
if partition, err = client.ClientAPI().GetMetaPartition( pid); err != nil {
if partition, err = client.ClientAPI().GetMetaPartition(pid); err != nil {
err = fmt.Errorf("Partition not found, err:[%v] ", err)
return
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func stdout(format string, a ...interface{}) {
}

func errout(format string, a ...interface{}) {
log.LogErrorf(format + "\n", a...)
log.LogErrorf(format+"\n", a...)
_, _ = fmt.Fprintf(os.Stderr, format, a...)
OsExitWithLogFlush()
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/valid.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func validMetaNodes(client *sdk.MasterClient, toComplete string) []string {
var (
validMetaNodes []string
clusterView *proto.ClusterView
err error
err error
)
if clusterView, err = client.AdminAPI().GetCluster(); err != nil {
errout("Error: %v", err)
Expand Down
11 changes: 5 additions & 6 deletions cli/cmd/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const (

func newZoneCmd(client *sdk.MasterClient) *cobra.Command {
var cmd = &cobra.Command{
Use: cmdZoneUse,
Short: cmdZoneShort,
Args: cobra.MinimumNArgs(0),
Use: cmdZoneUse,
Short: cmdZoneShort,
Args: cobra.MinimumNArgs(0),
}
cmd.AddCommand(
newZoneListCmd(client),
Expand Down Expand Up @@ -71,11 +71,10 @@ func newZoneListCmd(client *sdk.MasterClient) *cobra.Command {
return cmd
}


func newZoneInfoCmd(client *sdk.MasterClient) *cobra.Command {
var cmd = &cobra.Command{
Use: CliOpInfo + " [NAME]",
Short: cmdZoneInfoShort,
Use: CliOpInfo + " [NAME]",
Short: cmdZoneInfoShort,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
var topo *proto.TopologyView
Expand Down
8 changes: 4 additions & 4 deletions datanode/limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
)

var (
deleteLimiteRater = rate.NewLimiter(rate.Inf, defaultMarkDeleteLimitBurst)
MaxExtentRepairLimit = 20000
MinExtentRepairLimit = 5
CurExtentRepairLimit = MaxExtentRepairLimit
deleteLimiteRater = rate.NewLimiter(rate.Inf, defaultMarkDeleteLimitBurst)
MaxExtentRepairLimit = 20000
MinExtentRepairLimit = 5
CurExtentRepairLimit = MaxExtentRepairLimit
extentRepairLimitRater chan struct{}
)

Expand Down
4 changes: 2 additions & 2 deletions master/admin_task_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type AdminTaskManager struct {
targetAddr string
TaskMap map[string]*proto.AdminTask
sync.RWMutex
exitCh chan struct{}
connPool *util.ConnectPool
exitCh chan struct{}
connPool *util.ConnectPool
}

func newAdminTaskManager(targetAddr, clusterID string) (sender *AdminTaskManager) {
Expand Down
3 changes: 2 additions & 1 deletion master/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,8 @@ func (c *Cluster) removeDataPartitionRaftMember(dp *DataPartition, removePeer pr
defer dp.offlineMutex.Unlock()
defer func() {
if err1 := c.updateDataPartitionOfflinePeerIDWithLock(dp, 0); err1 != nil {
err = errors.Trace(err, "updateDataPartitionOfflinePeerIDWithLock failed, err[%v]", err1) }
err = errors.Trace(err, "updateDataPartitionOfflinePeerIDWithLock failed, err[%v]", err1)
}
}()
if err = c.updateDataPartitionOfflinePeerIDWithLock(dp, removePeer.ID); err != nil {
log.LogErrorf("action[removeDataPartitionRaftMember] vol[%v],data partition[%v],err[%v]", dp.VolName, dp.PartitionID, err)
Expand Down
8 changes: 4 additions & 4 deletions master/cluster_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ type volStatInfo = proto.VolStatInfo

func newVolStatInfo(name string, total, used uint64, ratio string) *volStatInfo {
return &volStatInfo{
Name: name,
TotalSize: total,
UsedSize: used,
UsedRatio: ratio,
Name: name,
TotalSize: total,
UsedSize: used,
UsedRatio: ratio,
}
}

Expand Down
6 changes: 3 additions & 3 deletions master/cluster_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (c *Cluster) deleteMetaPartition(partition *MetaPartition, removeMetaNode *
func (c *Cluster) removeMetaPartitionRaftMember(partition *MetaPartition, removePeer proto.Peer) (err error) {
partition.offlineMutex.Lock()
defer partition.offlineMutex.Unlock()
defer func(){
defer func() {
if err1 := c.updateMetaPartitionOfflinePeerIDWithLock(partition, 0); err1 != nil {
err = errors.Trace(err, "updateMetaPartitionOfflinePeerIDWithLock failed, err[%v]", err1)
}
Expand Down Expand Up @@ -373,7 +373,7 @@ func (c *Cluster) removeMetaPartitionRaftMember(partition *MetaPartition, remove
return
}

func (c *Cluster) updateMetaPartitionOfflinePeerIDWithLock(mp *MetaPartition, peerID uint64) (err error){
func (c *Cluster) updateMetaPartitionOfflinePeerIDWithLock(mp *MetaPartition, peerID uint64) (err error) {
mp.Lock()
defer mp.Unlock()
mp.OfflinePeerID = peerID
Expand Down Expand Up @@ -569,7 +569,7 @@ func (c *Cluster) doLoadDataPartition(dp *DataPartition) {

dp.getFileCount()
dp.validateCRC(c.Name)
dp.checkReplicaSize(c.Name,c.cfg.diffSpaceUsage)
dp.checkReplicaSize(c.Name, c.cfg.diffSpaceUsage)
dp.setToNormal()
}

Expand Down
2 changes: 1 addition & 1 deletion master/gapi_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (s *VolumeService) volPermission(ctx context.Context, args struct {
func (s *VolumeService) createVolume(ctx context.Context, args struct {
Name, Owner, ZoneName, Description string
Capacity, DataPartitionSize, MpCount, DpReplicaNum uint64
FollowerRead, Authenticate, CrossZone bool
FollowerRead, Authenticate, CrossZone bool
}) (*Vol, error) {
uid, per, err := permissions(ctx, ADMIN|USER)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions master/meta_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ func (mp *MetaPartition) checkStatus(clusterID string, writeLog bool, replicaNum
log.LogInfo(msg)
doSplit = true
} else {
if(mr.metaNode.reachesThreshold() || mp.End - mp.MaxInodeID > 2 * defaultMetaPartitionInodeIDStep) {
if mr.metaNode.reachesThreshold() || mp.End-mp.MaxInodeID > 2*defaultMetaPartitionInodeIDStep {
msg := fmt.Sprintf("split[checkStatus],change state,id:%v,status:%v,replicaNum:%v,replicas:%v,persistenceHosts:%v, inodeCount:%v, MaxInodeID:%v, start:%v, end:%v",
mp.PartitionID, mp.Status, mp.ReplicaNum, len(liveReplicas), mp.Hosts, mp.InodeCount, mp.MaxInodeID, mp.Start, mp.End)
log.LogInfo(msg)
log.LogInfo(msg)
mp.Status = proto.ReadOnly
}
}
Expand Down
3 changes: 0 additions & 3 deletions master/metadata_fsm_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ func (m *RaftCmd) setOpType() {
}
}


//key=#c#name
func (c *Cluster) syncPutCluster() (err error) {
metadata := new(RaftCmd)
Expand Down Expand Up @@ -724,5 +723,3 @@ func (c *Cluster) loadDataPartitions() (err error) {
}
return
}


4 changes: 2 additions & 2 deletions master/vol.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ func (vol *Vol) checkMetaPartitions(c *Cluster) {
doSplit = mp.checkStatus(c.Name, true, int(vol.mpReplicaNum), maxPartitionID)
if doSplit {
nextStart := mp.MaxInodeID + defaultMetaPartitionInodeIDStep
log.LogInfof(c.Name, fmt.Sprintf("cluster[%v],vol[%v],meta partition[%v] splits start[%v] maxinodeid:[%v] default step:[%v],nextStart[%v]",
c.Name, vol.Name, mp.PartitionID, mp.Start ,mp.MaxInodeID ,defaultMetaPartitionInodeIDStep, nextStart))
log.LogInfof(c.Name, fmt.Sprintf("cluster[%v],vol[%v],meta partition[%v] splits start[%v] maxinodeid:[%v] default step:[%v],nextStart[%v]",
c.Name, vol.Name, mp.PartitionID, mp.Start, mp.MaxInodeID, defaultMetaPartitionInodeIDStep, nextStart))
if err = vol.splitMetaPartition(c, mp, nextStart); err != nil {
Warn(c.Name, fmt.Sprintf("cluster[%v],vol[%v],meta partition[%v] splits failed,err[%v]", c.Name, vol.Name, mp.PartitionID, err))
}
Expand Down
2 changes: 1 addition & 1 deletion metanode/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"net"
syslog "log"
"net"
_ "net/http/pprof"
"os"
"path"
Expand Down
4 changes: 2 additions & 2 deletions objectnode/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ type FSFileInfo struct {
Size int64
Mode os.FileMode
ModifyTime time.Time
CreateTime time.Time
CreateTime time.Time
ETag string
Inode uint64
MIMEType string
Disposition string
CacheControl string
Expires string
Metadata map[string]string `graphql:"-"` // User-defined metadata
Metadata map[string]string `graphql:"-"` // User-defined metadata
}

type Prefixes []string
Expand Down
Loading

0 comments on commit b07bb17

Please sign in to comment.