Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer.writeByte()


    opcode.writeByte(event.getType());
    if (Events.LOG_IN == event.getType() || Events.RECONNECT == event.getType())
    {
      // write protocol version also
      ChannelBuffer protocolVersion = ChannelBuffers.buffer(1);
      protocolVersion.writeByte(Events.PROTOCOL_VERSION);
      opcode = ChannelBuffers.wrappedBuffer(opcode, protocolVersion);
    }
   
    ChannelBuffer buffer = null;
    if (null != event.getSource())
View Full Code Here


  }

  public static ChannelBuffer createBufferForOpcode(int opcode)
  {
    ChannelBuffer buffer = ChannelBuffers.buffer(1);
    buffer.writeByte(opcode);
    return buffer;
  }

  /**
   * This method will read multiple strings of the buffer and return them as a
View Full Code Here

      for (CacheElement result : results) {
        if (result != null) {
          writeBuffer.writeBytes(VALUE.duplicate());
          writeBuffer.writeBytes(ChannelBuffers.copiedBuffer(result.getKeystring(), USASCII));
          writeBuffer.writeByte((byte) ' ');
          writeBuffer.writeBytes(ChannelBuffers.copiedBuffer(String.valueOf(result.getFlags()), USASCII));
          writeBuffer.writeByte((byte) ' ');
          writeBuffer.writeBytes(ChannelBuffers
              .copiedBuffer(String.valueOf(result.getData().length), USASCII));
          if (cmd == Command.GETS) {
View Full Code Here

        if (result != null) {
          writeBuffer.writeBytes(VALUE.duplicate());
          writeBuffer.writeBytes(ChannelBuffers.copiedBuffer(result.getKeystring(), USASCII));
          writeBuffer.writeByte((byte) ' ');
          writeBuffer.writeBytes(ChannelBuffers.copiedBuffer(String.valueOf(result.getFlags()), USASCII));
          writeBuffer.writeByte((byte) ' ');
          writeBuffer.writeBytes(ChannelBuffers
              .copiedBuffer(String.valueOf(result.getData().length), USASCII));
          if (cmd == Command.GETS) {
            writeBuffer.writeByte((byte) ' ');
            writeBuffer.writeBytes(ChannelBuffers.copiedBuffer(String.valueOf(result.getCasUnique()),
View Full Code Here

          writeBuffer.writeBytes(ChannelBuffers.copiedBuffer(String.valueOf(result.getFlags()), USASCII));
          writeBuffer.writeByte((byte) ' ');
          writeBuffer.writeBytes(ChannelBuffers
              .copiedBuffer(String.valueOf(result.getData().length), USASCII));
          if (cmd == Command.GETS) {
            writeBuffer.writeByte((byte) ' ');
            writeBuffer.writeBytes(ChannelBuffers.copiedBuffer(String.valueOf(result.getCasUnique()),
                USASCII));
          }
          writeBuffer.writeByte((byte) '\r');
          writeBuffer.writeByte((byte) '\n');
View Full Code Here

          if (cmd == Command.GETS) {
            writeBuffer.writeByte((byte) ' ');
            writeBuffer.writeBytes(ChannelBuffers.copiedBuffer(String.valueOf(result.getCasUnique()),
                USASCII));
          }
          writeBuffer.writeByte((byte) '\r');
          writeBuffer.writeByte((byte) '\n');
          writeBuffer.writeBytes(result.getData());
          writeBuffer.writeByte((byte) '\r');
          writeBuffer.writeByte((byte) '\n');
        }
View Full Code Here

            writeBuffer.writeByte((byte) ' ');
            writeBuffer.writeBytes(ChannelBuffers.copiedBuffer(String.valueOf(result.getCasUnique()),
                USASCII));
          }
          writeBuffer.writeByte((byte) '\r');
          writeBuffer.writeByte((byte) '\n');
          writeBuffer.writeBytes(result.getData());
          writeBuffer.writeByte((byte) '\r');
          writeBuffer.writeByte((byte) '\n');
        }
      }
View Full Code Here

                USASCII));
          }
          writeBuffer.writeByte((byte) '\r');
          writeBuffer.writeByte((byte) '\n');
          writeBuffer.writeBytes(result.getData());
          writeBuffer.writeByte((byte) '\r');
          writeBuffer.writeByte((byte) '\n');
        }
      }
      writeBuffer.writeBytes(END.duplicate());
      StatsCounter.bytes_read.addAndGet(writeBuffer.writerIndex());
View Full Code Here

          }
          writeBuffer.writeByte((byte) '\r');
          writeBuffer.writeByte((byte) '\n');
          writeBuffer.writeBytes(result.getData());
          writeBuffer.writeByte((byte) '\r');
          writeBuffer.writeByte((byte) '\n');
        }
      }
      writeBuffer.writeBytes(END.duplicate());
      StatsCounter.bytes_read.addAndGet(writeBuffer.writerIndex());
      Channels.write(channel, writeBuffer);
View Full Code Here


    public ChannelBuffer constructHeader(MemcachedBinaryCommandDecoder.BinaryCommand bcmd, ChannelBuffer extrasBuffer, ChannelBuffer keyBuffer, ChannelBuffer valueBuffer, short responseCode, int opaqueValue, long casUnique) {
        // take the ResponseMessage and turn it into a binary payload.
        ChannelBuffer header = ChannelBuffers.buffer(ByteOrder.BIG_ENDIAN, 24);
        header.writeByte((byte)0x81)// magic
        header.writeByte(bcmd.code); // opcode
        short keyLength = (short) (keyBuffer != null ? keyBuffer.capacity() :0);

        header.writeShort(keyLength);
        int extrasLength = extrasBuffer != null ? extrasBuffer.capacity() : 0;
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.