Package org.jboss.netty.buffer

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


            OioDatagramChannel channel, ChannelFuture future,
            Object message, SocketAddress remoteAddress) {
        try {
            ChannelBuffer buf = (ChannelBuffer) message;
            int length = buf.readableBytes();
            ByteBuffer nioBuf = buf.toByteBuffer();
            DatagramPacket packet;
            if (nioBuf.hasArray()) {
                // Avoid copy if the buffer is backed by an array.
                packet = new DatagramPacket(
                        nioBuf.array(), nioBuf.arrayOffset(), length);
View Full Code Here


          if (response.isChunked()) {
            readingChunks = true;
          } else {
            ChannelBuffer content = response.getContent();
            if (content.readable()) {
              fc.write(content.toByteBuffer());
            }
          }
        } else {
          HttpChunk chunk = (HttpChunk) e.getMessage();
          if (chunk.isLast()) {
View Full Code Here

      if (GDATRecordType.getGDATRecordType(buffer.getByte(fieldSize + Ints.BYTES)).equals(GDATRecordType.EOF)) {
        eofRecordLatch.countDown();
        log.info(String.format("Output Stream %s : Received EOF Record", outputName));
        //TODO: Let Health Manager know (and let it decide if it is an failure case)?
      } else {
        GDATDecoder decoder = new GDATDecoder(buffer.toByteBuffer());
        //Add Decoder to queue
        recordQueue.add(Maps.immutableEntry(outputName, decoder));
        dataRecordsReceived++;
        super.messageReceived(ctx, e);
      }
View Full Code Here

        }

        // Otherwise, all messages are encrypted.
        ChannelBuffer msg = (ChannelBuffer) e.getMessage();
        PendingWrite pendingWrite =
            new PendingWrite(evt.getFuture(), msg.toByteBuffer(msg.readerIndex(), msg.readableBytes()));
        synchronized (pendingUnencryptedWrites) {
            boolean offered = pendingUnencryptedWrites.offer(pendingWrite);
            assert offered;
        }
View Full Code Here

    ChannelBuffer chBuffer = ChannelBuffers.buffer(baos.size());
    chBuffer.writeBytes(baos.toByteArray());
    channel.write(chBuffer);
    if (ConnectionLogger.isEnabledFull()) {
      ConnectionLogger.logWriteBuffer(this.getClass().getSimpleName(), this.remotSocketAddress.getHostName(),
          this.remotSocketAddress.getPort(), chBuffer.toByteBuffer().array(), 0, chBuffer.toByteBuffer().array().length);
    }
  }

  @Override
  public void setQuietDisconnect() throws Exception {
View Full Code Here

    ChannelBuffer chBuffer = ChannelBuffers.buffer(baos.size());
    chBuffer.writeBytes(baos.toByteArray());
    channel.write(chBuffer);
    if (ConnectionLogger.isEnabledFull()) {
      ConnectionLogger.logWriteBuffer(this.getClass().getSimpleName(), this.remotSocketAddress.getHostName(),
          this.remotSocketAddress.getPort(), chBuffer.toByteBuffer().array(), 0, chBuffer.toByteBuffer().array().length);
    }
  }

  @Override
  public void setQuietDisconnect() throws Exception {
View Full Code Here

    httpResponse.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buffer.readableBytes()));
    // Write the response.
    channel.write(httpResponse);
    if (ConnectionLogger.isEnabledFull()) {
      ConnectionLogger.logWriteBuffer(this.getClass().getSimpleName(), ((InetSocketAddress) this.channel.getRemoteAddress())
          .getHostName(), ((InetSocketAddress) this.channel.getRemoteAddress()).getPort(), buffer.toByteBuffer().array(),
          0, buffer.toByteBuffer().array().length);
    }
  }
}
View Full Code Here

    // Write the response.
    channel.write(httpResponse);
    if (ConnectionLogger.isEnabledFull()) {
      ConnectionLogger.logWriteBuffer(this.getClass().getSimpleName(), ((InetSocketAddress) this.channel.getRemoteAddress())
          .getHostName(), ((InetSocketAddress) this.channel.getRemoteAddress()).getPort(), buffer.toByteBuffer().array(),
          0, buffer.toByteBuffer().array().length);
    }
  }
}
View Full Code Here

    ChannelBuffer chBuffer = ChannelBuffers.buffer(baos.size());
    chBuffer.writeBytes(baos.toByteArray());
    channel.write(chBuffer);
    if (ConnectionLogger.isEnabledFull()) {
      ConnectionLogger.logWriteBuffer(this.getClass().getSimpleName(), this.remotSocketAddress.getHostName(),
          this.remotSocketAddress.getPort(), chBuffer.toByteBuffer().array(), 0, chBuffer.toByteBuffer().array().length);
    }
  }

  @Override
  public void setQuietDisconnect() throws Exception {
View Full Code Here

    ChannelBuffer chBuffer = ChannelBuffers.buffer(baos.size());
    chBuffer.writeBytes(baos.toByteArray());
    channel.write(chBuffer);
    if (ConnectionLogger.isEnabledFull()) {
      ConnectionLogger.logWriteBuffer(this.getClass().getSimpleName(), this.remotSocketAddress.getHostName(),
          this.remotSocketAddress.getPort(), chBuffer.toByteBuffer().array(), 0, chBuffer.toByteBuffer().array().length);
    }
  }

  @Override
  public void setQuietDisconnect() throws Exception {
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.