Skip to content

Commit

Permalink
context everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalinas committed Jul 7, 2017
1 parent bfd038e commit ec9f9e0
Show file tree
Hide file tree
Showing 19 changed files with 263 additions and 214 deletions.
@@ -1,10 +1,12 @@
package com.hubspot.singularity.proxy;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

Expand All @@ -28,13 +30,13 @@ public AuthResource(ClusterCoordinatorConfiguration configuration, AsyncHttpClie

@GET
@Path("/user")
public SingularityUserHolder getUser() {
public SingularityUserHolder getUser(@Context HttpServletRequest request) {
throw new NotImplemenedException();
}

@GET
@Path("/{requestId}/auth-check/{userId}")
public Response checkReadOnlyAuth(@PathParam("requestId") String requestId, @PathParam("userId") String userId, @QueryParam("scope") Optional<SingularityAuthorizationScope> scope) {
public Response checkReadOnlyAuth(@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("userId") String userId, @QueryParam("scope") Optional<SingularityAuthorizationScope> scope) {
throw new NotImplemenedException();
}
}
Expand Up @@ -32,7 +32,7 @@ public DeployResource(ClusterCoordinatorConfiguration configuration, AsyncHttpCl

@GET
@Path("/pending")
public Iterable<SingularityPendingDeploy> getPendingDeploys() {
public Iterable<SingularityPendingDeploy> getPendingDeploys(@Context HttpServletRequest request) {
throw new NotImplemenedException();
}

Expand All @@ -44,13 +44,13 @@ public SingularityRequestParent deploy(@Context HttpServletRequest requestContex

@DELETE
@Path("/deploy/{deployId}/request/{requestId}")
public SingularityRequestParent cancelDeploy(@PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
public SingularityRequestParent cancelDeploy(@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
throw new NotImplemenedException();
}

@POST
@Path("/update")
public SingularityRequestParent updatePendingDeploy(SingularityUpdatePendingDeployRequest updateRequest) {
public SingularityRequestParent updatePendingDeploy(@Context HttpServletRequest request, SingularityUpdatePendingDeployRequest updateRequest) {
throw new NotImplemenedException();
}
}
Expand Up @@ -37,61 +37,61 @@ public DisastersResource(ClusterCoordinatorConfiguration configuration, AsyncHtt

@GET
@Path("/stats")
public SingularityDisastersData disasterStats() {
public SingularityDisastersData disasterStats(@Context HttpServletRequest request) {
throw new NotImplemenedException();
}

@GET
@Path("/active")
public List<SingularityDisasterType> activeDisasters() {
public List<SingularityDisasterType> activeDisasters(@Context HttpServletRequest request) {
throw new NotImplemenedException();
}

@POST
@Path("/disable")
public void disableAutomatedDisasterCreation() {
public void disableAutomatedDisasterCreation(@Context HttpServletRequest request) {
throw new NotImplemenedException();
}

@POST
@Path("/enable")
public void enableAutomatedDisasterCreation() {
public void enableAutomatedDisasterCreation(@Context HttpServletRequest request) {
throw new NotImplemenedException();
}

@DELETE
@Path("/active/{type}")
public void removeDisaster(@PathParam("type") SingularityDisasterType type) {
public void removeDisaster(@Context HttpServletRequest request,@PathParam("type") SingularityDisasterType type) {
throw new NotImplemenedException();
}

@POST
@Path("/active/{type}")
public void newDisaster(@PathParam("type") SingularityDisasterType type) {
public void newDisaster(@Context HttpServletRequest request,@PathParam("type") SingularityDisasterType type) {
throw new NotImplemenedException();
}

@GET
@Path("/disabled-actions")
public List<SingularityDisabledAction> disabledActions() {
public List<SingularityDisabledAction> disabledActions(@Context HttpServletRequest request) {
throw new NotImplemenedException();
}

@POST
@Path("/disabled-actions/{action}")
public void disableAction(@PathParam("action") SingularityAction action, SingularityDisabledActionRequest disabledActionRequest) {
public void disableAction(@Context HttpServletRequest request,@PathParam("action") SingularityAction action, SingularityDisabledActionRequest disabledActionRequest) {
throw new NotImplemenedException();
}

@DELETE
@Path("/disabled-actions/{action}")
public void enableAction(@PathParam("action") SingularityAction action) {
public void enableAction(@Context HttpServletRequest request,@PathParam("action") SingularityAction action) {
throw new NotImplemenedException();
}

@POST
@Path("/task-credits")
public void addTaskCredits(@QueryParam("credits") Optional<Integer> credits) throws Exception {
public void addTaskCredits(@Context HttpServletRequest request,@QueryParam("credits") Optional<Integer> credits) throws Exception {
throw new NotImplemenedException();
}

Expand All @@ -103,7 +103,7 @@ public void disableTaskCredits(@Context HttpServletRequest request) throws Excep

@GET
@Path("/task-credits")
public SingularityTaskCredits getTaskCreditData() throws Exception {
public SingularityTaskCredits getTaskCreditData(@Context HttpServletRequest request) throws Exception {
throw new NotImplemenedException();
}
}
Expand Up @@ -3,18 +3,18 @@
import java.util.List;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Optional;
import com.google.inject.Inject;
import com.hubspot.singularity.ExtendedTaskState;
import com.hubspot.singularity.OrderDirection;
import com.hubspot.singularity.SingularityDeployHistory;
import com.hubspot.singularity.SingularityPaginatedResponse;
import com.hubspot.singularity.SingularityRequestHistory;
Expand All @@ -24,6 +24,7 @@
import com.hubspot.singularity.config.ClusterCoordinatorConfiguration;
import com.ning.http.client.AsyncHttpClient;

// Omits some or all @QueryParam annotated args, will be copied from request context
@Path(ApiPaths.HISTORY_RESOURCE_PATH)
@Produces({ MediaType.APPLICATION_JSON })
public class HistoryResource extends ProxyResource {
Expand All @@ -35,7 +36,7 @@ public HistoryResource(ClusterCoordinatorConfiguration configuration, AsyncHttpC

@GET
@Path("/task/{taskId}")
public SingularityTaskHistory getHistoryForTask(@PathParam("taskId") String taskId) {
public SingularityTaskHistory getHistoryForTask(@Context HttpServletRequest request, @PathParam("taskId") String taskId) {
throw new NotImplemenedException();
}

Expand All @@ -48,116 +49,105 @@ public List<SingularityTaskIdHistory> getTaskHistoryForRequest(@PathParam("reque

@GET
@Path("/request/{requestId}/deploy/{deployId}")
public SingularityDeployHistory getDeploy(@PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
public SingularityDeployHistory getDeploy(@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/deploy/{deployId}/tasks/active")
public List<SingularityTaskIdHistory> getActiveDeployTasks( @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
public List<SingularityTaskIdHistory> getActiveDeployTasks(@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/deploy/{deployId}/tasks/inactive")
public List<SingularityTaskIdHistory> getInactiveDeployTasks(
@PathParam("requestId") String requestId, @PathParam("deployId") String deployId,
@QueryParam("count") Integer count, @QueryParam("page") Integer page) {
public List<SingularityTaskIdHistory> getInactiveDeployTasks(@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/deploy/{deployId}/tasks/inactive/withmetadata")
public SingularityPaginatedResponse<SingularityTaskIdHistory> getInactiveDeployTasksWithMetadata(
@PathParam("requestId") String requestId, @PathParam("deployId") String deployId,
@QueryParam("count") Integer count, @QueryParam("page") Integer page) {
@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("deployId") String deployId) {
throw new NotImplemenedException();
}

@GET
@Path("/tasks")
public List<SingularityTaskIdHistory> getTaskHistory(
@QueryParam("requestId") Optional<String> requestId, @QueryParam("deployId") Optional<String> deployId, @QueryParam("runId") Optional<String> runId,
@QueryParam("host") Optional<String> host, @QueryParam("lastTaskStatus") Optional<ExtendedTaskState> lastTaskStatus, @QueryParam("startedBefore") Optional<Long> startedBefore,
@QueryParam("startedAfter") Optional<Long> startedAfter, @QueryParam("updatedBefore") Optional<Long> updatedBefore, @QueryParam("updatedAfter") Optional<Long> updatedAfter,
@QueryParam("orderDirection") Optional<OrderDirection> orderDirection, @QueryParam("count") Integer count, @QueryParam("page") Integer page) {
@Context HttpServletRequest request, @QueryParam("requestId") Optional<String> requestId, @QueryParam("deployId") Optional<String> deployId,
@QueryParam("runId") Optional<String> runId, @QueryParam("host") Optional<String> host) {
throw new NotImplemenedException();
}

@GET
@Path("/tasks/withmetadata")
public SingularityPaginatedResponse<SingularityTaskIdHistory> getTaskHistoryWithMetadata(
@QueryParam("requestId") Optional<String> requestId, @QueryParam("deployId") Optional<String> deployId, @QueryParam("runId") Optional<String> runId,
@QueryParam("host") Optional<String> host, @QueryParam("lastTaskStatus") Optional<ExtendedTaskState> lastTaskStatus, @QueryParam("startedBefore") Optional<Long> startedBefore,
@QueryParam("startedAfter") Optional<Long> startedAfter, @QueryParam("updatedBefore") Optional<Long> updatedBefore, @QueryParam("updatedAfter") Optional<Long> updatedAfter,
@QueryParam("orderDirection") Optional<OrderDirection> orderDirection, @QueryParam("count") Integer count, @QueryParam("page") Integer page) {
@Context HttpServletRequest request, @QueryParam("requestId") Optional<String> requestId, @QueryParam("deployId") Optional<String> deployId,
@QueryParam("runId") Optional<String> runId, @QueryParam("host") Optional<String> host) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/tasks")
public List<SingularityTaskIdHistory> getTaskHistoryForRequest(
@PathParam("requestId") String requestId, @QueryParam("deployId") Optional<String> deployId, @QueryParam("runId") Optional<String> runId,
@QueryParam("host") Optional<String> host, @QueryParam("lastTaskStatus") Optional<ExtendedTaskState> lastTaskStatus, @QueryParam("startedBefore") Optional<Long> startedBefore,
@QueryParam("startedAfter") Optional<Long> startedAfter, @QueryParam("updatedBefore") Optional<Long> updatedBefore, @QueryParam("updatedAfter") Optional<Long> updatedAfter,
@QueryParam("orderDirection") Optional<OrderDirection> orderDirection, @QueryParam("count") Integer count, @QueryParam("page") Integer page) {
@Context HttpServletRequest request, @PathParam("requestId") String requestId, @QueryParam("deployId") Optional<String> deployId,
@QueryParam("runId") Optional<String> runId, @QueryParam("host") Optional<String> host) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/tasks/withmetadata")
public SingularityPaginatedResponse<SingularityTaskIdHistory> getTaskHistoryForRequestWithMetadata(
@PathParam("requestId") String requestId, @QueryParam("deployId") Optional<String> deployId, @QueryParam("runId") Optional<String> runId,
@QueryParam("host") Optional<String> host, @QueryParam("lastTaskStatus") Optional<ExtendedTaskState> lastTaskStatus, @QueryParam("startedBefore") Optional<Long> startedBefore,
@QueryParam("startedAfter") Optional<Long> startedAfter, @QueryParam("updatedBefore") Optional<Long> updatedBefore, @QueryParam("updatedAfter") Optional<Long> updatedAfter,
@QueryParam("orderDirection") Optional<OrderDirection> orderDirection, @QueryParam("count") Integer count, @QueryParam("page") Integer page) {
@Context HttpServletRequest request, @PathParam("requestId") String requestId, @QueryParam("deployId") Optional<String> deployId,
@QueryParam("runId") Optional<String> runId, @QueryParam("host") Optional<String> host) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/run/{runId}")
public Optional<SingularityTaskIdHistory> getTaskHistoryForRequestAndRunId(
@PathParam("requestId") String requestId, @PathParam("runId") String runId) {
@Context HttpServletRequest request, @PathParam("requestId") String requestId, @PathParam("runId") String runId) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/deploys")
public List<SingularityDeployHistory> getDeploys(
@PathParam("requestId") String requestId, @QueryParam("count") Integer count, @QueryParam("page") Integer page) {
@Context HttpServletRequest request, @PathParam("requestId") String requestId) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/deploys/withmetadata")
public SingularityPaginatedResponse<SingularityDeployHistory> getDeploysWithMetadata(
@PathParam("requestId") String requestId, @QueryParam("count") Integer count, @QueryParam("page") Integer page) {
@Context HttpServletRequest request, @PathParam("requestId") String requestId) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/requests")
public List<SingularityRequestHistory> getRequestHistoryForRequest(
@PathParam("requestId") String requestId, @QueryParam("count") Integer count, @QueryParam("page") Integer page) {
@Context HttpServletRequest request, @PathParam("requestId") String requestId) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/requests/withmetadata")
public SingularityPaginatedResponse<SingularityRequestHistory> getRequestHistoryForRequestWithMetadata(
@PathParam("requestId") String requestId, @QueryParam("count") Integer count, @QueryParam("page") Integer page) {
@Context HttpServletRequest request, @PathParam("requestId") String requestId) {
throw new NotImplemenedException();
}

@GET
@Path("/requests/search")
public Iterable<String> getRequestHistoryForRequestLike(@QueryParam("requestIdLike") String requestIdLike, @QueryParam("count") Integer count, @QueryParam("page") Integer page, @QueryParam("useWebCache") Boolean useWebCache) {
public Iterable<String> getRequestHistoryForRequestLike(@Context HttpServletRequest request, @QueryParam("requestIdLike") String requestIdLike) {
throw new NotImplemenedException();
}

@GET
@Path("/request/{requestId}/command-line-args")
public Set<List<String>> getRecentCommandLineArgs(@PathParam("requestId") String requestId, @QueryParam("count") Optional<Integer> count) {
public Set<List<String>> getRecentCommandLineArgs(@Context HttpServletRequest request, @PathParam("requestId") String requestId) {
throw new NotImplemenedException();
}
}
Expand Up @@ -2,12 +2,14 @@

import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -26,17 +28,17 @@ public InactiveSlaveResource(ClusterCoordinatorConfiguration configuration, Asyn
}

@GET
public Set<String> getInactiveSlaves() {
public Set<String> getInactiveSlaves(@Context HttpServletRequest request) {
throw new NotImplemenedException();
}

@POST
public void deactivateSlave(@QueryParam("host") String host) {
public void deactivateSlave(@Context HttpServletRequest request, @QueryParam("host") String host) {
throw new NotImplemenedException();
}

@DELETE
public void reactivateSlave(@QueryParam("host") String host) {
public void reactivateSlave(@Context HttpServletRequest request, @QueryParam("host") String host) {
throw new NotImplemenedException();
}
}
@@ -1,10 +1,12 @@
package com.hubspot.singularity.proxy;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -27,19 +29,19 @@ public PriorityResource(ClusterCoordinatorConfiguration configuration, AsyncHttp

@GET
@Path("/freeze")
public Optional<SingularityPriorityFreezeParent> getActivePriorityFreeze() {
public Optional<SingularityPriorityFreezeParent> getActivePriorityFreeze(@Context HttpServletRequest request) {
throw new NotImplemenedException();
}

@DELETE
@Path("/freeze")
public void deleteActivePriorityFreeze() {
public void deleteActivePriorityFreeze(@Context HttpServletRequest request) {
throw new NotImplemenedException();
}

@POST
@Path("/freeze")
public SingularityPriorityFreezeParent createPriorityFreeze(SingularityPriorityFreeze priorityFreezeRequest) {
public SingularityPriorityFreezeParent createPriorityFreeze(@Context HttpServletRequest request, SingularityPriorityFreeze priorityFreezeRequest) {
throw new NotImplemenedException();
}
}

0 comments on commit ec9f9e0

Please sign in to comment.