mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
go fmt project
Signed-off-by: awzhgw <guowl18702995996@gmail.com>
This commit is contained in:
parent
f3eead28cb
commit
e841bb8e4b
@ -138,7 +138,7 @@ func Mount(cfg *config.Config) (err error) {
|
||||
fmt.Println(http.ListenAndServe(":"+profport, nil))
|
||||
}()
|
||||
|
||||
if err=ump.InitUmp(fmt.Sprintf("%v_%v", super.ClusterName(), ModuleName), umpDatadir);err!=nil {
|
||||
if err = ump.InitUmp(fmt.Sprintf("%v_%v", super.ClusterName(), ModuleName), umpDatadir); err != nil {
|
||||
return err
|
||||
}
|
||||
exporter.Init(super.ClusterName(), ModuleName, cfg)
|
||||
|
||||
@ -136,7 +136,7 @@ func main() {
|
||||
|
||||
//for multi-cpu scheduling
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
if err=ump.InitUmp(role, umpDatadir);err!=nil {
|
||||
if err = ump.InitUmp(role, umpDatadir); err != nil {
|
||||
fmt.Println(fmt.Sprintf("Fatal: init warnLogDir fail:%v ", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@ -25,8 +25,8 @@ const (
|
||||
|
||||
const (
|
||||
IntervalToUpdateReplica = 600 // interval to update the replica
|
||||
IntervalToUpdatePartitionSize = 60 // interval to update the partition size
|
||||
NumOfFilesToRecoverInParallel = 7 // number of files to be recovered simultaneously
|
||||
IntervalToUpdatePartitionSize = 60 // interval to update the partition size
|
||||
NumOfFilesToRecoverInParallel = 7 // number of files to be recovered simultaneously
|
||||
)
|
||||
|
||||
// Network protocol
|
||||
|
||||
@ -160,8 +160,8 @@ func (d *Disk) updateSpaceInfo() (err error) {
|
||||
if err = syscall.Statfs(d.Path, &statsInfo); err != nil {
|
||||
d.incReadErrCnt()
|
||||
}
|
||||
if d.Status==proto.Unavailable{
|
||||
mesg:=fmt.Sprintf("disk path %v error on %v", d.Path, LocalIP)
|
||||
if d.Status == proto.Unavailable {
|
||||
mesg := fmt.Sprintf("disk path %v error on %v", d.Path, LocalIP)
|
||||
log.LogErrorf(mesg)
|
||||
exporter.Warning(mesg)
|
||||
d.ForceExitRaftStore()
|
||||
|
||||
@ -366,8 +366,8 @@ func (dp *DataPartition) statusUpdate() {
|
||||
if dp.extentStore.GetExtentCount() >= storage.MaxExtentCount {
|
||||
status = proto.ReadOnly
|
||||
}
|
||||
if dp.Status()==proto.Unavailable{
|
||||
status= proto.Unavailable
|
||||
if dp.Status() == proto.Unavailable {
|
||||
status = proto.Unavailable
|
||||
}
|
||||
|
||||
dp.partitionStatus = int(math.Min(float64(status), float64(dp.disk.Status)))
|
||||
|
||||
@ -35,7 +35,7 @@ func (dp *DataPartition) Apply(command []byte, index uint64) (resp interface{},
|
||||
msg := &RaftCmdItem{}
|
||||
defer func(index uint64) {
|
||||
if err != nil {
|
||||
prefix := fmt.Sprintf("RandomWrite Datapartition(%v)_Extent(%v) apply error (%v)", dp.partitionID, extentID,err)
|
||||
prefix := fmt.Sprintf("RandomWrite Datapartition(%v)_Extent(%v) apply error (%v)", dp.partitionID, extentID, err)
|
||||
err = errors.Trace(err, prefix)
|
||||
exporter.Warning(err.Error())
|
||||
resp = proto.OpExistErr
|
||||
|
||||
@ -746,7 +746,7 @@ func (c *Cluster) decommissionDataPartition(offlineAddr string, dp *DataPartitio
|
||||
c.Name, dp.PartitionID, offlineAddr, newAddr, dp.Hosts)
|
||||
return
|
||||
errHandler:
|
||||
msg = fmt.Sprintf(errMsg + " clusterID[%v] partitionID:%v on Node:%v "+
|
||||
msg = fmt.Sprintf(errMsg+" clusterID[%v] partitionID:%v on Node:%v "+
|
||||
"Then Fix It on newHost:%v Err:%v , PersistenceHosts:%v ",
|
||||
c.Name, dp.PartitionID, offlineAddr, newAddr, err, dp.Hosts)
|
||||
if err != nil {
|
||||
|
||||
@ -561,7 +561,7 @@ func (c *Cluster) updateDataNode(dataNode *DataNode, dps []*proto.PartitionRepor
|
||||
continue
|
||||
}
|
||||
if dp, err := c.getDataPartitionByID(vr.PartitionID); err == nil {
|
||||
dp.updateMetric(vr, dataNode,c)
|
||||
dp.updateMetric(vr, dataNode, c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,14 +25,14 @@ import (
|
||||
|
||||
// DataNode stores all the information about a data node
|
||||
type DataNode struct {
|
||||
Total uint64 `json:"TotalWeight"`
|
||||
Used uint64 `json:"UsedWeight"`
|
||||
AvailableSpace uint64
|
||||
ID uint64
|
||||
RackName string `json:"Rack"`
|
||||
Addr string
|
||||
ReportTime time.Time
|
||||
isActive bool
|
||||
Total uint64 `json:"TotalWeight"`
|
||||
Used uint64 `json:"UsedWeight"`
|
||||
AvailableSpace uint64
|
||||
ID uint64
|
||||
RackName string `json:"Rack"`
|
||||
Addr string
|
||||
ReportTime time.Time
|
||||
isActive bool
|
||||
sync.RWMutex
|
||||
UsageRatio float64 // used / total space
|
||||
SelectedTimes uint64 // number times that this datanode has been selected as the location for a data partition.
|
||||
|
||||
@ -28,14 +28,14 @@ import (
|
||||
|
||||
// DataPartition represents the structure of storing the file contents.
|
||||
type DataPartition struct {
|
||||
PartitionID uint64
|
||||
LastLoadedTime int64
|
||||
ReplicaNum uint8
|
||||
Status int8
|
||||
isRecover bool
|
||||
Replicas []*DataReplica
|
||||
Hosts []string // host addresses
|
||||
Peers []proto.Peer
|
||||
PartitionID uint64
|
||||
LastLoadedTime int64
|
||||
ReplicaNum uint8
|
||||
Status int8
|
||||
isRecover bool
|
||||
Replicas []*DataReplica
|
||||
Hosts []string // host addresses
|
||||
Peers []proto.Peer
|
||||
sync.RWMutex
|
||||
total uint64
|
||||
used uint64
|
||||
@ -310,7 +310,7 @@ func (partition *DataPartition) getFileCount() {
|
||||
}
|
||||
|
||||
for _, replica := range partition.Replicas {
|
||||
msg = fmt.Sprintf(getFileCountOnDataReplica + "partitionID:%v replicaAddr:%v FileCount:%v "+
|
||||
msg = fmt.Sprintf(getFileCountOnDataReplica+"partitionID:%v replicaAddr:%v FileCount:%v "+
|
||||
"NodeIsActive:%v replicaIsActive:%v .replicaStatusOnNode:%v ", partition.PartitionID, replica.Addr, replica.FileCount,
|
||||
replica.getReplicaNode().isActive, replica.isActive(defaultDataPartitionTimeOutSec), replica.Status)
|
||||
log.LogInfo(msg)
|
||||
|
||||
@ -17,9 +17,9 @@ package master
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/chubaofs/chubaofs/proto"
|
||||
"github.com/chubaofs/chubaofs/util"
|
||||
"github.com/chubaofs/chubaofs/util/log"
|
||||
"time"
|
||||
"github.com/chubaofs/chubaofs/util"
|
||||
)
|
||||
|
||||
func (partition *DataPartition) checkStatus(clusterName string, needLog bool, dpTimeOutSec int64) {
|
||||
|
||||
@ -853,8 +853,8 @@ func (c *Cluster) loadDataPartitions() (err error) {
|
||||
dp := newDataPartition(dpv.PartitionID, dpv.ReplicaNum, dpv.VolName, dpv.VolID)
|
||||
dp.Hosts = strings.Split(dpv.Hosts, underlineSeparator)
|
||||
dp.Peers = dpv.Peers
|
||||
for _,rv := range dpv.Replicas {
|
||||
dp.afterCreation(rv.Addr,rv.DiskPath,c)
|
||||
for _, rv := range dpv.Replicas {
|
||||
dp.afterCreation(rv.Addr, rv.DiskPath, c)
|
||||
}
|
||||
vol.dataPartitions.put(dp)
|
||||
log.LogInfof("action[loadDataPartitions],vol[%v],dp[%v]", vol.Name, dp.PartitionID)
|
||||
|
||||
@ -32,7 +32,7 @@ import (
|
||||
const (
|
||||
ExtentOpenOpt = os.O_CREATE | os.O_RDWR | os.O_EXCL
|
||||
ExtentHasClose = -1
|
||||
SEEK_DATA = 3
|
||||
SEEK_DATA = 3
|
||||
)
|
||||
|
||||
type ExtentInfo struct {
|
||||
@ -311,28 +311,28 @@ const (
|
||||
)
|
||||
|
||||
// DeleteTiny deletes a tiny extent.
|
||||
func (e *Extent) DeleteTiny(offset, size int64) (hasDelete bool,err error) {
|
||||
func (e *Extent) DeleteTiny(offset, size int64) (hasDelete bool, err error) {
|
||||
if int(offset)%PageSize != 0 {
|
||||
return false,ParameterMismatchError
|
||||
return false, ParameterMismatchError
|
||||
}
|
||||
|
||||
if int(size)%PageSize != 0 {
|
||||
size += int64(PageSize - int(size)%PageSize)
|
||||
}
|
||||
if int(size)%PageSize != 0 {
|
||||
return false,ParameterMismatchError
|
||||
return false, ParameterMismatchError
|
||||
}
|
||||
|
||||
newOffset,err:=e.file.Seek(offset,SEEK_DATA)
|
||||
if err!=nil {
|
||||
newOffset, err := e.file.Seek(offset, SEEK_DATA)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), syscall.ENXIO.Error()) {
|
||||
return true, nil
|
||||
}
|
||||
return false,err
|
||||
return false, err
|
||||
}
|
||||
if newOffset-offset>=size{
|
||||
hasDelete=true
|
||||
return true,nil
|
||||
if newOffset-offset >= size {
|
||||
hasDelete = true
|
||||
return true, nil
|
||||
}
|
||||
err = syscall.Fallocate(int(e.file.Fd()), FallocFLPunchHole|FallocFLKeepSize, offset, size)
|
||||
|
||||
|
||||
@ -354,7 +354,7 @@ func (s *ExtentStore) tinyDelete(e *Extent, offset, size, tinyDeleteFileOffset i
|
||||
var (
|
||||
hasDelete bool
|
||||
)
|
||||
if hasDelete,err = e.DeleteTiny(offset, size); err != nil {
|
||||
if hasDelete, err = e.DeleteTiny(offset, size); err != nil {
|
||||
return
|
||||
}
|
||||
if hasDelete {
|
||||
@ -636,9 +636,9 @@ func (s *ExtentStore) ReadTinyDeleteRecords(offset, size int64, data []byte) (cr
|
||||
// NextExtentID returns the next extentID. When the client sends the request to create an extent,
|
||||
// this function generates an unique extentID within the current partition.
|
||||
// This function can only be called by the leader.
|
||||
func (s *ExtentStore) NextExtentID() (extentID uint64,err error) {
|
||||
extentID=atomic.AddUint64(&s.baseExtentID, 1)
|
||||
err=s.PersistenceBaseExtentID(extentID)
|
||||
func (s *ExtentStore) NextExtentID() (extentID uint64, err error) {
|
||||
extentID = atomic.AddUint64(&s.baseExtentID, 1)
|
||||
err = s.PersistenceBaseExtentID(extentID)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ func Warning(detail string) (a *Alarm) {
|
||||
return
|
||||
}
|
||||
a = AlarmPool.Get().(*Alarm)
|
||||
a.name = metricsName(fmt.Sprintf("%s_%s_alarm", clustername,modulename))
|
||||
a.name = metricsName(fmt.Sprintf("%s_%s_alarm", clustername, modulename))
|
||||
a.Add(1)
|
||||
return
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ var (
|
||||
}}
|
||||
)
|
||||
|
||||
func InitUmp(module, dataDir string)(err error) {
|
||||
func InitUmp(module, dataDir string) (err error) {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
if err := initLogName(module, dataDir); err != nil {
|
||||
return err
|
||||
|
||||
@ -157,7 +157,7 @@ func initLogName(module, dataDir string) (err error) {
|
||||
if !strings.HasSuffix(UmpDataDir, "/") {
|
||||
UmpDataDir += "/"
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
return fmt.Errorf("warnLogDir dir not config")
|
||||
}
|
||||
if err = os.MkdirAll(UmpDataDir, 0666); err != nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user