forked from apache/doris-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c29e991
commit d5102b9
Showing
4 changed files
with
229 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package resource | ||
|
||
import ( | ||
"github.com/apache/doris-operator/pkg/common/utils/mysql" | ||
) | ||
|
||
type DecommissionPhase string | ||
|
||
const ( | ||
Decommissioned DecommissionPhase = "Decommissioned" | ||
Decommissioning DecommissionPhase = "Decommissioning" | ||
DecommissionPhaseSteady DecommissionPhase = "Steady" | ||
DecommissionPhaseUnknown DecommissionPhase = "Unknown" | ||
) | ||
|
||
type DecommissionDetail struct { | ||
AllBackendsSize int | ||
UnDecommissionedCount int | ||
DecommissioningCount int | ||
DecommissionedCount int | ||
BeKeepAmount int | ||
} | ||
|
||
func ConstructDecommissionDetail(allBackends []*mysql.Backend, cgKeepAmount int32) DecommissionDetail { | ||
var unDecommissionedCount, decommissioningCount, decommissionedCount int | ||
|
||
for i := range allBackends { | ||
node := allBackends[i] | ||
if !node.SystemDecommissioned { | ||
unDecommissionedCount++ | ||
} else { | ||
if node.TabletNum == 0 { | ||
decommissionedCount++ | ||
} else { | ||
decommissioningCount++ | ||
} | ||
} | ||
} | ||
|
||
return DecommissionDetail{ | ||
AllBackendsSize: len(allBackends), | ||
UnDecommissionedCount: unDecommissionedCount, | ||
DecommissioningCount: decommissioningCount, | ||
DecommissionedCount: decommissionedCount, | ||
BeKeepAmount: int(cgKeepAmount), | ||
} | ||
} | ||
|
||
func (d *DecommissionDetail) GetDecommissionDetailStatus() DecommissionPhase { | ||
if d.DecommissioningCount == 0 && d.DecommissionedCount == 0 && d.UnDecommissionedCount > d.BeKeepAmount { | ||
return DecommissionPhaseSteady | ||
} | ||
if d.UnDecommissionedCount == d.BeKeepAmount && d.DecommissioningCount > 0 { | ||
return Decommissioning | ||
} | ||
|
||
if d.UnDecommissionedCount == d.BeKeepAmount && d.UnDecommissionedCount+d.DecommissionedCount == d.AllBackendsSize { | ||
return Decommissioned | ||
} | ||
return DecommissionPhaseUnknown | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters