private void msgHandler(
     final DirectBuffer buffer, final int offset, final int length, final Header header) {
   if (buffer.getByte(offset) == (byte) 'p') {
     timestamps[buffer.getInt(offset + 1)] = System.nanoTime() - buffer.getLong(offset + 5);
   } else {
     warmups++;
   }
 }
Ejemplo n.º 2
0
  private static ByteBuffer byteBuffer(final DirectBuffer buffer) {
    final ByteBuffer byteBuffer;

    if (null != buffer.byteBuffer()) {
      byteBuffer = buffer.byteBuffer().duplicate();
    } else {
      byteBuffer = ByteBuffer.wrap(buffer.byteArray());
    }

    byteBuffer.order(BYTE_ORDER);
    byteBuffer.clear();

    return byteBuffer;
  }
 public static int numRequests(final DirectBuffer directBuffer, final int offset) {
   return directBuffer.getInt(offset + NUM_REQUESTS_FIELD_OFFSET, ByteOrder.BIG_ENDIAN);
 }
Ejemplo n.º 4
0
 /**
  * Non-blocking publish of a buffer containing a message.
  *
  * @param buffer containing message.
  * @return The new stream position on success, otherwise {@link #BACK_PRESSURED} or {@link
  *     #NOT_CONNECTED}.
  */
 public long offer(final DirectBuffer buffer) {
   return offer(buffer, 0, buffer.capacity());
 }
 public static int ttl(final DirectBuffer directBuffer, final int offset) {
   return directBuffer.getInt(offset + TTL_FIELD_OFFSET, ByteOrder.BIG_ENDIAN);
 }