throw new TException("Unsupported Hive2 protocol"); throw new SQLException("Could not establish connection to " + jdbcUriString + ": " + e.getMessage(), " 08S01", e);
public String toBinaryString() throws IOException { org.apache.hadoop.hive.ql.plan.api.Query q = getQueryPlan(); TMemoryBuffer tmb = new TMemoryBuffer(q.toString().length() * 5); TBinaryProtocol oprot = new TBinaryProtocol(tmb); try { q.write(oprot); } catch (TException e) { // TODO Auto-generated catch block e.printStackTrace(); return q.toString(); } byte[] buf = new byte[tmb.length()]; tmb.read(buf, 0, tmb.length()); return new String(buf); // return getQueryPlan().toString(); }
/** * Poll the result set status by checking if isSetHasResultSet is set * @return * @throws SQLException */ private TGetOperationStatusResp waitForResultSetStatus() throws SQLException { TGetOperationStatusReq statusReq = new TGetOperationStatusReq(stmtHandle); TGetOperationStatusResp statusResp = null; while(statusResp == null || !statusResp.isSetHasResultSet()) { try { statusResp = client.GetOperationStatus(statusReq); } catch (TException e) { isLogBeingGenerated = false; throw new SQLException(e.toString(), "08S01", e); } } return statusResp; }
@Override Table resolveTable(CompactionInfo ci) throws MetaException { try { return msc.getTable(getDefaultCatalog(conf), ci.dbname, ci.tableName); } catch (TException e) { LOG.error("Unable to find table " + ci.getFullTableName() + ", " + e.getMessage()); throw new MetaException(e.toString()); } }
String errMsg = ex.getMessage(); if (errMsg == null) { errMsg = ex.toString(); ss.connect(); } catch (TException ex) { String errMsg = ex.getMessage(); if (errMsg == null) { errMsg = ex.toString();
public void cancelDelegationToken(String tokenStr) throws SQLException { TCancelDelegationTokenReq cancelReq = new TCancelDelegationTokenReq(sessHandle, tokenStr); try { TCancelDelegationTokenResp cancelResp = client.CancelDelegationToken(cancelReq); Utils.verifySuccess(cancelResp.getStatus()); return; } catch (TException e) { throw new SQLException("Could not cancel token: " + e.getMessage(), " 08S01", e); } }
throws TException { if (maxDepth <= 0) { throw new TException("Maximum skip depth exceeded"); prot.readBool(); break; prot.readByte(); break; prot.readI16(); break;
case TType.BOOL: if (field.type == TType.BOOL){ return protocol_.readBool(); return protocol_.readByte(); return protocol_.readDouble(); throw new TException(e); } finally { trans_.clear();
setIpAddress(in); final TMessage msg = in.readMessageBegin(); final ProcessFunction<Iface, ? extends TBase> fn = functions.get(msg.name); if (fn == null) { TProtocolUtil.skip(in, TType.STRUCT); in.readMessageEnd(); TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'"); out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); x.write(out); out.writeMessageEnd(); out.getTransport().flush(); return true; throw e; } catch (Exception e) { throw new TException(e.getCause());
protocol.readI16(); protocol.readByte(); serviceName = protocol.readString(); path = protocol.readString(); id = protocol.readI64(); message = protocol.readMessageBegin(); } catch (TException e) { throw new IOException(e.getMessage(), e); protocol.readMessageEnd(); } catch (TException e) { throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e); protocol.readMessageEnd(); } catch (TException e) { throw new IOException(e.getMessage(), e); protocol.readMessageEnd(); } catch (TException e) { throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
TBinaryProtocol protocol = new TBinaryProtocol(transport); try { protocol.writeI16(MAGIC); protocol.writeI32(Integer.MAX_VALUE); protocol.writeI16(Short.MAX_VALUE); protocol.writeI64(response.getId()); protocol.getTransport().flush(); headerLength = bos.size(); protocol.writeMessageEnd(); protocol.getTransport().flush(); int oldIndex = messageLength = bos.size(); throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
public static void main(String[] args) { TTransport transport; try { transport = new TSocket("localhost", 2000); TProtocol protocol = new TBinaryProtocol(transport); Suggestor.Client client = new Suggestor.Client(protocol); transport.open(); List<String> suggestions = client.complete(args[0], "text"); transport.close(); System.out.println(suggestions); } catch (TTransportException e) { e.printStackTrace(); } catch (TException e) { e.printStackTrace(); } }
protected void encodeRequest(Channel channel, ChannelBuffer buffer, Request request) throws IOException { Invocation invocation = (Invocation) request.getData(); TProtocol protocol = newProtocol(channel.getUrl(), buffer); try { protocol.writeMessageBegin(new TMessage( invocation.getMethodName(), TMessageType.CALL, thriftSeq.getAndIncrement())); protocol.writeStructBegin(new TStruct(invocation.getMethodName() + "_args")); for (int i = 0; i < invocation.getParameterTypes().length; i++) { Class<?> type = invocation.getParameterTypes()[i]; } } catch (TException e) { throw new IOException(e.getMessage(), e); } }
/** * Deserialize only the id of the field set in a TUnion (addressed by recursively using field id) * from a byte record. * @param bytes The serialized object to read from * @param fieldIdPathFirst First of the FieldId's that define a path to a TUnion * @param fieldIdPathRest The rest FieldId's that define a path to a TUnion * @throws TException */ public Short partialDeserializeSetFieldIdInUnion(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException { try { TField field = locateField(bytes, fieldIdPathFirst, fieldIdPathRest); if (field != null){ protocol_.readStructBegin(); // The Union return protocol_.readFieldBegin().id; // The field set in the union } return null; } catch (Exception e) { throw new TException(e); } finally { trans_.clear(); protocol_.reset(); } }
TBinaryProtocol protocol = new TBinaryProtocol(transport); magic = protocol.readI16(); messageLength = protocol.readI32(); throw new IOException(e.getMessage(), e);
public static void createErrorTMessage(TProtocol oprot, String methodName, int id, String errMsg) throws Exception { TMessage tmessage = new TMessage(methodName, TMessageType.EXCEPTION, id); oprot.writeMessageBegin(tmessage); oprot.writeMessageEnd(); TApplicationException ex = new TApplicationException(TApplicationException.INTERNAL_ERROR, errMsg); try { ex.write(oprot); } catch (TException e) { e.printStackTrace(); } } }
@Override public String getStormRawConf() throws TException { try { return FileUtils.readFileToString(new File(LoadConf.getStormYamlPath())); } catch (IOException ex) { throw new TException(ex); } }
@Override public boolean process(final TProtocol inProt, final TProtocol outProt) throws TException { TTransport trans = inProt.getTransport(); if (!(trans instanceof TSaslServerTransport)) { throw new TException("Unexpected non-SASL transport " + trans.getClass()); authenticationMethod.set(AuthenticationMethod.TOKEN); } catch (InvalidToken e) { throw new TException(e.getMessage());
public void _writeStringData(String s) throws TException { try { byte[] b = s.getBytes("UTF-8"); trans_.write(b); } catch (UnsupportedEncodingException uex) { throw new TException("JVM DOES NOT SUPPORT UTF-8"); } }
public String readString() throws TException { int size = readI32(); checkStringReadLength(size); if (trans_.getBytesRemainingInBuffer() >= size) { try { String s = new String(trans_.getBuffer(), trans_.getBufferPosition(), size, "UTF-8"); trans_.consumeBuffer(size); return s; } catch (UnsupportedEncodingException e) { throw new TException("JVM DOES NOT SUPPORT UTF-8"); } } return readStringBody(size); }