當前位置: 首頁>>代碼示例>>Java>>正文


Java TTransportException.getCause方法代碼示例

本文整理匯總了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());
}
 
開發者ID:Netflix,項目名稱:metacat,代碼行數:4,代碼來源:HiveMetastoreClientFactory.java

示例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;
}
 
開發者ID:opendaylight,項目名稱:netvirt,代碼行數:59,代碼來源:BgpRouter.java


注:本文中的org.apache.thrift.transport.TTransportException.getCause方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。