FederationInterceptorREST extends AbstractRESTRequestInterceptor { @Override public Response updateAppState(AppState targetState, HttpServletRequest hsr, String appId) throws AuthorizationException, YarnException, InterruptedException, IOException { long startTime = clock.getTime(); ApplicationId applicationId = null; try { applicationId = ApplicationId.fromString(appId); } catch (IllegalArgumentException e) { routerMetrics.incrAppsFailedKilled(); return Response .status(Status.BAD_REQUEST) .entity(e.getLocalizedMessage()) .build(); } SubClusterInfo subClusterInfo = null; SubClusterId subClusterId = null; try { subClusterId = federationFacade.getApplicationHomeSubCluster(applicationId); subClusterInfo = federationFacade.getSubCluster(subClusterId); } catch (YarnException e) { routerMetrics.incrAppsFailedKilled(); return Response .status(Status.BAD_REQUEST) .entity(e.getLocalizedMessage()) .build(); } Response response = getOrCreateInterceptorForSubCluster(subClusterId, subClusterInfo.getRMWebServiceAddress()).updateAppState(targetState, hsr, appId); long stopTime = clock.getTime(); routerMetrics.succeededAppsRetrieved(stopTime - startTime); return response; }  @Override void init(String user); @Override Response createNewApplication(HttpServletRequest hsr); @Override Response submitApplication(ApplicationSubmissionContextInfo newApp,
      HttpServletRequest hsr); @Override AppInfo getApp(HttpServletRequest hsr, String appId,
      Set<String> unselectedFields); @Override Response updateAppState(AppState targetState, HttpServletRequest hsr,
      String appId); @Override AppsInfo getApps(HttpServletRequest hsr, String stateQuery,
      Set<String> statesQuery, String finalStatusQuery, String userQuery,
      String queueQuery, String count, String startedBegin, String startedEnd,
      String finishBegin, String finishEnd, Set<String> applicationTypes,
      Set<String> applicationTags, String name, Set<String> unselectedFields); @Override NodeInfo getNode(String nodeId); @Override NodesInfo getNodes(String states); @Override ResourceInfo updateNodeResource(HttpServletRequest hsr,
      String nodeId, ResourceOptionInfo resourceOption); @Override ClusterMetricsInfo getClusterMetricsInfo(); @Override AppState getAppState(HttpServletRequest hsr, String appId); @Override ClusterInfo get(); @Override ClusterInfo getClusterInfo(); @Override ClusterUserInfo getClusterUserInfo(HttpServletRequest hsr); @Override SchedulerTypeInfo getSchedulerInfo(); @Override String dumpSchedulerLogs(String time, HttpServletRequest hsr); @Override ActivitiesInfo getActivities(HttpServletRequest hsr, String nodeId,
      String groupBy); @Override BulkActivitiesInfo getBulkActivities(HttpServletRequest hsr,
      String groupBy, int activitiesCount); @Override AppActivitiesInfo getAppActivities(HttpServletRequest hsr,
      String appId, String time, Set<String> requestPriorities,
      Set<String> allocationRequestIds, String groupBy, String limit,
      Set<String> actions, boolean summarize); @Override ApplicationStatisticsInfo getAppStatistics(HttpServletRequest hsr,
      Set<String> stateQueries, Set<String> typeQueries); @Override NodeToLabelsInfo getNodeToLabels(HttpServletRequest hsr); @Override LabelsToNodesInfo getLabelsToNodes(Set<String> labels); @Override Response replaceLabelsOnNodes(NodeToLabelsEntryList newNodeToLabels,
      HttpServletRequest hsr); @Override Response replaceLabelsOnNode(Set<String> newNodeLabelsName,
      HttpServletRequest hsr, String nodeId); @Override NodeLabelsInfo getClusterNodeLabels(HttpServletRequest hsr); @Override Response addToClusterNodeLabels(NodeLabelsInfo newNodeLabels,
      HttpServletRequest hsr); @Override Response removeFromCluserNodeLabels(Set<String> oldNodeLabels,
      HttpServletRequest hsr); @Override NodeLabelsInfo getLabelsOnNode(HttpServletRequest hsr, String nodeId); @Override AppPriority getAppPriority(HttpServletRequest hsr, String appId); @Override Response updateApplicationPriority(AppPriority targetPriority,
      HttpServletRequest hsr, String appId); @Override AppQueue getAppQueue(HttpServletRequest hsr, String appId); @Override Response updateAppQueue(AppQueue targetQueue, HttpServletRequest hsr,
      String appId); @Override Response postDelegationToken(DelegationToken tokenData,
      HttpServletRequest hsr); @Override Response postDelegationTokenExpiration(HttpServletRequest hsr); @Override Response cancelDelegationToken(HttpServletRequest hsr); @Override Response createNewReservation(HttpServletRequest hsr); @Override Response submitReservation(ReservationSubmissionRequestInfo resContext,
      HttpServletRequest hsr); @Override Response updateReservation(ReservationUpdateRequestInfo resContext,
      HttpServletRequest hsr); @Override Response deleteReservation(ReservationDeleteRequestInfo resContext,
      HttpServletRequest hsr); @Override Response listReservation(String queue, String reservationId,
      long startTime, long endTime, boolean includeResourceAllocations,
      HttpServletRequest hsr); @Override AppTimeoutInfo getAppTimeout(HttpServletRequest hsr, String appId,
      String type); @Override AppTimeoutsInfo getAppTimeouts(HttpServletRequest hsr, String appId); @Override Response updateApplicationTimeout(AppTimeoutInfo appTimeout,
      HttpServletRequest hsr, String appId); @Override AppAttemptsInfo getAppAttempts(HttpServletRequest hsr, String appId); @Override RMQueueAclInfo checkUserAccessToQueue(String queue, String username,
      String queueAclType, HttpServletRequest hsr); @Override AppAttemptInfo getAppAttempt(HttpServletRequest req,
      HttpServletResponse res, String appId, String appAttemptId); @Override ContainersInfo getContainers(HttpServletRequest req,
      HttpServletResponse res, String appId, String appAttemptId); @Override ContainerInfo getContainer(HttpServletRequest req,
      HttpServletResponse res, String appId, String appAttemptId,
      String containerId); @Override void setNextInterceptor(RESTRequestInterceptor next); @Override Response signalToContainer(String containerId, String command,
      HttpServletRequest req); @Override void shutdown();  }
@Test public void testForceKillApplicationNotExists() throws YarnException, IOException, InterruptedException { ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1); AppState appState = new AppState("KILLED"); Response response = interceptor.updateAppState(appState, null, appId.toString()); Assert.assertEquals(BAD_REQUEST, response.getStatus()); }
@Test public void testForceKillApplicationWrongFormat() throws YarnException, IOException, InterruptedException { AppState appState = new AppState("KILLED"); Response response = interceptor.updateAppState(appState, null, "Application_wrong_id"); Assert.assertEquals(BAD_REQUEST, response.getStatus()); }