Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,10 @@ public void putDomain(ApplicationAttemptId appAttemptId,
public void setTimelineWriter(TimelineWriter writer) {
this.timelineWriter = writer;
}

@Private
@VisibleForTesting
public TimelineConnector getConnector() {
return connector;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -113,7 +113,7 @@ protected void serviceInit(Configuration conf) throws Exception {
sslFactory = getSSLFactory(conf);
connConfigurator = getConnConfigurator(sslFactory);
} else {
connConfigurator = DEFAULT_TIMEOUT_CONN_CONFIGURATOR;
connConfigurator = defaultTimeoutConnConfigurator;
}
String defaultAuth = UserGroupInformation.isSecurityEnabled() ?
KerberosAuthenticationHandler.TYPE :
Expand All @@ -140,23 +140,18 @@ protected void serviceInit(Configuration conf) throws Exception {
}
}

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;
}
}

Expand Down Expand Up @@ -457,4 +452,9 @@ public boolean shouldRetryOn(Exception e) {
|| e instanceof SocketTimeoutException);
}
}

@VisibleForTesting
public void setSocketTimeOut(int socketTimeOut) {
this.socketTimeOut = socketTimeOut;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void setup() {
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
Expand All @@ -89,7 +89,7 @@ public void tearDown() throws Exception {
if (isSSLConfigured()) {
KeyStoreTestUtil.cleanupSSLConfig(keystoresDir, sslConfDir);
}
TimelineConnector.DEFAULT_SOCKET_TIMEOUT = 60_000;
client.getConnector().setSocketTimeOut(60_000);
}

@Test
Expand Down