use of com.hazelcast.client.impl.protocol.util.UnsafeBuffer in project hazelcast by hazelcast.
the class ClientMessage method readFrom.
public boolean readFrom(ByteBuffer src) {
int frameLength = 0;
if (this.buffer == null) {
// init internal buffer
final int remaining = src.remaining();
if (remaining < Bits.INT_SIZE_IN_BYTES) {
// we don't have even the frame length ready
return false;
}
frameLength = Bits.readIntL(src.array(), src.position());
if (frameLength < HEADER_SIZE) {
throw new IllegalArgumentException("Client message frame length cannot be smaller than header size.");
}
if (USE_UNSAFE) {
wrap(new UnsafeBuffer(new byte[frameLength]), 0);
} else {
wrap(new SafeBuffer(new byte[frameLength]), 0);
}
}
frameLength = frameLength > 0 ? frameLength : getFrameLength();
accumulate(src, frameLength - index());
return isComplete();
}
use of com.hazelcast.client.impl.protocol.util.UnsafeBuffer in project hazelcast by hazelcast.
the class FuzzyClientProtocolBufferTest method init.
@BeforeClass
public static void init() {
capacity = random.nextInt(1000) + 1000;
safeBuffer = new SafeBuffer(new byte[capacity]);
unsafeBuffer = new UnsafeBuffer(new byte[capacity]);
}
Aggregations