[WEB] Provide extra failure information from Balancer response #1309
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolve #1308.
現在 Balancer Web API 遇到找不到更好計劃的情況時,
GET /balancer/{id}
回傳的結果看起來像上面的 json,內容沒有太多關於計劃沒生出來的提示,使用者看到可能會很混淆。會造成這個的主要原因是Balancer#offer
回傳Optional<Balancer.Plan>
,由於 Optional 的存在我們基本上不知道為什麼計劃沒辦法被生成出來,也不清楚目前叢集的ClusterCost
分數(initial cluster cost),基本上 initial cluster cost 就算找不到更好的計劃也可以計算出來,但因為Optional
的關係這個資訊只有在計劃真的計算出來時才能提供(最早 BalancerHandler 的設計是儘管找不到更好的計劃,也能提供 initial cost,但因為Balancer#retryOffer
的 PR,這個計算 initial cost 的邏輯被迫從 Handler 移動到 Balancer 界面裡面,因此這個訊息被迫和Balancer.Plan
綁定)。這個 PR 做下面的修正
Balancer#offer()
和Balancer#retryOffer
現在直接回傳Balancer.Plan
Balancer.Plan
只剩下 initial cost 和一個新字串description
兩個欄位Balancer.Plan#description
是這個計劃的 metadata 字串,由 Balancer 的實作填寫,這個資訊會放到 Report 中Balancer.ProposalPlan
,他繼承Balancer.Plan
,多了三個欄位: proposed cost, proposed cluster, move cost然後順便修正了一個 bug
IllegalStateException
。下面是新的沒產生可用計劃的
GET /balancer/{id}
回應