* @return the sC mgmt client
* @throws WebCommandException
* the web command exception
*/
protected SCClient connectClientToService(Service service) throws WebCommandException {
ResponderRegistry responderRegistry = AppContext.getResponderRegistry();
if (service instanceof FileService) {
// get local service connector listener using sc-tcp
IResponder responder = responderRegistry.getFirstResponderForConnectionType(ConnectionType.NETTY_TCP);
if (responder != null) {
ListenerConfiguration myLocalListenerConfiguration = responder.getListenerConfig();
List<String> networkInterfaces = myLocalListenerConfiguration.getNetworkInterfaces();
for (String networkInterface : networkInterfaces) {
String host = networkInterface;
int port = myLocalListenerConfiguration.getPort();
try {
SCClient localClient = new SCClient(host, port, ConnectionType.NETTY_TCP);
localClient.attach();
return localClient;
} catch (Exception e) {
LOGGER.warn("upload current log files, connect to network interface " + host + " failed. " + e.toString());
}
}
}
responder = responderRegistry.getFirstResponderForConnectionType(ConnectionType.NETTY_HTTP);
if (responder != null) {
ListenerConfiguration myLocalListenerConfiguration = responder.getListenerConfig();
List<String> networkInterfaces = myLocalListenerConfiguration.getNetworkInterfaces();
// no netty tcp endpoint is available, try to get netty http
for (String networkInterface : networkInterfaces) {