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;
}
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;
}
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;
}
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;
}
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);
}
}
}
Aggregations