Package java.nio

Examples of java.nio.ByteBuffer.duplicate()


                (ByteBuffer) chunk.duplicate().limit(pos + size).position(pos)
            )
        );
      }
    }
    return HyperLogLogCollector.makeCollector(buf.duplicate()).estimateCardinality();
  }

  public static void main(String[] args) throws Exception {
    Runner.main(HyperLogLogCollectorBenchmark.class, args);
  }
View Full Code Here


   }
  
   public void multiConnectionSend(final Message message, final List<TCPConnection> connections) {
      ByteBuffer bb = message.getByteBufferWithLengthHeader();
      for (TCPConnection connection : connections)
         pendingSendMessages.add(new TCPMessage(connection, bb.duplicate()));
      writeSelector.wakeup();
   }
  
   public void stop() {
      running = false;
View Full Code Here

                        numbytes += temp_numbytes;
                    }
                    message.position(0);
                    synchronized (recvQueue) {
                        recvQueue
                        .put(new Message(message.duplicate(), sid));
                    }
                    msgLength.position(0);
                }
            } catch (Exception e) {
                LOG.warn("Connection broken for id " + sid + ", my id = " +
View Full Code Here

            ByteBuffer payload = xfr.getPayload();
            int payloadSent = send(xfr, payload);

            if(payload != null && payloadSent < payload.remaining())
            {
                payload = payload.duplicate();
                payload.position(payload.position()+payloadSent);

                Transfer secondTransfer = new Transfer();

                secondTransfer.setDeliveryTag(xfr.getDeliveryTag());
View Full Code Here

            payload.flip();
        }

        if(queueEntry.getDeliveryCount() != 0)
        {
            payload = payload.duplicate();
            ValueHandler valueHandler = new ValueHandler(_typeRegistry);

            Header oldHeader = null;
            try
            {
View Full Code Here

        {
            buf = encodeAsBuffer();
            _encoded = buf;
        }

        buf = buf.duplicate();

        buf.position(0);

        if(dest.remaining() < buf.limit())
        {
View Full Code Here

            ByteBuffer payload = xfr.getPayload();
            int payloadSent = send(xfr, payload);

            if(payload != null && payloadSent < payload.remaining() && payloadSent >= 0)
            {
                payload = payload.duplicate();
                payload.position(payload.position()+payloadSent);

                Transfer secondTransfer = new Transfer();

                secondTransfer.setDeliveryTag(xfr.getDeliveryTag());
View Full Code Here

                //execute this in the executor to preserve ordering, otherwise the socket
                //may be closed while invocations are active
                executor.execute(new Runnable() {
                    @Override
                    public void run() {
                        WebSockets.sendClose(buffer.duplicate(), channel, null);
                    }
                });
            }
        }
View Full Code Here

                    originalBuffer.put((byte) '*');
                }
                originalBuffer.flip();
                response.getWriteSetter().set(new ChannelListener<Channel>() {

                    private ByteBuffer buffer = originalBuffer.duplicate();
                    int count = 0;

                    @Override
                    public void handleEvent(final Channel channel) {
                        do {
View Full Code Here

                                exception = e;
                                errorLatch.countDown();
                            }
                            if(!buffer.hasRemaining()) {
                                count++;
                                buffer = originalBuffer.duplicate();
                            }
                        } while (count < 1000);
                        exchange.endExchange();
                    }
                });
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.