Repository navigation
fix(pd): distinguish maintenance task results from follower no-ops #3359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
277bfea
8ac1d94
f69a7b9
14a91a4
5fe9b27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,12 +20,14 @@ | |
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import org.apache.hugegraph.pd.TaskScheduleService.PartitionPatrolResult; | ||
| import org.apache.hugegraph.pd.common.KVPair; | ||
| import org.apache.hugegraph.pd.common.PDException; | ||
| import org.apache.hugegraph.pd.grpc.Metapb; | ||
| import org.apache.hugegraph.pd.service.PDRestService; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.ResponseBody; | ||
|
|
@@ -57,8 +59,11 @@ public String patrolStores() { | |
| @ResponseBody | ||
| public String patrolPartitions() { | ||
| try { | ||
| List<Metapb.Partition> partitions = pdRestService.patrolPartitions(); | ||
| return toJSON(partitions, "partitions"); | ||
| PartitionPatrolResult result = pdRestService.patrolPartitionsWithResult(); | ||
| String partitions = toJSON(result.getPartitions(), "partitions"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important: |
||
| return partitions.substring(0, partitions.length() - 1) + | ||
| ",\"reallocatedShardGroups\":" + toJSON(result.getReallocatedShardGroups()) + | ||
| ",\"offlineShardRequests\":" + toJSON(result.getOfflineShardRequests()) + "}"; | ||
| } catch (PDException e) { | ||
| e.printStackTrace(); | ||
| return toJSON(e); | ||
|
|
@@ -67,13 +72,16 @@ public String patrolPartitions() { | |
|
|
||
| @GetMapping(value = "/balancePartitions", produces = MediaType.APPLICATION_JSON_VALUE) | ||
| @ResponseBody | ||
| public Map<Integer, KVPair<Long, Long>> balancePartitions() { | ||
| public String balancePartitions() { | ||
| try { | ||
| Map<Integer, KVPair<Long, Long>> partitions = pdRestService.balancePartitions(); | ||
| return partitions; | ||
| if (partitions == null) { | ||
| return toJSON(Map.of("status", 0, "outcome", "skipped")); | ||
| } | ||
| return toJSON(partitions); | ||
| } catch (PDException e) { | ||
| e.printStackTrace(); | ||
| return null; | ||
| return toJSON(e); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -89,12 +97,6 @@ public String splitPartitions() { | |
| } | ||
| } | ||
|
|
||
| // TODO: make the task routes tell a real run from a no-op and a follower answer (a follower | ||
| // returns an empty success without doing anything), and return a body that names what was | ||
| // scheduled. Part 1 (#3233) replaced the bare 500 with a refusal body; this is part 2. The | ||
| // Helm chart (helm/hugegraph) documents the leader-first sequence and the 180 s spacing in its | ||
| // README until then. | ||
| // https://github.com/apache/hugegraph/issues/3231 | ||
| @GetMapping(value = "/balanceLeaders", produces = MediaType.APPLICATION_JSON_VALUE) | ||
| @ResponseBody | ||
| public String balanceLeaders() { | ||
|
|
@@ -108,8 +110,12 @@ public String balanceLeaders() { | |
| } | ||
|
|
||
| @GetMapping(value = "/compact") | ||
| public String dbCompaction() throws PDException { | ||
| pdRestService.dbCompaction(); | ||
| return "compact ok"; | ||
| public ResponseEntity<String> dbCompaction() { | ||
| try { | ||
| pdRestService.dbCompaction(); | ||
| return ResponseEntity.ok().contentType(MediaType.TEXT_PLAIN).body("compact ok"); | ||
| } catch (PDException e) { | ||
| return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(toJSON(e)); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.