use of org.apache.storm.thrift.transport.TSocket in project storm by apache.
the class ThriftClient method reconnect.
public synchronized void reconnect() {
close();
TSocket socket = null;
try {
socket = new TSocket(host, port);
if (timeout != null) {
socket.setTimeout(timeout);
}
// construct a transport plugin
ITransportPlugin transportPlugin = ClientAuthUtils.getTransportPlugin(type, conf);
// TODO get this from type instead of hardcoding to Nimbus.
// establish client-server transport via plugin
// do retries if the connect fails
TBackoffConnect connectionRetry = new TBackoffConnect(ObjectReader.getInt(conf.get(Config.STORM_NIMBUS_RETRY_TIMES)), ObjectReader.getInt(conf.get(Config.STORM_NIMBUS_RETRY_INTERVAL)), ObjectReader.getInt(conf.get(Config.STORM_NIMBUS_RETRY_INTERVAL_CEILING)), retryForever);
transport = connectionRetry.doConnectWithRetry(transportPlugin, socket, host, asUser);
} catch (Exception ex) {
// close the socket, which releases connection if it has created any.
if (socket != null) {
try {
socket.close();
} catch (Exception e) {
// ignore
}
}
throw new RuntimeException(ex);
}
protocol = null;
if (transport != null) {
protocol = new TBinaryProtocol(transport);
}
}
Aggregations