Class AbstractEndPoint

java.lang.Object
org.eclipse.jetty.io.IdleTimeout
org.eclipse.jetty.io.AbstractEndPoint
All Implemented Interfaces:
Closeable, AutoCloseable, EndPoint
Direct Known Subclasses:
ByteArrayEndPoint, ChannelEndPoint, SslConnection.DecryptedEndPoint

public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
  • Field Details

  • Constructor Details

    • AbstractEndPoint

      protected AbstractEndPoint(Scheduler scheduler)
  • Method Details

    • shutdownInput

      protected final void shutdownInput()
    • shutdownOutput

      public final void shutdownOutput()
      Description copied from interface: EndPoint
      Shutdown the output.

      This call indicates that no more data will be sent on this endpoint that that the remote end should read an EOF once all previously sent data has been consumed. Shutdown may be done either at the TCP/IP level, as a protocol exchange (Eg TLS close handshake) or both.

      If the endpoint has EndPoint.isInputShutdown() true, then this call has the same effect as EndPoint.close().

      Specified by:
      shutdownOutput in interface EndPoint
    • close

      public final void close()
      Description copied from interface: EndPoint
      Close any backing stream associated with the endpoint
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface EndPoint
    • close

      protected final void close(Throwable failure)
    • doShutdownInput

      protected void doShutdownInput()
    • doShutdownOutput

      protected void doShutdownOutput()
    • doOnClose

      private void doOnClose(Throwable failure)
    • doClose

      protected void doClose()
    • onClose

      protected void onClose(Throwable failure)
    • isOutputShutdown

      public boolean isOutputShutdown()
      Description copied from interface: EndPoint
      Test if output is shutdown. The output is shutdown by a call to EndPoint.shutdownOutput() or EndPoint.close().
      Specified by:
      isOutputShutdown in interface EndPoint
      Returns:
      true if the output is shutdown or the endpoint is closed.
    • isInputShutdown

      public boolean isInputShutdown()
      Description copied from interface: EndPoint
      Test if the input is shutdown. The input is shutdown if an EOF has been read while doing a EndPoint.fill(ByteBuffer). Once the input is shutdown, all calls to EndPoint.fill(ByteBuffer) will return -1, until such time as the end point is close, when they will return EofException.
      Specified by:
      isInputShutdown in interface EndPoint
      Returns:
      True if the input is shutdown or the endpoint is closed.
    • isOpen

      public boolean isOpen()
      Description copied from class: IdleTimeout
      This abstract method should be called to check if idle timeouts should still be checked.
      Specified by:
      isOpen in interface EndPoint
      Specified by:
      isOpen in class IdleTimeout
      Returns:
      True if the entity monitored should still be checked for idle timeouts
    • checkFlush

      public void checkFlush() throws IOException
      Throws:
      IOException
    • checkFill

      public void checkFill() throws IOException
      Throws:
      IOException
    • getCreatedTimeStamp

      public long getCreatedTimeStamp()
      Specified by:
      getCreatedTimeStamp in interface EndPoint
      Returns:
      the epoch time in milliseconds when this EndPoint was created
    • getConnection

      public Connection getConnection()
      Specified by:
      getConnection in interface EndPoint
      Returns:
      the Connection associated with this EndPoint
      See Also:
    • setConnection

      public void setConnection(Connection connection)
      Specified by:
      setConnection in interface EndPoint
      Parameters:
      connection - the Connection associated with this EndPoint
      See Also:
    • isOptimizedForDirectBuffers

      public boolean isOptimizedForDirectBuffers()
      Description copied from interface: EndPoint
      Is the endpoint optimized for DirectBuffer usage
      Specified by:
      isOptimizedForDirectBuffers in interface EndPoint
      Returns:
      True if direct buffers can be used optimally.
    • reset

      protected void reset()
    • onOpen

      public void onOpen()
      Description copied from interface: EndPoint

      Callback method invoked when this EndPoint is opened.

      Specified by:
      onOpen in interface EndPoint
      Overrides:
      onOpen in class IdleTimeout
      See Also:
    • onClose

      public void onClose()
      Description copied from interface: EndPoint

      Callback method invoked when this EndPoint is close.

      Specified by:
      onClose in interface EndPoint
      Overrides:
      onClose in class IdleTimeout
      See Also:
    • fillInterested

      public void fillInterested(Callback callback)
      Description copied from interface: EndPoint

      Requests callback methods to be invoked when a call to EndPoint.fill(ByteBuffer) would return data or EOF.

      Specified by:
      fillInterested in interface EndPoint
      Parameters:
      callback - the callback to call when an error occurs or we are readable. The callback may implement the Invocable interface to self declare its blocking status. Non-blocking callbacks may be called more efficiently without dispatch delays.
    • tryFillInterested

      public boolean tryFillInterested(Callback callback)
      Description copied from interface: EndPoint

      Requests callback methods to be invoked when a call to EndPoint.fill(ByteBuffer) would return data or EOF.

      Specified by:
      tryFillInterested in interface EndPoint
      Parameters:
      callback - the callback to call when an error occurs or we are readable. The callback may implement the Invocable interface to self declare its blocking status. Non-blocking callbacks may be called more efficiently without dispatch delays.
      Returns:
      true if set
    • isFillInterested

      public boolean isFillInterested()
      Specified by:
      isFillInterested in interface EndPoint
      Returns:
      whether EndPoint.fillInterested(Callback) has been called, but EndPoint.fill(ByteBuffer) has not yet been called
    • write

      public void write(Callback callback, ByteBuffer... buffers) throws IllegalStateException
      Description copied from interface: EndPoint

      Writes the given buffers via EndPoint.flush(ByteBuffer...) and invokes callback methods when either all the data has been flushed or an error occurs.

      Specified by:
      write in interface EndPoint
      Parameters:
      callback - the callback to call when an error occurs or the write completed. The callback may implement the Invocable interface to self declare its blocking status. Non-blocking callbacks may be called more efficiently without dispatch delays.
      buffers - one or more ByteBuffers that will be flushed.
      Throws:
      WritePendingException - if another write operation is concurrent.
      IllegalStateException
    • onIncompleteFlush

      protected abstract void onIncompleteFlush()
    • needsFillInterest

      protected abstract void needsFillInterest() throws IOException
      Throws:
      IOException
    • getFillInterest

      public FillInterest getFillInterest()
    • getWriteFlusher

      public WriteFlusher getWriteFlusher()
    • onIdleExpired

      protected void onIdleExpired(TimeoutException timeout)
      Description copied from class: IdleTimeout
      This abstract method is called when the idle timeout has expired.
      Specified by:
      onIdleExpired in class IdleTimeout
      Parameters:
      timeout - a TimeoutException
    • upgrade

      public void upgrade(Connection newConnection)
      Description copied from interface: EndPoint

      Upgrades this EndPoint from the current connection to the given new connection.

      Closes the current connection, links this EndPoint to the new connection and then opens the new connection.

      If the current connection is an instance of Connection.UpgradeFrom then a buffer of unconsumed bytes is requested. If the buffer of unconsumed bytes is non-null and non-empty, then the new connection is tested: if it is an instance of Connection.UpgradeTo, then the unconsumed buffer is passed to the new connection; otherwise, an exception is thrown since there are unconsumed bytes that cannot be consumed by the new connection.

      Specified by:
      upgrade in interface EndPoint
      Parameters:
      newConnection - the connection to upgrade to
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toEndPointString

      public String toEndPointString()
    • toConnectionString

      public String toConnectionString()