Package org.apache.thrift.transport

Examples of org.apache.thrift.transport.TIOStreamTransport


    mClass = c;
  }

  @Override
  public void open(InputStream is) {
    mTransport = new TIOStreamTransport(is);
  }
View Full Code Here


    socket.setSoLinger(false, 0);
    socket.setTcpNoDelay(true);
    socket.connect(addr);
    InputStream input = new BufferedInputStream(getInputStream(socket, timeoutMillis), 1024 * 10);
    OutputStream output = new BufferedOutputStream(NetUtils.getOutputStream(socket, timeoutMillis), 1024 * 10);
    return new TIOStreamTransport(input, output);
  }
View Full Code Here

          "org.apache.thrift.protocol");
      TProtocolFactory protFactory = TReflectionUtils
          .getProtocolFactoryByName(protoName);
      bos_ = new ByteStream.Output();
      bis_ = new ByteStream.Input();
      tios = new TIOStreamTransport(bis_, bos_);

      oprot_ = protFactory.getProtocol(tios);
      iprot_ = protFactory.getProtocol(tios);

      /**
 
View Full Code Here

        String serviceName = in.readString();
        long id = in.readI64();

        ByteArrayOutputStream bos = new ByteArrayOutputStream( 1024 );

        TIOStreamTransport transport = new TIOStreamTransport( bos );

        TProtocol protocol = protocolFactory.getProtocol( transport );

        TProcessor processor = processorMap.get( serviceName );

        if ( processor == null ) {
            logger.error(
                    new StringBuilder( 32 )
                            .append( "Could not find processor for service " )
                            .append( serviceName )
                            .toString() );
            return false;
        }

        // todo if exception
        boolean result = processor.process( in, protocol );

        ByteArrayOutputStream header = new ByteArrayOutputStream( 512 );

        TIOStreamTransport headerTransport = new TIOStreamTransport( header );

        TProtocol headerProtocol = protocolFactory.getProtocol( headerTransport );

        headerProtocol.writeI16( magic );
        headerProtocol.writeI32( Integer.MAX_VALUE );
View Full Code Here

    protected static TProtocol newProtocol(URL url, OutputStream output) throws IOException {
        String protocol = url.getParameter(ThriftConstants.THRIFT_PROTOCOL_KEY,
                                           ThriftConstants.DEFAULT_PROTOCOL);
        if (ThriftConstants.BINARY_THRIFT_PROTOCOL.equals(protocol)) {
            return new TBinaryProtocol(new TIOStreamTransport(output));
        }
        throw new IOException("Unsupported protocol type " + protocol);
    }
View Full Code Here

            return Codec.NEED_MORE_INPUT;

        } else {

            TIOStreamTransport transport = new TIOStreamTransport( input );

            TBinaryProtocol protocol = new TBinaryProtocol( transport );

            short magic;
            int messageLength;

            try{
//                protocol.readI32(); // skip the first message length
                byte[] bytes = new byte[4];
                transport.read( bytes, 0, 4 );
                magic = protocol.readI16();
                messageLength = protocol.readI32();

            } catch ( TException e ) {
                throw new IOException( e.getMessage(), e );
View Full Code Here

        }

        RandomAccessByteArrayOutputStream bos = new RandomAccessByteArrayOutputStream( 1024 );

        TIOStreamTransport transport = new TIOStreamTransport( bos );

        TBinaryProtocol protocol = new TBinaryProtocol( transport );

        int headerLength, messageLength;
View Full Code Here

            message = new TMessage( rd.methodName, TMessageType.REPLY, rd.id );
        }

        RandomAccessByteArrayOutputStream bos = new RandomAccessByteArrayOutputStream( 1024 );

        TIOStreamTransport transport = new TIOStreamTransport( bos );

        TBinaryProtocol protocol = new TBinaryProtocol( transport );

        int messageLength;
        int headerLength;
View Full Code Here

    /**
     * Wrap the read buffer in a memory-based transport so a processor can read
     * the data it needs to handle an invocation.
     */
    private TTransport getInputTransport() {
      return inputTransportFactory_.getTransport(new TIOStreamTransport(
        new ByteArrayInputStream(buffer_.array())));
    }
View Full Code Here

    /**
     * Get the transport that should be used by the invoker for responding.
     */
    private TTransport getOutputTransport() {
      response_ = new TByteArrayOutputStream();
      return outputTransportFactory_.getTransport(new TIOStreamTransport(response_));
    }
View Full Code Here

TOP

Related Classes of org.apache.thrift.transport.TIOStreamTransport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.