Examples of ByteBufferOutputStream


Examples of atg.core.io.ByteBufferOutputStream

         *         if true, a new stream is always created. Otherwise the previous
         *         stream is returned.
         */
        public OutputStream getClientOutputStream(boolean pNew) {
            if (mClientOutputStream == null || pNew) {
                mClientOutputStream = new ByteBufferOutputStream(mBuffer);
            }
            return mClientOutputStream;
        }
View Full Code Here

Examples of com.alibaba.wasp.util.ByteBufferOutputStream

      }
    }

    protected List<ByteBuffer> prepareResponse(Object value, Status status,
        String errorClass, String error) {
      ByteBufferOutputStream buf = new ByteBufferOutputStream();
      DataOutputStream out = new DataOutputStream(buf);
      try {
        RpcResponseHeader.Builder builder = RpcResponseHeader.newBuilder();
        builder.setStatus(status);
        builder.build().writeDelimitedTo(out);
        if (error != null) {
          RpcException.Builder b = RpcException.newBuilder();
          b.setExceptionName(errorClass);
          b.setStackTrace(error);
          b.build().writeDelimitedTo(out);
        } else {
          if (value != null) {
            ((Message) value).writeDelimitedTo(out);
          }
        }
      } catch (IOException e) {
        LOG.warn("Exception while creating response " + e);
      }
      return buf.getBufferList();
    }
View Full Code Here

Examples of com.alibaba.wasp.util.ByteBufferOutputStream

      headerBuilder.setTinfo(RPCTInfo.newBuilder().setParentId(s.getSpanId())
          .setTraceId(s.getTraceId()));
    }
    RpcRequestHeader rpcHeader = headerBuilder.build();

    ByteBufferOutputStream bbo = new ByteBufferOutputStream();
    connectionHeader.writeDelimitedTo(bbo);
    rpcHeader.writeDelimitedTo(bbo);
    param.writeDelimitedTo(bbo);

    List<ByteBuffer> res = transceive(bbo.getBufferList());

    return processResponse(res, protocol, param);
  }
View Full Code Here

Examples of com.esotericsoftware.kryo.io.ByteBufferOutputStream

    assertEquals(10, in.available());
  }
 
  public void testSmallBuffers() throws Exception {
    ByteBuffer buf = ByteBuffer.allocate(1024);
    ByteBufferOutputStream byteBufferOutputStream = new ByteBufferOutputStream(buf);
    Output testOutput = new Output(byteBufferOutputStream);
    testOutput.writeBytes(new byte[512]);
    testOutput.writeBytes(new byte[512]);
    testOutput.flush();
View Full Code Here

Examples of com.esotericsoftware.kryo.io.ByteBufferOutputStream

      earliest = Math.min(d.getTimeStamp().getTime(), earliest);
      latest = Math.max(d.getTimeStamp().getTime(), latest);
    }
    Kryo kryo = SerializeUtil.createKryo();
    b.position(MonitoringDataStorage.FIRST_RECORD_POSITION);
    Output output = new Output(new ByteBufferOutputStream(b));
    for (MonitoringData data : values) {
      kryo.writeClassAndObject(output, data);
    }
    output.close();
    int limit = b.position();
View Full Code Here

Examples of com.netflix.astyanax.serializers.ByteBufferOutputStream

    public ByteBuffer serialize() {
        if (serialized != null) {
            return serialized.duplicate();
        }

        ByteBufferOutputStream out = new ByteBufferOutputStream();

        int i = 0;
        for (Component c : components) {
            Serializer<?> s = serializerForPosition(i);
            ByteBuffer cb = c.getBytes(s);
            if (cb == null) {
                cb = ByteBuffer.allocate(0);
            }

            if (dynamic) {
                String comparator = comparatorForPosition(i);
                if (comparator == null) {
                    comparator = c.getComparator();
                }
                if (comparator == null) {
                    comparator = ComparatorType.BYTESTYPE.getTypeName();
                }
                int p = comparator.indexOf("(reversed=true)");
                boolean desc = false;
                if (p >= 0) {
                    comparator = comparator.substring(0, p);
                    desc = true;
                }
                if (aliasToComparatorMapping.inverse().containsKey(comparator)) {
                    byte a = aliasToComparatorMapping.inverse().get(comparator);
                    if (desc) {
                        a = (byte) Character.toUpperCase((char) a);
                    }
                    out.writeShort((short) (0x8000 | a));
                }
                else {
                    out.writeShort((short) comparator.length());
                    out.write(ByteBufferUtil.bytes(comparator));
                }
            }
            out.writeShort((short) cb.remaining());
            out.write(cb.slice());
            out.write(c.getEquality().toByte());
            i++;
        }

        serialized = out.getByteBuffer();
        return serialized.duplicate();
    }
View Full Code Here

Examples of de.netseeker.ejoe.io.ByteBufferOutputStream

     * @return a ByteBuffer containing the encoded HTTP request data
     */
    public ByteBuffer toByteBuffer()
    {
        ByteBuffer result = null;
        ByteBufferOutputStream lOut = null;

        try
        {
            lOut = new ByteBufferOutputStream();
            lOut.write( IOUtil.encodeToBytes( toHeaderString(), CHARSET ) );
            ByteBuffer buffer = this._out.getBackingBuffer();
            int pos = buffer.position();
            int limit = buffer.limit();
            buffer.flip();
            lOut.write( buffer );
            result = lOut.getBackingBuffer();
            result.flip();
            buffer.limit( limit );
            buffer.position( pos );
        }
        catch ( IOException e )
View Full Code Here

Examples of de.netseeker.ejoe.io.ByteBufferOutputStream

    private void send( ConnectionHeader serverInfo, ConnectionHeader clientInfo, SelectionKey selKey, Object obj )
            throws IOException
    {
        ByteBuffer dataBuf = (ByteBuffer) selKey.attachment();
        DataChannel dataChannel = DataChannel.getInstance( serverInfo );
        ByteBufferOutputStream out = null;

        try
        {
            if ( dataBuf == null )
            {
                // usual way: serialize using a adapter
                if ( !clientInfo.isDirect() )
                {
                    out = new ByteBufferOutputStream();
                    serialize( out, obj, clientInfo );
                    dataBuf = out.getBackingBuffer();
                }
                // direct mode: just use the attachement
                else
                {
                    dataBuf = (ByteBuffer) obj;
View Full Code Here

Examples of de.netseeker.ejoe.io.ByteBufferOutputStream

    /**
     * @throws IOException
     */
    private void write() throws IOException
    {
        ByteBufferOutputStream out = null;
        ByteBuffer dataBuf = null;
        SerializeAdapter adapter = this._receiverInfo.getAdapterName() != null ? AdapterFactory
                .createAdapter( this._receiverInfo.getAdapterName() ) : null;
        WritableByteChannel channel = this._receiverInfo.getChannel();
        DataChannel dataChannel = DataChannel.getInstance( this._receiverInfo );

        try
        {
            if ( this._receiverInfo.hasAttachment() )
            {
                // usual way: convert the serialized object to a ByteBuffer
                if ( !this._receiverInfo.isDirect() )
                {
                    out = new ByteBufferOutputStream();
                    serialize( adapter, out );
                    dataBuf = out.getBackingBuffer();
                }
                // direct mode: just use the attachement
                else
                {
                    ByteBuffer tmp = (ByteBuffer) this._receiverInfo.getAttachment();
View Full Code Here

Examples of info.ata4.io.buffer.ByteBufferOutputStream

        ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
        executor.scheduleAtFixedRate(new ByteBufferProgress(bbc), 2, 1, TimeUnit.SECONDS);
       
        try {
            InputStream is = new ByteBufferInputStream(bbc);
            OutputStream os = new ByteBufferOutputStream(bbu);
            if (!dec.code(is, os, lzmaSize)) {
                throw new IOException("LZMA decoding error");
            }
        } finally {   
            executor.shutdown();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.