1
// Copyright 2022 The CubeFS Authors.
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
// implied. See the License for the specific language governing
13
// permissions and limitations under the License.
22
"github.com/cubefs/cubefs/blobstore/common/errors"
23
"github.com/cubefs/cubefs/blobstore/common/proto"
24
"github.com/cubefs/cubefs/blobstore/common/rpc"
35
func New(cfg *Config) StorageAPI {
36
return &client{rpc.NewClient(&cfg.Config)}
39
func (c *client) String(ctx context.Context, host string) string {
43
func (c *client) IsOnline(ctx context.Context, host string) (b bool) {
47
func (c *client) Close(ctx context.Context, host string) (err error) {
51
func (c *client) Stat(ctx context.Context, host string) (dis []*DiskInfo, err error) {
52
urlStr := fmt.Sprintf("%v/stat", host)
53
dis = make([]*DiskInfo, 0)
54
err = c.GetWith(ctx, urlStr, &dis)
58
type ConfigReloadArgs struct {
59
Key string `json:"key"`
60
Value string `json:"value"`
63
type InspectRateArgs struct {
64
Rate int `json:"rate"`
67
type DiskStatArgs struct {
68
DiskID proto.DiskID `json:"diskid"`
71
func (c *client) DiskInfo(ctx context.Context, host string, args *DiskStatArgs) (di *DiskInfo, err error) {
72
if !IsValidDiskID(args.DiskID) {
73
return nil, errors.ErrInvalidDiskId
76
urlStr := fmt.Sprintf("%v/disk/stat/diskid/%v", host, args.DiskID)
78
err = c.GetWith(ctx, urlStr, di)
82
type StorageAPI interface {
83
String(ctx context.Context, host string) string
84
IsOnline(ctx context.Context, host string) bool
85
Close(ctx context.Context, host string) error
86
Stat(ctx context.Context, host string) (infos []*DiskInfo, err error)
87
DiskInfo(ctx context.Context, host string, args *DiskStatArgs) (di *DiskInfo, err error)
90
CreateChunk(ctx context.Context, host string, args *CreateChunkArgs) (err error)
91
StatChunk(ctx context.Context, host string, args *StatChunkArgs) (ci *ChunkInfo, err error)
92
ReleaseChunk(ctx context.Context, host string, args *ChangeChunkStatusArgs) (err error)
93
SetChunkReadonly(ctx context.Context, host string, args *ChangeChunkStatusArgs) (err error)
94
SetChunkReadwrite(ctx context.Context, host string, args *ChangeChunkStatusArgs) (err error)
95
ListChunks(ctx context.Context, host string, args *ListChunkArgs) (cis []*ChunkInfo, err error)
98
GetShard(ctx context.Context, host string, args *GetShardArgs) (body io.ReadCloser, shardCrc uint32, err error)
99
RangeGetShard(ctx context.Context, host string, args *RangeGetShardArgs) (body io.ReadCloser, shardCrc uint32, err error)
100
PutShard(ctx context.Context, host string, args *PutShardArgs) (crc uint32, err error)
101
StatShard(ctx context.Context, host string, args *StatShardArgs) (si *ShardInfo, err error)
102
MarkDeleteShard(ctx context.Context, host string, args *DeleteShardArgs) (err error)
103
DeleteShard(ctx context.Context, host string, args *DeleteShardArgs) (err error)
104
ListShards(ctx context.Context, host string, args *ListShardsArgs) (sis []*ShardInfo, next proto.BlobID, err error)
109
// WorkerAPI woker api on blobnode.
110
type WorkerAPI interface {
111
RepairShard(ctx context.Context, host string, args *proto.ShardRepairTask) (err error)
112
WorkerStats(ctx context.Context, host string) (ret WorkerStats, err error)