@Override public void close() { if (_open.compareAndSet(true, false)) { super.close(); _selector.destroyEndPoint(this); } }
@Override public void onOpen() { if (_open.compareAndSet(false, true)) super.onOpen(); }
@Override protected void needsFillInterest() { changeInterests(SelectionKey.OP_READ); }
@Override public void run() { getWriteFlusher().completeWrite(); getFillInterest().fillable(); } };
@Override public int fill(ByteBuffer buffer) throws IOException { if (_ishut) return -1; int pos=BufferUtil.flipToFill(buffer); try { int filled = _channel.read(buffer); if (LOG.isDebugEnabled()) // Avoid boxing of variable 'filled' LOG.debug("filled {} {}", filled, this); if (filled>0) notIdle(); else if (filled==-1) shutdownInput(); return filled; } catch(IOException e) { LOG.debug(e); shutdownInput(); return -1; } finally { BufferUtil.flipToFlush(buffer,pos); } }
@Override public int fill(ByteBuffer buffer) throws IOException { if (isInputShutdown()) return -1; int pos=BufferUtil.flipToFill(buffer); try { int filled = _channel.read(buffer); if (LOG.isDebugEnabled()) // Avoid boxing of variable 'filled' LOG.debug("filled {} {}", filled, this); if (filled>0) notIdle(); else if (filled==-1) shutdownInput(); return filled; } catch(IOException e) { LOG.debug(e); shutdownInput(); return -1; } finally { BufferUtil.flipToFlush(buffer,pos); } }
@Override public String toString() { // We do a best effort to print the right toString() and that's it. try { boolean valid = _key != null && _key.isValid(); int keyInterests = valid ? _key.interestOps() : -1; int keyReadiness = valid ? _key.readyOps() : -1; return String.format("%s{io=%d/%d,kio=%d,kro=%d}", super.toString(), _currentInterestOps, _desiredInterestOps, keyInterests, keyReadiness); } catch (Throwable x) { return String.format("%s{io=%s,kio=-2,kro=-2}", super.toString(), _desiredInterestOps); } } }
@Override public String toString() { return String.format("CEP:%s:%s:%s->%s",ChannelEndPoint.this,_operation,getInvocationType(),getWriteFlusher()); }
@Override public void run() { getFillInterest().fillable(); } };
@Override public int fill(ByteBuffer buffer) throws IOException { if (_ishut) return -1; int pos=BufferUtil.flipToFill(buffer); try { int filled = _channel.read(buffer); LOG.debug("filled {} {}", filled, this); if (filled>0) notIdle(); else if (filled==-1) shutdownInput(); return filled; } catch(IOException e) { LOG.debug(e); shutdownInput(); return -1; } finally { BufferUtil.flipToFlush(buffer,pos); } }
@Override public int fill(ByteBuffer buffer) throws IOException { if (isInputShutdown()) return -1; int pos=BufferUtil.flipToFill(buffer); int filled; try { filled = _channel.read(buffer); if (filled>0) notIdle(); else if (filled==-1) shutdownInput(); } catch(IOException e) { LOG.debug(e); shutdownInput(); filled = -1; } finally { BufferUtil.flipToFlush(buffer,pos); } if (LOG.isDebugEnabled()) LOG.debug("filled {} {}", filled, BufferUtil.toDetailString(buffer)); return filled; }
@Override public InvocationType getInvocationType() { InvocationType fillT = getFillInterest().getCallbackInvocationType(); InvocationType flushT = getWriteFlusher().getCallbackInvocationType(); if (fillT==flushT) return fillT; if (fillT==InvocationType.EITHER && flushT==InvocationType.NON_BLOCKING) return InvocationType.EITHER; if (fillT==InvocationType.NON_BLOCKING && flushT==InvocationType.EITHER) return InvocationType.EITHER; return InvocationType.BLOCKING; }
@Override public String toString() { // Do NOT use synchronized (this) // because it's very easy to deadlock when debugging is enabled. // We do a best effort to print the right toString() and that's it. try { boolean valid = _key!=null && _key.isValid(); int keyInterests = valid ? _key.interestOps() : -1; int keyReadiness = valid ? _key.readyOps() : -1; return String.format("%s{io=%d,kio=%d,kro=%d}", super.toString(), _interestOps.get(), keyInterests, keyReadiness); } catch (CancelledKeyException x) { return String.format("%s{io=%s,kio=-2,kro=-2}", super.toString(), _interestOps.get()); } } }
@Override public InvocationType getInvocationType() { return getWriteFlusher().getCallbackInvocationType(); }
@Override public InvocationType getInvocationType() { return getFillInterest().getCallbackInvocationType(); }
protected void shutdownInput() { LOG.debug("ishut {}", this); _ishut=true; if (_oshut) close(); }
@Override public int fill(ByteBuffer buffer) throws IOException { if (_ishut) return -1; int pos=BufferUtil.flipToFill(buffer); try { int filled = _channel.read(buffer); LOG.debug("filled {} {}", filled, this); if (filled>0) notIdle(); else if (filled==-1) shutdownInput(); return filled; } catch(IOException e) { LOG.debug(e); shutdownInput(); return -1; } finally { BufferUtil.flipToFlush(buffer,pos); } }