@Override public void onDataAvailable() { notifyOnAsyncRead(handler); nioInputStream.notifyAvailable(this); }
/** * Close the stream * Since we re-cycle, we can't allow the call to super.close() * which would permanently disable us. */ @Override @SuppressWarnings("unchecked") public void close() throws IOException { inputStream.close(); }
@Override public void onAllDataRead() { if (nioInputStream.isReady()) { notifyOnAsyncRead(handler); } } }
@Override public void onDataAvailable() throws Exception { LOGGER.log(Level.FINE, "[onDataAvailable] length: {0}", in.readyData()); storeAvailableData(in, fileChannel); in.notifyAvailable(this); }
void readLine() { final Buffer buffer = parentInputStream.getBuffer(); final int position = buffer.position() + line.offset; // final int limit = buffer.limit(); final int limit = buffer.position() + parentInputStream.readyData(); int offset = position + line.len; while(offset < limit) { final byte b = buffer.get(offset++); if (b == Constants.LF) { line.isCrLf = position <= offset - 2 && buffer.get(offset - 2) == Constants.CR; line.isComplete = true; break; } } line.len = offset - position; }
boolean result = inputStream.isReady(); if (!result) { if (hasSetReadListener) { IS_READY_SCOPE.set(Boolean.TRUE); try { inputStream.notifyAvailable(readHandler); } finally { IS_READY_SCOPE.remove();
@Override public int read(final byte[] b) throws IOException { if (!prevIsReady) { throw new IllegalStateException( LogMessages.WARNING_GRIZZLY_HTTP_SERVLET_NON_BLOCKING_ERROR()); } return inputStream.read(b, 0, b.length); }
/** * {@inheritDoc} */ @Override public void mark(final int readlimit) { parentNIOInputStream.mark(readlimit); }
/** * {@inheritDoc} */ @Override public void reset() throws IOException { parentNIOInputStream.reset(); }
/** * This {@link InputStream} implementation supports marking. * * @return <code>true</code> */ @Override public boolean markSupported() { return parentNIOInputStream.markSupported(); }
/** * Skip the multipart entry processing. */ @SuppressWarnings({"ResultOfMethodCallIgnored"}) public void skip() throws IOException { isSkipping = true; requestInputStream.skip(availableBytes); availableBytes = 0; }
/** * {@inheritDoc} */ @Override public Buffer readBuffer(final int size) { if (size > readyData()) { throw new IllegalStateException("Can not read more bytes than available"); } multipartEntry.addAvailableBytes(-size); return parentNIOInputStream.readBuffer(size); }
/** * Read available file content data out of HTTP request and save the * chunk into local file output stream * * @throws IOException */ private void readAndSaveAvail() throws IOException { while (inputStream.isReady()) { final Buffer buffer = inputStream.readBuffer(); if (buffer.isComposite()) { writeCompositeBuffer(buffer); } else { writeBufferToDiskAndUpdateStats(buffer.toByteBuffer()); } } }
/** * Read available file content data out of HTTP request and save the * chunk into local file output stream * * @throws IOException */ private void readAndSaveAvail() throws IOException { while (inputStream.isReady()) { // read the available bytes from input stream final int readBytes = inputStream.read(buf); // update the counter uploadedBytesCounter.addAndGet(readBytes); // save the file content to the file fileOutputStream.write(buf, 0, readBytes); } }
@Override public void onAllDataRead() throws Exception { LOGGER.log(Level.FINE, "[onAllDataRead] length: {0}", in.readyData()); storeAvailableData(in, fileChannel); response.setStatus(HttpStatus.ACCEPTED_202); complete(false); response.resume(); }
void readLine() { final Buffer buffer = parentInputStream.getBuffer(); final int position = buffer.position() + line.offset; // final int limit = buffer.limit(); final int limit = buffer.position() + parentInputStream.readyData(); int offset = position + line.len; while(offset < limit) { final byte b = buffer.get(offset++); if (b == Constants.LF) { line.isCrLf = position <= offset - 2 && buffer.get(offset - 2) == Constants.CR; line.isComplete = true; break; } } line.len = offset - position; }
boolean result = inputStream.isReady(); if (!result) { if (hasSetReadListener) { IS_READY_SCOPE.set(Boolean.TRUE); try { inputStream.notifyAvailable(readHandler); } finally { IS_READY_SCOPE.remove();
@Override public int read(final byte[] b, final int off, final int len) throws IOException { if (!prevIsReady) { throw new IllegalStateException( LogMessages.WARNING_GRIZZLY_HTTP_SERVLET_NON_BLOCKING_ERROR()); } return inputStream.read(b, off, len); }
/** * {@inheritDoc} */ @Override public void mark(final int readlimit) { parentNIOInputStream.mark(readlimit); }
/** * {@inheritDoc} */ @Override public void reset() throws IOException { inputStream.reset(); }