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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]