YARN-11634. [Addendum] Speed-up TestTimelineClient. (#6419)
Co-authored-by: slfan1989 <slfan1989@apache.org>
This commit is contained in:
parent
0f8b74b03f
commit
6ebce65ae8
@ -459,4 +459,10 @@ public class TimelineClientImpl extends TimelineClient {
|
||||
public void setTimelineWriter(TimelineWriter writer) {
|
||||
this.timelineWriter = writer;
|
||||
}
|
||||
|
||||
@Private
|
||||
@VisibleForTesting
|
||||
public TimelineConnector getConnector() {
|
||||
return connector;
|
||||
}
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ public class TimelineConnector extends AbstractService {
|
||||
private static final Joiner JOINER = Joiner.on("");
|
||||
private static final Logger LOG =
|
||||
LoggerFactory.getLogger(TimelineConnector.class);
|
||||
@VisibleForTesting
|
||||
public static int DEFAULT_SOCKET_TIMEOUT = 60_000; // 1 minute
|
||||
|
||||
private int socketTimeOut = 60_000;
|
||||
|
||||
private SSLFactory sslFactory;
|
||||
Client client;
|
||||
@ -113,7 +113,7 @@ public class TimelineConnector extends AbstractService {
|
||||
sslFactory = getSSLFactory(conf);
|
||||
connConfigurator = getConnConfigurator(sslFactory);
|
||||
} else {
|
||||
connConfigurator = DEFAULT_TIMEOUT_CONN_CONFIGURATOR;
|
||||
connConfigurator = defaultTimeoutConnConfigurator;
|
||||
}
|
||||
String defaultAuth = UserGroupInformation.isSecurityEnabled() ?
|
||||
KerberosAuthenticationHandler.TYPE :
|
||||
@ -140,23 +140,18 @@ public class TimelineConnector extends AbstractService {
|
||||
}
|
||||
}
|
||||
|
||||
private static final ConnectionConfigurator DEFAULT_TIMEOUT_CONN_CONFIGURATOR
|
||||
= new ConnectionConfigurator() {
|
||||
@Override
|
||||
public HttpURLConnection configure(HttpURLConnection conn)
|
||||
throws IOException {
|
||||
setTimeouts(conn, DEFAULT_SOCKET_TIMEOUT);
|
||||
return conn;
|
||||
}
|
||||
};
|
||||
private ConnectionConfigurator defaultTimeoutConnConfigurator = conn -> {
|
||||
setTimeouts(conn, socketTimeOut);
|
||||
return conn;
|
||||
};
|
||||
|
||||
private ConnectionConfigurator getConnConfigurator(SSLFactory sslFactoryObj) {
|
||||
try {
|
||||
return initSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, sslFactoryObj);
|
||||
return initSslConnConfigurator(socketTimeOut, sslFactoryObj);
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Cannot load customized ssl related configuration. "
|
||||
+ "Fallback to system-generic settings.", e);
|
||||
return DEFAULT_TIMEOUT_CONN_CONFIGURATOR;
|
||||
return defaultTimeoutConnConfigurator;
|
||||
}
|
||||
}
|
||||
|
||||
@ -457,4 +452,9 @@ public class TimelineConnector extends AbstractService {
|
||||
|| e instanceof SocketTimeoutException);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setSocketTimeOut(int socketTimeOut) {
|
||||
this.socketTimeOut = socketTimeOut;
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class TestTimelineClient {
|
||||
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
||||
conf.setFloat(YarnConfiguration.TIMELINE_SERVICE_VERSION, 1.0f);
|
||||
client = createTimelineClient(conf);
|
||||
TimelineConnector.DEFAULT_SOCKET_TIMEOUT = 10;
|
||||
client.getConnector().setSocketTimeOut(10);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
@ -89,7 +89,7 @@ public class TestTimelineClient {
|
||||
if (isSSLConfigured()) {
|
||||
KeyStoreTestUtil.cleanupSSLConfig(keystoresDir, sslConfDir);
|
||||
}
|
||||
TimelineConnector.DEFAULT_SOCKET_TIMEOUT = 60_000;
|
||||
client.getConnector().setSocketTimeOut(60_000);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user