Skip to content

Commit 9cbdcee

Browse files
committed
YARN-11634. [Addendum] Speed-up TestTimelineClient.
1 parent 64beecb commit 9cbdcee

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineClientImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,4 +459,10 @@ public void putDomain(ApplicationAttemptId appAttemptId,
459459
public void setTimelineWriter(TimelineWriter writer) {
460460
this.timelineWriter = writer;
461461
}
462+
463+
@Private
464+
@VisibleForTesting
465+
public TimelineConnector getConnector() {
466+
return connector;
467+
}
462468
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineConnector.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public class TimelineConnector extends AbstractService {
7878
private static final Joiner JOINER = Joiner.on("");
7979
private static final Logger LOG =
8080
LoggerFactory.getLogger(TimelineConnector.class);
81-
@VisibleForTesting
82-
public static int DEFAULT_SOCKET_TIMEOUT = 60_000; // 1 minute
81+
82+
private int socketTimeOut = 60_000;
8383

8484
private SSLFactory sslFactory;
8585
Client client;
@@ -145,14 +145,14 @@ protected void serviceInit(Configuration conf) throws Exception {
145145
@Override
146146
public HttpURLConnection configure(HttpURLConnection conn)
147147
throws IOException {
148-
setTimeouts(conn, DEFAULT_SOCKET_TIMEOUT);
148+
setTimeouts(conn, 60_000);
149149
return conn;
150150
}
151151
};
152152

153153
private ConnectionConfigurator getConnConfigurator(SSLFactory sslFactoryObj) {
154154
try {
155-
return initSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, sslFactoryObj);
155+
return initSslConnConfigurator(socketTimeOut, sslFactoryObj);
156156
} catch (Exception e) {
157157
LOG.debug("Cannot load customized ssl related configuration. "
158158
+ "Fallback to system-generic settings.", e);
@@ -457,4 +457,9 @@ public boolean shouldRetryOn(Exception e) {
457457
|| e instanceof SocketTimeoutException);
458458
}
459459
}
460+
461+
@VisibleForTesting
462+
public void setSocketTimeOut(int socketTimeOut) {
463+
this.socketTimeOut = socketTimeOut;
464+
}
460465
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void setup() {
7878
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
7979
conf.setFloat(YarnConfiguration.TIMELINE_SERVICE_VERSION, 1.0f);
8080
client = createTimelineClient(conf);
81-
TimelineConnector.DEFAULT_SOCKET_TIMEOUT = 10;
81+
client.getConnector().setSocketTimeOut(10);
8282
}
8383

8484
@AfterEach
@@ -89,7 +89,7 @@ public void tearDown() throws Exception {
8989
if (isSSLConfigured()) {
9090
KeyStoreTestUtil.cleanupSSLConfig(keystoresDir, sslConfDir);
9191
}
92-
TimelineConnector.DEFAULT_SOCKET_TIMEOUT = 60_000;
92+
client.getConnector().setSocketTimeOut(60_1000);
9393
}
9494

9595
@Test

0 commit comments

Comments
 (0)