Skip to content

Commit e9dd485

Browse files
author
slfan1989
committed
YARN-6572. Fix CheckStyle.
1 parent bb8011a commit e9dd485

File tree

4 files changed

+16
-40
lines changed

4 files changed

+16
-40
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterServerUtil.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
package org.apache.hadoop.yarn.server.router;
2020

21-
import org.apache.commons.lang3.reflect.FieldUtils;
22-
import org.apache.commons.lang3.reflect.MethodUtils;
2321
import org.apache.hadoop.classification.InterfaceAudience.Private;
2422
import org.apache.hadoop.classification.InterfaceAudience.Public;
2523
import org.apache.hadoop.classification.InterfaceStability.Unstable;
@@ -29,12 +27,9 @@
2927
import org.apache.hadoop.yarn.exceptions.YarnException;
3028
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
3129
import org.apache.hadoop.yarn.server.router.clientrm.ClientMethod;
32-
import org.apache.hadoop.yarn.server.router.clientrm.ClientRequestInterceptor;
33-
import org.apache.hadoop.yarn.server.router.rmadmin.RMAdminRequestInterceptor;
3430
import org.slf4j.Logger;
3531
import org.slf4j.LoggerFactory;
3632

37-
import java.lang.reflect.Field;
3833
import java.lang.reflect.InvocationTargetException;
3934
import java.lang.reflect.Method;
4035
import java.util.ArrayList;
@@ -90,15 +85,15 @@ public static <R> R createRequestInterceptorChain(Configuration conf, String pip
9085
try {
9186
Class<?> interceptorClass = conf.getClassByName(className);
9287
if (clazz.isAssignableFrom(interceptorClass)) {
93-
R interceptorInstance = (R) ReflectionUtils.newInstance(interceptorClass, conf);
88+
Object interceptorInstance = ReflectionUtils.newInstance(interceptorClass, conf);
9489
if (pipeline == null) {
95-
pipeline = interceptorInstance;
96-
current = interceptorInstance;
90+
pipeline = clazz.cast(interceptorInstance);
91+
current = clazz.cast(interceptorInstance);
9792
continue;
9893
} else {
9994
Method method = clazz.getMethod(request.getMethodName(), request.getTypes());
10095
method.invoke(current, interceptorInstance);
101-
current = interceptorInstance;
96+
current = clazz.cast(interceptorInstance);
10297
}
10398
} else {
10499
LOG.error("Class: {} not instance of {}.", className, clazz.getCanonicalName());
@@ -116,7 +111,7 @@ public static <R> R createRequestInterceptorChain(Configuration conf, String pip
116111
private static List<String> getInterceptorClassNames(Configuration conf,
117112
String pipeLineClass, String interceptorClass) {
118113
String configuredInterceptorClassNames = conf.get(pipeLineClass, interceptorClass);
119-
List<String> interceptorClassNames = new ArrayList<String>();
114+
List<String> interceptorClassNames = new ArrayList<>();
120115
Collection<String> tempList =
121116
StringUtils.getStringCollection(configuredInterceptorClassNames);
122117
for (String item : tempList) {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterClientRMService.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
import java.io.IOException;
2222
import java.lang.reflect.InvocationTargetException;
2323
import java.net.InetSocketAddress;
24-
import java.util.ArrayList;
25-
import java.util.Collection;
2624
import java.util.Collections;
27-
import java.util.List;
2825
import java.util.Map;
2926

3027
import org.apache.hadoop.classification.InterfaceAudience.Private;
@@ -34,8 +31,6 @@
3431
import org.apache.hadoop.security.UserGroupInformation;
3532
import org.apache.hadoop.security.authorize.PolicyProvider;
3633
import org.apache.hadoop.service.AbstractService;
37-
import org.apache.hadoop.util.ReflectionUtils;
38-
import org.apache.hadoop.util.StringUtils;
3934
import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
4035
import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenRequest;
4136
import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenResponse;

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/rmadmin/RouterRMAdminService.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
import java.io.IOException;
2222
import java.lang.reflect.InvocationTargetException;
2323
import java.net.InetSocketAddress;
24-
import java.util.ArrayList;
25-
import java.util.Collection;
2624
import java.util.Collections;
27-
import java.util.List;
2825
import java.util.Map;
2926

3027
import org.apache.hadoop.classification.InterfaceAudience.Private;
@@ -35,8 +32,6 @@
3532
import org.apache.hadoop.security.UserGroupInformation;
3633
import org.apache.hadoop.security.authorize.PolicyProvider;
3734
import org.apache.hadoop.service.AbstractService;
38-
import org.apache.hadoop.util.ReflectionUtils;
39-
import org.apache.hadoop.util.StringUtils;
4035
import org.apache.hadoop.yarn.conf.YarnConfiguration;
4136
import org.apache.hadoop.yarn.exceptions.YarnException;
4237
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
@@ -72,7 +67,6 @@
7267
import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse;
7368
import org.apache.hadoop.yarn.server.router.RouterServerUtil;
7469
import org.apache.hadoop.yarn.server.router.clientrm.ClientMethod;
75-
import org.apache.hadoop.yarn.server.router.clientrm.ClientRequestInterceptor;
7670
import org.apache.hadoop.yarn.server.router.security.authorize.RouterPolicyProvider;
7771
import org.apache.hadoop.yarn.util.LRUCacheHashMap;
7872
import org.slf4j.Logger;
@@ -125,8 +119,7 @@ protected void serviceStart() throws Exception {
125119
conf.getInt(YarnConfiguration.ROUTER_PIPELINE_CACHE_MAX_SIZE,
126120
YarnConfiguration.DEFAULT_ROUTER_PIPELINE_CACHE_MAX_SIZE);
127121
this.userPipelineMap = Collections.synchronizedMap(
128-
new LRUCacheHashMap<String, RequestInterceptorChainWrapper>(
129-
maxCacheSize, true));
122+
new LRUCacheHashMap<>(maxCacheSize, true));
130123

131124
Configuration serverConf = new Configuration(conf);
132125

@@ -143,14 +136,13 @@ protected void serviceStart() throws Exception {
143136
}
144137

145138
this.server.start();
146-
LOG.info("Router RMAdminService listening on address: "
147-
+ this.server.getListenerAddress());
139+
LOG.info("Router RMAdminService listening on address: {}", this.server.getListenerAddress());
148140
super.serviceStart();
149141
}
150142

151143
@Override
152144
protected void serviceStop() throws Exception {
153-
LOG.info("Stopping Router RMAdminService");
145+
LOG.info("Stopping Router RMAdminService.");
154146
if (this.server != null) {
155147
this.server.stop();
156148
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServices.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020

2121
import java.io.IOException;
2222
import java.lang.reflect.InvocationTargetException;
23-
import java.util.ArrayList;
24-
import java.util.Collection;
2523
import java.util.Collections;
26-
import java.util.List;
2724
import java.util.Map;
2825
import java.util.Set;
2926

@@ -49,8 +46,6 @@
4946
import org.apache.hadoop.http.JettyUtils;
5047
import org.apache.hadoop.security.UserGroupInformation;
5148
import org.apache.hadoop.security.authorize.AuthorizationException;
52-
import org.apache.hadoop.util.ReflectionUtils;
53-
import org.apache.hadoop.util.StringUtils;
5449
import org.apache.hadoop.yarn.conf.YarnConfiguration;
5550
import org.apache.hadoop.yarn.exceptions.YarnException;
5651
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
@@ -89,7 +84,6 @@
8984
import org.apache.hadoop.yarn.server.router.Router;
9085
import org.apache.hadoop.yarn.server.router.RouterServerUtil;
9186
import org.apache.hadoop.yarn.server.router.clientrm.ClientMethod;
92-
import org.apache.hadoop.yarn.server.router.rmadmin.RMAdminRequestInterceptor;
9387
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
9488
import org.apache.hadoop.yarn.server.webapp.dao.ContainersInfo;
9589
import org.apache.hadoop.yarn.util.LRUCacheHashMap;
@@ -139,9 +133,7 @@ public RouterWebServices(final Router router, Configuration conf) {
139133
int maxCacheSize =
140134
conf.getInt(YarnConfiguration.ROUTER_PIPELINE_CACHE_MAX_SIZE,
141135
YarnConfiguration.DEFAULT_ROUTER_PIPELINE_CACHE_MAX_SIZE);
142-
this.userPipelineMap = Collections.synchronizedMap(
143-
new LRUCacheHashMap<String, RequestInterceptorChainWrapper>(
144-
maxCacheSize, true));
136+
this.userPipelineMap = Collections.synchronizedMap(new LRUCacheHashMap<>(maxCacheSize, true));
145137
}
146138

147139
private void init() {
@@ -193,7 +185,7 @@ protected RESTRequestInterceptor createRequestInterceptorChain() {
193185
ClientMethod remoteMethod = null;
194186
try {
195187
remoteMethod = new ClientMethod("setNextInterceptor",
196-
new Class[]{RMAdminRequestInterceptor.class}, new Object[]{null});
188+
new Class[]{RESTRequestInterceptor.class}, new Object[]{null});
197189

198190
pipeline = RouterServerUtil.createRequestInterceptorChain(conf,
199191
YarnConfiguration.ROUTER_WEBAPP_INTERCEPTOR_CLASS_PIPELINE,
@@ -215,7 +207,7 @@ protected RESTRequestInterceptor createRequestInterceptorChain() {
215207
/**
216208
* Initializes the request intercepter pipeline for the specified user.
217209
*
218-
* @param user
210+
* @param user specified user.
219211
*/
220212
private RequestInterceptorChainWrapper initializePipeline(String user) {
221213
synchronized (this.userPipelineMap) {
@@ -303,7 +295,7 @@ public ClusterInfo getClusterInfo() {
303295
@GET
304296
@Path(RMWSConsts.CLUSTER_USER_INFO)
305297
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
306-
MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
298+
MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
307299
@Override
308300
public ClusterUserInfo getClusterUserInfo(@Context HttpServletRequest hsr) {
309301
init();
@@ -799,10 +791,12 @@ public Response deleteReservation(ReservationDeleteRequestInfo resContext,
799791
@Override
800792
public Response listReservation(
801793
@QueryParam(RMWSConsts.QUEUE) @DefaultValue(DEFAULT_QUEUE) String queue,
802-
@QueryParam(RMWSConsts.RESERVATION_ID) @DefaultValue(DEFAULT_RESERVATION_ID) String reservationId,
794+
@QueryParam(RMWSConsts.RESERVATION_ID)
795+
@DefaultValue(DEFAULT_RESERVATION_ID) String reservationId,
803796
@QueryParam(RMWSConsts.START_TIME) @DefaultValue(DEFAULT_START_TIME) long startTime,
804797
@QueryParam(RMWSConsts.END_TIME) @DefaultValue(DEFAULT_END_TIME) long endTime,
805-
@QueryParam(RMWSConsts.INCLUDE_RESOURCE) @DefaultValue(DEFAULT_INCLUDE_RESOURCE) boolean includeResourceAllocations,
798+
@QueryParam(RMWSConsts.INCLUDE_RESOURCE)
799+
@DefaultValue(DEFAULT_INCLUDE_RESOURCE) boolean includeResourceAllocations,
806800
@Context HttpServletRequest hsr) throws Exception {
807801
init();
808802
RequestInterceptorChainWrapper pipeline = getInterceptorChain(hsr);

0 commit comments

Comments
 (0)