Search in sources :

Example 41 with TTransportException

use of org.apache.thrift.transport.TTransportException in project presto by prestodb.

the class MockHiveMetastoreClientFactory method create.

@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);
    }
    return client;
}
Also used : TTransportException(org.apache.thrift.transport.TTransportException) HiveMetastoreClient(com.facebook.presto.hive.metastore.HiveMetastoreClient)

Example 42 with TTransportException

use of org.apache.thrift.transport.TTransportException in project jstorm by alibaba.

the class TBackoffConnect method doConnectWithRetry.

public TTransport doConnectWithRetry(ITransportPlugin transportPlugin, TTransport underlyingTransport, String host, String asUser) throws IOException {
    boolean connected = false;
    TTransport transportResult = null;
    while (!connected) {
        try {
            transportResult = transportPlugin.connect(underlyingTransport, host, asUser);
            connected = true;
        } catch (TTransportException ex) {
            retryNext(ex);
        }
    }
    return transportResult;
}
Also used : TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport)

Example 43 with TTransportException

use of org.apache.thrift.transport.TTransportException in project jstorm by alibaba.

the class BlobStoreUtils method downloadUpdatedBlob.

// Download updated blobs from potential nimbodes
public static boolean downloadUpdatedBlob(Map conf, BlobStore blobStore, String key, Set<NimbusInfo> nimbusInfos) throws TTransportException {
    NimbusClient client;
    ClientBlobStore remoteBlobStore;
    InputStreamWithMeta in;
    AtomicOutputStream out;
    boolean isSuccess = false;
    LOG.debug("Download blob NimbusInfos {}", nimbusInfos);
    for (NimbusInfo nimbusInfo : nimbusInfos) {
        if (isSuccess) {
            break;
        }
        try {
            client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null);
            remoteBlobStore = new NimbusBlobStore();
            remoteBlobStore.setClient(conf, client);
            isSuccess = updateBlob(blobStore, key, remoteBlobStore.getBlob(key));
        } catch (IOException exception) {
            throw new RuntimeException(exception);
        } catch (KeyNotFoundException knf) {
            // Catching and logging KeyNotFoundException because, if
            // there is a subsequent update and delete, the non-leader
            // nimbodes might throw an exception.
            LOG.info("KeyNotFoundException {}", knf);
        } catch (Exception exp) {
            // Logging an exception while client is connecting
            LOG.error("Exception {}", exp);
        }
    }
    if (!isSuccess) {
        LOG.error("Could not update the blob with key" + key);
    }
    return isSuccess;
}
Also used : NimbusClient(backtype.storm.utils.NimbusClient) IOException(java.io.IOException) KeyNotFoundException(backtype.storm.generated.KeyNotFoundException) KeyNotFoundException(backtype.storm.generated.KeyNotFoundException) TTransportException(org.apache.thrift.transport.TTransportException) TException(org.apache.thrift.TException) IOException(java.io.IOException) KeyAlreadyExistsException(backtype.storm.generated.KeyAlreadyExistsException) NimbusInfo(backtype.storm.nimbus.NimbusInfo)

Example 44 with TTransportException

use of org.apache.thrift.transport.TTransportException in project jstorm by alibaba.

the class BlobStoreUtils method downloadMissingBlob.

// Download missing blobs from potential nimbodes
public static boolean downloadMissingBlob(Map conf, BlobStore blobStore, String key, Set<NimbusInfo> nimbusInfos) throws TTransportException {
    NimbusClient client;
    ReadableBlobMeta rbm;
    ClientBlobStore remoteBlobStore;
    InputStreamWithMeta in;
    boolean isSuccess = false;
    LOG.debug("Download blob NimbusInfos {}", nimbusInfos);
    for (NimbusInfo nimbusInfo : nimbusInfos) {
        if (isSuccess) {
            break;
        }
        try {
            client = new NimbusClient(conf, nimbusInfo.getHost(), nimbusInfo.getPort(), null);
            rbm = client.getClient().getBlobMeta(key);
            remoteBlobStore = new NimbusBlobStore();
            remoteBlobStore.setClient(conf, client);
            in = remoteBlobStore.getBlob(key);
            blobStore.createBlob(key, in, rbm.get_settable());
            // if key already exists while creating the blob else update it
            Iterator<String> keyIterator = blobStore.listKeys();
            while (keyIterator.hasNext()) {
                if (keyIterator.next().equals(key)) {
                    LOG.debug("Success creating key, {}", key);
                    isSuccess = true;
                    break;
                }
            }
        } catch (IOException exception) {
            throw new RuntimeException(exception);
        } catch (KeyAlreadyExistsException kae) {
            LOG.info("KeyAlreadyExistsException Key: {} {}", key, kae);
        } catch (KeyNotFoundException knf) {
            // Catching and logging KeyNotFoundException because, if
            // there is a subsequent update and delete, the non-leader
            // nimbodes might throw an exception.
            LOG.info("KeyNotFoundException Key: {} {}", key, knf);
        } catch (Exception exp) {
            // Logging an exception while client is connecting
            LOG.error("Exception ", exp);
        }
    }
    if (!isSuccess) {
        LOG.error("Could not download blob with key" + key);
    }
    return isSuccess;
}
Also used : ReadableBlobMeta(backtype.storm.generated.ReadableBlobMeta) NimbusClient(backtype.storm.utils.NimbusClient) IOException(java.io.IOException) KeyAlreadyExistsException(backtype.storm.generated.KeyAlreadyExistsException) KeyNotFoundException(backtype.storm.generated.KeyNotFoundException) TTransportException(org.apache.thrift.transport.TTransportException) TException(org.apache.thrift.TException) IOException(java.io.IOException) KeyAlreadyExistsException(backtype.storm.generated.KeyAlreadyExistsException) NimbusInfo(backtype.storm.nimbus.NimbusInfo) KeyNotFoundException(backtype.storm.generated.KeyNotFoundException)

Example 45 with TTransportException

use of org.apache.thrift.transport.TTransportException in project jstorm by alibaba.

the class ReturnResultsReducer method complete.

@Override
public void complete(ReturnResultsState state, TridentCollector collector) {
    // only one of the multireducers will receive the tuples
    if (state.returnInfo != null) {
        String result = JSONValue.toJSONString(state.results);
        Map retMap = (Map) JSONValue.parse(state.returnInfo);
        final String host = (String) retMap.get("host");
        final int port = Utils.getInt(retMap.get("port"));
        String id = (String) retMap.get("id");
        DistributedRPCInvocations.Iface client;
        if (local) {
            client = (DistributedRPCInvocations.Iface) ServiceRegistry.getService(host);
        } else {
            List server = new ArrayList() {

                {
                    add(host);
                    add(port);
                }
            };
            if (!_clients.containsKey(server)) {
                try {
                    _clients.put(server, new DRPCInvocationsClient(conf, host, port));
                } catch (TTransportException ex) {
                    throw new RuntimeException(ex);
                }
            }
            client = _clients.get(server);
        }
        try {
            client.result(id, result);
        } catch (AuthorizationException aze) {
            collector.reportError(aze);
        } catch (TException e) {
            collector.reportError(e);
        }
    }
}
Also used : DRPCInvocationsClient(backtype.storm.drpc.DRPCInvocationsClient) TException(org.apache.thrift.TException) AuthorizationException(backtype.storm.generated.AuthorizationException) ArrayList(java.util.ArrayList) DistributedRPCInvocations(backtype.storm.generated.DistributedRPCInvocations) TTransportException(org.apache.thrift.transport.TTransportException) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

TTransportException (org.apache.thrift.transport.TTransportException)67 IOException (java.io.IOException)23 TException (org.apache.thrift.TException)22 TTransport (org.apache.thrift.transport.TTransport)18 TSocket (org.apache.thrift.transport.TSocket)14 Test (org.junit.Test)13 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)8 TProtocol (org.apache.thrift.protocol.TProtocol)8 TFramedTransport (org.apache.thrift.transport.TFramedTransport)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 List (java.util.List)4 Map (java.util.Map)4 KeyAlreadyExistsException (backtype.storm.generated.KeyAlreadyExistsException)3 KeyNotFoundException (backtype.storm.generated.KeyNotFoundException)3 NimbusInfo (backtype.storm.nimbus.NimbusInfo)3 NimbusClient (backtype.storm.utils.NimbusClient)3 SocketException (java.net.SocketException)3 PrivilegedActionException (java.security.PrivilegedActionException)3 LoginException (javax.security.auth.login.LoginException)3