Netty 4 based transport implementation plugin for Elasticsearch providing high-performance networking layer for HTTP and node-to-node communications
npx @tessl/cli install tessl/maven-org-elasticsearch-plugin--transport-netty4-client@7.17.0The Elasticsearch Transport Netty4 Plugin provides a high-performance, Netty 4-based networking layer for Elasticsearch clusters. It serves as the core transport implementation for both HTTP API communications and internal node-to-node transport, enabling scalable distributed operations with non-blocking I/O capabilities.
org.elasticsearch.transport.Netty4Pluginimport org.elasticsearch.transport.Netty4Plugin;
import org.elasticsearch.transport.netty4.Netty4Transport;
import org.elasticsearch.http.netty4.Netty4HttpServerTransport;
import org.elasticsearch.transport.SharedGroupFactory;
import org.elasticsearch.transport.NettyAllocator;// Plugin is automatically loaded by Elasticsearch
// Main plugin class provides transport implementations
Netty4Plugin plugin = new Netty4Plugin();
// Access transport settings
List<Setting<?>> settings = plugin.getSettings();
// Plugin provides transport factory methods to Elasticsearch core
Map<String, Supplier<Transport>> transports = plugin.getTransports(
settings, threadPool, pageCacheRecycler, circuitBreakerService,
namedWriteableRegistry, networkService
);
Map<String, Supplier<HttpServerTransport>> httpTransports = plugin.getHttpTransports(
settings, threadPool, bigArrays, pageCacheRecycler, circuitBreakerService,
xContentRegistry, networkService, dispatcher, perRequestThreadContext, clusterSettings
);The Transport Netty4 Plugin is built around several key components:
Core plugin implementation that integrates Netty4 transport with Elasticsearch. Provides configuration settings and factory methods for transport implementations.
public class Netty4Plugin extends Plugin implements NetworkPlugin {
public static final String NETTY_TRANSPORT_NAME = "netty4";
public static final String NETTY_HTTP_TRANSPORT_NAME = "netty4";
public List<Setting<?>> getSettings();
public Settings additionalSettings();
public Map<String, Supplier<Transport>> getTransports(
Settings settings, ThreadPool threadPool, PageCacheRecycler pageCacheRecycler,
CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry,
NetworkService networkService
);
public Map<String, Supplier<HttpServerTransport>> getHttpTransports(
Settings settings, ThreadPool threadPool, BigArrays bigArrays,
PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService,
NamedXContentRegistry xContentRegistry, NetworkService networkService,
HttpServerTransport.Dispatcher dispatcher,
BiConsumer<HttpPreRequest, ThreadContext> perRequestThreadContext,
ClusterSettings clusterSettings
);
}High-performance TCP transport implementation for node-to-node communication in Elasticsearch clusters. Handles cluster coordination, data replication, and internal messaging.
public class Netty4Transport extends TcpTransport {
public static final Setting<Integer> WORKER_COUNT;
public static final Setting<ByteSizeValue> NETTY_RECEIVE_PREDICTOR_SIZE;
public static final Setting<ByteSizeValue> NETTY_RECEIVE_PREDICTOR_MIN;
public static final Setting<ByteSizeValue> NETTY_RECEIVE_PREDICTOR_MAX;
public static final Setting<Integer> NETTY_BOSS_COUNT;
}
public class Netty4TcpChannel implements TcpChannel {
void addCloseListener(ActionListener<Void> listener);
boolean isOpen();
InetSocketAddress getLocalAddress();
InetSocketAddress getRemoteAddress();
void sendMessage(BytesReference reference, ActionListener<Void> listener);
void close();
}HTTP server implementation providing REST API access to Elasticsearch. Handles HTTP request/response processing with support for various content types, compression, and pipelining.
public class Netty4HttpServerTransport extends AbstractHttpServerTransport {
public static Setting<Integer> SETTING_HTTP_NETTY_MAX_COMPOSITE_BUFFER_COMPONENTS;
public static final Setting<Integer> SETTING_HTTP_WORKER_COUNT;
public static final Setting<ByteSizeValue> SETTING_HTTP_NETTY_RECEIVE_PREDICTOR_SIZE;
}
public class Netty4HttpRequest implements HttpRequest {
RestRequest.Method method();
String uri();
BytesReference content();
Map<String, List<String>> getHeaders();
List<String> strictCookies();
HttpVersion protocolVersion();
Netty4HttpResponse createResponse(RestStatus status, BytesReference contentRef);
}Efficient management of Netty resources including EventLoopGroups, buffer allocation, and connection pooling. Provides shared resource pools to optimize memory usage and performance.
public final class SharedGroupFactory {
public SharedGroupFactory(Settings settings);
public Settings getSettings();
public int getTransportWorkerCount();
public SharedGroup getTransportGroup();
public SharedGroup getHttpGroup();
}
public class NettyAllocator {
public static ByteBufAllocator getAllocator();
public static long suggestedMaxAllocationSize();
public static String getAllocatorDescription();
public static void logAllocatorDescriptionIfNeeded();
public static Class<? extends Channel> getChannelType();
public static Class<? extends ServerChannel> getServerChannelType();
}Low-level channel implementations providing connection management, data serialization, and network I/O operations. Handles both client and server channel lifecycle.
public class Netty4TcpServerChannel implements TcpServerChannel {
void addCloseListener(ActionListener<Void> listener);
boolean isOpen();
InetSocketAddress getLocalAddress();
void close();
}
public class Netty4HttpServerChannel implements HttpServerChannel {
InetSocketAddress getLocalAddress();
void addCloseListener(ActionListener<Void> listener);
boolean isOpen();
void close();
}Utility classes providing Netty-specific optimizations, byte buffer management, and configuration helpers for optimal performance tuning.
public class Netty4Utils {
public static void setAvailableProcessors(int availableProcessors);
public static ByteBuf toByteBuf(BytesReference reference);
public static BytesReference toBytesReference(ByteBuf byteBuf);
}
public class NettyByteBufSizer extends MessageToMessageDecoder<ByteBuf> {
// Handles byte buffer sizing for optimal memory usage
}// Core transport interfaces from Elasticsearch
interface Transport {
void sendRequest(DiscoveryNode node, String action, TransportRequest request,
TransportRequestOptions options, TransportResponseHandler<T> handler);
}
interface HttpServerTransport {
BoundTransportAddress boundAddress();
HttpInfo info();
HttpStats stats();
}
interface TcpChannel {
void addCloseListener(ActionListener<Void> listener);
boolean isOpen();
InetSocketAddress getLocalAddress();
InetSocketAddress getRemoteAddress();
void sendMessage(BytesReference reference, ActionListener<Void> listener);
void close();
}
interface HttpChannel {
void sendResponse(HttpResponse response, ActionListener<Void> listener);
InetSocketAddress getLocalAddress();
InetSocketAddress getRemoteAddress();
void close();
}
// Settings types
class Setting<T> {
String getKey();
T get(Settings settings);
}
// Netty buffer types (from io.netty.buffer)
interface ByteBufAllocator {
ByteBuf buffer();
ByteBuf directBuffer();
CompositeByteBuf compositeBuffer();
}
// Elasticsearch utility types
class ByteSizeValue {
long getBytes();
String toString();
}
class Settings {
<T> T get(Setting<T> setting);
Settings.Builder builder();
}