Skip to content

Commit

Permalink
fix(blobnode): modify camel case
Browse files Browse the repository at this point in the history
Signed-off-by: fengshunli <[email protected]>
  • Loading branch information
fengshunli authored and sejust committed Jul 7, 2023
1 parent 2d5176f commit a4537b5
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions blobstore/api/blobnode/iostat.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ func (it IOType) IsValid() bool {
}

func (it IOType) String() string {
return IOtypemap[uint64(it)]
return IOtypemap[it]
}

func Getiotype(ctx context.Context) IOType {
func GetIoType(ctx context.Context) IOType {
v := ctx.Value(_ioFlowStatKey)
if v == nil {
return NormalIO
}
return v.(IOType)
}

func Setiotype(ctx context.Context, iot IOType) context.Context {
func SetIoType(ctx context.Context, iot IOType) context.Context {
return context.WithValue(ctx, _ioFlowStatKey, iot)
}

Expand Down
8 changes: 4 additions & 4 deletions blobstore/api/blobnode/iostat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ import (
"github.com/stretchr/testify/require"
)

func TestGetIotype(t *testing.T) {
func TestGetIoType(t *testing.T) {
ctx := context.TODO()

iotype := Getiotype(ctx)
iotype := GetIoType(ctx)
require.Equal(t, NormalIO, iotype)

ctx0 := context.WithValue(ctx, _ioFlowStatKey, CompactIO)
iotype = Getiotype(ctx0)
iotype = GetIoType(ctx0)
require.Equal(t, CompactIO, iotype)

ctx1 := context.WithValue(ctx0, _ioFlowStatKey, DiskRepairIO)
iotype = Getiotype(ctx1)
iotype = GetIoType(ctx1)
require.Equal(t, DiskRepairIO, iotype)
}
2 changes: 1 addition & 1 deletion blobstore/blobnode/base/flow/iostat.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func SetupDefaultIOStat(s *IOFlowStat) {
defaultIOStat = s
}

// ${pid}.${key}_${value}.${suffix}
// GenerateStatName ${pid}.${key}_${value}.${suffix}
func GenerateStatName(pid int, key string, value string, suffix string) string {
return fmt.Sprintf("%d.%s_%s.%s", pid, key, value, suffix)
}
Expand Down
2 changes: 1 addition & 1 deletion blobstore/blobnode/core/chunk/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (cs *chunk) handleErrCompact(ctx context.Context, ncs core.ChunkAPI) {
func (cs *chunk) doCompact(ctx context.Context, ncs *chunk) (err error) {
span := trace.SpanFromContextSafe(ctx)

ctx = bnapi.Setiotype(ctx, bnapi.CompactIO)
ctx = bnapi.SetIoType(ctx, bnapi.CompactIO)

startBid := proto.InValidBlobID
replStg := cs.getStg()
Expand Down
2 changes: 1 addition & 1 deletion blobstore/blobnode/core/disk/chunkinspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (ds *DiskStorage) maybeCleanRubbishChunk(ctx context.Context, id bnapi.Chun
span := trace.SpanFromContextSafe(ctx)

// set io type
ctx = bnapi.Setiotype(ctx, bnapi.InternalIO)
ctx = bnapi.SetIoType(ctx, bnapi.InternalIO)

span.Debugf("chunk:%s maybe rubbish, will confirm", id)

Expand Down
2 changes: 1 addition & 1 deletion blobstore/blobnode/core/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ func (ds *DiskStorage) cleanReleasedChunks() (err error) {
span.Debugf("come in CleanChunks.")

// set io type
ctx = bnapi.Setiotype(ctx, bnapi.InternalIO)
ctx = bnapi.SetIoType(ctx, bnapi.InternalIO)

protectionPeriod := time.Duration(ds.Conf.ChunkReleaseProtectionM)
now := time.Now().UnixNano()
Expand Down
6 changes: 3 additions & 3 deletions blobstore/blobnode/core/storage/datafile.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,17 @@ func (cd *datafile) spaceInfo() (size int64, phySpace int64, err error) {
}

func (cd *datafile) qosReaderAt(ctx context.Context, reader io.ReaderAt) io.ReaderAt {
ioType := bnapi.Getiotype(ctx)
ioType := bnapi.GetIoType(ctx)
return cd.ioQos.ReaderAt(ctx, ioType, reader)
}

func (cd *datafile) qosWriterAt(ctx context.Context, writer io.WriterAt) io.WriterAt {
ioType := bnapi.Getiotype(ctx)
ioType := bnapi.GetIoType(ctx)
w := cd.ioQos.WriterAt(ctx, ioType, writer)
return w
}

func (cd *datafile) qosWriter(ctx context.Context, writer io.Writer) io.Writer {
ioType := bnapi.Getiotype(ctx)
ioType := bnapi.GetIoType(ctx)
return cd.ioQos.Writer(ctx, ioType, writer)
}
2 changes: 1 addition & 1 deletion blobstore/blobnode/datainspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func ScanShard(ctx context.Context, cs core.ChunkAPI, startBid proto.BlobID, ins
func startInspect(ctx context.Context, cs core.ChunkAPI) ([]bnapi.BadShard, error) {
span := trace.SpanFromContextSafe(ctx)
span.Debugf("start inspect chunk, vuid:%v,chunkid:%s.", cs.Vuid(), cs.ID())
ctx = bnapi.Setiotype(ctx, bnapi.InspectIO)
ctx = bnapi.SetIoType(ctx, bnapi.InspectIO)
startBid := proto.InValidBlobID
ds := cs.Disk()
badShards := make([]bnapi.BadShard, 0)
Expand Down
12 changes: 6 additions & 6 deletions blobstore/blobnode/db/metadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (md *metadb) SetIOStat(stat *flow.IOFlowStat) {
}

func (md *metadb) Get(ctx context.Context, key []byte) (value []byte, err error) {
mgr, iot := md.getiotype(ctx)
mgr, iot := md.getIoType(ctx)

mgr.ReadBegin(1)
defer mgr.ReadEnd(time.Now())
Expand Down Expand Up @@ -134,7 +134,7 @@ func (md *metadb) Put(ctx context.Context, kv rdb.KV) (err error) {
Data: kv,
}

mgr, iot := md.getiotype(ctx)
mgr, iot := md.getIoType(ctx)

mgr.WriteBegin(1)
defer mgr.WriteEnd(time.Now())
Expand All @@ -158,7 +158,7 @@ func (md *metadb) Delete(ctx context.Context, key []byte) (err error) {
Data: rdb.KV{Key: key},
}

mgr, iot := md.getiotype(ctx)
mgr, iot := md.getIoType(ctx)

mgr.WriteBegin(1)
defer mgr.WriteEnd(time.Now())
Expand All @@ -182,7 +182,7 @@ func (md *metadb) DeleteRange(ctx context.Context, start, end []byte) (err error
Data: rdb.Range{Start: start, Limit: end},
}

mgr, iot := md.getiotype(ctx)
mgr, iot := md.getIoType(ctx)

mgr.WriteBegin(1)
defer mgr.WriteEnd(time.Now())
Expand Down Expand Up @@ -325,8 +325,8 @@ func (md *metadb) doBatch(ctx context.Context, reqs []Request) (err error) {
return err
}

func (md *metadb) getiotype(ctx context.Context) (iostat.StatMgrAPI, bnapi.IOType) {
iot := bnapi.Getiotype(ctx)
func (md *metadb) getIoType(ctx context.Context) (iostat.StatMgrAPI, bnapi.IOType) {
iot := bnapi.GetIoType(ctx)
mgr := md.iostat.GetStatMgr(iot)
return mgr, iot
}
Expand Down
8 changes: 4 additions & 4 deletions blobstore/blobnode/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (s *Service) ShardGet(c *rpc.Context) {
}

// set io type
ctx = bnapi.Setiotype(ctx, args.Type)
ctx = bnapi.SetIoType(ctx, args.Type)
ctx = limitio.SetLimitTrack(ctx)

s.lock.RLock()
Expand Down Expand Up @@ -342,7 +342,7 @@ func (s *Service) ShardMarkdelete(c *rpc.Context) {
}

// set io type
ctx = bnapi.Setiotype(ctx, bnapi.DeleteIO)
ctx = bnapi.SetIoType(ctx, bnapi.DeleteIO)
ctx = limitio.SetLimitTrack(ctx)

err = cs.MarkDelete(ctx, args.Bid)
Expand Down Expand Up @@ -413,7 +413,7 @@ func (s *Service) ShardDelete(c *rpc.Context) {
}

// set io type
ctx = bnapi.Setiotype(ctx, bnapi.DeleteIO)
ctx = bnapi.SetIoType(ctx, bnapi.DeleteIO)
ctx = limitio.SetLimitTrack(ctx)

err = cs.Delete(ctx, args.Bid)
Expand Down Expand Up @@ -465,7 +465,7 @@ func (s *Service) ShardPut(c *rpc.Context) {
}

// set io type
ctx = bnapi.Setiotype(ctx, args.Type)
ctx = bnapi.SetIoType(ctx, args.Type)
ctx = limitio.SetLimitTrack(ctx)

s.lock.RLock()
Expand Down

0 comments on commit a4537b5

Please sign in to comment.