From d11be2dcac8116d1b7244112e85b91955a3627a4 Mon Sep 17 00:00:00 2001 From: Carlo Curino Date: Thu, 21 Sep 2017 17:56:46 -0700 Subject: [PATCH] [YARN FEDERATION BACKPORT] Fix compilation issues due to: hadoop-router/pom.xml versions and Java 1.7 --- .../LocalityMulticastAMRMProxyPolicy.java | 3 +- .../yarn/server/utils/AMRMClientUtils.java | 2 +- .../policies/BaseFederationPoliciesTest.java | 5 +- .../utils/FederationPoliciesTestUtil.java | 21 ++- .../resourcemanager/ResourceManager.java | 4 +- .../hadoop-yarn-server-router/pom.xml | 4 +- .../router/webapp/RouterWebServiceUtil.java | 7 +- .../router/webapp/RouterWebServices.java | 132 ++++++------------ .../router/rmadmin/BaseRouterRMAdminTest.java | 2 +- .../webapp/TestRouterWebServicesREST.java | 14 +- 10 files changed, 79 insertions(+), 115 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/LocalityMulticastAMRMProxyPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/LocalityMulticastAMRMProxyPolicy.java index 454962f63f6..f50d3b0b984 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/LocalityMulticastAMRMProxyPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/LocalityMulticastAMRMProxyPolicy.java @@ -494,7 +494,8 @@ public class LocalityMulticastAMRMProxyPolicy extends AbstractAMRMProxyPolicy { .checkArgument(!ResourceRequest.isAnyLocation(rr.getResourceName())); if (!countContainersPerRM.containsKey(rr.getAllocationRequestId())) { - countContainersPerRM.put(rr.getAllocationRequestId(), new HashMap<>()); + countContainersPerRM.put(rr.getAllocationRequestId(), + new HashMap()); } if (!countContainersPerRM.get(rr.getAllocationRequestId()) .containsKey(targetId)) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/AMRMClientUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/AMRMClientUtils.java index 7993bd8a5ec..9f15d905eb6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/AMRMClientUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/AMRMClientUtils.java @@ -161,7 +161,7 @@ public final class AMRMClientUtils { final Token token) throws IOException { try { String rmClusterId = configuration.get(YarnConfiguration.RM_CLUSTER_ID, - YarnConfiguration.DEFAULT_RM_CLUSTER_ID); + "yarn_cluster"); LOG.info("Creating RMProxy to RM {} for protocol {} for user {}", rmClusterId, protocol.getSimpleName(), user); if (token != null) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/BaseFederationPoliciesTest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/BaseFederationPoliciesTest.java index 23978ed886e..208a46c8978 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/BaseFederationPoliciesTest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/BaseFederationPoliciesTest.java @@ -50,7 +50,8 @@ public abstract class BaseFederationPoliciesTest { private ConfigurableFederationPolicy policy; private WeightedPolicyInfo policyInfo = mock(WeightedPolicyInfo.class); - private Map activeSubclusters = new HashMap<>(); + private Map activeSubclusters = + new HashMap(); private FederationPolicyInitializationContext federationPolicyContext; private ApplicationSubmissionContext applicationSubmissionContext = mock(ApplicationSubmissionContext.class); @@ -99,7 +100,7 @@ public abstract class BaseFederationPoliciesTest { public void testNoSubclusters() throws YarnException { // empty the activeSubclusters map FederationPoliciesTestUtil.initializePolicyContext(getPolicy(), - getPolicyInfo(), new HashMap<>()); + getPolicyInfo(), new HashMap()); ConfigurableFederationPolicy localPolicy = getPolicy(); if (localPolicy instanceof FederationRouterPolicy) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/FederationPoliciesTestUtil.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/FederationPoliciesTestUtil.java index acc14dd9f79..4954197ecfe 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/FederationPoliciesTestUtil.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/FederationPoliciesTestUtil.java @@ -132,7 +132,8 @@ public final class FederationPoliciesTestUtil { GetSubClustersInfoResponse response = GetSubClustersInfoResponse .newInstance(new ArrayList(activeSubclusters.values())); - when(fss.getSubClusters(any())).thenReturn(response); + when(fss.getSubClusters(any(GetSubClustersInfoRequest.class))) + .thenReturn(response); facade.reinitialize(fss, new Configuration()); fpc.setFederationStateStoreFacade(facade); policy.reinitialize(fpc); @@ -192,20 +193,26 @@ public final class FederationPoliciesTestUtil { FederationStateStore fss = mock(FederationStateStore.class); GetSubClustersInfoResponse response = GetSubClustersInfoResponse .newInstance(subClusterInfos); - when(fss.getSubClusters(any())).thenReturn(response); + when(fss.getSubClusters(any(GetSubClustersInfoRequest.class))) + .thenReturn(response); - List configurations = new ArrayList<>(); + List configurations = + new ArrayList(); configurations.add(policyConfiguration); GetSubClusterPoliciesConfigurationsResponse policiesResponse = GetSubClusterPoliciesConfigurationsResponse .newInstance(configurations); - when(fss.getPoliciesConfigurations(any())).thenReturn(policiesResponse); + when(fss.getPoliciesConfigurations( + any(GetSubClusterPoliciesConfigurationsRequest.class))) + .thenReturn(policiesResponse); GetSubClusterPolicyConfigurationResponse policyResponse = GetSubClusterPolicyConfigurationResponse .newInstance(policyConfiguration); - when(fss.getPolicyConfiguration(any())).thenReturn(policyResponse); + when(fss.getPolicyConfiguration( + any(GetSubClusterPolicyConfigurationRequest.class))) + .thenReturn(policyResponse); goodFacade.reinitialize(fss, new Configuration()); return goodFacade; @@ -220,8 +227,8 @@ public final class FederationPoliciesTestUtil { * @throws YarnException in case the initialization is not successful. */ public static FederationStateStoreFacade initFacade() throws YarnException { - return initFacade(new ArrayList<>(), mock(SubClusterPolicyConfiguration - .class)); + return initFacade(new ArrayList(), + mock(SubClusterPolicyConfiguration.class)); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java index 22478190687..aed295e299e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java @@ -1000,13 +1000,11 @@ public class ResourceManager extends CompositeService implements Recoverable { fetcher = new AppReportFetcher(conf, getClientRMService()); } builder.withServlet(ProxyUriUtils.PROXY_SERVLET_NAME, - ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class); + ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class); builder.withAttribute(WebAppProxy.FETCHER_ATTRIBUTE, fetcher); String[] proxyParts = proxyHostAndPort.split(":"); builder.withAttribute(WebAppProxy.PROXY_HOST_ATTRIBUTE, proxyParts[0]); } - - } webApp = builder.start(new RMWebApp(this)); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/pom.xml index e8b4d565a81..053918bc795 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/pom.xml @@ -19,12 +19,12 @@ hadoop-yarn-server org.apache.hadoop - 3.0.0-beta1-SNAPSHOT + 2.9.0-SNAPSHOT 4.0.0 org.apache.hadoop hadoop-yarn-server-router - 3.0.0-beta1-SNAPSHOT + 2.9.0-SNAPSHOT Apache Hadoop YARN Router diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServiceUtil.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServiceUtil.java index 18618eeac1b..1c4332e85d8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServiceUtil.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServiceUtil.java @@ -73,9 +73,10 @@ public final class RouterWebServiceUtil { * call in case the call has no servlet request * @return the retrieved entity from the REST call */ - protected static T genericForward(String webApp, HttpServletRequest hsr, - final Class returnType, HTTPMethods method, String targetPath, - Object formParam, Map additionalParam) { + protected static T genericForward(final String webApp, + final HttpServletRequest hsr, final Class returnType, + final HTTPMethods method, final String targetPath, final Object formParam, + final Map additionalParam) { UserGroupInformation callerUGI = null; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServices.java index bbb83268274..4bb6271f192 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServices.java @@ -44,7 +44,6 @@ import javax.ws.rs.core.Response; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.http.JettyUtils; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.authorize.AuthorizationException; import org.apache.hadoop.util.ReflectionUtils; @@ -134,7 +133,7 @@ public class RouterWebServices implements RMWebServiceProtocol { /** * Returns the comma separated intercepter class names from the configuration. * - * @param conf + * @param config * @return the intercepter class names as an instance of ArrayList */ private List getInterceptorClassNames(Configuration config) { @@ -302,8 +301,7 @@ public class RouterWebServices implements RMWebServiceProtocol { } @GET - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public ClusterInfo get() { return getClusterInfo(); @@ -311,8 +309,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.INFO) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public ClusterInfo getClusterInfo() { init(); @@ -322,8 +319,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.METRICS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public ClusterMetricsInfo getClusterMetricsInfo() { init(); @@ -333,8 +329,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.SCHEDULER) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public SchedulerTypeInfo getSchedulerInfo() { init(); @@ -344,8 +339,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.SCHEDULER_LOGS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public String dumpSchedulerLogs(@FormParam(RMWSConsts.TIME) String time, @Context HttpServletRequest hsr) throws IOException { @@ -356,8 +350,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.NODES) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public NodesInfo getNodes(@QueryParam(RMWSConsts.STATES) String states) { init(); @@ -367,8 +360,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.NODES_NODEID) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public NodeInfo getNode(@PathParam(RMWSConsts.NODEID) String nodeId) { init(); @@ -378,8 +370,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APPS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public AppsInfo getApps(@Context HttpServletRequest hsr, @QueryParam(RMWSConsts.STATE) String stateQuery, @@ -405,8 +396,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.SCHEDULER_ACTIVITIES) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public ActivitiesInfo getActivities(@Context HttpServletRequest hsr, @QueryParam(RMWSConsts.NODEID) String nodeId) { @@ -417,8 +407,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.SCHEDULER_APP_ACTIVITIES) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public AppActivitiesInfo getAppActivities(@Context HttpServletRequest hsr, @QueryParam(RMWSConsts.APP_ID) String appId, @@ -430,8 +419,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APP_STATISTICS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public ApplicationStatisticsInfo getAppStatistics( @Context HttpServletRequest hsr, @@ -445,8 +433,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APPS_APPID) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public AppInfo getApp(@Context HttpServletRequest hsr, @PathParam(RMWSConsts.APPID) String appId, @@ -458,8 +445,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APPS_APPID_STATE) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public AppState getAppState(@Context HttpServletRequest hsr, @PathParam(RMWSConsts.APPID) String appId) throws AuthorizationException { @@ -470,8 +456,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @PUT @Path(RMWSConsts.APPS_APPID_STATE) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response updateAppState(AppState targetState, @Context HttpServletRequest hsr, @@ -485,8 +470,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.GET_NODE_TO_LABELS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public NodeToLabelsInfo getNodeToLabels(@Context HttpServletRequest hsr) throws IOException { @@ -497,8 +481,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.LABEL_MAPPINGS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public LabelsToNodesInfo getLabelsToNodes( @QueryParam(RMWSConsts.LABELS) Set labels) throws IOException { @@ -509,8 +492,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.REPLACE_NODE_TO_LABELS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response replaceLabelsOnNodes( final NodeToLabelsEntryList newNodeToLabels, @@ -523,8 +505,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.NODES_NODEID_REPLACE_LABELS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response replaceLabelsOnNode( @QueryParam(RMWSConsts.LABELS) Set newNodeLabelsName, @@ -538,8 +519,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.GET_NODE_LABELS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public NodeLabelsInfo getClusterNodeLabels(@Context HttpServletRequest hsr) throws IOException { @@ -550,8 +530,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.ADD_NODE_LABELS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response addToClusterNodeLabels(NodeLabelsInfo newNodeLabels, @Context HttpServletRequest hsr) throws Exception { @@ -563,8 +542,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.REMOVE_NODE_LABELS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response removeFromCluserNodeLabels( @QueryParam(RMWSConsts.LABELS) Set oldNodeLabels, @@ -577,8 +555,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.NODES_NODEID_GETLABELS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public NodeLabelsInfo getLabelsOnNode(@Context HttpServletRequest hsr, @PathParam(RMWSConsts.NODEID) String nodeId) throws IOException { @@ -589,8 +566,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APPS_APPID_PRIORITY) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public AppPriority getAppPriority(@Context HttpServletRequest hsr, @PathParam(RMWSConsts.APPID) String appId) throws AuthorizationException { @@ -601,8 +577,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @PUT @Path(RMWSConsts.APPS_APPID_PRIORITY) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response updateApplicationPriority(AppPriority targetPriority, @Context HttpServletRequest hsr, @@ -616,8 +591,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APPS_APPID_QUEUE) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public AppQueue getAppQueue(@Context HttpServletRequest hsr, @PathParam(RMWSConsts.APPID) String appId) throws AuthorizationException { @@ -628,8 +602,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @PUT @Path(RMWSConsts.APPS_APPID_QUEUE) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response updateAppQueue(AppQueue targetQueue, @Context HttpServletRequest hsr, @@ -643,8 +616,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.APPS_NEW_APPLICATION) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response createNewApplication(@Context HttpServletRequest hsr) throws AuthorizationException, IOException, InterruptedException { @@ -655,8 +627,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.APPS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response submitApplication(ApplicationSubmissionContextInfo newApp, @Context HttpServletRequest hsr) @@ -668,8 +639,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.DELEGATION_TOKEN) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response postDelegationToken(DelegationToken tokenData, @Context HttpServletRequest hsr) throws AuthorizationException, @@ -681,8 +651,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.DELEGATION_TOKEN_EXPIRATION) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response postDelegationTokenExpiration(@Context HttpServletRequest hsr) throws AuthorizationException, IOException, Exception { @@ -693,8 +662,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @DELETE @Path(RMWSConsts.DELEGATION_TOKEN) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response cancelDelegationToken(@Context HttpServletRequest hsr) throws AuthorizationException, IOException, InterruptedException, @@ -706,8 +674,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.RESERVATION_NEW) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response createNewReservation(@Context HttpServletRequest hsr) throws AuthorizationException, IOException, InterruptedException { @@ -718,8 +685,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.RESERVATION_SUBMIT) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response submitReservation(ReservationSubmissionRequestInfo resContext, @Context HttpServletRequest hsr) @@ -731,8 +697,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.RESERVATION_UPDATE) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response updateReservation(ReservationUpdateRequestInfo resContext, @Context HttpServletRequest hsr) @@ -744,8 +709,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @POST @Path(RMWSConsts.RESERVATION_DELETE) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response deleteReservation(ReservationDeleteRequestInfo resContext, @Context HttpServletRequest hsr) @@ -757,8 +721,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.RESERVATION_LIST) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response listReservation( @QueryParam(RMWSConsts.QUEUE) @DefaultValue(DEFAULT_QUEUE) String queue, @@ -775,8 +738,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APPS_TIMEOUTS_TYPE) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public AppTimeoutInfo getAppTimeout(@Context HttpServletRequest hsr, @PathParam(RMWSConsts.APPID) String appId, @@ -788,8 +750,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APPS_TIMEOUTS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public AppTimeoutsInfo getAppTimeouts(@Context HttpServletRequest hsr, @PathParam(RMWSConsts.APPID) String appId) throws AuthorizationException { @@ -800,8 +761,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @PUT @Path(RMWSConsts.APPS_TIMEOUT) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public Response updateApplicationTimeout(AppTimeoutInfo appTimeout, @Context HttpServletRequest hsr, @@ -815,8 +775,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APPS_APPID_APPATTEMPTS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Override public AppAttemptsInfo getAppAttempts(@Context HttpServletRequest hsr, @PathParam(RMWSConsts.APPID) String appId) { @@ -827,8 +786,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APPS_APPID_APPATTEMPTS_APPATTEMPTID) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo getAppAttempt( @Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam(RMWSConsts.APPID) String appId, @@ -841,8 +799,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.APPS_APPID_APPATTEMPTS_APPATTEMPTID_CONTAINERS) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ContainersInfo getContainers(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam(RMWSConsts.APPID) String appId, @@ -855,8 +812,7 @@ public class RouterWebServices implements RMWebServiceProtocol { @GET @Path(RMWSConsts.GET_CONTAINER) - @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, - MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ContainerInfo getContainer(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam(RMWSConsts.APPID) String appId, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/rmadmin/BaseRouterRMAdminTest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/rmadmin/BaseRouterRMAdminTest.java index d3eba618028..86fb8843062 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/rmadmin/BaseRouterRMAdminTest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/rmadmin/BaseRouterRMAdminTest.java @@ -330,7 +330,7 @@ public abstract class BaseRouterRMAdminTest { }); } - protected String[] getGroupsForUser(String user) + protected String[] getGroupsForUser(final String user) throws IOException, InterruptedException { return UserGroupInformation.createRemoteUser(user) .doAs(new PrivilegedExceptionAction() { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java index d7b1a0f94bc..31a2ab25ad0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java @@ -150,8 +150,8 @@ public class TestRouterWebServicesREST { * Performs 2 GET calls one to RM and the one to Router. In positive case, it * returns the 2 answers in a list. */ - private static List performGetCalls(String path, Class returnType, - String queryName, String queryValue) + private static List performGetCalls(String path, + final Class returnType, String queryName, String queryValue) throws IOException, InterruptedException { Client clientToRouter = Client.create(); WebResource toRouter = clientToRouter @@ -161,8 +161,8 @@ public class TestRouterWebServicesREST { WebResource toRM = clientToRM .resource(WebAppUtils.getRMWebAppURLWithScheme(conf)).path(path); - Builder toRouterBuilder; - Builder toRMBuilder; + final Builder toRouterBuilder; + final Builder toRMBuilder; if (queryValue != null && queryName != null) { toRouterBuilder = toRouter.queryParam(queryName, queryValue) @@ -197,9 +197,9 @@ public class TestRouterWebServicesREST { /** * Performs a POST/PUT/DELETE call to Router and returns the ClientResponse. */ - private static ClientResponse performCall(String webAddress, String queryKey, - String queryValue, Object context, HTTPMethods method) - throws IOException, InterruptedException { + private static ClientResponse performCall(final String webAddress, + final String queryKey, final String queryValue, final Object context, + final HTTPMethods method) throws IOException, InterruptedException { return UserGroupInformation.createRemoteUser(userName) .doAs(new PrivilegedExceptionAction() {