mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(master): some fix about datapartition creation
(1) while creating dp in vol creation, check dp count by mediaType to judge if success. (2) when background periodical check if need to create dp, skip volumes whose createTime is too recently, to avoid background create dp while volume is creating. (3) display mediaType of dp in cfs-cli cmd "volume info -d" Signed-off-by: true1064 <tangjingyu@oppo.com>
This commit is contained in:
parent
9d0d2c9fef
commit
f04993070b
@ -263,15 +263,15 @@ func formatVerInfoTableRow(verInfo *proto.VolVersionInfo) string {
|
||||
}
|
||||
|
||||
var (
|
||||
dataPartitionTablePattern = "%-8v %-8v %-10v %-10v %-18v %-18v"
|
||||
dataPartitionTablePattern = "%-8v %-8v %-10v %-10v %-10v %-18v %-18v"
|
||||
dataPartitionTableHeader = fmt.Sprintf(dataPartitionTablePattern,
|
||||
"ID", "REPLICAS", "STATUS", "ISRECOVER", "LEADER", "MEMBERS")
|
||||
"ID", "REPLICAS", "STATUS", "ISRECOVER", "MEDIA", "LEADER", "MEMBERS")
|
||||
)
|
||||
|
||||
func formatDataPartitionTableRow(view *proto.DataPartitionResponse) string {
|
||||
return fmt.Sprintf(dataPartitionTablePattern,
|
||||
view.PartitionID, view.ReplicaNum, formatDataPartitionStatus(view.Status), view.IsRecover, view.LeaderAddr,
|
||||
strings.Join(view.Hosts, ","))
|
||||
view.PartitionID, view.ReplicaNum, formatDataPartitionStatus(view.Status), view.IsRecover,
|
||||
proto.MediaTypeString(view.MediaType), view.LeaderAddr, strings.Join(view.Hosts, ","))
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@ -39,7 +39,7 @@ type DataPartitionMap struct {
|
||||
lastAutoCreateTime time.Time
|
||||
volName string
|
||||
readMutex sync.RWMutex
|
||||
partitionMapByMediaType map[uint32]map[uint64]struct{} //level-1 key: mediaType, level-2 key: dpId
|
||||
partitionMapByMediaType map[uint32]map[uint64]struct{} // level-1 key: mediaType, level-2 key: dpId
|
||||
rwCntByMediaType map[uint32]int // readable and writable dp count by mediaType
|
||||
}
|
||||
|
||||
|
||||
@ -651,9 +651,10 @@ func (vol *Vol) checkDataPartitions(c *Cluster) (cnt int) {
|
||||
shouldDpInhibitWriteByVolFull := vol.shouldInhibitWriteBySpaceFull()
|
||||
vol.SetReadOnlyForVolFull(shouldDpInhibitWriteByVolFull)
|
||||
|
||||
if vol.Status != proto.VolStatusMarkDelete && proto.IsHot(vol.VolType) && vol.IsReadOnlyForVolFull() {
|
||||
//check if need create dp for each allowedStorageClass of vol
|
||||
if vol.Status != proto.VolStatusMarkDelete && proto.IsHot(vol.VolType) &&
|
||||
(time.Now().Unix()-vol.createTime >= defaultIntervalToCheckDataPartition) {
|
||||
for _, asc := range vol.allowedStorageClass {
|
||||
//check if need create dp for each allowedStorageClass of vol
|
||||
if !proto.IsStorageClassReplica(asc) {
|
||||
continue
|
||||
}
|
||||
@ -666,6 +667,7 @@ func (vol *Vol) checkDataPartitions(c *Cluster) (cnt int) {
|
||||
c.batchCreateDataPartition(vol, 1, false, mediaType)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
totalPreloadCapacity := uint64(0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user