FederationInterceptorREST extends AbstractRESTRequestInterceptor { @Override public AppInfo getApp(HttpServletRequest hsr, String appId, Set<String> unselectedFields) { long startTime = clock.getTime(); ApplicationId applicationId = null; try { applicationId = ApplicationId.fromString(appId); } catch (IllegalArgumentException e) { routerMetrics.incrAppsFailedRetrieved(); return null; } SubClusterInfo subClusterInfo = null; SubClusterId subClusterId = null; try { subClusterId = federationFacade.getApplicationHomeSubCluster(applicationId); if (subClusterId == null) { routerMetrics.incrAppsFailedRetrieved(); return null; } subClusterInfo = federationFacade.getSubCluster(subClusterId); } catch (YarnException e) { routerMetrics.incrAppsFailedRetrieved(); return null; } DefaultRequestInterceptorREST interceptor = getOrCreateInterceptorForSubCluster( subClusterId, subClusterInfo.getRMWebServiceAddress()); AppInfo response = interceptor.getApp(hsr, appId, unselectedFields); 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, Set<String> unselectedFields); @Override NodeInfo getNode(String nodeId); @Override NodesInfo getNodes(String states); @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); @Override AppActivitiesInfo getAppActivities(HttpServletRequest hsr,
      String appId, String time); @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 void shutdown();  }
@Test public void testGetApplicationNotExists() throws YarnException, IOException, InterruptedException { ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1); AppInfo response = interceptor.getApp(null, appId.toString(), null); Assert.assertNull(response); }
@Test public void testGetApplicationWrongFormat() throws YarnException, IOException, InterruptedException { AppInfo response = interceptor.getApp(null, "Application_wrong_id", null); Assert.assertNull(response); }