You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/10/18 15:41:30 UTC

[GitHub] leventov commented on a change in pull request #6234: 'suspend' and 'resume' support for supervisors (kafka indexing service, materialized views)

leventov commented on a change in pull request #6234: 'suspend' and 'resume' support for supervisors (kafka indexing service, materialized views)
URL: https://github.com/apache/incubator-druid/pull/6234#discussion_r226358880
 
 

 ##########
 File path: indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResource.java
 ##########
 @@ -90,49 +92,55 @@ public SupervisorResource(TaskMaster taskMaster, AuthorizerMapper authorizerMapp
   public Response specPost(final SupervisorSpec spec, @Context final HttpServletRequest req)
   {
     return asLeaderWithSupervisorManager(
-        new Function<SupervisorManager, Response>()
-        {
-          @Override
-          public Response apply(SupervisorManager manager)
-          {
-            Preconditions.checkArgument(
-                spec.getDataSources() != null && spec.getDataSources().size() > 0,
-                "No dataSources found to perform authorization checks"
-            );
-
-            Access authResult = AuthorizationUtils.authorizeAllResourceActions(
-                req,
-                Iterables.transform(spec.getDataSources(), AuthorizationUtils.DATASOURCE_WRITE_RA_GENERATOR),
-                authorizerMapper
-            );
+        manager -> {
+          Preconditions.checkArgument(
+              spec.getDataSources() != null && spec.getDataSources().size() > 0,
+              "No dataSources found to perform authorization checks"
+          );
 
-            if (!authResult.isAllowed()) {
-              throw new ForbiddenException(authResult.toString());
-            }
+          Access authResult = AuthorizationUtils.authorizeAllResourceActions(
+              req,
+              Iterables.transform(spec.getDataSources(), AuthorizationUtils.DATASOURCE_WRITE_RA_GENERATOR),
+              authorizerMapper
+          );
 
-            manager.createOrUpdateAndStartSupervisor(spec);
-            return Response.ok(ImmutableMap.of("id", spec.getId())).build();
+          if (!authResult.isAllowed()) {
+            throw new ForbiddenException(authResult.toString());
           }
+
+          manager.createOrUpdateAndStartSupervisor(spec);
+          return Response.ok(ImmutableMap.of("id", spec.getId())).build();
         }
     );
   }
 
   @GET
   @Produces(MediaType.APPLICATION_JSON)
-  public Response specGetAll(@Context final HttpServletRequest req)
+  public Response specGetAll(
+      @QueryParam("full") String full,
+      @Context final HttpServletRequest req
+  )
   {
     return asLeaderWithSupervisorManager(
-        new Function<SupervisorManager, Response>()
-        {
-          @Override
-          public Response apply(final SupervisorManager manager)
-          {
-            Set<String> authorizedSupervisorIds = filterAuthorizedSupervisorIds(
-                req,
-                manager,
-                manager.getSupervisorIds()
-            );
+        manager -> {
+          Set<String> authorizedSupervisorIds = filterAuthorizedSupervisorIds(
+              req,
+              manager,
+              manager.getSupervisorIds()
+          );
+
+          if (full == null) {
             return Response.ok(authorizedSupervisorIds).build();
+          } else {
+            List<Map<String, ?>> all =
+                authorizedSupervisorIds.stream()
+                                       .map(x -> ImmutableMap.<String, Object>builder()
+                                           .put("id", x)
+                                           .put("spec", manager.getSupervisorSpec(x).get())
 
 Review comment:
   Calls Optional.get() without a check

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


With regards,
Apache Git Services

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