public void putToArray(ByteBuffer byteBuffer) { ensureArraySize(); array[arraySize++] = byteBuffer; }
public void finishBufferSlice() { if (directBufferSlice != null) { directBufferSlice.flip(); final int sliceSz = directBufferSlice.remaining(); sliceOffset += sliceSz; if (sliceSz > 0) { putToArray(directBufferSlice); } directBufferSlice = null; } }
DirectByteBufferRecord.get(); directByteBufferRecord.finishBufferSlice(); final int arraySize = directByteBufferRecord.getArraySize(); socketChannel, directByteBufferRecord.getArray()[0]) : socketChannel, directByteBufferRecord.getArray(), 0, arraySize) ; throw e; } finally { directByteBufferRecord.release();
ioRecord.finishBufferSlice(); ioRecord.putToArray(buffer.toByteBuffer()); } else { ByteBuffer currentDirectBufferSlice = ioRecord.getDirectBufferSlice(); final ByteBuffer directByteBuffer = ioRecord.getDirectBuffer(); if (directByteBuffer == null) { ioRecord.allocate(totalRemaining); // allocate buffer big enough to put the entire message (not just the chunk we're writing) currentDirectBufferSlice = ioRecord.sliceBuffer();
private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
public static DirectByteBufferRecord get() { final DirectByteBufferRecord record = ThreadCache.getFromCache(CACHE_IDX); if (record != null) { return record; } final DirectByteBufferRecord recordLocal = new DirectByteBufferRecord(); ThreadCache.putToCache(CACHE_IDX, recordLocal); return recordLocal; }
DirectByteBufferRecord.get(); directByteBufferRecord.finishBufferSlice(); final int arraySize = directByteBufferRecord.getArraySize(); socketChannel, directByteBufferRecord.getArray()[0]) : socketChannel, directByteBufferRecord.getArray(), 0, arraySize) ; throw e; } finally { directByteBufferRecord.release();
ioRecord.finishBufferSlice(); ioRecord.putToArray(buffer.toByteBuffer()); } else { ByteBuffer currentDirectBufferSlice = ioRecord.getDirectBufferSlice(); final ByteBuffer directByteBuffer = ioRecord.getDirectBuffer(); if (directByteBuffer == null) { ioRecord.allocate(totalRemaining); // allocate buffer big enough to put the entire message (not just the chunk we're writing) currentDirectBufferSlice = ioRecord.sliceBuffer();
private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
public static DirectByteBufferRecord get() { final DirectByteBufferRecord record = ThreadCache.getFromCache(CACHE_IDX); if (record != null) { return record; } final DirectByteBufferRecord recordLocal = new DirectByteBufferRecord(); ThreadCache.putToCache(CACHE_IDX, recordLocal); return recordLocal; }
DirectByteBufferRecord.get(); directByteBufferRecord.finishBufferSlice(); final int arraySize = directByteBufferRecord.getArraySize(); socketChannel, directByteBufferRecord.getArray()[0]) : socketChannel, directByteBufferRecord.getArray(), 0, arraySize) ; throw e; } finally { directByteBufferRecord.release();
ioRecord.finishBufferSlice(); ioRecord.putToArray(buffer.toByteBuffer()); } else { ByteBuffer currentDirectBufferSlice = ioRecord.getDirectBufferSlice(); final ByteBuffer directByteBuffer = ioRecord.getDirectBuffer(); if (directByteBuffer == null) { ioRecord.allocate(totalRemaining); // allocate buffer big enough to put the entire message (not just the chunk we're writing) currentDirectBufferSlice = ioRecord.sliceBuffer();
private int readNonConnected(final UDPNIOConnection connection, Buffer buffer, final ReadResult<Buffer, SocketAddress> currentResult) throws IOException { final SocketAddress peerAddress; final int read; final DirectByteBufferRecord ioRecord = DirectByteBufferRecord.get(); try { final ByteBuffer directByteBuffer = ioRecord.allocate(buffer.limit()); final int initialBufferPos = directByteBuffer.position(); peerAddress = ((DatagramChannel) connection.getChannel()).receive( directByteBuffer); read = directByteBuffer.position() - initialBufferPos; if (read > 0) { directByteBuffer.flip(); buffer.put(directByteBuffer); } } finally { ioRecord.release(); } final boolean hasRead = (read > 0); if (hasRead && currentResult != null) { currentResult.setMessage(buffer); currentResult.setReadSize(currentResult.getReadSize() + read); currentResult.setSrcAddress(peerAddress); } return read; }
public static DirectByteBufferRecord get() { final DirectByteBufferRecord record = ThreadCache.getFromCache(CACHE_IDX); if (record != null) { return record; } final DirectByteBufferRecord recordLocal = new DirectByteBufferRecord(); ThreadCache.putToCache(CACHE_IDX, recordLocal); return recordLocal; }
public void finishBufferSlice() { if (directBufferSlice != null) { directBufferSlice.flip(); final int sliceSz = directBufferSlice.remaining(); sliceOffset += sliceSz; if (sliceSz > 0) { putToArray(directBufferSlice); } directBufferSlice = null; } }
public void putToArray(ByteBuffer byteBuffer) { ensureArraySize(); array[arraySize++] = byteBuffer; }
DirectByteBufferRecord.get(); directByteBufferRecord.finishBufferSlice(); final int arraySize = directByteBufferRecord.getArraySize(); socketChannel, directByteBufferRecord.getArray()[0]) : socketChannel, directByteBufferRecord.getArray(), 0, arraySize) ; throw e; } finally { directByteBufferRecord.release();
ioRecord.finishBufferSlice(); ioRecord.putToArray(buffer.toByteBuffer()); } else { ByteBuffer currentDirectBufferSlice = ioRecord.getDirectBufferSlice(); final ByteBuffer directByteBuffer = ioRecord.getDirectBuffer(); if (directByteBuffer == null) { ioRecord.allocate(totalRemaining); // allocate buffer big enough to put the entire message (not just the chunk we're writing) currentDirectBufferSlice = ioRecord.sliceBuffer();