Package org.apache.avro.util

Examples of org.apache.avro.util.ByteBufferInputStream


   * response or error.  Transciever is used by connection-based servers to
   * track handshake status of connection. */
  public List<ByteBuffer> respond(List<ByteBuffer> buffers,
                                  Transceiver connection) throws IOException {
    Decoder in = DecoderFactory.get().binaryDecoder(
        new ByteBufferInputStream(buffers), null);
    ByteBufferOutputStream bbo = new ByteBufferOutputStream();
    BinaryEncoder out = EncoderFactory.get().binaryEncoder(bbo, null);
    Exception error = null;
    RPCContext context = new RPCContext();
    List<ByteBuffer> payload = null;
View Full Code Here


      writeHandshake(out);
      out.writeInt(0);                              // empty metadata
      out.writeString("");                          // bogus message name
      List<ByteBuffer> response =
        getTransceiver().transceive(bbo.getBufferList());
      ByteBufferInputStream bbi = new ByteBufferInputStream(response);
      BinaryDecoder in =
        DecoderFactory.get().binaryDecoder(bbi, null);
      readHandshake(in);
      return this.remote;
    } finally {
View Full Code Here

    }
   
    @Override
    @SuppressWarnings("unchecked")
    public void handleResult(List<ByteBuffer> responseBytes) {
      ByteBufferInputStream bbi = new ByteBufferInputStream(responseBytes);
      BinaryDecoder in = DecoderFactory.get().binaryDecoder(bbi, null);
      try {
        if (!readHandshake(in)) {
          // Resend the handshake and return
          Request handshake = new Request(request);
View Full Code Here

    BinaryEncoder e2 = e_factory.binaryEncoder(bbo2, null);
    e2.writeBytes(b1);
    e2.flush();
   
    DirectBinaryDecoder d = new DirectBinaryDecoder(
        new ByteBufferInputStream(bbo1.getBufferList()));
    ByteBuffer bb1 = d.readBytes(null);
    Assert.assertEquals(b1.length, bb1.limit() - bb1.position());
   
    d.configure(new ByteBufferInputStream(bbo2.getBufferList()));
    ByteBuffer bb2 = d.readBytes(null);
    Assert.assertEquals(b1.length, bb2.limit() - bb2.position());
   
  }
View Full Code Here

   * response or error.  Transciever is used by connection-based servers to
   * track handshake status of connection. */
  public List<ByteBuffer> respond(List<ByteBuffer> buffers,
                                  Transceiver connection) throws IOException {
    Decoder in = DecoderFactory.get().binaryDecoder(
        new ByteBufferInputStream(buffers), null);
    ByteBufferOutputStream bbo = new ByteBufferOutputStream();
    BinaryEncoder out = EncoderFactory.get().binaryEncoder(bbo, null);
    Exception error = null;
    RPCContext context = new RPCContext();
    List<ByteBuffer> payload = null;
View Full Code Here

        t.writeBuffers(requestBytes);
       
        return null;
      } else {                                    // two-way message
        List<ByteBuffer> response = t.transceive(requestBytes);
        ByteBufferInputStream bbi = new ByteBufferInputStream(response);
        in = DecoderFactory.get().binaryDecoder(bbi, in);
      }
    } while (!readHandshake(in));

    // use remote protocol to read response
View Full Code Here

    writeHandshake(out);
    out.writeInt(0);                              // empty metadata
    out.writeString("");                          // bogus message name
    List<ByteBuffer> response =
      getTransceiver().transceive(bbo.getBufferList());
    ByteBufferInputStream bbi = new ByteBufferInputStream(response);
    BinaryDecoder in =
      DecoderFactory.get().binaryDecoder(bbi, null);
    readHandshake(in);
    return this.remote;
  }
View Full Code Here

 
  @SuppressWarnings("unchecked")
  public static <T> void testSerializeDeserialize(T... objects) throws Exception {
    ByteBufferOutputStream os = new ByteBufferOutputStream();
    DataOutputStream dos = new DataOutputStream(os);
    ByteBufferInputStream is = null;
    DataInputStream dis = null;
   
    GoraMapReduceUtils.setIOSerializations(conf, true);
   
    try {
      for(T before : objects) {
        IOUtils.serialize(conf, dos , before, (Class<T>)before.getClass());
        dos.flush();
      }
      
      is = new ByteBufferInputStream(os.getBufferList());
      dis = new DataInputStream(is);
     
      for(T before : objects) {
        T after = IOUtils.deserialize(conf, dis, null, (Class<T>)before.getClass());
        if (before instanceof BoolArrayWrapper) {
View Full Code Here

   * response or error.  Transciever is used by connection-based servers to
   * track handshake status of connection. */
  public List<ByteBuffer> respond(List<ByteBuffer> buffers,
                                  Transceiver connection) throws IOException {
    Decoder in = DecoderFactory.get().binaryDecoder(
        new ByteBufferInputStream(buffers), null);
    ByteBufferOutputStream bbo = new ByteBufferOutputStream();
    BinaryEncoder out = EncoderFactory.get().binaryEncoder(bbo, null);
    Exception error = null;
    RPCContext context = new RPCContext();
    List<ByteBuffer> payload = null;
View Full Code Here

      writeHandshake(out);
      out.writeInt(0);                              // empty metadata
      out.writeString("");                          // bogus message name
      List<ByteBuffer> response =
        getTransceiver().transceive(bbo.getBufferList());
      ByteBufferInputStream bbi = new ByteBufferInputStream(response);
      BinaryDecoder in =
        DecoderFactory.get().binaryDecoder(bbi, null);
      readHandshake(in);
      return this.remote;
    } finally {
View Full Code Here

TOP

Related Classes of org.apache.avro.util.ByteBufferInputStream

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.