|
@@ -78,8 +78,8 @@ public class TimelineConnector extends AbstractService {
|
|
private static final Joiner JOINER = Joiner.on("");
|
|
private static final Joiner JOINER = Joiner.on("");
|
|
private static final Logger LOG =
|
|
private static final Logger LOG =
|
|
LoggerFactory.getLogger(TimelineConnector.class);
|
|
LoggerFactory.getLogger(TimelineConnector.class);
|
|
- @VisibleForTesting
|
|
|
|
- public static int DEFAULT_SOCKET_TIMEOUT = 60_000; // 1 minute
|
|
|
|
|
|
+
|
|
|
|
+ private int socketTimeOut = 60_000;
|
|
|
|
|
|
private SSLFactory sslFactory;
|
|
private SSLFactory sslFactory;
|
|
Client client;
|
|
Client client;
|
|
@@ -113,7 +113,7 @@ public class TimelineConnector extends AbstractService {
|
|
sslFactory = getSSLFactory(conf);
|
|
sslFactory = getSSLFactory(conf);
|
|
connConfigurator = getConnConfigurator(sslFactory);
|
|
connConfigurator = getConnConfigurator(sslFactory);
|
|
} else {
|
|
} else {
|
|
- connConfigurator = DEFAULT_TIMEOUT_CONN_CONFIGURATOR;
|
|
|
|
|
|
+ connConfigurator = defaultTimeoutConnConfigurator;
|
|
}
|
|
}
|
|
String defaultAuth = UserGroupInformation.isSecurityEnabled() ?
|
|
String defaultAuth = UserGroupInformation.isSecurityEnabled() ?
|
|
KerberosAuthenticationHandler.TYPE :
|
|
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) {
|
|
private ConnectionConfigurator getConnConfigurator(SSLFactory sslFactoryObj) {
|
|
try {
|
|
try {
|
|
- return initSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, sslFactoryObj);
|
|
|
|
|
|
+ return initSslConnConfigurator(socketTimeOut, sslFactoryObj);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
LOG.debug("Cannot load customized ssl related configuration. "
|
|
LOG.debug("Cannot load customized ssl related configuration. "
|
|
+ "Fallback to system-generic settings.", e);
|
|
+ "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);
|
|
|| e instanceof SocketTimeoutException);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @VisibleForTesting
|
|
|
|
+ public void setSocketTimeOut(int socketTimeOut) {
|
|
|
|
+ this.socketTimeOut = socketTimeOut;
|
|
|
|
+ }
|
|
}
|
|
}
|