Package org.apache.thrift.transport

Examples of org.apache.thrift.transport.TIOStreamTransport


        if ( bis.markSupported() ) {
            bis.mark( 0 );
        }

        TIOStreamTransport transport = new TIOStreamTransport( bis );
        TBinaryProtocol protocol = new TBinaryProtocol( transport );

        Assert.assertEquals( ThriftCodec.MAGIC, protocol.readI16() );
        Assert.assertEquals( protocol.readI32() + 4, bos.writerIndex() );
        int headerLength = protocol.readI16();
View Full Code Here


        if ( bis.markSupported() ) {
            bis.mark( 0 );
        }

        TIOStreamTransport transport = new TIOStreamTransport( bis );
        TBinaryProtocol protocol = new TBinaryProtocol( transport );

        Assert.assertEquals( ThriftCodec.MAGIC, protocol.readI16() );
        Assert.assertEquals( protocol.readI32() + 4, bos.writerIndex() );
        int headerLength = protocol.readI16();
View Full Code Here

    public void testDecodeRequest() throws Exception {
        Request request = createRequest();
        // encode
        RandomAccessByteArrayOutputStream bos = new RandomAccessByteArrayOutputStream( 1024 );

        TIOStreamTransport transport = new TIOStreamTransport( bos );

        TBinaryProtocol protocol = new TBinaryProtocol( transport );

        int messageLength, headerLength;
View Full Code Here

  public static class TSerializerAdapter implements Serializer<TBase> {
    private TIOStreamTransport transport;
    private TProtocol protocol;
   
    public void open(OutputStream out) {
      transport = new TIOStreamTransport(out);
      protocol = new TBinaryProtocol(transport);
    }
View Full Code Here

    public TDeserializerAdapter(Class<? extends TBase> tClass) {
      this.tClass = tClass;
    }
 
    public void open(InputStream in) {
      transport = new TIOStreamTransport(in);
      protocol = new TBinaryProtocol(transport);
    }
View Full Code Here

    if (setUpComplete) {
      return;
    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    TIOStreamTransport transport = new TIOStreamTransport(out);
    TBinaryProtocol protocol = new TBinaryProtocol(transport);

    IntString intString = new IntString(1, "one", 1);
    intString.write(protocol);
    BytesWritable bytesWritable = new BytesWritable(out.toByteArray());
View Full Code Here

      // There are actually 2 buffers in play here - the BufferedOutputStream prevents thrift from
      // causing a call to deflate() on every encoded primitive. The DeflaterOutputStream buffer
      // allows the underlying Deflater to operate on a larger chunk at a time without stopping to
      // copy the intermediate compressed output to outBytes.
      // See http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4986239
      TTransport transport = new TIOStreamTransport(
          new BufferedOutputStream(
              new DeflaterOutputStream(outBytes, new Deflater(DEFLATE_LEVEL), DEFLATER_BUFFER_SIZE),
              DEFLATER_BUFFER_SIZE));
      TProtocol protocol = PROTOCOL_FACTORY.getProtocol(transport);
      tBase.write(protocol);
      transport.close();
      return outBytes.toByteArray();
    } catch (TException e) {
      throw new CodingException("Failed to serialize: " + tBase, e);
    }
  }
View Full Code Here

    requireNonNull(clazz);
    requireNonNull(buffer);

    T tBase = newInstance(clazz);
    try {
      TTransport transport = new TIOStreamTransport(
          new InflaterInputStream(new ByteArrayInputStream(buffer)));
      TProtocol protocol = PROTOCOL_FACTORY.getProtocol(transport);
      tBase.read(protocol);
      return tBase;
    } catch (TException e) {
View Full Code Here

        if (mutationMap.isEmpty()) {
            throw new Exception("Mutation is empty");
        }

        ByteBufferOutputStream out       = new ByteBufferOutputStream();
        TIOStreamTransport     transport = new TIOStreamTransport(out);
        batch_mutate_args      args      = new batch_mutate_args();
        args.setMutation_map(mutationMap);

        try {
            args.write(new TBinaryProtocol(transport));
View Full Code Here

    }

    @Override
    public void deserialize(ByteBuffer data) throws Exception {
        ByteArrayInputStream in = new ByteArrayInputStream(data.array());
        TIOStreamTransport transport = new TIOStreamTransport(in);
        batch_mutate_args args = new batch_mutate_args();

        try {
            TBinaryProtocol bp = new TBinaryProtocol(transport);
            bp.setReadLength(data.remaining());
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.