@ApiStatus.Internal public class Netty extends Object
Modifier and Type | Field and Description |
---|---|
static Function<LinkedList<io.netty.channel.ChannelInboundHandler>,io.netty.channel.ChannelHandler> |
INBOUND
Constant
INBOUND |
static Function<LinkedList<io.netty.channel.ChannelOutboundHandler>,io.netty.channel.ChannelHandler> |
OUTBOUND
Constant
OUTBOUND |
Constructor and Description |
---|
Netty() |
Modifier and Type | Method and Description |
---|---|
static void |
clearAttribute(io.netty.channel.Channel ch,
io.netty.util.AttributeKey<?> key)
Clears the value of a netty
Attribute |
static CompletableFuture<Void> |
close(io.netty.channel.Channel channel)
Closes a
Channel . |
static CompletableFuture<io.netty.channel.Channel> |
deregister(io.netty.channel.Channel channel)
deregister.
|
static void |
dumpBuffer(BiConsumer<String,Object[]> logger,
String msg,
io.netty.buffer.ByteBuf buf,
Integer limit)
dumpBuffer.
|
static byte[] |
getBufferContents(io.netty.buffer.ByteBuf buf)
Return a byte array contents of a
ByteBuf |
static byte[] |
getBufferContents(io.netty.buffer.ByteBuf buf,
Integer limit)
Return a byte array contents of a
ByteBuf |
static byte[] |
getBufferContentsAll(io.netty.buffer.ByteBuf buf)
getBufferContentsAll.
|
static String |
getThreadName(io.netty.channel.Channel channel)
getThreadName.
|
static String |
getThreadName(io.netty.channel.EventLoop eventLoop)
getThreadName.
|
static String |
getType(io.netty.channel.ChannelHandler handler)
Returns the type name of a
ChannelHandler |
static String |
id(io.netty.channel.Channel ch)
Translate
Channel to it's unique id string representation |
static String |
id(io.netty.channel.ChannelHandlerContext ctx)
id.
|
static String |
id(Envelope<?> envelope)
Translates an
Envelope instance to it's unique id string representation |
static String |
id(Object message)
Translates a message instance to it's unique id string representation
|
static <V extends Number> |
incrementAttrNumber(io.netty.channel.Channel channel,
io.netty.util.AttributeKey<V> stat)
Increments an
Attribute value whose underlying type is a Number |
static <V> void |
notifyOnCompletion(io.netty.channel.ChannelFuture future,
V completedValue,
CompletableFuture<V> promise,
io.netty.channel.ChannelFutureListener listener)
notifyOnCompletion.
|
static String |
prettyHexDump(byte[] buf)
prettyHexDump.
|
static String |
prettyHexDump(io.netty.buffer.ByteBuf buf)
prettyHexDump.
|
static String |
prettyHexDump(io.netty.buffer.ByteBuf buf,
boolean dumpAll)
prettyHexDump.
|
static void |
printChannelPipeline(org.slf4j.Logger log,
io.netty.channel.Channel ch)
printChannelPipeline.
|
static String |
readString(io.netty.buffer.ByteBuf buffer)
Reads a null-terminated string from the provided
ByteBuf |
static String |
readString(io.netty.buffer.ByteBuf buffer,
Charset charset)
Reads a null-terminated string from the provided
ByteBuf |
static CompletableFuture<io.netty.channel.Channel> |
register(io.netty.channel.Channel channel,
io.netty.channel.EventLoop group)
register.
|
static <H extends io.netty.channel.ChannelHandler> |
registerHandlers(io.netty.channel.ChannelPipeline pipeline,
Consumer<LinkedList<H>> initializer,
Function<LinkedList<H>,io.netty.channel.ChannelHandler> extractStrategy)
registerHandlers.
|
static void |
registerTimeoutHandlers(io.netty.channel.Channel ch)
registerTimeoutHandlers.
|
static CompletableFuture<Void> |
release(io.netty.channel.Channel ch)
Release a
Channel from the pool (if applicable) |
static CompletableFuture<io.netty.channel.Channel> |
toCompletable(io.netty.channel.ChannelFuture channelFuture)
Converts a netty
ChannelFuture to a CompletableFuture |
static <A,B,C extends io.netty.util.concurrent.Future<B>> |
toCompletable(C future,
Supplier<A> success,
Supplier<Throwable> fail)
Converts a netty based
Future to a CompletableFuture . |
static <V> CompletableFuture<V> |
toCompletable(io.netty.util.concurrent.Future<V> future)
Converts a netty based
Future to a CompletableFuture . |
static CompletableFuture<io.netty.channel.Channel> |
useEventLoop(CompletableFuture<io.netty.channel.Channel> channelFuture,
io.netty.channel.EventLoop eventLoop)
useEventLoop.
|
public static final Function<LinkedList<io.netty.channel.ChannelInboundHandler>,io.netty.channel.ChannelHandler> INBOUND
INBOUND
public static final Function<LinkedList<io.netty.channel.ChannelOutboundHandler>,io.netty.channel.ChannelHandler> OUTBOUND
OUTBOUND
public static CompletableFuture<io.netty.channel.Channel> useEventLoop(CompletableFuture<io.netty.channel.Channel> channelFuture, io.netty.channel.EventLoop eventLoop)
useEventLoop.
channelFuture
- a CompletableFuture
objecteventLoop
- a EventLoop
objectCompletableFuture
objectpublic static CompletableFuture<io.netty.channel.Channel> toCompletable(io.netty.channel.ChannelFuture channelFuture)
ChannelFuture
to a CompletableFuture
channelFuture
- The ChannelFuture
to convertCompletableFuture
public static <V> void notifyOnCompletion(io.netty.channel.ChannelFuture future, V completedValue, CompletableFuture<V> promise, io.netty.channel.ChannelFutureListener listener)
notifyOnCompletion.
V
- a V classfuture
- a ChannelFuture
objectcompletedValue
- a V objectpromise
- a CompletableFuture
objectlistener
- a ChannelFutureListener
objectpublic static CompletableFuture<io.netty.channel.Channel> register(io.netty.channel.Channel channel, io.netty.channel.EventLoop group)
register.
channel
- a Channel
objectgroup
- a EventLoop
objectCompletableFuture
objectpublic static CompletableFuture<io.netty.channel.Channel> deregister(io.netty.channel.Channel channel)
deregister.
channel
- a Channel
objectCompletableFuture
objectpublic static void dumpBuffer(BiConsumer<String,Object[]> logger, String msg, io.netty.buffer.ByteBuf buf, Integer limit)
dumpBuffer.
logger
- a BiConsumer
objectmsg
- a String
objectbuf
- a ByteBuf
objectlimit
- a Integer
objectpublic static String prettyHexDump(byte[] buf)
prettyHexDump.
buf
- an array of byte
objectsString
objectpublic static String prettyHexDump(io.netty.buffer.ByteBuf buf)
prettyHexDump.
buf
- a ByteBuf
objectString
objectpublic static String prettyHexDump(io.netty.buffer.ByteBuf buf, boolean dumpAll)
prettyHexDump.
buf
- a ByteBuf
objectdumpAll
- a booleanString
objectpublic static byte[] getBufferContents(io.netty.buffer.ByteBuf buf)
ByteBuf
buf
- The ByteBuf
to processpublic static byte[] getBufferContents(io.netty.buffer.ByteBuf buf, Integer limit)
ByteBuf
buf
- The ByteBuf
to processlimit
- Limit the number of bytes to read or null
to read the entire bufferpublic static byte[] getBufferContentsAll(io.netty.buffer.ByteBuf buf)
getBufferContentsAll.
buf
- a ByteBuf
objectbyte
objectspublic static void printChannelPipeline(org.slf4j.Logger log, io.netty.channel.Channel ch)
printChannelPipeline.
log
- a Logger
objectch
- a Channel
objectpublic static String id(io.netty.channel.Channel ch)
Channel
to it's unique id string representationch
- The Channel
to translateChannel
public static String getType(io.netty.channel.ChannelHandler handler)
Returns the type name of a ChannelHandler
handler
- a ChannelHandler
objectString
objectpublic static String getThreadName(io.netty.channel.Channel channel)
getThreadName.
channel
- a Channel
objectString
objectpublic static String getThreadName(io.netty.channel.EventLoop eventLoop)
getThreadName.
eventLoop
- a EventLoop
objectString
objectpublic static CompletableFuture<Void> release(io.netty.channel.Channel ch)
Channel
from the pool (if applicable)ch
- The Channel
to be releasedCompletableFuture
that will be notified if the Channel
has been successfully released or notpublic static String id(io.netty.channel.ChannelHandlerContext ctx)
id.
ctx
- a ChannelHandlerContext
objectString
objectpublic static String id(Envelope<?> envelope)
Envelope
instance to it's unique id string representationpublic static String id(Object message)
message
- The message content to translateEnvelope
public static <H extends io.netty.channel.ChannelHandler> void registerHandlers(io.netty.channel.ChannelPipeline pipeline, Consumer<LinkedList<H>> initializer, Function<LinkedList<H>,io.netty.channel.ChannelHandler> extractStrategy)
registerHandlers.
public static void registerTimeoutHandlers(io.netty.channel.Channel ch)
registerTimeoutHandlers.
ch
- a Channel
objectpublic static void clearAttribute(io.netty.channel.Channel ch, io.netty.util.AttributeKey<?> key)
Clears the value of a netty Attribute
ch
- a Channel
objectkey
- a AttributeKey
objectpublic static <V> CompletableFuture<V> toCompletable(io.netty.util.concurrent.Future<V> future)
Converts a netty based Future
to a CompletableFuture
.
V
- a V classfuture
- a Future
objectCompletableFuture
objectpublic static <A,B,C extends io.netty.util.concurrent.Future<B>> CompletableFuture<A> toCompletable(C future, Supplier<A> success, Supplier<Throwable> fail)
Converts a netty based Future
to a CompletableFuture
.
A
- a A classB
- a B classC
- a C classfuture
- a C objectsuccess
- a Supplier
objectfail
- a Supplier
objectCompletableFuture
objectpublic static String readString(io.netty.buffer.ByteBuf buffer)
Reads a null-terminated string from the provided ByteBuf
buffer
- a ByteBuf
objectString
objectpublic static String readString(io.netty.buffer.ByteBuf buffer, Charset charset)
Reads a null-terminated string from the provided ByteBuf
public static CompletableFuture<Void> close(io.netty.channel.Channel channel)
Closes a Channel
.
channel
- a Channel
objectCompletableFuture
objectpublic static <V extends Number> Number incrementAttrNumber(io.netty.channel.Channel channel, io.netty.util.AttributeKey<V> stat)
Increments an Attribute
value whose underlying type is a Number
V
- a V classchannel
- a Channel
objectstat
- a AttributeKey
objectNumber
objectCopyright © 2016–2024. All rights reserved.