[ 
https://issues.apache.org/jira/browse/YARN-11492?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17726283#comment-17726283
 ] 

ASF GitHub Bot commented on YARN-11492:
---------------------------------------

slfan1989 commented on code in PR #5636:
URL: https://github.com/apache/hadoop/pull/5636#discussion_r1205701835


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServiceUtil.java:
##########
@@ -678,4 +683,83 @@ public void testMergeDiffApplicationStatisticsInfo() {
     Assert.assertEquals(YarnApplicationState.FINISHED, item3Result.getState());
     Assert.assertEquals(item4.getCount(), item3Result.getCount());
   }
+
+  @Test
+  public void testCreateJerseyClient() {
+    // Case1,  default timeout, The default timeout is 30s.
+    YarnConfiguration configuration = new YarnConfiguration();
+    Client client01 = RouterWebServiceUtil.createJerseyClient(configuration);
+    Map<String, Object> properties = client01.getProperties();
+    int readTimeOut = (int) properties.get(ClientConfig.PROPERTY_READ_TIMEOUT);
+    int connectTimeOut = (int) 
properties.get(ClientConfig.PROPERTY_CONNECT_TIMEOUT);
+    Assert.assertEquals(30000, readTimeOut);
+    Assert.assertEquals(30000, connectTimeOut);
+    client01.destroy();
+
+    // Case2, set a negative timeout, We'll get the default timeout(30s)
+    YarnConfiguration configuration2 = new YarnConfiguration();
+    configuration2.setLong(YarnConfiguration.ROUTER_WEBAPP_CONNECT_TIMEOUT, 
-1L);
+    configuration2.setLong(YarnConfiguration.ROUTER_WEBAPP_READ_TIMEOUT, -1L);
+    Client client02 = RouterWebServiceUtil.createJerseyClient(configuration2);
+    Map<String, Object> properties02 = client02.getProperties();
+    int readTimeOut02 = (int) 
properties02.get(ClientConfig.PROPERTY_READ_TIMEOUT);
+    int connectTimeOut02 =  (int) 
properties02.get(ClientConfig.PROPERTY_CONNECT_TIMEOUT);
+    Assert.assertEquals(30000, readTimeOut02);
+    Assert.assertEquals(30000, connectTimeOut02);
+    client02.destroy();
+
+    // Case3, Set the maximum value that exceeds the integer
+    // We'll get the default timeout(30s)
+    YarnConfiguration configuration3 = new YarnConfiguration();
+    long connectTimeOutLong = (long) Integer.MAX_VALUE + 1;
+    long readTimeOutLong = (long) Integer.MAX_VALUE + 1;

Review Comment:
   Thank you for helping to review the code! I agree with your point that if 
users set a very large value for the timeout, it could indeed lead to 
unexpected timeouts. Generally, this timeout value should not exceed 1 minute. 
If the user sets a value much larger than this, I will print a warning log to 
alert them. 
   
   Could this approach work? 





> Improve createJerseyClient#setConnectTimeout Code
> -------------------------------------------------
>
>                 Key: YARN-11492
>                 URL: https://issues.apache.org/jira/browse/YARN-11492
>             Project: Hadoop YARN
>          Issue Type: Improvement
>          Components: federation
>    Affects Versions: 3.4.0
>            Reporter: Shilun Fan
>            Assignee: Shilun Fan
>            Priority: Major
>              Labels: pull-request-available
>
> createJerseyClient#setConnectTimeout There is a type conversion code that 
> converts long to int, we should be careful with this part of code, I added 
> some verification rules.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to