forked from cubefs/cubefs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
254 lines (232 loc) · 7.21 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
// Copyright 2018 The Chubao Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
package proto
import (
"time"
)
const (
DefaultZoneName = "default"
)
// MetaNode defines the structure of a meta node
type MetaNodeInfo struct {
ID uint64
Addr string
IsActive bool
IsWriteAble bool
ZoneName string `json:"Zone"`
MaxMemAvailWeight uint64 `json:"MaxMemAvailWeight"`
Total uint64 `json:"TotalWeight"`
Used uint64 `json:"UsedWeight"`
Ratio float64
SelectCount uint64
Carry float64
Threshold float32
ReportTime time.Time
MetaPartitionCount int
NodeSetID uint64
PersistenceMetaPartitions []uint64
RdOnly bool
}
// DataNode stores all the information about a data node
type DataNodeInfo struct {
Total uint64 `json:"TotalWeight"`
Used uint64 `json:"UsedWeight"`
AvailableSpace uint64
ID uint64
ZoneName string `json:"Zone"`
Addr string
ReportTime time.Time
IsActive bool
IsWriteAble bool
UsageRatio float64 // used / total space
SelectedTimes uint64 // number times that this datanode has been selected as the location for a data partition.
Carry float64 // carry is a factor used in cacluate the node's weight
DataPartitionReports []*PartitionReport
DataPartitionCount uint32
NodeSetID uint64
PersistenceDataPartitions []uint64
BadDisks []string
RdOnly bool
}
// MetaPartition defines the structure of a meta partition
type MetaPartitionInfo struct {
PartitionID uint64
Start uint64
End uint64
MaxInodeID uint64
InodeCount uint64
DentryCount uint64
VolName string
Replicas []*MetaReplicaInfo
ReplicaNum uint8
Status int8
IsRecover bool
Hosts []string
Peers []Peer
Zones []string
OfflinePeerID uint64
MissNodes map[string]int64
LoadResponse []*MetaPartitionLoadResponse
}
// MetaReplica defines the replica of a meta partition
type MetaReplicaInfo struct {
Addr string
ReportTime int64
Status int8 // unavailable, readOnly, readWrite
IsLeader bool
}
// ClusterView provides the view of a cluster.
type ClusterView struct {
Name string
LeaderAddr string
DisableAutoAlloc bool
MetaNodeThreshold float32
Applied uint64
MaxDataPartitionID uint64
MaxMetaNodeID uint64
MaxMetaPartitionID uint64
DataNodeStatInfo *NodeStatInfo
MetaNodeStatInfo *NodeStatInfo
VolStatInfo []*VolStatInfo
BadPartitionIDs []BadPartitionView
BadMetaPartitionIDs []BadPartitionView
MetaNodes []NodeView
DataNodes []NodeView
}
// ClusterNode defines the structure of a cluster node
type ClusterNodeInfo struct {
//BatchCount int
LoadFactor string
//MarkDeleteRate int
//AutoRepairRate int
//DeleteWorkerSleepMs int
}
type ClusterIP struct {
Cluster string
//MetaNodeDeleteBatchCount int
//MetaNodeDeleteWorkerSleepMs int
//DataNodeDeleteLimitRate int
//DataNodeAutoRepairLimitRate int
//Ip string
EbsAddr string
//ServicePath string
}
// NodeView provides the view of the data or meta node.
type NodeView struct {
Addr string
Status bool
ID uint64
IsWritable bool
}
type BadPartitionView struct {
Path string
PartitionIDs []uint64
}
type ClusterStatInfo struct {
DataNodeStatInfo *NodeStatInfo
MetaNodeStatInfo *NodeStatInfo
ZoneStatInfo map[string]*ZoneStat
}
type ZoneStat struct {
DataNodeStat *ZoneNodesStat
MetaNodeStat *ZoneNodesStat
}
type ZoneNodesStat struct {
Total float64 `json:"TotalGB"`
Used float64 `json:"UsedGB"`
Avail float64 `json:"AvailGB"`
UsedRatio float64
TotalNodes int
WritableNodes int
}
type NodeStatInfo struct {
TotalGB uint64
UsedGB uint64
IncreasedGB int64
UsedRatio string
}
type VolStatInfo struct {
Name string
TotalSize uint64
UsedSize uint64
UsedRatio string
CacheTotalSize uint64
CacheUsedSize uint64
CacheUsedRatio string
EnableToken bool
InodeCount uint64
}
// DataPartition represents the structure of storing the file contents.
type DataPartitionInfo struct {
PartitionID uint64
PartitionTTL int64
PartitionType int
LastLoadedTime int64
ReplicaNum uint8
Status int8
Recover bool
Replicas []*DataReplica
Hosts []string // host addresses
Peers []Peer
Zones []string
MissingNodes map[string]int64 // key: address of the missing node, value: when the node is missing
VolName string
VolID uint64
OfflinePeerID uint64
FileInCoreMap map[string]*FileInCore
IsRecover bool
FilesWithMissingReplica map[string]int64 // key: file name, value: last time when a missing replica is found
SingleDecommissionStatus uint8
SingleDecommissionAddr string
RdOnly bool
}
//FileInCore define file in data partition
type FileInCore struct {
Name string
LastModify int64
MetadataArray []*FileMetadata
}
// FileMetadata defines the file metadata on a dataNode
type FileMetadata struct {
Crc uint32
LocAddr string
Size uint32
}
// DataReplica represents the replica of a data partition
type DataReplica struct {
Addr string
ReportTime int64
FileCount uint32
Status int8
HasLoadResponse bool // if there is any response when loading
Total uint64 `json:"TotalSize"`
Used uint64 `json:"UsedSize"`
IsLeader bool
NeedsToCompare bool
DiskPath string
}
// data partition diagnosis represents the inactive data nodes, corrupt data partitions, and data partitions lack of replicas
type DataPartitionDiagnosis struct {
InactiveDataNodes []string
CorruptDataPartitionIDs []uint64
LackReplicaDataPartitionIDs []uint64
BadDataPartitionIDs []BadPartitionView
}
// meta partition diagnosis represents the inactive meta nodes, corrupt meta partitions, and meta partitions lack of replicas
type MetaPartitionDiagnosis struct {
InactiveMetaNodes []string
CorruptMetaPartitionIDs []uint64
LackReplicaMetaPartitionIDs []uint64
BadMetaPartitionIDs []BadPartitionView
}