refactor(fmt): use gofumpt to format code. #1000063488

Signed-off-by: Victor1319 <zengxuewei@oppo.com>
This commit is contained in:
Victor1319 2025-04-24 17:32:44 +08:00
parent a819193dcd
commit 89a262f82d
16 changed files with 77 additions and 100 deletions

View File

@ -5,16 +5,19 @@ package raftserver
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/golang/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
var (
_ = proto.Marshal
_ = fmt.Errorf
_ = math.Inf
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
@ -38,9 +41,11 @@ func (*Member) ProtoMessage() {}
func (*Member) Descriptor() ([]byte, []int) {
return fileDescriptor_2fcc84b9998d60d8, []int{0}
}
func (m *Member) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Member) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Member.Marshal(b, m, deterministic)
@ -53,12 +58,15 @@ func (m *Member) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return b[:n], nil
}
}
func (m *Member) XXX_Merge(src proto.Message) {
xxx_messageInfo_Member.Merge(m, src)
}
func (m *Member) XXX_Size() int {
return m.Size()
}
func (m *Member) XXX_DiscardUnknown() {
xxx_messageInfo_Member.DiscardUnknown(m)
}
@ -111,9 +119,11 @@ func (*SnapshotMeta) ProtoMessage() {}
func (*SnapshotMeta) Descriptor() ([]byte, []int) {
return fileDescriptor_2fcc84b9998d60d8, []int{1}
}
func (m *SnapshotMeta) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SnapshotMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SnapshotMeta.Marshal(b, m, deterministic)
@ -126,12 +136,15 @@ func (m *SnapshotMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
return b[:n], nil
}
}
func (m *SnapshotMeta) XXX_Merge(src proto.Message) {
xxx_messageInfo_SnapshotMeta.Merge(m, src)
}
func (m *SnapshotMeta) XXX_Size() int {
return m.Size()
}
func (m *SnapshotMeta) XXX_DiscardUnknown() {
xxx_messageInfo_SnapshotMeta.DiscardUnknown(m)
}
@ -368,6 +381,7 @@ func encodeVarintProto(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
return base
}
func (m *Member) Size() (n int) {
if m == nil {
return 0
@ -439,9 +453,11 @@ func (m *SnapshotMeta) Size() (n int) {
func sovProto(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozProto(x uint64) (n int) {
return sovProto(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *Member) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -598,6 +614,7 @@ func (m *Member) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *SnapshotMeta) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -905,6 +922,7 @@ func (m *SnapshotMeta) Unmarshal(dAtA []byte) error {
}
return nil
}
func skipProto(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0

View File

@ -1365,52 +1365,6 @@ func (dp *DataPartition) isNormalType() bool {
return proto.IsNormalDp(dp.partitionType)
}
type SimpleVolView struct {
vv *proto.SimpleVolView
lastUpdateTime time.Time
}
type VolMap struct {
sync.Mutex
volMap map[string]*SimpleVolView
}
var volViews = VolMap{
Mutex: sync.Mutex{},
volMap: make(map[string]*SimpleVolView),
}
func (vo *VolMap) getSimpleVolView(VolumeID string) (vv *proto.SimpleVolView, err error) {
vo.Lock()
if volView, ok := vo.volMap[VolumeID]; ok && time.Since(volView.lastUpdateTime) < 5*time.Minute {
vo.Unlock()
return volView.vv, nil
}
vo.Unlock()
volView := &SimpleVolView{
vv: nil,
lastUpdateTime: time.Time{},
}
if vv, err = MasterClient.AdminAPI().GetVolumeSimpleInfo(VolumeID); err != nil {
log.LogErrorf("action[GetVolumeSimpleInfo] cannot get vol(%v) from master(%v) err(%v).",
VolumeID, MasterClient.Leader(), err)
return nil, err
}
log.LogDebugf("get volume info, vol(%s), vol(%v)", vv.Name, volView)
volView.vv = vv
volView.lastUpdateTime = time.Now()
vo.Lock()
vo.volMap[VolumeID] = volView
vo.Unlock()
return
}
func (dp *DataPartition) StopDecommissionRecover(stop bool) {
// only work for decommission repair
if !dp.isDecommissionRecovering() {

View File

@ -210,7 +210,6 @@ func (dp *DataPartition) CanRemoveRaftMember(peer proto.Peer, force bool) error
// 2. collect the applied ids from raft members.
// 3. based on the minimum applied id to cutoff and delete the saved raft log in order to free the disk space.
func (dp *DataPartition) StartRaftLoggingSchedule() {
getAppliedIDTimer := time.NewTimer(time.Second * 1)
truncateRaftLogTimer := time.NewTimer(time.Minute * 10)
storeAppliedIDTimer := time.NewTimer(time.Second * 10)
@ -389,7 +388,6 @@ func (dp *DataPartition) StartRaftAfterRepair(isLoad bool) {
// Add a raft node.
func (dp *DataPartition) addRaftNode(req *proto.AddDataPartitionRaftMemberRequest, index uint64) (isUpdated bool, err error) {
var (
heartbeatPort int
replicaPort int

View File

@ -323,7 +323,8 @@ func (manager *SpaceManager) reloadDisk(path string) (err error) {
rdonlySpace uint64
maxErr int
repairLimit bool
}) {
},
) {
err := manager.LoadDisk(
params.path,
params.reserved,

View File

@ -52,8 +52,10 @@ const (
magicNumber = byte('M')
)
var ErrNonBytecodeEncode = errors.New("non-bytecode serialization method")
var atime uint64
var (
ErrNonBytecodeEncode = errors.New("non-bytecode serialization method")
atime uint64
)
func alignment(block []byte, AlignSize int) int {
return int(uintptr(unsafe.Pointer(&block[0])) & uintptr(AlignSize-1))

View File

@ -67,7 +67,8 @@ type CacheBlock struct {
// NewCacheBlock create and returns a new extent instance.
func NewCacheBlock(rootPath string, volume string, inode, fixedOffset uint64, version uint32, allocSize uint64,
reader ReadExtentData, clientIP string, d *Disk) (cb *CacheBlock) {
reader ReadExtentData, clientIP string, d *Disk,
) (cb *CacheBlock) {
cb = new(CacheBlock)
cb.volume = volume
cb.inode = inode

View File

@ -389,7 +389,8 @@ func (f *FlashNode) getValidViewInfo(req *proto.FlashNodeManualTaskRequest) (met
}
func (f *FlashNode) doStreamReadRequest(ctx context.Context, conn net.Conn, req *proto.CacheReadRequest, p *proto.Packet,
block *cachengine.CacheBlock) (err error) {
block *cachengine.CacheBlock,
) (err error) {
const action = "action[doStreamReadRequest]"
needReplySize := uint32(req.Size_)
offset := int64(req.Offset)

View File

@ -1864,19 +1864,6 @@ func extractUint(r *http.Request, key string) (val int, err error) {
return val, nil
}
func extractPositiveUint(r *http.Request, key string) (val int, err error) {
var str string
if str = r.FormValue(key); str == "" {
return 0, fmt.Errorf("args [%s] is not legal", key)
}
if val, err = strconv.Atoi(str); err != nil || val <= 0 {
return 0, fmt.Errorf("args [%s] is not legal, val %s", key, str)
}
return val, nil
}
func extractUint64(r *http.Request, key string) (val uint64, err error) {
var str string
if str = r.FormValue(key); str == "" {

View File

@ -143,19 +143,6 @@ func (partition *DataPartition) resetFilesWithMissingReplica() {
partition.FilesWithMissingReplica = make(map[string]int64)
}
func (partition *DataPartition) dataNodeStartTime() int64 {
partition.Lock()
defer partition.Unlock()
startTime := int64(0)
for _, replica := range partition.Replicas {
if startTime < replica.dataNode.StartTime {
startTime = replica.dataNode.StartTime
}
}
return startTime
}
func (partition *DataPartition) addReplica(replica *DataReplica) {
for _, r := range partition.Replicas {
if replica.Addr == r.Addr {

View File

@ -188,7 +188,8 @@ func (metaNode *MetaNode) reachesThreshold() bool {
}
func (metaNode *MetaNode) createHeartbeatTask(masterAddr string, fileStatsEnable bool, fileStatsThresholds []uint64,
notifyForbidWriteOpOfProtoVer0 bool, metaNodeGOGC int, RaftPartitionCanUsingDifferentPortEnabled bool) (task *proto.AdminTask) {
notifyForbidWriteOpOfProtoVer0 bool, metaNodeGOGC int, RaftPartitionCanUsingDifferentPortEnabled bool,
) (task *proto.AdminTask) {
request := &proto.HeartBeatRequest{
CurrTime: time.Now().Unix(),
MasterAddr: masterAddr,

View File

@ -725,7 +725,6 @@ func (vol *Vol) checkDataPartitions(c *Cluster) (cnt int) {
}
}
totalPreloadCapacity := uint64(0)
var rwDpCountOfSSD int
var rwDpCountOfHDD int
@ -779,10 +778,6 @@ func (vol *Vol) checkDataPartitions(c *Cluster) (cnt int) {
dp.checkReplicationTask(c.Name, vol.dataPartitionSize)
}
if overSoldFactor > 0 {
totalPreloadCapacity = uint64(float32(totalPreloadCapacity) / overSoldFactor)
}
vol.dataPartitions.setReadWriteDataPartitionCntByMediaType(rwDpCountOfHDD, proto.MediaType_HDD)
vol.dataPartitions.setReadWriteDataPartitionCntByMediaType(rwDpCountOfSSD, proto.MediaType_SSD)
log.LogInfof("[checkDataPartitions] vol(%v), rwDpCountOfHDD(%v), rwDpCountOfSSD(%v)",
@ -1529,7 +1524,6 @@ func (vol *Vol) deleteDataPartitionFromDataNode(c *Cluster, task *proto.AdminTas
_, err = dataNode.TaskManager.syncSendAdminTask(task)
if err != nil {
log.LogErrorf("action[deleteDataReplica] vol[%v],data partition[%v],err[%v]", dp.VolName, dp.PartitionID, err)
err = nil
}
dp.Lock()

View File

@ -109,7 +109,6 @@ func (i *Inode) LeaseNotExpire() bool {
}
func (i *Inode) GetExtents() *SortedExtents {
if proto.IsStorageClassBlobStore(i.StorageClass) {
return NewSortedExtents()
}

View File

@ -3014,7 +3014,8 @@ func (m *metadataManager) opDeleteMigrationExtentKey(conn net.Conn, p *Packet,
}
func (m *metadataManager) opMetaUpdateInodeMeta(conn net.Conn, p *Packet,
remoteAddr string) (err error) {
remoteAddr string,
) (err error) {
req := &proto.UpdateInodeMetaRequest{}
if err = json.Unmarshal(p.Data, req); err != nil {
p.PacketErrorWithBody(proto.OpErr, ([]byte)(err.Error()))

View File

@ -839,7 +839,8 @@ func (v *Volume) PutObject(path string, reader io.Reader, opt *PutFileOption) (f
}
func (v *Volume) applyInodeToDEntry(parentId uint64, name string, inode uint64, isCompleteMultipart bool,
fullPath string, storageClass uint32) (err error) {
fullPath string, storageClass uint32,
) (err error) {
var existMode uint32
_, existMode, err = v.mw.Lookup_ll(parentId, name) // exist object inode
if err != nil && err != syscall.ENOENT {
@ -1482,7 +1483,8 @@ func (v *Volume) applyInodeToNewDentry(parentID uint64, name string, inode uint6
}
func (v *Volume) applyInodeToExistDentry(parentID uint64, name string, inode uint64, isCompleteMultipart bool,
fullPath string, storageClass uint32) (err error) {
fullPath string, storageClass uint32,
) (err error) {
var oldInode uint64
oldInode, err = v.mw.DentryUpdate_ll(parentID, name, inode, fullPath)
if err != nil {

View File

@ -5,17 +5,20 @@ package proto
import (
fmt "fmt"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/golang/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/golang/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
var (
_ = proto.Marshal
_ = fmt.Errorf
_ = math.Inf
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
@ -40,9 +43,11 @@ func (*DataSource) ProtoMessage() {}
func (*DataSource) Descriptor() ([]byte, []int) {
return fileDescriptor_9a29821e5022ef34, []int{0}
}
func (m *DataSource) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *DataSource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_DataSource.Marshal(b, m, deterministic)
@ -55,12 +60,15 @@ func (m *DataSource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return b[:n], nil
}
}
func (m *DataSource) XXX_Merge(src proto.Message) {
xxx_messageInfo_DataSource.Merge(m, src)
}
func (m *DataSource) XXX_Size() int {
return m.Size()
}
func (m *DataSource) XXX_DiscardUnknown() {
xxx_messageInfo_DataSource.DiscardUnknown(m)
}
@ -127,9 +135,11 @@ func (*CacheRequest) ProtoMessage() {}
func (*CacheRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_9a29821e5022ef34, []int{1}
}
func (m *CacheRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CacheRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CacheRequest.Marshal(b, m, deterministic)
@ -142,12 +152,15 @@ func (m *CacheRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
return b[:n], nil
}
}
func (m *CacheRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CacheRequest.Merge(m, src)
}
func (m *CacheRequest) XXX_Size() int {
return m.Size()
}
func (m *CacheRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CacheRequest.DiscardUnknown(m)
}
@ -217,9 +230,11 @@ func (*CacheReadRequest) ProtoMessage() {}
func (*CacheReadRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_9a29821e5022ef34, []int{2}
}
func (m *CacheReadRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CacheReadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CacheReadRequest.Marshal(b, m, deterministic)
@ -232,12 +247,15 @@ func (m *CacheReadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, er
return b[:n], nil
}
}
func (m *CacheReadRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CacheReadRequest.Merge(m, src)
}
func (m *CacheReadRequest) XXX_Size() int {
return m.Size()
}
func (m *CacheReadRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CacheReadRequest.DiscardUnknown(m)
}
@ -278,9 +296,11 @@ func (*CachePrepareRequest) ProtoMessage() {}
func (*CachePrepareRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_9a29821e5022ef34, []int{3}
}
func (m *CachePrepareRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CachePrepareRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CachePrepareRequest.Marshal(b, m, deterministic)
@ -293,12 +313,15 @@ func (m *CachePrepareRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte,
return b[:n], nil
}
}
func (m *CachePrepareRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CachePrepareRequest.Merge(m, src)
}
func (m *CachePrepareRequest) XXX_Size() int {
return m.Size()
}
func (m *CachePrepareRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CachePrepareRequest.DiscardUnknown(m)
}
@ -601,6 +624,7 @@ func encodeVarintDistributedCache(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
return base
}
func (m *DataSource) Size() (n int) {
if m == nil {
return 0
@ -718,9 +742,11 @@ func (m *CachePrepareRequest) Size() (n int) {
func sovDistributedCache(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozDistributedCache(x uint64) (n int) {
return sovDistributedCache(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *DataSource) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -899,6 +925,7 @@ func (m *DataSource) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *CacheRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -1111,6 +1138,7 @@ func (m *CacheRequest) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *CacheReadRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -1236,6 +1264,7 @@ func (m *CacheReadRequest) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *CachePrepareRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -1355,6 +1384,7 @@ func (m *CachePrepareRequest) Unmarshal(dAtA []byte) error {
}
return nil
}
func skipDistributedCache(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0

View File

@ -543,7 +543,8 @@ func getExtentsByMpId(dir string, volname string, mpId string) {
}
func InitLocalDir(dir string, volname string, partitionId string, dirType string) (tinyFilePath string,
normalFilePath string, normalMigrateFilePath string, err error) {
normalFilePath string, normalMigrateFilePath string, err error,
) {
var file *os.File
// tinyPath := filepath.Join(dir, volname, dirType, tinyDir)