public MessageInputStream(AnnotatedEventDriver driver) { this.driver = driver; this.buf = ByteBuffer.allocate(BUFFER_SIZE); BufferUtil.clearToFill(this.buf); size = 0; readPosition = this.buf.position(); finished = false; needsNotification = true; }
public MessageInputStream(AnnotatedEventDriver driver) { this.driver = driver; this.buf = ByteBuffer.allocateDirect(BUFFER_SIZE); BufferUtil.clearToFill(this.buf); size = 0; readPosition = this.buf.position(); finished = false; needsNotification = true; }
public MessageInputStream(AnnotatedEventDriver driver) { this.driver = driver; this.buf = ByteBuffer.allocateDirect(BUFFER_SIZE); BufferUtil.clearToFill(this.buf); size = 0; readPosition = this.buf.position(); finished = false; needsNotification = true; }
public ByteBuffer acquire(int capacity, boolean direct) { ByteBuffer buffer = byteBufferPool.acquire(capacity, direct); BufferUtil.clearToFill(buffer); return buffer; }
public ByteBuffer acquire(int capacity, boolean direct) { ByteBuffer buffer = byteBufferPool.acquire(capacity, direct); BufferUtil.clearToFill(buffer); return buffer; }
public ByteBuffer acquire(int capacity, boolean direct) { ByteBuffer buffer = byteBufferPool.acquire(capacity, direct); BufferUtil.clearToFill(buffer); return buffer; }
@Override public ByteBuffer generate(ControlFrame frame) { NoOpFrame noOp = (NoOpFrame)frame; int frameBodyLength = 0; int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, Generator.useDirectBuffers); BufferUtil.clearToFill(buffer); generateControlFrameHeader(noOp, frameBodyLength, buffer); buffer.flip(); return buffer; } }
@Override public ByteBuffer generate(ControlFrame frame) { PingFrame ping = (PingFrame)frame; int frameBodyLength = 4; int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, Generator.useDirectBuffers); BufferUtil.clearToFill(buffer); generateControlFrameHeader(ping, frameBodyLength, buffer); buffer.putInt(ping.getPingId()); buffer.flip(); return buffer; } }
BufferUtil.clearToFill(buf);
BufferUtil.clearToFill(buf);
BufferUtil.clearToFill(buf);
@Override public ByteBuffer generate(ControlFrame frame) { CredentialFrame credential = (CredentialFrame)frame; byte[] proof = credential.getProof(); List<byte[]> certificates = serializeCertificates(credential.getCertificateChain()); int certificatesLength = 0; for (byte[] certificate : certificates) certificatesLength += certificate.length; int frameBodyLength = 2 + 4 + proof.length + certificates.size() * 4 + certificatesLength; int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, Generator.useDirectBuffers); BufferUtil.clearToFill(buffer); generateControlFrameHeader(credential, frameBodyLength, buffer); buffer.putShort(credential.getSlot()); buffer.putInt(proof.length); buffer.put(proof); for (byte[] certificate : certificates) { buffer.putInt(certificate.length); buffer.put(certificate); } buffer.flip(); return buffer; }
@Override protected Action process() throws Exception { // Only return if EOF has previously been read and thus // a write done with EOF=true if (_eof) { if (LOG.isDebugEnabled()) LOG.debug("EOF of {}", this); _in.close(); closed(); _channel.getByteBufferPool().release(_buffer); return Action.SUCCEEDED; } // Read from stream until buffer full or EOF BufferUtil.clearToFill(_buffer); while (_buffer.hasRemaining() && !_eof) _eof = (_in.read(_buffer)) < 0; // write what we have BufferUtil.flipToFlush(_buffer, 0); _written += _buffer.remaining(); write(_buffer, _eof, this); return Action.SCHEDULED; }
BufferUtil.clearToFill(hpacked); encoder.encode(hpacked, metaData); int hpackedLength = hpacked.position();
BufferUtil.clearToFill(chunk); generateTrailers(chunk,trailers); BufferUtil.flipToFlush(chunk,0); BufferUtil.clearToFill(chunk); prepareChunk(chunk,0); BufferUtil.flipToFlush(chunk,0);
@Override protected Action process() throws Exception { // Only return if EOF has previously been read and thus // a write done with EOF=true if (_eof) { if (LOG.isDebugEnabled()) LOG.debug("EOF of {}",this); _in.close(); closed(); _channel.getByteBufferPool().release(_buffer); return Action.SUCCEEDED; } // Read from stream until buffer full or EOF BufferUtil.clearToFill(_buffer); while (_buffer.hasRemaining() && !_eof) _eof = (_in.read(_buffer)) < 0; // write what we have BufferUtil.flipToFlush(_buffer, 0); write(_buffer,_eof,this); return Action.SCHEDULED; }
BufferUtil.clearToFill(hpacked); encoder.encode(hpacked, metaData); int hpackedLength = hpacked.position();
private Result committed( ByteBuffer chunk, ByteBuffer content, boolean last) { int len = BufferUtil.length(content); // handle the content. if (len>0) { if (isChunking()) { if (chunk==null) return Result.NEED_CHUNK; BufferUtil.clearToFill(chunk); prepareChunk(chunk,len); BufferUtil.flipToFlush(chunk,0); } _contentPrepared+=len; } if (last) { _state=State.COMPLETING; return len>0?Result.FLUSH:Result.CONTINUE; } return len>0?Result.FLUSH:Result.DONE; }
private Result committed( ByteBuffer chunk, ByteBuffer content, boolean last) { int len = BufferUtil.length(content); // handle the content. if (len>0) { if (isChunking()) { if (chunk==null) return Result.NEED_CHUNK; BufferUtil.clearToFill(chunk); prepareChunk(chunk,len); BufferUtil.flipToFlush(chunk,0); } _contentPrepared+=len; } if (last) { _state=State.COMPLETING; return len>0?Result.FLUSH:Result.CONTINUE; } return len>0?Result.FLUSH:Result.DONE; }
@Override public ByteBuffer generate(ControlFrame frame) { SettingsFrame settingsFrame = (SettingsFrame)frame; Settings settings = settingsFrame.getSettings(); int size = settings.size(); int frameBodyLength = 4 + 8 * size; int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength; ByteBuffer buffer = getByteBufferPool().acquire(totalLength, Generator.useDirectBuffers); BufferUtil.clearToFill(buffer); generateControlFrameHeader(settingsFrame, frameBodyLength, buffer); buffer.putInt(size); for (Settings.Setting setting : settings) { int id = setting.id().code(); byte flags = setting.flag().code(); int idAndFlags = convertIdAndFlags(frame.getVersion(), id, flags); buffer.putInt(idAndFlags); buffer.putInt(setting.value()); } buffer.flip(); return buffer; }