本文整理匯總了Java中org.apache.thrift.transport.TTransportException.getCause方法的典型用法代碼示例。如果您正苦於以下問題:Java TTransportException.getCause方法的具體用法?Java TTransportException.getCause怎麽用?Java TTransportException.getCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.thrift.transport.TTransportException
的用法示例。
在下文中一共展示了TTransportException.getCause方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: rewriteException
import org.apache.thrift.transport.TTransportException; //導入方法依賴的package包/類
private static TTransportException rewriteException(final TTransportException e, final String host) {
return new TTransportException(e.getType(), String.format("%s: %s", host, e.getMessage()), e.getCause());
}
示例2: connect
import org.apache.thrift.transport.TTransportException; //導入方法依賴的package包/類
public synchronized boolean connect(String bgpHost, int bgpPort) {
String msgPiece = "BGP config server at " + bgpHost + ":" + bgpPort;
if (!BgpConfigurationManager.isValidConfigBgpHostPort(bgpHost, bgpPort)) {
LOG.error("Invalid config server host: {}, port: {}", bgpHost, bgpPort);
return false;
}
final int numberOfConnectRetries = 180;
configServerUpdated = false;
RetryOnException connectRetry = new RetryOnException(numberOfConnectRetries);
disconnect();
setConnectTS(System.currentTimeMillis());
do {
if (!isBGPEntityOwner.getAsBoolean()) {
LOG.error("Non Entity BGP owner trying to connect to thrift. Returning");
isConnected = false;
return false;
}
if (configServerUpdated) {
LOG.error("Config server updated while connecting to server {} {}", bgpHost, bgpPort);
isConnected = false;
return false;
}
try {
LOG.error("Trying to connect BGP config server at {} : {}", bgpHost, bgpPort);
TSocket ts = new TSocket(bgpHost, bgpPort, CONNECTION_TIMEOUT);
transport = ts;
transport.open();
ts.setTimeout(THRIFT_TIMEOUT_MILLI);
isConnected = true;
setLastConnectedTS(System.currentTimeMillis());
LOG.error("Connected to BGP config server at {} : {}", bgpHost, bgpPort);
break;
} catch (TTransportException tte) {
LOG.debug("Failed connecting to BGP config server at {} : {}. msg: {}; Exception :",
bgpHost, bgpPort, msgPiece, tte);
if (tte.getCause() instanceof ConnectException) {
LOG.debug("Connect exception. Failed connecting to BGP config server at {} : {}. "
+ "msg: {}; Exception :", bgpHost, bgpPort, msgPiece, tte);
connectRetry.errorOccured();
} else {
//In Case of other exceptions we try only 3 times
connectRetry.errorOccured(60);
}
}
} while (connectRetry.shouldRetry());
if (!connectRetry.shouldRetry()) {
isConnected = false;
return false;
}
bgpClient = new BgpConfigurator.Client(new TBinaryProtocol(transport));
LOG.info("Connected to " + msgPiece);
return true;
}