ccaominh commented on a change in pull request #8547: Add `sys.supervisors` 
table to system tables
URL: https://github.com/apache/incubator-druid/pull/8547#discussion_r324945586
 
 

 ##########
 File path: 
indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResource.java
 ##########
 @@ -132,24 +137,39 @@ public Response specGetAll(
           );
           final boolean includeFull = full != null;
           final boolean includeState = state != null && state;
+          final boolean includeFullStatus = fullStatus != null;
 
-          if (includeFull || includeState) {
-            List<Map<String, ?>> allStates = authorizedSupervisorIds
+          if (includeFull || includeState || includeFullStatus) {
+            List<SupervisorStatus> allStates = authorizedSupervisorIds
                 .stream()
                 .map(x -> {
                   Optional<SupervisorStateManager.State> theState =
                       manager.getSupervisorState(x);
-                  ImmutableMap.Builder<String, Object> theBuilder = 
ImmutableMap.builder();
-                  theBuilder.put("id", x);
+                  SupervisorStatus.Builder theBuilder = new 
SupervisorStatus.Builder();
+                  theBuilder.withId(x);
                   if (theState.isPresent()) {
-                    theBuilder.put("state", theState.get().getBasicState());
-                    theBuilder.put("detailedState", theState.get());
-                    theBuilder.put("healthy", theState.get().isHealthy());
+                    
theBuilder.withState(theState.get().getBasicState().toString())
+                              .withDetailedState(theState.get().toString())
+                              .withHealthy(theState.get().isHealthy());
                   }
                   if (includeFull) {
                     Optional<SupervisorSpec> theSpec = 
manager.getSupervisorSpec(x);
                     if (theSpec.isPresent()) {
-                      theBuilder.put("spec", theSpec.get());
+                      theBuilder.withSpec(manager.getSupervisorSpec(x).get());
+                    }
+                  }
+                  if (includeFullStatus) {
+                    Optional<SupervisorSpec> theSpec = 
manager.getSupervisorSpec(x);
+                    if (theSpec.isPresent()) {
+                      try {
+                        
theBuilder.withSpecString(objectMapper.writeValueAsString(manager.getSupervisorSpec(x).get()));
 
 Review comment:
   It may be nice to have to builder accept SupervisorSpec and 
serialize/deserialize it to a string internally so that the formatting logic is 
all in one place.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to