or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

buffer-management.mdconnection-management.mdcontent-streaming.mdcore-io.mdindex.mdselector-management.mdssl-support.md
tile.json

tessl/maven-org-eclipse-jetty--jetty-io

Core I/O components for Eclipse Jetty providing essential I/O utilities, buffer management, and network connection handling

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.eclipse.jetty/jetty-io@12.0.x

To install, run

npx @tessl/cli install tessl/maven-org-eclipse-jetty--jetty-io@12.0.0

index.mddocs/

Eclipse Jetty IO Module

Eclipse Jetty IO is a high-performance, asynchronous I/O library that provides the foundational networking components for the Eclipse Jetty web server and HTTP client. It offers non-blocking I/O abstractions, buffer pooling, content streaming, and SSL/TLS support designed for scalable network applications.

Package Information

  • Package Name: jetty-io
  • Package Type: maven
  • Language: Java
  • Installation: <dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-io</artifactId><version>12.0.21</version></dependency>
  • Module: org.eclipse.jetty.io

Core Imports

import org.eclipse.jetty.io.*;
import org.eclipse.jetty.io.content.*;
import org.eclipse.jetty.io.ssl.*;

Basic Usage

import org.eclipse.jetty.io.*;
import org.eclipse.jetty.io.content.*;
import org.eclipse.jetty.util.Callback;
import java.nio.ByteBuffer;

// Buffer pooling
ByteBufferPool pool = new ArrayByteBufferPool();
RetainableByteBuffer buffer = pool.acquire(1024, false);
try {
    ByteBuffer bb = buffer.getByteBuffer();
    // Use buffer for I/O operations
} finally {
    buffer.release();
}

// Content handling
Content.Source source = Content.Source.from("Hello World");
Content.Chunk chunk = source.read();
if (chunk != null) {
    ByteBuffer data = chunk.getByteBuffer();
    // Process data
}

// Async content copying
Content.Source source = Content.Source.from(inputStream);
Content.Sink sink = Content.Sink.asBuffered(outputSink);
Content.copy(source, sink, Callback.NOOP);

Architecture

Jetty IO is built around several key architectural patterns:

  • Non-blocking I/O: Built on Java NIO with asynchronous callbacks for scalable network operations
  • Reference Counting: Automatic resource management through the Retainable interface
  • Content Streaming: Demand-based content processing with backpressure support
  • Protocol Layering: Connection upgrade mechanism for protocol switching (HTTP/1.1 → HTTP/2, HTTP → WebSocket)
  • Transport Abstraction: Pluggable transport layer supporting TCP, UDP, and Unix domain sockets

Capabilities

Core I/O Abstractions

Essential interfaces and abstract base classes that define the I/O model, including non-blocking endpoints, connections, and lifecycle management.

interface EndPoint extends Closeable {
    int fill(ByteBuffer buffer) throws IOException;
    boolean flush(ByteBuffer... buffers) throws IOException;
    void fillInterested(Callback callback) throws ReadPendingException;
    void write(Callback callback, ByteBuffer... buffers) throws WritePendingException;
    Connection getConnection();
    void setConnection(Connection connection);
}

interface Connection extends Closeable {
    void onOpen();
    void onClose(Throwable cause);
    EndPoint getEndPoint();
    boolean onIdleExpired(TimeoutException timeoutException);
}

Core I/O Abstractions

Buffer Management

High-performance buffer pooling and reference-counted buffer management for memory efficiency in high-throughput applications.

interface ByteBufferPool {
    RetainableByteBuffer acquire(int size, boolean direct);
    void clear();
}

interface RetainableByteBuffer extends Retainable {
    ByteBuffer getByteBuffer();
    boolean isDirect();
    int capacity();
    void clear();
}

interface Retainable {
    void retain();
    boolean release();
    boolean canRetain();
}

Buffer Management

Content Streaming

Demand-driven content processing system with support for backpressure, async operations, and integration with reactive streams.

class Content {
    interface Source {
        Chunk read();
        void demand(Runnable demandCallback);
        void fail(Throwable failure);
        long getLength();
        static Source from(ByteBuffer... buffers);
        static Source from(Path path);
        static Source from(InputStream inputStream);
    }
    
    interface Sink {
        void write(boolean last, ByteBuffer byteBuffer, Callback callback);
        static Sink asBuffered(Sink sink);
        static OutputStream asOutputStream(Sink sink);
    }
    
    interface Chunk {
        ByteBuffer getByteBuffer();
        boolean isLast();
        boolean hasRemaining();
        Throwable getFailure();
    }
}

Content Streaming

Connection Management

Client connection factories, transport abstractions, and connection lifecycle management for establishing and managing network connections.

interface ClientConnectionFactory {
    Connection newConnection(EndPoint endPoint, Map<String, Object> context) throws IOException;
}

interface Transport {
    boolean isIntrinsicallySecure();
    void connect(SocketAddress socketAddress, Map<String, Object> context);
    Connection newConnection(EndPoint endPoint, Map<String, Object> context) throws IOException;
}

Connection Management

SSL/TLS Support

Secure connection implementations with SSL/TLS encryption, handshake management, and ALPN (Application Layer Protocol Negotiation) support.

class SslConnection extends AbstractConnection implements Connection.UpgradeTo {
    // SSL connection wrapper
}

interface SslHandshakeListener extends EventListener {
    default void handshakeSucceeded(Event event) {}
    default void handshakeFailed(Event event, Throwable failure) {}
}

interface ALPNProcessor {
    void process(SSLEngine sslEngine, List<String> protocols, String selected);
}

SSL/TLS Support

Selector Management

Non-blocking I/O management using Java NIO selectors for handling multiple connections efficiently in a single-threaded or thread-pool model.

abstract class SelectorManager extends ContainerLifeCycle {
    protected abstract EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey key);
    protected abstract Connection newConnection(EndPoint endPoint, Object attachment);
}

class ManagedSelector extends AbstractLifeCycle implements Dumpable {
    // Single-threaded NIO selector management
}

Selector Management

Types

Core Types

// Exception types
class EofException extends EOFException implements QuietException {
    EofException();
    EofException(String reason);
    EofException(Throwable cause);
}

interface QuietException {
    static boolean isQuiet(Throwable throwable);
}

class RuntimeIOException extends RuntimeException {
    RuntimeIOException(IOException cause);
}

// Timeout management
interface IdleTimeout {
    long getIdleTimeout();
    void setIdleTimeout(long idleTimeout);
    boolean isIdleTimeoutExpired();
    void onIdleExpired(TimeoutException timeout);
}

// Statistics and monitoring
class ConnectionStatistics extends AbstractLifeCycle implements Connection.Listener {
    long getConnectionsTotal();
    long getConnectionsOpened();
    long getConnectionsClosed();
    long getMessagesIn();
    long getMessagesOut();
    long getBytesIn();
    long getBytesOut();
}