Skip to content

Commit 46a61d9

Browse files
author
slfan1989
committed
YARN-7077. Fix CheckStyle.
1 parent 4099297 commit 46a61d9

File tree

5 files changed

+40
-20
lines changed

5 files changed

+40
-20
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-globalpolicygenerator/src/main/java/org/apache/hadoop/yarn/server/globalpolicygenerator/GPGPolicyFacade.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public GPGPolicyFacade(FederationStateStoreFacade stateStore,
9595
*
9696
* @param queueName the name of the queue we want the policy manager for.
9797
* @return the policy manager responsible for the queue policy.
98+
* @throws YarnException exceptions from yarn servers.
9899
*/
99100
public FederationPolicyManager getPolicyManager(String queueName)
100101
throws YarnException {
@@ -155,6 +156,7 @@ public FederationPolicyManager getPolicyManager(String queueName)
155156
* @param policyManager The policy manager we want to update into the state
156157
* store. It contains policy information as well as
157158
* the queue name we will update for.
159+
* @throws YarnException exceptions from yarn servers.
158160
*/
159161
public void setPolicyManager(FederationPolicyManager policyManager)
160162
throws YarnException {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-globalpolicygenerator/src/main/java/org/apache/hadoop/yarn/server/globalpolicygenerator/GPGUtils.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import javax.servlet.http.HttpServletResponse;
2626
import javax.ws.rs.core.MediaType;
2727

28-
import org.apache.hadoop.conf.Configuration;
2928
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
3029

3130
import com.sun.jersey.api.client.Client;
@@ -45,10 +44,15 @@ private GPGUtils() {
4544
}
4645

4746
/**
48-
* Performs an invocation of the the remote RMWebService.
47+
* Performs an invocation of the remote RMWebService.
48+
*
49+
* @param <T> Generic T.
50+
* @param webAddr WebAddress.
51+
* @param path url path.
52+
* @param returnType return type.
53+
* @return response entity.
4954
*/
50-
public static <T> T invokeRMWebService(Configuration conf, String webAddr,
51-
String path, final Class<T> returnType) {
55+
public static <T> T invokeRMWebService(String webAddr, String path, final Class<T> returnType) {
5256
Client client = Client.create();
5357
T obj = null;
5458

@@ -66,6 +70,9 @@ public static <T> T invokeRMWebService(Configuration conf, String webAddr,
6670

6771
/**
6872
* Creates a uniform weighting of 1.0 for each sub cluster.
73+
*
74+
* @param ids subClusterId set
75+
* @return weight of subCluster.
6976
*/
7077
public static Map<SubClusterIdInfo, Float> createUniformWeights(
7178
Set<SubClusterId> ids) {
@@ -76,5 +83,4 @@ public static Map<SubClusterIdInfo, Float> createUniformWeights(
7683
}
7784
return weights;
7885
}
79-
8086
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-globalpolicygenerator/src/main/java/org/apache/hadoop/yarn/server/globalpolicygenerator/policygenerator/GlobalPolicy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public Configuration getConf() {
5050
* Delegating this responsibility to the PolicyGenerator enables us to avoid
5151
* duplicate calls to the same * endpoints as the GlobalPolicy is invoked
5252
* once per queue.
53+
*
54+
* @return a map of the object type and RM path.
5355
*/
5456
protected Map<Class, String> registerPaths() {
5557
// Default register nothing

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-globalpolicygenerator/src/main/java/org/apache/hadoop/yarn/server/globalpolicygenerator/policygenerator/PolicyGenerator.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,14 @@ public class PolicyGenerator implements Runnable, Configurable {
6262

6363
// Global policy instance
6464
@VisibleForTesting
65-
protected GlobalPolicy policy;
65+
private GlobalPolicy policy;
6666

6767
/**
6868
* The PolicyGenerator periodically reads SubCluster load and updates
6969
* policies into the FederationStateStore.
70+
*
71+
* @param conf Configuration.
72+
* @param context GPG Context.
7073
*/
7174
public PolicyGenerator(Configuration conf, GPGContext context) {
7275
setConf(conf);
@@ -157,7 +160,7 @@ protected Map<SubClusterId, Map<Class, Object>> getInfos(
157160
clusterInfo.put(sci.getSubClusterId(), new HashMap<Class, Object>());
158161
}
159162
Object ret = GPGUtils
160-
.invokeRMWebService(conf, sci.getRMWebServiceAddress(),
163+
.invokeRMWebService(sci.getRMWebServiceAddress(),
161164
e.getValue(), e.getKey());
162165
clusterInfo.get(sci.getSubClusterId()).put(e.getKey(), ret);
163166
}
@@ -178,7 +181,7 @@ protected Map<SubClusterId, SchedulerInfo> getSchedulerInfo(
178181
new HashMap<>();
179182
for (SubClusterInfo sci : activeSubClusters.values()) {
180183
SchedulerTypeInfo sti = GPGUtils
181-
.invokeRMWebService(conf, sci.getRMWebServiceAddress(),
184+
.invokeRMWebService(sci.getRMWebServiceAddress(),
182185
RMWSConsts.SCHEDULER, SchedulerTypeInfo.class);
183186
if(sti != null){
184187
schedInfo.put(sci.getSubClusterId(), sti.getSchedulerInfo());
@@ -258,4 +261,11 @@ private <K, V> void addOrAppend(Map<K, Set<V>> multimap, K key, V value) {
258261
multimap.get(key).add(value);
259262
}
260263

264+
public GlobalPolicy getPolicy() {
265+
return policy;
266+
}
267+
268+
public void setPolicy(GlobalPolicy policy) {
269+
this.policy = policy;
270+
}
261271
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-globalpolicygenerator/src/test/java/org/apache/hadoop/yarn/server/globalpolicygenerator/policygenerator/TestPolicyGenerator.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ private <T> T readJSON(String pathname, Class<T> classy)
172172
@Test
173173
public void testPolicyGenerator() throws YarnException {
174174
policyGenerator = new TestablePolicyGenerator();
175-
policyGenerator.policy = mock(GlobalPolicy.class);
175+
policyGenerator.setPolicy(mock(GlobalPolicy.class));
176176
policyGenerator.run();
177-
verify(policyGenerator.policy, times(1))
177+
verify(policyGenerator.getPolicy(), times(1))
178178
.updatePolicy("default", clusterInfos, null);
179-
verify(policyGenerator.policy, times(1))
179+
verify(policyGenerator.getPolicy(), times(1))
180180
.updatePolicy("default2", clusterInfos, null);
181181
}
182182

@@ -188,11 +188,11 @@ public void testBlacklist() throws YarnException {
188188
new HashMap<>(clusterInfos);
189189
blacklistedCMI.remove(subClusterIds.get(0));
190190
policyGenerator = new TestablePolicyGenerator();
191-
policyGenerator.policy = mock(GlobalPolicy.class);
191+
policyGenerator.setPolicy(mock(GlobalPolicy.class));
192192
policyGenerator.run();
193-
verify(policyGenerator.policy, times(1))
193+
verify(policyGenerator.getPolicy(), times(1))
194194
.updatePolicy("default", blacklistedCMI, null);
195-
verify(policyGenerator.policy, times(0))
195+
verify(policyGenerator.getPolicy(), times(0))
196196
.updatePolicy("default", clusterInfos, null);
197197
}
198198

@@ -206,11 +206,11 @@ public void testBlacklistTwo() throws YarnException {
206206
blacklistedCMI.remove(subClusterIds.get(0));
207207
blacklistedCMI.remove(subClusterIds.get(1));
208208
policyGenerator = new TestablePolicyGenerator();
209-
policyGenerator.policy = mock(GlobalPolicy.class);
209+
policyGenerator.setPolicy(mock(GlobalPolicy.class));
210210
policyGenerator.run();
211-
verify(policyGenerator.policy, times(1))
211+
verify(policyGenerator.getPolicy(), times(1))
212212
.updatePolicy("default", blacklistedCMI, null);
213-
verify(policyGenerator.policy, times(0))
213+
verify(policyGenerator.getPolicy(), times(0))
214214
.updatePolicy("default", clusterInfos, null);
215215
}
216216

@@ -230,12 +230,12 @@ public void testExistingPolicy() throws YarnException {
230230
GetSubClusterPolicyConfigurationResponse.newInstance(testConf));
231231

232232
policyGenerator = new TestablePolicyGenerator();
233-
policyGenerator.policy = mock(GlobalPolicy.class);
233+
policyGenerator.setPolicy(mock(GlobalPolicy.class));
234234
policyGenerator.run();
235235

236236
ArgumentCaptor<FederationPolicyManager> argCaptor =
237237
ArgumentCaptor.forClass(FederationPolicyManager.class);
238-
verify(policyGenerator.policy, times(1))
238+
verify(policyGenerator.getPolicy(), times(1))
239239
.updatePolicy(eq("default"), eq(clusterInfos), argCaptor.capture());
240240
assertEquals(argCaptor.getValue().getClass(), manager.getClass());
241241
assertEquals(argCaptor.getValue().serializeConf(), manager.serializeConf());
@@ -294,7 +294,7 @@ public void testCallRM() {
294294

295295
String rmAddress = WebAppUtils.getRMWebAppURLWithScheme(this.conf);
296296
SchedulerTypeInfo sti = GPGUtils
297-
.invokeRMWebService(conf, rmAddress, RMWSConsts.SCHEDULER,
297+
.invokeRMWebService(rmAddress, RMWSConsts.SCHEDULER,
298298
SchedulerTypeInfo.class);
299299

300300
Assert.assertNotNull(sti);

0 commit comments

Comments
 (0)