@Path("/config") @PermitAll public static class ConfigResource { @GET @Produces(MediaType.APPLICATION_JSON) public Map<String,Object> getConfig( ) { Map<String, Object> map = new HashMap<>(); for (NameValuePair pair : DrillOnYarnConfig.instance().getPairs()) { map.put(pair.getName(), pair.getValue()); } return map; } }
@PermitAll public String getPermitAll() { return permitAll; }
/** * DoY provides a link to YARN to display the AM UI. YARN wants to display the * linked page in a frame, which does not play well with the DoY UI. To avoid * this, we give YARN a link to this redirect page which does nothing other * than to redirect the browser to the (full) DoY main UI. */ @Path("/redirect") @PermitAll public static class RedirectPage { @GET @Produces(MediaType.TEXT_HTML) public Viewable getRoot() { Map<String, String> map = new HashMap<>(); String baseUrl = DoYUtil.unwrapAmUrl(dispatcher.getTrackingUrl()); map.put("amLink", baseUrl); map.put("clusterName", config.getString(DrillOnYarnConfig.APP_NAME)); return new Viewable("/drill-am/redirect.ftl", map); } }
@PermitAll public void permitAllMethod() { } }
@Path("/resize/{quantity}") @PermitAll public static class ResizeResource { @PathParam(value = "quantity") String quantity; @DefaultValue( "" ) @QueryParam( "key" ) String key; @POST @Produces(MediaType.APPLICATION_JSON) public Map<String,String> postResize( ) { ResizeRequest request = new ResizeRequest(key, quantity); if (request.error != null) { return request.error; } int curSize = dispatcher.getController().getTargetCount(); dispatcher.getController().resizeTo(request.n); return successResponse("Resizing from " + curSize + " to " + request.n); } }
@PermitAll String jsr250PermitAll();
/** * Download a zip-compressed archive of the client configuration, * of a specific service. This resource does not require any authentication. * * @param serviceName The service name. * @return The archive data. */ @GET @PermitAll @Path("/{serviceName}/clientConfig") @Produces(MediaType.APPLICATION_OCTET_STREAM) public InputStreamDataSource getClientConfig( @PathParam(SERVICE_NAME) String serviceName);
/** * Stop the cluster. Uses a key to validate the request. The value of the key is * set in the Drill-on-YARN configuration file. The purpose is simply to prevent * accidental cluster shutdown when experimenting with the REST API; this is * not meant to be a security mechanism. */ @Path("/stop") @PermitAll public static class StopResource { @DefaultValue( "" ) @QueryParam( "key" ) String key; @POST @Produces(MediaType.APPLICATION_JSON) public Map<String,String> postStop( ) { Map<String, String> error = checkKey(key); if (error != null) { return error; } dispatcher.getController().shutDown(); return successResponse("Shutting down"); } }
@GET @Timed @Produces(APPLICATION_JSON_WITH_CHARSET) @PermitAll public Object list() { Map<String, String> versions = ImmutableMap.of("version", "v1", "core", CoreVersion.VERSION.toString(), "gremlin", CoreVersion.GREMLIN_VERSION, "api", ApiVersion.VERSION.toString()); return ImmutableMap.of("versions", versions); } }
@PermitAll public class Jsr250BusinessServiceImpl implements BusinessService {
/** * Download a zip-compressed archive of the client configuration, of a * specific cluster. Currently, this only includes Kerberos Client * Configuration (krb5.conf). For client configuration of services, use the * clientConfig endpoint of the services resource. This resource does not * require any authentication. * * @param clusterName The cluster name. * @return The archive data. */ @GET @PermitAll @Path("/{clusterName}/clientConfig") @Produces(MediaType.APPLICATION_OCTET_STREAM) public InputStreamDataSource getClientConfig( @PathParam(CLUSTER_NAME) String clusterName);
@Path("/grow/{quantity}") @PermitAll public static class GrowResource { @PathParam(value = "quantity") @DefaultValue( "1" ) String quantity; @DefaultValue( "" ) @QueryParam( "key" ) String key; @POST @Produces(MediaType.APPLICATION_JSON) public Map<String,String> postResize( ) { ResizeRequest request = new ResizeRequest(key, quantity); if (request.error != null) { return request.error; } int curSize = dispatcher.getController().getTargetCount(); int newSize = curSize + request.n; dispatcher.getController().resizeTo(newSize); return successResponse("Growing by " + request.n + " to " + newSize); } }
@PermitAll @POST public User add( @FormParam("email") String email, @FormParam("password") String password) throws SQLException { User user = Context.getPermissionsManager().login(email, password); if (user != null) { request.getSession().setAttribute(USER_ID_KEY, user.getId()); LogAction.login(user.getId()); return user; } else { throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } }