private static TTransportException rewriteException(TTransportException e, HostAndPort address) { return new TTransportException(e.getType(), String.format("%s: %s", address, e.getMessage()), e); }
/** * Read in the root node if it has not yet been read. */ private void readRoot() throws IOException { if (root != null) { return; } final ByteArrayOutputStream content = new ByteArrayOutputStream(); final byte[] buffer = new byte[READ_BUFFER_SIZE]; try { while (trans_.read(buffer, 0, READ_BUFFER_SIZE) > 0) { content.write(buffer); } } catch (TTransportException e) { if (TTransportException.END_OF_FILE != e.getType()) { throw new IOException(e); } } root = OBJECT_MAPPER.readTree(content.toByteArray()); }
private boolean fillTokenizer() { try { int length = trans.read(buf, 0, buf.length); if (length <= 0) { tokenizer = new StringTokenizer("", separator, true); return false; } String row; try { row = Text.decode(buf, 0, length); } catch (CharacterCodingException e) { throw new RuntimeException(e); } tokenizer = new StringTokenizer(row, separator, true); } catch (TTransportException e) { if(e.getType() == TTransportException.END_OF_FILE){ tokenizer = new StringTokenizer("", separator, true); return false; } tokenizer = null; throw new RuntimeException(e); } return true; }
switch (((TTransportException)e.getCause()).getType()) { case TTransportException.ALREADY_OPEN: error(loc("hs2-connection-already-open"));
private void processUntil(int lastChunk) throws TException { TProtocol ip = inputProtocolFactory_.getProtocol(inputTransport_); TProtocol op = outputProtocolFactory_.getProtocol(outputTransport_); int curChunk = inputTransport_.getCurChunk(); try { while (lastChunk >= curChunk) { processor_.process(ip, op); int newChunk = inputTransport_.getCurChunk(); curChunk = newChunk; } } catch (TTransportException e) { // if we are processing the last chunk - we could have just hit EOF // on EOF - trap the error and stop processing. if(e.getType() != TTransportException.END_OF_FILE) throw e; else { return; } } }
&& ((TTransportException) e).getType() == TTransportException.END_OF_FILE) {
/** * Determines if the transport close caused by the given exception was a "clean" close, i.e. the exception is null * (closed by user) or it's a TTransportException.END_OF_FILE (remote peer closed). * * @param cause exception which caused the close * @return true if the close was clean, false if not */ private boolean isCleanClose(Exception cause) { if (cause == null) { return true; } if (cause instanceof TTransportException) { return ((TTransportException) cause).getType() == TTransportExceptionType.END_OF_FILE; } return false; }
switch (e.getType()) { case TTransportException.END_OF_FILE: if (transport != null) {
if (!readSaslHeader && e.getType() == TTransportException.END_OF_FILE) { underlyingTransport.close(); LOGGER.debug("No data or no sasl data in the stream");
/** * Read in the root node if it has not yet been read. */ private void readRoot() throws IOException { if (root != null) { return; } final ByteArrayOutputStream content = new ByteArrayOutputStream(); final byte[] buffer = new byte[READ_BUFFER_SIZE]; try { while (trans_.read(buffer, 0, READ_BUFFER_SIZE) > 0) { content.write(buffer); } } catch (TTransportException e) { if (TTransportException.END_OF_FILE != e.getType()) { throw new IOException(e); } } root = OBJECT_MAPPER.readTree(content.toByteArray()); }
/** * Read in the root node if it has not yet been read. */ private void readRoot() throws IOException { if (root != null) { return; } final ByteArrayOutputStream content = new ByteArrayOutputStream(); final byte[] buffer = new byte[READ_BUFFER_SIZE]; try { while (trans_.read(buffer, 0, READ_BUFFER_SIZE) > 0) { content.write(buffer); } } catch (TTransportException e) { if (TTransportException.END_OF_FILE != e.getType()) { throw new IOException(e); } } root = OBJECT_MAPPER.readTree(content.toByteArray()); }
private static TTransportException rewriteException(TTransportException e, HostAndPort address) { return new TTransportException(e.getType(), String.format("%s: %s", address, e.getMessage()), e); }
private boolean isThriftFramedTransportSizeOverrun(Execution<?> execution, ConnectionException exception) { // Thrift framed transport size overruns don't have an explicit exception, but they fall under the general // umbrella of "unknown" thrift transport exceptions. Optional<Throwable> thriftException = Iterables.tryFind(Throwables.getCausalChain(exception), Predicates.instanceOf(TTransportException.class)); //noinspection ThrowableResultOfMethodCallIgnored if (!thriftException.isPresent() || ((TTransportException) thriftException.get()).getType() != TTransportException.UNKNOWN) { return false; } return execution instanceof MutationBatch && getMutationBatchSize((MutationBatch) execution) >= MAX_THRIFT_FRAMED_TRANSPORT_SIZE; }
private boolean isThriftFramedTransportSizeOverrun(Execution<?> execution, ConnectionException exception) { // Thrift framed transport size overruns don't have an explicit exception, but they fall under the general // umbrella of "unknown" thrift transport exceptions. Optional<Throwable> thriftException = Iterables.tryFind(Throwables.getCausalChain(exception), Predicates.instanceOf(TTransportException.class)); //noinspection ThrowableResultOfMethodCallIgnored if (!thriftException.isPresent() || ((TTransportException) thriftException.get()).getType() != TTransportException.UNKNOWN) { return false; } return execution instanceof MutationBatch && getMutationBatchSize((MutationBatch) execution) >= MAX_THRIFT_FRAMED_TRANSPORT_SIZE; }
private static TTransportException rewriteException(final TTransportException e, final String host) { return new TTransportException(e.getType(), String.format("%s: %s", host, e.getMessage()), e.getCause()); }
private static TTransportException rewriteException(TTransportException e, String host) { return new TTransportException(e.getType(), String.format("%s: %s", host, e.getMessage()), e.getCause()); }
private static TTransportException rewriteException(final TTransportException e, final String host) { return new TTransportException(e.getType(), String.format("%s: %s", host, e.getMessage()), e.getCause()); }
/** * Send the contents of a RDF-encoded Thrift file to an "action" * @param protocol TProtocol * @param action Code to act on the row. */ public static void apply(TProtocol protocol, Consumer<RDF_StreamRow> action) { RDF_StreamRow row = new RDF_StreamRow() ; while(protocol.getTransport().isOpen()) { try { row.read(protocol) ; } catch (TTransportException e) { if ( e.getType() == TTransportException.END_OF_FILE ) break ; } catch (TException ex) { TRDF.exception(ex) ; } action.accept(row) ; row.clear() ; } }
@Override public synchronized void open() throws TTransportException { if (isOpen()) { throw new TTransportException(TTransportExceptionType.ALREADY_OPEN, "Transport already open"); } try { framedTransport.open(); } catch (TTransportException e) { // It's OK if the underlying transport is already open. if (e.getType() != TTransportExceptionType.ALREADY_OPEN) { throw e; } } readExecutor = executorFactory.newExecutor(); readExecutor.execute(newTransportReader()); super.open(); }
@Override protected StreamRowRDF moveToNext() { if ( ! protocol.getTransport().isOpen() ) return null ; try { row.read(protocol) ; } catch (TTransportException e) { if ( e.getType() == TTransportException.END_OF_FILE ) return null ; } catch (TException ex) { TRDF.exception(ex) ; } TRDF.visit(row, converter); row.clear() ; return collector.getRow() ; }