Skip to content

Commit 2fa4c9f

Browse files
author
slfan1989
committed
YARN-11332. Fix CheckStyle.
1 parent 0804d57 commit 2fa4c9f

File tree

4 files changed

+104
-7
lines changed

4 files changed

+104
-7
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4128,27 +4128,73 @@ public static boolean isAclEnabled(Configuration conf) {
41284128
*
41294129
* maximumPoolSize use
41304130
* {@link YarnConfiguration#ROUTER_USER_CLIENT_THREAD_POOL_MAXIMUM_POOL_SIZE}
4131+
*
4132+
* This configurable will be deprecated.
41314133
*/
4132-
@Deprecated
41334134
public static final String ROUTER_USER_CLIENT_THREADS_SIZE =
41344135
ROUTER_PREFIX + "interceptor.user.threadpool-size";
41354136

4136-
@Deprecated
4137+
/**
4138+
* The default value is 5.
4139+
* which means that the corePoolSize(minimumPoolSize) and maximumPoolSize
4140+
* of the thread pool are both 5s.
4141+
*
4142+
* corePoolSize(minimumPoolSize) default value use
4143+
* {@link YarnConfiguration#DEFAULT_ROUTER_USER_CLIENT_THREAD_POOL_MINIMUM_POOL_SIZE}
4144+
*
4145+
* maximumPoolSize default value use
4146+
* {@link YarnConfiguration#DEFAULT_ROUTER_USER_CLIENT_THREAD_POOL_MAXIMUM_POOL_SIZE}
4147+
*/
41374148
public static final int DEFAULT_ROUTER_USER_CLIENT_THREADS_SIZE = 5;
41384149

4150+
/**
4151+
* This configurable is used to set the corePoolSize(minimumPoolSize)
4152+
* of the thread pool of the interceptor.
4153+
*
4154+
* corePoolSize the number of threads to keep in the pool, even if they are idle.
4155+
*/
41394156
public static final String ROUTER_USER_CLIENT_THREAD_POOL_MINIMUM_POOL_SIZE =
41404157
ROUTER_PREFIX + "interceptor.user-thread-pool.minimum-pool-size";
41414158

4159+
/**
4160+
* This configuration is used to set the default value of corePoolSize (minimumPoolSize)
4161+
* of the thread pool of the interceptor.
4162+
*
4163+
* Default is 5.
4164+
*/
41424165
public static final int DEFAULT_ROUTER_USER_CLIENT_THREAD_POOL_MINIMUM_POOL_SIZE = 5;
41434166

4167+
/**
4168+
* This configurable is used to set the maximumPoolSize of the thread pool of the interceptor.
4169+
*
4170+
* maximumPoolSize the maximum number of threads to allow in the pool.
4171+
*/
41444172
public static final String ROUTER_USER_CLIENT_THREAD_POOL_MAXIMUM_POOL_SIZE =
41454173
ROUTER_PREFIX + "interceptor.user-thread-pool.maximum-pool-size";
41464174

4175+
/**
4176+
* This configuration is used to set the default value of maximumPoolSize
4177+
* of the thread pool of the interceptor.
4178+
*
4179+
* Default is 10.
4180+
*/
41474181
public static final int DEFAULT_ROUTER_USER_CLIENT_THREAD_POOL_MAXIMUM_POOL_SIZE = 10;
41484182

4183+
/**
4184+
* This configurable is used to set the keepAliveTime of the thread pool of the interceptor.
4185+
*
4186+
* keepAliveTime when the number of threads is greater than the core,
4187+
* this is the maximum time that excess idle threads will wait for new tasks before terminating.
4188+
*/
41494189
public static final String ROUTER_USER_CLIENT_THREAD_POOL_KEEP_ALIVE_TIME =
41504190
ROUTER_PREFIX + "interceptor.user-thread-pool.keep-alive-time";
41514191

4192+
/**
4193+
* This configurable is used to set the default time of keepAliveTime
4194+
* of the thread pool of the interceptor.
4195+
*
4196+
* the default value is 10s.
4197+
*/
41524198
public static final long DEFAULT_ROUTER_USER_CLIENT_THREAD_POOL_KEEP_ALIVE_TIME =
41534199
10*1000; // 10s
41544200

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5016,4 +5016,33 @@
50165016
</description>
50175017
</property>
50185018

5019+
<property>
5020+
<name>yarn.router.interceptor.user-thread-pool.minimum-pool-size</name>
5021+
<value>5</value>
5022+
<description>
5023+
This configurable is used to set the corePoolSize(minimumPoolSize)
5024+
of the thread pool of the interceptor.
5025+
Default is 5.
5026+
</description>
5027+
</property>
5028+
5029+
<property>
5030+
<name>yarn.router.interceptor.user-thread-pool.maximum-pool-size</name>
5031+
<value>10</value>
5032+
<description>
5033+
This configuration is used to set the default value of maximumPoolSize
5034+
of the thread pool of the interceptor.
5035+
Default is 10.
5036+
</description>
5037+
</property>
5038+
5039+
<property>
5040+
<name>yarn.router.interceptor.user-thread-pool.keep-alive-time</name>
5041+
<value>10s</value>
5042+
<description>
5043+
This configurable is used to set the keepAliveTime of the thread pool of the interceptor.
5044+
Default is 10s.
5045+
</description>
5046+
</property>
5047+
50195048
</configuration>

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public void init(String userName) {
195195
ThreadFactory threadFactory = new ThreadFactoryBuilder()
196196
.setNameFormat("RPC Router Client-" + userName + "-%d ").build();
197197

198-
BlockingQueue workQueue = new LinkedBlockingQueue<>();
198+
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
199199
this.executorService = new ThreadPoolExecutor(numMinThreads, numMaxThreads,
200200
keepAliveTime, TimeUnit.MILLISECONDS, workQueue, threadFactory);
201201

@@ -1809,11 +1809,15 @@ private void updateReservationHomeSubCluster(SubClusterId subClusterId,
18091809
protected int getNumMinThreads(Configuration conf) {
18101810

18111811
String threadSize = conf.get(YarnConfiguration.ROUTER_USER_CLIENT_THREADS_SIZE);
1812+
1813+
// If the user configures YarnConfiguration.ROUTER_USER_CLIENT_THREADS_SIZE,
1814+
// we will still get the number of threads from this configuration.
18121815
if (StringUtils.isNotBlank(threadSize)) {
18131816
LOG.warn("{} is an deprecated property, " +
1814-
"please use {} to configure the minimum number of thread pool.",
1815-
YarnConfiguration.ROUTER_USER_CLIENT_THREADS_SIZE,
1816-
YarnConfiguration.ROUTER_USER_CLIENT_THREAD_POOL_MINIMUM_POOL_SIZE);
1817+
"please use {} to configure the minimum number of thread pool.",
1818+
YarnConfiguration.ROUTER_USER_CLIENT_THREADS_SIZE,
1819+
YarnConfiguration.ROUTER_USER_CLIENT_THREAD_POOL_MINIMUM_POOL_SIZE);
1820+
return Integer.parseInt(threadSize);
18171821
}
18181822

18191823
int numMinThreads = getConf().getInt(
@@ -1825,11 +1829,15 @@ protected int getNumMinThreads(Configuration conf) {
18251829
protected int getNumMaxThreads(Configuration conf) {
18261830

18271831
String threadSize = conf.get(YarnConfiguration.ROUTER_USER_CLIENT_THREADS_SIZE);
1832+
1833+
// If the user configures YarnConfiguration.ROUTER_USER_CLIENT_THREADS_SIZE,
1834+
// we will still get the number of threads from this configuration.
18281835
if (StringUtils.isNotBlank(threadSize)) {
18291836
LOG.warn("{} is an deprecated property, " +
18301837
"please use {} to configure the maximum number of thread pool.",
18311838
YarnConfiguration.ROUTER_USER_CLIENT_THREADS_SIZE,
18321839
YarnConfiguration.ROUTER_USER_CLIENT_THREAD_POOL_MAXIMUM_POOL_SIZE);
1840+
return Integer.parseInt(threadSize);
18331841
}
18341842

18351843
int numMaxThreads = getConf().getInt(

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ private ReservationDefinition createReservationDefinition(long arrival,
15221522
}
15231523

15241524
@Test
1525-
public void testGetNumMinThreads() throws Exception {
1525+
public void testGetNumMinThreads() {
15261526
// If we don't configure YarnConfiguration.ROUTER_USER_CLIENT_THREAD_POOL_MINIMUM_POOL_SIZE,
15271527
// we expect to get 5 threads
15281528
int minThreads = interceptor.getNumMinThreads(this.getConf());
@@ -1534,4 +1534,18 @@ public void testGetNumMinThreads() throws Exception {
15341534
int minThreads2 = interceptor.getNumMinThreads(this.getConf());
15351535
Assert.assertEquals(3, minThreads2);
15361536
}
1537+
1538+
@Test
1539+
public void testGetNumMaxThreads() {
1540+
// If we don't configure YarnConfiguration.ROUTER_USER_CLIENT_THREAD_POOL_MAXIMUM_POOL_SIZE,
1541+
// we expect to get 5 threads
1542+
int minThreads = interceptor.getNumMaxThreads(this.getConf());
1543+
Assert.assertEquals(5, minThreads);
1544+
1545+
// If we configure YarnConfiguration.ROUTER_USER_CLIENT_THREAD_POOL_MAXIMUM_POOL_SIZE,
1546+
// we expect to get 3 threads
1547+
this.getConf().setInt(YarnConfiguration.ROUTER_USER_CLIENT_THREAD_POOL_MAXIMUM_POOL_SIZE, 8);
1548+
int minThreads2 = interceptor.getNumMaxThreads(this.getConf());
1549+
Assert.assertEquals(8, minThreads2);
1550+
}
15371551
}

0 commit comments

Comments
 (0)