1
// Copyright 2018 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.
23
"github.com/cubefs/cubefs/util"
29
AdminGetMasterApiList = "/admin/getMasterApiList"
30
AdminSetApiQpsLimit = "/admin/setApiQpsLimit"
31
AdminGetApiQpsLimit = "/admin/getApiQpsLimit"
32
AdminRemoveApiQpsLimit = "/admin/rmApiQpsLimit"
33
AdminGetCluster = "/admin/getCluster"
34
AdminSetClusterInfo = "/admin/setClusterInfo"
35
AdminGetMonitorPushAddr = "/admin/getMonitorPushAddr"
36
AdminGetDataPartition = "/dataPartition/get"
37
AdminLoadDataPartition = "/dataPartition/load"
38
AdminCreateDataPartition = "/dataPartition/create"
39
AdminCreatePreLoadDataPartition = "/dataPartition/createPreLoad"
40
AdminDecommissionDataPartition = "/dataPartition/decommission"
41
AdminDiagnoseDataPartition = "/dataPartition/diagnose"
42
AdminResetDataPartitionDecommissionStatus = "/dataPartition/resetDecommissionStatus"
43
AdminQueryDataPartitionDecommissionStatus = "/dataPartition/queryDecommissionStatus"
44
AdminDeleteDataReplica = "/dataReplica/delete"
45
AdminAddDataReplica = "/dataReplica/add"
46
AdminDeleteVol = "/vol/delete"
47
AdminUpdateVol = "/vol/update"
48
AdminVolShrink = "/vol/shrink"
49
AdminVolExpand = "/vol/expand"
50
AdminVolForbidden = "/vol/forbidden"
51
AdminVolEnableAuditLog = "/vol/auditlog"
52
AdminCreateVol = "/admin/createVol"
53
AdminGetVol = "/admin/getVol"
54
AdminClusterFreeze = "/cluster/freeze"
55
AdminClusterForbidMpDecommission = "/cluster/forbidMetaPartitionDecommission"
56
AdminClusterStat = "/cluster/stat"
57
AdminSetCheckDataReplicasEnable = "/cluster/setCheckDataReplicasEnable"
58
AdminGetIP = "/admin/getIp"
59
AdminCreateMetaPartition = "/metaPartition/create"
60
AdminSetMetaNodeThreshold = "/threshold/set"
61
AdminListVols = "/vol/list"
62
AdminSetNodeInfo = "/admin/setNodeInfo"
63
AdminGetNodeInfo = "/admin/getNodeInfo"
64
AdminGetAllNodeSetGrpInfo = "/admin/getDomainInfo"
65
AdminGetNodeSetGrpInfo = "/admin/getDomainNodeSetGrpInfo"
66
AdminGetIsDomainOn = "/admin/getIsDomainOn"
67
AdminUpdateNodeSetCapcity = "/admin/updateNodeSetCapcity"
68
AdminUpdateNodeSetId = "/admin/updateNodeSetId"
69
AdminUpdateNodeSetNodeSelector = "/admin/updateNodeSetNodeSelector"
70
AdminUpdateDomainDataUseRatio = "/admin/updateDomainDataRatio"
71
AdminUpdateZoneExcludeRatio = "/admin/updateZoneExcludeRatio"
72
AdminSetNodeRdOnly = "/admin/setNodeRdOnly"
73
AdminSetDpRdOnly = "/admin/setDpRdOnly"
74
AdminSetConfig = "/admin/setConfig"
75
AdminGetConfig = "/admin/getConfig"
76
AdminDataPartitionChangeLeader = "/dataPartition/changeleader"
77
AdminChangeMasterLeader = "/master/changeleader"
78
AdminOpFollowerPartitionsRead = "/master/opFollowerPartitionRead"
79
AdminUpdateDecommissionLimit = "/admin/updateDecommissionLimit"
80
AdminQueryDecommissionLimit = "/admin/queryDecommissionLimit"
82
AdminQueryDecommissionToken = "/admin/queryDecommissionToken"
83
AdminSetFileStats = "/admin/setFileStatsEnable"
84
AdminGetFileStats = "/admin/getFileStatsEnable"
85
AdminGetClusterValue = "/admin/getClusterValue"
86
AdminSetClusterUuidEnable = "/admin/setClusterUuidEnable"
87
AdminGetClusterUuid = "/admin/getClusterUuid"
88
AdminGenerateClusterUuid = "/admin/generateClusterUuid"
89
AdminSetDpDiscard = "/admin/setDpDiscard"
90
AdminGetDiscardDp = "/admin/getDiscardDp"
92
AdminSetConLcNodeNum = "/admin/setConLcNodeNum"
93
AdminGetAllLcNodeInfo = "/admin/getAllLcNodeInfo"
95
AdminLcNode = "/admin/lcnode"
97
AdminUpdateDecommissionDiskFactor = "/admin/updateDecommissionDiskFactor"
98
AdminQueryDecommissionDiskLimit = "/admin/queryDecommissionDiskLimit"
99
AdminEnableAutoDecommissionDisk = "/admin/enableAutoDecommissionDisk"
100
AdminQueryAutoDecommissionDisk = "/admin/queryAutoDecommissionDisk"
101
// graphql master api
102
AdminClusterAPI = "/api/cluster"
103
AdminUserAPI = "/api/user"
104
AdminVolumeAPI = "/api/volume"
106
// graphql coonsole api
108
ConsoleLoginAPI = "/login"
109
ConsoleMonitorAPI = "/cfs_monitor"
110
ConsoleFile = "/file"
111
ConsoleFileDown = "/file/down"
112
ConsoleFileUpload = "/file/upload"
115
ClientDataPartitions = "/client/partitions"
116
ClientVol = "/client/vol"
117
ClientMetaPartition = "/metaPartition/get"
118
ClientVolStat = "/client/volStat"
119
ClientMetaPartitions = "/client/metaPartitions"
122
QosGetStatus = "/qos/getStatus"
123
QosGetClientsLimitInfo = "/qos/getClientsInfo"
124
QosGetZoneLimitInfo = "/qos/getZoneLimit" // include disk enable
125
QosUpdate = "/qos/update" // include disk enable
126
QosUpdateMagnify = "/qos/updateMagnify"
127
QosUpdateClientParam = "/qos/updateClientParam"
128
QosUpdateZoneLimit = "/qos/updateZoneLimit" // include disk enable
129
QosUpload = "/admin/qosUpload"
130
QosUpdateMasterLimit = "/qos/masterLimit"
133
AdminACL = "/admin/aclOp"
135
AdminUid = "/admin/uidOp"
138
AddRaftNode = "/raftNode/add"
139
RemoveRaftNode = "/raftNode/remove"
140
RaftStatus = "/get/raftStatus"
144
AddDataNode = "/dataNode/add"
145
DecommissionDataNode = "/dataNode/decommission"
146
QueryDataNodeDecoProgress = "/dataNode/queryDecommissionProgress"
147
QueryDataNodeDecoFailedDps = "/dataNode/queryDecommissionFailedDps"
148
MigrateDataNode = "/dataNode/migrate"
149
CancelDecommissionDataNode = "/dataNode/cancelDecommission"
150
DecommissionDisk = "/disk/decommission"
151
RecommissionDisk = "/disk/recommission"
152
QueryDiskDecoProgress = "/disk/queryDecommissionProgress"
153
MarkDecoDiskFixed = "/disk/MarkDecommissionDiskFixed"
154
CancelDecommissionDisk = "/disk/cancelDecommission"
155
QueryDecommissionDiskDecoFailedDps = "/disk/queryDecommissionFailedDps"
156
QueryBadDisks = "/disk/queryBadDisks"
157
RestoreStoppedAutoDecommissionDisk = "/disk/restoreStoppedAutoDecommissionDisk"
158
QueryAllDecommissionDisk = "/disk/queryAllDecommissionDisk"
159
GetDataNode = "/dataNode/get"
160
AddMetaNode = "/metaNode/add"
161
DecommissionMetaNode = "/metaNode/decommission"
162
MigrateMetaNode = "/metaNode/migrate"
163
GetMetaNode = "/metaNode/get"
164
AdminUpdateMetaNode = "/metaNode/update"
165
AdminUpdateDataNode = "/dataNode/update"
166
AdminGetInvalidNodes = "/invalid/nodes"
167
AdminLoadMetaPartition = "/metaPartition/load"
168
AdminDiagnoseMetaPartition = "/metaPartition/diagnose"
169
AdminDecommissionMetaPartition = "/metaPartition/decommission"
170
AdminChangeMetaPartitionLeader = "/metaPartition/changeleader"
171
AdminBalanceMetaPartitionLeader = "/metaPartition/balanceLeader"
172
AdminAddMetaReplica = "/metaReplica/add"
173
AdminDeleteMetaReplica = "/metaReplica/delete"
174
AdminPutDataPartitions = "/dataPartitions/set"
176
// admin multi version snapshot
177
AdminCreateVersion = "/multiVer/create"
178
AdminDelVersion = "/multiVer/del"
179
AdminGetVersionInfo = "/multiVer/get"
180
AdminGetAllVersionInfo = "/multiVer/getAll"
181
AdminGetVolVer = "/vol/getVer"
182
AdminSetVerStrategy = "/vol/SetVerStrategy"
184
// S3 lifecycle configuration APIS
185
SetBucketLifecycle = "/s3/setLifecycle"
186
GetBucketLifecycle = "/s3/getLifecycle"
187
DeleteBucketLifecycle = "/s3/deleteLifecycle"
189
AddLcNode = "/lcNode/add"
191
QueryDisableDisk = "/dataNode/queryDisableDisk"
192
// Operation response
193
GetMetaNodeTaskResponse = "/metaNode/response" // Method: 'POST', ContentType: 'application/json'
194
GetDataNodeTaskResponse = "/dataNode/response" // Method: 'POST', ContentType: 'application/json'
195
GetLcNodeTaskResponse = "/lcNode/response" // Method: 'POST', ContentType: 'application/json'
197
GetTopologyView = "/topo/get"
198
UpdateZone = "/zone/update"
199
GetAllZones = "/zone/list"
200
GetAllNodeSets = "/nodeSet/list"
201
GetNodeSet = "/nodeSet/get"
202
UpdateNodeSet = "/nodeSet/update"
205
SkipOwnerValidation = "Skip-Owner-Validation"
206
ForceDelete = "Force-Delete"
208
// APIs for user management
209
UserCreate = "/user/create"
210
UserDelete = "/user/delete"
211
UserUpdate = "/user/update"
212
UserUpdatePolicy = "/user/updatePolicy"
213
UserRemovePolicy = "/user/removePolicy"
214
UserDeleteVolPolicy = "/user/deleteVolPolicy"
215
UserGetInfo = "/user/info"
216
UserGetAKInfo = "/user/akInfo"
217
UserTransferVol = "/user/transferVol"
218
UserList = "/user/list"
219
UsersOfVol = "/vol/users"
220
// graphql api for header
221
HeadAuthorized = "Authorization"
222
ParamAuthorized = "_authorization"
223
UserKey = "_user_key"
224
UserInfoKey = "_user_info_key"
226
QuotaCreate = "/quota/create"
227
QuotaUpdate = "/quota/update"
228
QuotaDelete = "/quota/delete"
229
QuotaList = "/quota/list"
230
QuotaGet = "/quota/get"
231
// QuotaBatchModifyPath = "/quota/batchModifyPath"
232
QuotaListAll = "/quota/listAll"
235
S3QoSSet = "/s3/qos/set"
236
S3QoSGet = "/s3/qos/get"
237
S3QoSDelete = "/s3/qos/delete"
240
var GApiInfo map[string]string = map[string]string{
241
"admingetmasterapilist": AdminGetMasterApiList,
242
"adminsetapiqpslimit": AdminSetApiQpsLimit,
243
"admingetcluster": AdminGetCluster,
244
"adminsetclusterinfo": AdminSetClusterInfo,
245
"admingetdatapartition": AdminGetDataPartition,
246
"adminloaddatapartition": AdminLoadDataPartition,
247
"admincreatedatapartition": AdminCreateDataPartition,
248
"admincreatepreloaddatapartition": AdminCreatePreLoadDataPartition,
249
"admindecommissiondatapartition": AdminDecommissionDataPartition,
250
"admindiagnosedatapartition": AdminDiagnoseDataPartition,
251
"admindeletedatareplica": AdminDeleteDataReplica,
252
"adminadddatareplica": AdminAddDataReplica,
253
"admindeletevol": AdminDeleteVol,
254
"adminupdatevol": AdminUpdateVol,
255
"adminvolshrink": AdminVolShrink,
256
"adminvolexpand": AdminVolExpand,
257
"admincreatevol": AdminCreateVol,
258
"admingetvol": AdminGetVol,
259
"adminclusterfreeze": AdminClusterFreeze,
260
"adminclusterforbidmpdecommission": AdminClusterForbidMpDecommission,
261
"adminclusterstat": AdminClusterStat,
262
"admingetip": AdminGetIP,
263
"admincreatemetapartition": AdminCreateMetaPartition,
264
"adminsetmetanodethreshold": AdminSetMetaNodeThreshold,
265
"adminlistvols": AdminListVols,
266
"adminsetnodeinfo": AdminSetNodeInfo,
267
"admingetnodeinfo": AdminGetNodeInfo,
268
"admingetallnodesetgrpinfo": AdminGetAllNodeSetGrpInfo,
269
"admingetnodesetgrpinfo": AdminGetNodeSetGrpInfo,
270
"admingetisdomainon": AdminGetIsDomainOn,
271
"adminupdatenodesetcapcity": AdminUpdateNodeSetCapcity,
272
"adminupdatenodesetid": AdminUpdateNodeSetId,
273
"adminupdatedomaindatauseratio": AdminUpdateDomainDataUseRatio,
274
"adminupdatezoneexcluderatio": AdminUpdateZoneExcludeRatio,
275
"adminsetnoderdonly": AdminSetNodeRdOnly,
276
"adminsetdprdonly": AdminSetDpRdOnly,
277
"admindatapartitionchangeleader": AdminDataPartitionChangeLeader,
278
"adminsetdpdiscard": AdminSetDpDiscard,
279
"admingetdiscarddp": AdminGetDiscardDp,
281
//"adminclusterapi": AdminClusterAPI,
282
//"adminuserapi": AdminUserAPI,
283
//"adminvolumeapi": AdminVolumeAPI,
284
//"consoleiql": ConsoleIQL,
285
//"consoleloginapi": ConsoleLoginAPI,
286
//"consolemonitorapi": ConsoleMonitorAPI,
287
//"consolefile": ConsoleFile,
288
//"consolefiledown": ConsoleFileDown,
289
//"consolefileupload": ConsoleFileUpload,
290
"clientdatapartitions": ClientDataPartitions,
291
"clientvol": ClientVol,
292
"clientmetapartition": ClientMetaPartition,
293
"clientvolstat": ClientVolStat,
294
"clientmetapartitions": ClientMetaPartitions,
295
"qosgetstatus": QosGetStatus,
296
"qosgetclientslimitinfo": QosGetClientsLimitInfo,
297
"qosgetzonelimitinfo": QosGetZoneLimitInfo,
298
"qosupdate": QosUpdate,
299
//"qosupdatemagnify": QosUpdateMagnify,
300
"qosupdateclientparam": QosUpdateClientParam,
301
"qosupdatezonelimit": QosUpdateZoneLimit,
302
"qosupload": QosUpload,
303
"qosupdatemasterlimit": QosUpdateMasterLimit,
304
"addraftnode": AddRaftNode,
305
"removeraftnode": RemoveRaftNode,
306
"raftstatus": RaftStatus,
307
"adddatanode": AddDataNode,
308
"decommissiondatanode": DecommissionDataNode,
309
"migratedatanode": MigrateDataNode,
310
"canceldecommissiondatanode": CancelDecommissionDataNode,
311
"decommissiondisk": DecommissionDisk,
312
"getdatanode": GetDataNode,
313
"addmetanode": AddMetaNode,
314
"decommissionmetanode": DecommissionMetaNode,
315
"migratemetanode": MigrateMetaNode,
316
"getmetanode": GetMetaNode,
317
"adminupdatemetanode": AdminUpdateMetaNode,
318
"adminupdatedatanode": AdminUpdateDataNode,
319
"admingetinvalidnodes": AdminGetInvalidNodes,
320
"adminloadmetapartition": AdminLoadMetaPartition,
321
"admindiagnosemetapartition": AdminDiagnoseMetaPartition,
322
"admindecommissionmetapartition": AdminDecommissionMetaPartition,
323
"adminchangemetapartitionleader": AdminChangeMetaPartitionLeader,
324
"adminbalancemetapartitionleader": AdminBalanceMetaPartitionLeader,
325
"adminaddmetareplica": AdminAddMetaReplica,
326
"admindeletemetareplica": AdminDeleteMetaReplica,
327
"getmetanodetaskresponse": GetMetaNodeTaskResponse,
328
"getdatanodetaskresponse": GetDataNodeTaskResponse,
329
"gettopologyview": GetTopologyView,
330
"updatezone": UpdateZone,
331
"getallzones": GetAllZones,
332
"usercreate": UserCreate,
333
"userdelete": UserDelete,
334
"userupdate": UserUpdate,
335
"userupdatepolicy": UserUpdatePolicy,
336
"userremovepolicy": UserRemovePolicy,
337
"userdeletevolpolicy": UserDeleteVolPolicy,
338
"usergetinfo": UserGetInfo,
339
"usergetakinfo": UserGetAKInfo,
340
"usertransfervol": UserTransferVol,
341
"userlist": UserList,
342
"usersofvol": UsersOfVol,
345
// const TimeFormat = "2006-01-02 15:04:05"
348
TimeFormat = "2006-01-02 15:04:05"
349
DefaultDirChildrenNumLimit = 20000000
350
MinDirChildrenNumLimit = 1000000
353
// HTTPReply uniform response structure
354
type HTTPReply struct {
355
Code int32 `json:"code"`
356
Msg string `json:"msg"`
357
Data interface{} `json:"data"`
360
type HTTPReplyRaw struct {
361
Code int32 `json:"code"`
362
Msg string `json:"msg"`
363
Data json.RawMessage `json:"data"`
366
func (raw *HTTPReplyRaw) Unmarshal(body []byte) error {
367
r := new(HTTPReplyRaw)
368
if err := json.Unmarshal(body, r); err != nil {
369
return fmt.Errorf("httpreply unmarshal [%s]", err.Error())
375
func (raw *HTTPReplyRaw) Success() error {
376
if code := raw.Code; code != ErrCodeSuccess {
377
err := ParseErrorCode(code)
378
return fmt.Errorf("httpreply code[%d] err[%s] msg[%s]", code, err.Error(), raw.Msg)
383
func (raw *HTTPReplyRaw) Bytes() []byte {
387
func (raw *HTTPReplyRaw) String() string {
388
return string(raw.Bytes())
391
func (raw *HTTPReplyRaw) Int64() (int64, error) {
392
return strconv.ParseInt(string(raw.Data), 10, 64)
395
func (raw *HTTPReplyRaw) Uint64() (uint64, error) {
396
return strconv.ParseUint(string(raw.Data), 10, 64)
399
func (raw *HTTPReplyRaw) Result(result interface{}) error {
400
return json.Unmarshal(raw.Data, result)
403
func UnmarshalHTTPReply(body []byte, result interface{}) error {
404
raw := new(HTTPReplyRaw)
405
if err := raw.Unmarshal(body); err != nil {
408
if err := raw.Success(); err != nil {
415
switch v := result.(type) {
419
val, err := raw.Int64()
425
val, err := raw.Uint64()
431
return raw.Result(result)
436
// RegisterMetaNodeResp defines the response to register a meta node.
437
type RegisterMetaNodeResp struct {
441
type AclIpInfo struct {
453
type UidSpaceRsp struct {
456
UidSpaceArr []*UidSpaceInfo
460
type VolumeVerStrategy struct {
468
func (v *VolumeVerStrategy) GetPeriodic() int {
472
func (v *VolumeVerStrategy) GetPeriodicSecond() int {
473
// return v.Periodic*24*3600
474
return v.Periodic * 3600
477
func (v *VolumeVerStrategy) TimeUp(curTime time.Time) bool {
478
return v.UTime.Add(time.Second * time.Duration(v.GetPeriodicSecond())).Before(curTime)
481
type VolumeVerInfo struct {
485
VerPrepareStatus uint8
489
// ClusterInfo defines the cluster infomation.
490
type ClusterInfo struct {
493
MetaNodeDeleteBatchCount uint64
494
MetaNodeDeleteWorkerSleepMs uint64
495
DataNodeDeleteLimitRate uint64
496
DataNodeAutoRepairLimitRate uint64
497
DpMaxRepairErrCnt uint64
498
DirChildrenNumLimit uint32
502
ClusterUuidEnable bool
505
// CreateDataPartitionRequest defines the request to create a data partition.
506
type CreateDataPartitionRequest struct {
517
DecommissionedDisks []string
522
// CreateDataPartitionResponse defines the response to the request of creating a data partition.
523
type CreateDataPartitionResponse struct {
529
// DeleteDataPartitionRequest defines the request to delete a data partition.
530
type DeleteDataPartitionRequest struct {
531
DataPartitionType string
536
// DeleteDataPartitionResponse defines the response to the request of deleting a data partition.
537
type DeleteDataPartitionResponse struct {
543
// DataPartitionDecommissionRequest defines the request of decommissioning a data partition.
544
type DataPartitionDecommissionRequest struct {
550
// AddDataPartitionRaftMemberRequest defines the request of add raftMember a data partition.
551
type AddDataPartitionRaftMemberRequest struct {
556
// RemoveDataPartitionRaftMemberRequest defines the request of add raftMember a data partition.
557
type RemoveDataPartitionRaftMemberRequest struct {
563
// AddMetaPartitionRaftMemberRequest defines the request of add raftMember a meta partition.
564
type AddMetaPartitionRaftMemberRequest struct {
569
// RemoveMetaPartitionRaftMemberRequest defines the request of add raftMember a meta partition.
570
type RemoveMetaPartitionRaftMemberRequest struct {
575
// LoadDataPartitionRequest defines the request of loading a data partition.
576
type LoadDataPartitionRequest struct {
580
// LoadDataPartitionResponse defines the response to the request of loading a data partition.
581
type LoadDataPartitionResponse struct {
584
PartitionSnapshot []*File
591
type StopDataPartitionRepairRequest struct {
596
// DeleteDataPartitionResponse defines the response to the request of deleting a data partition.
597
type StopDataPartitionRepairResponse struct {
603
// File defines the file struct.
612
// LoadMetaPartitionMetricRequest defines the request of loading the meta partition metrics.
613
type LoadMetaPartitionMetricRequest struct {
619
// LoadMetaPartitionMetricResponse defines the response to the request of loading the meta partition metrics.
620
type LoadMetaPartitionMetricResponse struct {
628
type UidLimitToMetaNode struct {
629
UidLimitInfo []*UidSpaceInfo
632
type QosToDataNode struct {
634
QosIopsReadLimit uint64
635
QosIopsWriteLimit uint64
636
QosFlowReadLimit uint64
637
QosFlowWriteLimit uint64
640
// MultiVersionOpRequest defines the request of
641
type MultiVersionOpRequest struct {
646
VolVerList []*VolVersionInfo
649
// MultiVersionOpResponse defines the response to the request of l.
650
type MultiVersionOpResponse struct {
659
type QuotaHeartBeatInfos struct {
660
QuotaHbInfos []*QuotaHeartBeatInfo
673
// HeartBeatRequest define the heartbeat request.
674
type HeartBeatRequest struct {
683
ForbiddenVols []string
684
DisableAuditVols []string
685
DecommissionDisks []string // NOTE: for datanode
688
// DataPartitionReport defines the partition report.
689
type DataPartitionReport struct {
699
DecommissionRepairProgress float64
702
type DataNodeQosResponse struct {
711
type BadDiskStat struct {
713
TotalPartitionCnt int
714
DiskErrPartitionList []uint64
717
// DataNodeHeartbeatResponse defines the response to the data node heartbeat.
718
type DataNodeHeartbeatResponse struct {
722
TotalPartitionSize uint64 // volCnt * volsize
723
RemainingCapacity uint64 // remaining capacity to create partition
724
CreatedPartitionCnt uint32
725
MaxCapacity uint64 // maximum capacity to create partition
728
PartitionReports []*DataPartitionReport
731
BadDisks []string // Keep this old field for compatibility
732
BadDiskStats []BadDiskStat // key: disk path
733
CpuUtil float64 `json:"cpuUtil"`
734
IoUtils map[string]float64 `json:"ioUtil"`
737
// MetaPartitionReport defines the meta partition report.
738
type MetaPartitionReport struct {
753
UidInfo []*UidReportSpaceInfo
754
QuotaReportInfos []*QuotaReportInfo
757
// MetaNodeHeartbeatResponse defines the response to the meta node heartbeat request.
758
type MetaNodeHeartbeatResponse struct {
762
MetaPartitionReports []*MetaPartitionReport
765
CpuUtil float64 `json:"cpuUtil"`
768
// LcNodeHeartbeatResponse defines the response to the lc node heartbeat.
769
type LcNodeHeartbeatResponse struct {
773
LcScanningTasks map[string]*LcNodeRuleTaskResponse
774
SnapshotScanningTasks map[string]*SnapshotVerDelTaskResponse
777
// DeleteFileRequest defines the request to delete a file.
778
type DeleteFileRequest struct {
783
// DeleteFileResponse defines the response to the request of deleting a file.
784
type DeleteFileResponse struct {
791
// DeleteMetaPartitionRequest defines the request of deleting a meta partition.
792
type DeleteMetaPartitionRequest struct {
796
// DeleteMetaPartitionResponse defines the response to the request of deleting a meta partition.
797
type DeleteMetaPartitionResponse struct {
803
// UpdateMetaPartitionRequest defines the request to update a meta partition.
804
type UpdateMetaPartitionRequest struct {
811
// UpdateMetaPartitionResponse defines the response to the request of updating the meta partition.
812
type UpdateMetaPartitionResponse struct {
820
// MetaPartitionDecommissionRequest defines the request of decommissioning a meta partition.
821
type MetaPartitionDecommissionRequest struct {
828
// MetaPartitionDecommissionResponse defines the response to the request of decommissioning a meta partition.
829
type MetaPartitionDecommissionResponse struct {
836
// MetaPartitionLoadRequest defines the request to load meta partition.
837
type MetaPartitionLoadRequest struct {
841
// MetaPartitionLoadResponse defines the response to the request of loading meta partition.
842
type MetaPartitionLoadResponse struct {
853
// DataPartitionResponse defines the response from a data node to the master that is related to a data partition.
854
type DataPartitionResponse struct {
867
// DataPartitionsView defines the view of a data partition
868
type DataPartitionsView struct {
869
DataPartitions []*DataPartitionResponse
872
func NewDataPartitionsView() (dataPartitionsView *DataPartitionsView) {
873
dataPartitionsView = new(DataPartitionsView)
874
dataPartitionsView.DataPartitions = make([]*DataPartitionResponse, 0)
878
// MetaPartitionView defines the view of a meta partition
879
type MetaPartitionView struct {
896
type DataNodeDisksRequest struct{}
898
type DataNodeDisksResponse struct{}
900
type OSSSecure struct {
905
// VolView defines the view of a volume
911
MetaPartitions []*MetaPartitionView
912
DataPartitions []*DataPartitionResponse
921
func (v *VolView) SetOwner(owner string) {
925
func (v *VolView) SetOSSSecure(accessKey, secretKey string) {
926
v.OSSSecure = &OSSSecure{AccessKey: accessKey, SecretKey: secretKey}
929
func NewVolView(name string, status uint8, followerRead bool, createTime int64, cacheTTL int, volType int, deleteLockTime int64) (view *VolView) {
932
view.FollowerRead = followerRead
933
view.CreateTime = createTime
934
view.DeleteLockTime = deleteLockTime
936
view.MetaPartitions = make([]*MetaPartitionView, 0)
937
view.DataPartitions = make([]*DataPartitionResponse, 0)
938
view.CacheTTL = cacheTTL
939
view.VolType = volType
943
func NewMetaPartitionView(partitionID, start, end uint64, status int8) (mpView *MetaPartitionView) {
944
mpView = new(MetaPartitionView)
945
mpView.PartitionID = partitionID
948
mpView.Status = status
949
mpView.Members = make([]string, 0)
954
QosStateNormal uint8 = 0x01
955
QosStateHitLimit uint8 = 0x02
957
MinIopsLimit uint64 = 3
958
MinFLowLimit uint64 = 128 * util.KB
962
IopsReadType uint32 = 0x01
963
IopsWriteType uint32 = 0x02
964
FlowReadType uint32 = 0x03
965
FlowWriteType uint32 = 0x04
969
QosDefaultBurst = 16000000
970
QosDefaultClientCnt uint32 = 100
971
QosDefaultDiskMaxFLowLimit int = 0x7FFFFFFF
972
QosDefaultDiskMaxIoLimit int = 100000
975
func QosTypeString(factorType uint32) string {
990
type ClientLimitInfo struct {
997
type ClientReportLimitInfo struct {
999
FactorMap map[uint32]*ClientLimitInfo
1002
_ string // reserved
1005
func NewClientReportLimitInfo() *ClientReportLimitInfo {
1006
return &ClientReportLimitInfo{
1007
FactorMap: make(map[uint32]*ClientLimitInfo),
1011
type LimitRsp2Client struct {
1016
FactorMap map[uint32]*ClientLimitInfo
1017
Magnify map[uint32]uint32
1018
_ string // reserved
1021
func NewLimitRsp2Client() *LimitRsp2Client {
1022
limit := &LimitRsp2Client{
1023
FactorMap: make(map[uint32]*ClientLimitInfo),
1024
Magnify: make(map[uint32]uint32),
1029
type UidSimpleInfo struct {
1034
// SimpleVolView defines the simple view of a volume
1035
type SimpleVolView struct {
1044
MaxMetaPartitionID uint64
1046
Capacity uint64 // GB
1051
NeedToLowerReplica bool
1054
DefaultPriority bool
1057
DeleteLockTime int64
1061
EnableTransaction string
1063
TxConflictRetryNum int64
1064
TxConflictRetryInterval int64
1067
DpSelectorName string
1068
DpSelectorParm string
1069
DefaultZonePrior bool
1070
DpReadOnlyWhenVolFull bool
1074
CacheCapacity uint64
1079
CacheLruInterval int
1082
PreloadCapacity uint64
1083
Uids []UidSimpleInfo
1084
// multi version snapshot
1090
type NodeSetInfo struct {
1094
DataUseRatio float64
1095
MetaUseRatio float64
1098
MetaNodes []*MetaNodeInfo
1101
DataNodes []*DataNodeInfo
1104
type SimpleNodeSetGrpInfo struct {
1107
NodeSetInfo []NodeSetInfo
1110
type SimpleNodeSetGrpInfoList struct {
1113
SimpleNodeSetGrpInfo []*SimpleNodeSetGrpInfo
1116
type DomainNodeSetGrpInfoList struct {
1118
DataRatioLimit float64
1119
ZoneExcludeRatioLimit float64
1121
ExcludeZones []string
1122
DomainNodeSetGrpInfo []*SimpleNodeSetGrpInfoList
1125
// MasterAPIAccessResp defines the response for getting meta partition
1126
type MasterAPIAccessResp struct {
1127
APIResp APIAccessResp `json:"api_resp"`
1128
Data []byte `json:"data"`
1131
type VolInfo struct {
1138
DpReadOnlyWhenVolFull bool
1141
func NewVolInfo(name, owner string, createTime int64, status uint8, totalSize, usedSize uint64, dpReadOnlyWhenVolFull bool) *VolInfo {
1145
CreateTime: createTime,
1147
TotalSize: totalSize,
1149
DpReadOnlyWhenVolFull: dpReadOnlyWhenVolFull,
1153
// ZoneView define the view of zone
1154
type ZoneView struct {
1157
DataNodesetSelector string
1158
MetaNodesetSelector string
1159
NodeSet map[uint64]*NodeSetView
1162
type NodeSetView struct {
1165
MetaNodes []NodeView
1166
DataNodes []NodeView
1169
// TopologyView provides the view of the topology view of the cluster
1170
type TopologyView struct {
1175
PartitionTypeNormal = 0
1176
PartitionTypeCache = 1
1177
PartitionTypePreLoad = 2
1180
func GetDpType(volType int, isPreload bool) int {
1181
if volType == VolumeTypeHot {
1182
return PartitionTypeNormal
1186
return PartitionTypePreLoad
1189
return PartitionTypeCache
1192
func IsCacheDp(typ int) bool {
1193
return typ == PartitionTypeCache
1196
func IsNormalDp(typ int) bool {
1197
return typ == PartitionTypeNormal
1200
func IsPreLoadDp(typ int) bool {
1201
return typ == PartitionTypePreLoad
1209
func IsCold(typ int) bool {
1210
return typ == VolumeTypeCold
1213
func IsHot(typ int) bool {
1214
return typ == VolumeTypeHot
1224
LFClient = 1 // low frequency client