Example usage for org.apache.thrift.transport TTransportException TIMED_OUT

List of usage examples for org.apache.thrift.transport TTransportException TIMED_OUT

Introduction

In this page you can find the example usage for org.apache.thrift.transport TTransportException TIMED_OUT.

Prototype

int TIMED_OUT

To view the source code for org.apache.thrift.transport TTransportException TIMED_OUT.

Click Source Link

Usage

From source file:com.facebook.presto.hive.metastore.thrift.MockHiveMetastoreClientFactory.java

License:Apache License

@Override
public HiveMetastoreClient create(String host, int port) throws TTransportException {
    checkState(!clients.isEmpty(), "mock not given enough clients");
    HiveMetastoreClient client = clients.remove(0);
    if (client == null) {
        throw new TTransportException(TTransportException.TIMED_OUT);
    }/*  w  ww.ja  va2 s .c  o m*/
    return client;
}

From source file:io.prestosql.plugin.hive.metastore.thrift.MockHiveMetastoreClientFactory.java

License:Apache License

@Override
public HiveMetastoreClient create(HostAndPort address) throws TTransportException {
    checkState(!clients.isEmpty(), "mock not given enough clients");
    HiveMetastoreClient client = clients.remove(0);
    if (client == null) {
        throw new TTransportException(TTransportException.TIMED_OUT);
    }//from w  w  w.j  a va2s  .c  o  m
    return client;
}

From source file:org.apache.hadoop.hdfs.notifier.server.ServerDispatcher.java

License:Apache License

private DispatchStatus sendHeartbeat(ClientData clientData) {
    long currentTime = System.currentTimeMillis();
    DispatchStatus status = new DispatchStatus();

    status.time = currentTime;//  w  w w.j a va 2  s .c o  m
    if (currentTime - clientData.lastSentTime > heartbeatTimeout) {
        try {
            clientData.handler.heartbeat(core.getId());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Successfully sent heartbeat to " + clientData);
            }
            core.getMetrics().heartbeats.inc();
            status.action = DispatchStatus.Action.DISPATCH_SUCCESSFUL;
        } catch (TTransportException e) {
            LOG.warn("Failed to heartbeat " + clientData, e);
            if (e.getType() != TTransportException.TIMED_OUT) {
                core.removeClient(clientData.id);
            }
            status.action = DispatchStatus.Action.DISPATCH_FAILED;
        } catch (InvalidServerIdException e) {
            LOG.warn("Client removed this server " + clientData, e);
            status.action = DispatchStatus.Action.DISPATCH_FAILED;
        } catch (TException e) {
            LOG.warn("Failed to heartbeat " + clientData, e);
            core.removeClient(clientData.id);
            status.action = DispatchStatus.Action.DISPATCH_FAILED;
        }
    }

    return status;
}

From source file:org.apache.hadoop.hdfs.notifier.server.ServerDispatcher.java

License:Apache License

private DispatchStatus sendNotification(ClientData clientData, NamespaceNotification notification) {
    DispatchStatus status = new DispatchStatus();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Sending " + NotifierUtils.asString(notification) + " to client " + clientData + " ...");
    }/*from ww  w.j av a  2s  .c om*/

    status.time = System.currentTimeMillis();
    try {
        clientData.handler.handleNotification(notification, core.getId());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Successfully sent " + NotifierUtils.asString(notification) + " to " + clientData);
        }
        core.getMetrics().dispatchedNotifications.inc();
        status.action = DispatchStatus.Action.DISPATCH_SUCCESSFUL;
    } catch (TTransportException e) {
        LOG.warn("Failed to send notification to " + clientData, e);
        if (e.getType() != TTransportException.TIMED_OUT) {
            core.removeClient(clientData.id);
        }
        status.action = DispatchStatus.Action.DISPATCH_FAILED;
        core.getMetrics().failedNotifications.inc();
    } catch (InvalidServerIdException e) {
        LOG.warn("Client removed this server " + clientData, e);
        status.action = DispatchStatus.Action.DISPATCH_FAILED;
    } catch (TException e) {
        LOG.warn("Failed to send notification to " + clientData, e);
        core.removeClient(clientData.id);
        status.action = DispatchStatus.Action.DISPATCH_FAILED;
        core.getMetrics().failedNotifications.inc();
    }

    return status;
}

From source file:org.apache.hive.beeline.TestBeeLineExceptionHandling.java

License:Apache License

@Test
public void testHandleSQLExceptionLog() throws Exception {
    checkException(TTransportException.ALREADY_OPEN, "hs2-connection-already-open");
    checkException(TTransportException.END_OF_FILE, "hs2-unexpected-end-of-file");
    checkException(TTransportException.NOT_OPEN, "hs2-could-not-open-connection");
    checkException(TTransportException.TIMED_OUT, "hs2-connection-timed-out");
    checkException(TTransportException.UNKNOWN, "hs2-unknown-connection-problem");
    checkException(-1, "hs2-unexpected-error");
}