@Override public void open() throws TTransportException { try { transport.open(); } catch (TTransportException e) { throw rewriteException(e, address); } }
@Override public void flush() throws TTransportException { try { transport.flush(); } catch (TTransportException e) { throw rewriteException(e, address); } } }
public boolean process(TProtocol iprot, TProtocol oprot) throws TException { TMessage msg = iprot.readMessageBegin(); ProcessFunction fn = processMap_.get(msg.name); if (fn == null) { TProtocolUtil.skip(iprot, TType.STRUCT); iprot.readMessageEnd(); TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'"); oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); x.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); return true; } fn.process(msg.seqid, iprot, oprot); return true; }
public void send_handshake() throws TException { oprot_.writeMessageBegin(new TMessage("handshake", TMessageType.CALL, ++seqid_)); handshake_args args = new handshake_args(); args.write(oprot_); oprot_.writeMessageEnd(); oprot_.getTransport().flush(); }
@Override public boolean process(TProtocol in, TProtocol out) throws TException { short magic = in.readI16(); in.readI32(); in.readI16(); byte version = in.readByte(); String serviceName = in.readString(); headerProtocol.writeString(serviceName); headerProtocol.writeI64(id); headerProtocol.getTransport().flush(); out.writeI16(magic); out.writeI64(id); out.getTransport().write(bos.toByteArray()); out.getTransport().flush();
boolean framed = false; TTransport transport = new TSocket(host, port, timeout); if (framed) { transport = new TFramedTransport(transport); TProtocol protocol = new TBinaryProtocol(transport); transport.open(); transport.close();
applicationException = new TApplicationException(throwable.getMessage()); message = new TMessage(rd.methodName, TMessageType.EXCEPTION, rd.id); } else { message = new TMessage(rd.methodName, TMessageType.REPLY, rd.id); 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();
includeProtocols, excludeCipherSuites, includeCipherSuites); } else { tsocket = new TSocket(hostname, port); if (!transport.isOpen()) { transport.open(); client = new ThriftSourceProtocol.Client(new TBinaryProtocol(transport)); } else { LOGGER.info("Using TCompactProtocol");
protected synchronized TTransport connect(HiveConf conf) throws HiveSQLException, TTransportException { if (transport != null && transport.isOpen()) { transport.close(); } String host = conf.getVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST); int port = conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_PORT); LOG.info("Connecting to " + host + ":" + port); transport = new TSocket(host, port); ((TSocket) transport).setTimeout((int) conf.getTimeVar(HiveConf.ConfVars.SERVER_READ_SOCKET_TIMEOUT, TimeUnit.SECONDS) * 1000); try { ((TSocket) transport).getSocket().setKeepAlive(conf.getBoolVar(HiveConf.ConfVars.SERVER_TCP_KEEP_ALIVE)); } catch (SocketException e) { LOG.error("Error setting keep alive to " + conf.getBoolVar(HiveConf.ConfVars.SERVER_TCP_KEEP_ALIVE), e); } String userName = conf.getVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_USER); String passwd = conf.getVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_PASSWORD); try { transport = PlainSaslHelper.getPlainTransport(userName, passwd, transport); } catch (SaslException e) { LOG.error("Error creating plain SASL transport", e); } TProtocol protocol = new TBinaryProtocol(transport); transport.open(); base = new ThriftCLIServiceClient(new TCLIService.Client(protocol), conf); LOG.info("Connected!"); return transport; }
/** * Connect to Thrift Server. * * @throws TException the t exception */ public void connect() throws TException { transport = new TSocket(host, port); TProtocol protocol = new TBinaryProtocol(transport); TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, KaaThriftService.KAA_NODE_SERVICE.getServiceName()); client = new CliClient(mp); transport.open(); remoteServerName = client.serverName(); remoteMode = true; }
@Override public void close() { transport.close(); }
private void openTransport() throws Exception { assumeSubject = JdbcConnectionParams.AUTH_KERBEROS_AUTH_TYPE_FROM_SUBJECT.equals(sessConfMap .get(JdbcConnectionParams.AUTH_KERBEROS_AUTH_TYPE)); transport = isHttpTransportMode() ? createHttpTransport() : createBinaryTransport(); if (!transport.isOpen()) { transport.open(); } logZkDiscoveryMessage("Connected to " + connParams.getHost() + ":" + connParams.getPort()); }
transport.write("stat\n".getBytes(UTF_8), 0, 5); StringBuilder response = new StringBuilder(); try { transport.flush(); byte[] buffer = new byte[1024 * 100]; int n = 0; while ((n = transport.read(buffer, 0, buffer.length)) > 0) { response.append(new String(buffer, 0, n, UTF_8)); if (transport != null) { try { transport.close(); } catch (Exception ex) { log.error("Exception", ex);
@Override public boolean isOpen() { return transport.isOpen(); }
@Override public void write(byte[] bytes) throws TTransportException { try { transport.write(bytes); } catch (TTransportException e) { throw rewriteException(e, address); } }
@Override public int read(byte[] bytes, int off, int len) throws TTransportException { try { return transport.read(bytes, off, len); } catch (TTransportException e) { throw rewriteException(e, address); } }
public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException { write_args args = new write_args(); try { args.read(iprot); } catch (TProtocolException e) { iprot.readMessageEnd(); TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage()); oprot.writeMessageBegin(new TMessage("write", TMessageType.EXCEPTION, seqid)); x.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); return; } iprot.readMessageEnd(); write_result result = new write_result(); result.success = iface_.write(args.stream, args.data); oprot.writeMessageBegin(new TMessage("write", TMessageType.REPLY, seqid)); result.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); } }