Package com.facebook.thrift.protocol

Examples of com.facebook.thrift.protocol.TBinaryProtocol


 
  private void run() throws IOError, TException, NotFound, IllegalArgument,
      AlreadyExists {
   
    TTransport transport = new TSocket("localhost", port);
    TProtocol protocol = new TBinaryProtocol(transport, true, true);
    Hbase.Client client = new Hbase.Client(protocol);

    transport.open();

    byte[] t = bytes("demo_table");
View Full Code Here


    public MediaContent deserialize(byte[] array) throws Exception
  {
    ByteArrayInputStream bais = new ByteArrayInputStream(array);
    TIOStreamTransport trans = new TIOStreamTransport(bais);
    TBinaryProtocol oprot = new TBinaryProtocol(trans);
    MediaContent content = new MediaContent();
    content.read(oprot);
    return content;
  }
View Full Code Here

    public byte[] serialize(MediaContent content) throws Exception
  {
      ByteArrayOutputStream baos = new ByteArrayOutputStream(expectedSize);
    TIOStreamTransport trans = new TIOStreamTransport(baos);
    TBinaryProtocol oprot = new TBinaryProtocol(trans);
    content.write(oprot);
    byte[] array = baos.toByteArray();
    expectedSize = array.length;
    return array;
  }
View Full Code Here

 
  private void run() throws IOError, TException, NotFound, IllegalArgument,
      AlreadyExists {
   
    TTransport transport = new TSocket("localhost", port);
    TProtocol protocol = new TBinaryProtocol(transport, true, true);
    Hbase.Client client = new Hbase.Client(protocol);

    transport.open();

    byte[] t = bytes("demo_table");
View Full Code Here

 
  private synchronized void open()
  {
    LOG.info("Opening Thrift connection to " + host + ":" + port);
    transport = new TSocket(host, port);
      TProtocol protocol = new TBinaryProtocol(transport);
      client = new XTraceReporter.Client(protocol);
      shouldRetry = true;
     
      while (shouldRetry) {
        try {
View Full Code Here

      TProtocol prot;
      if (header) {
        prot = new TCompactProtocol(transport);
      } else {
        prot = new TBinaryProtocol(transport);
      }
      ThriftTest.Client testClient =
        new ThriftTest.Client(prot);
      Insanity insane = new Insanity();
View Full Code Here

  public static void main(String[] args) throws Exception {
    int msg_size_mb = Integer.parseInt(args[0]);
    int msg_size = msg_size_mb * 1024 * 1024;

    TSocket socket = new TSocket("localhost", 9090);
    TBinaryProtocol binprot = new TBinaryProtocol(socket);
    socket.open();
    binprot.writeI32(msg_size);
    binprot.writeI32(1);
    socket.flush();

    System.in.read();
    // Thread.sleep(30000);
    for (int i = 0; i < msg_size_mb; i++) {
      binprot.writeBinary(new byte[1024 * 1024]);
    }

    socket.close();
  }
View Full Code Here

  }

  public static <T extends TBase> void testSerialization(Class<T> klass, T obj) throws Exception {
    TMemoryBuffer buf = new TMemoryBuffer(0);
    TBinaryProtocol binproto = new TBinaryProtocol(buf);

    try {
      obj.write(binproto);
      // System.out.println("Size in binary protocol: " + buf.length());
View Full Code Here

  @Test
  public static void testSerialization() throws Exception {
    TestUnion union = new TestUnion(TestUnion.I32_FIELD, 25);

    TMemoryBuffer buf = new TMemoryBuffer(0);
    TProtocol proto = new TBinaryProtocol(buf);

    union.write(proto);

    TestUnion u2 = new TestUnion();

    u2.read(proto);

    if (!u2.equals(union)) {
      throw new RuntimeException("serialization fails!");
    }

    StructWithAUnion swau = new StructWithAUnion(u2);

    buf = new TMemoryBuffer(0);
    proto = new TBinaryProtocol(buf);

    swau.write(proto);

    StructWithAUnion swau2 = new StructWithAUnion();
    if (swau2.equals(swau)) {
      throw new RuntimeException("objects match before they are supposed to!");
    }
    swau2.read(proto);
    if (!swau2.equals(swau)) {
      throw new RuntimeException("objects don't match when they are supposed to!");
    }

    // this should NOT throw an exception.
    buf = new TMemoryBuffer(0);
    proto = new TBinaryProtocol(buf);

    swau.write(proto);
    new Empty().read(proto);

  }
View Full Code Here

                            boolean framed, boolean header) throws TException{
    TTransport transport;
    TSocket socket = new TSocket("localhost", TEST_PORT);
    socket.setTimeout(1000);
    transport = socket;
    TProtocol prot = new TBinaryProtocol(transport);
    if (unframed) {
      testClient(transport, prot); // Unframed
    }
    List<THeaderTransport.ClientTypes> clientTypes =
      new ArrayList<THeaderTransport.ClientTypes>();
    prot = new THeaderProtocol(transport, clientTypes);
    if (header) {
      testClient(transport, prot); // Header w/compact
    }
    TFramedTransport framedTransport = new TFramedTransport(transport);
    prot = new TBinaryProtocol(framedTransport);
    if (framed) {
      testClient(transport, prot); // Framed
    }
  }
View Full Code Here

TOP

Related Classes of com.facebook.thrift.protocol.TBinaryProtocol

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.