You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "ayushtkn (via GitHub)" <gi...@apache.org> on 2023/06/01 04:34:04 UTC

[GitHub] [hadoop] ayushtkn commented on a diff in pull request #5636: YARN-11492. Improve createJerseyClient#setConnectTimeout Code.

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


##########
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:
   I think the correct approach would be first get the long, figure out whether it is -ve or bigger than Integer.MAX and if so put a log and use the default.
   If it is within limit, then may be we can do a cast



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org