use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project netty by netty.
the class Http2MultiplexTest method setUp.
@BeforeEach
public void setUp() {
childChannelInitializer = new TestChannelInitializer();
parentChannel = new EmbeddedChannel();
frameInboundWriter = new Http2FrameInboundWriter(parentChannel);
parentChannel.connect(new InetSocketAddress(0));
frameWriter = Http2TestUtil.mockedFrameWriter();
codec = newCodec(childChannelInitializer, frameWriter);
parentChannel.pipeline().addLast(codec);
ChannelHandler multiplexer = newMultiplexer(childChannelInitializer);
if (multiplexer != null) {
parentChannel.pipeline().addLast(multiplexer);
}
parentChannel.runPendingTasks();
parentChannel.pipeline().fireChannelActive();
parentChannel.writeInbound(Http2CodecUtil.connectionPrefaceBuf());
Http2Settings settings = new Http2Settings().initialWindowSize(initialRemoteStreamWindow);
frameInboundWriter.writeInboundSettings(settings);
verify(frameWriter).writeSettingsAck(eqCodecCtx(), anyChannelPromise());
frameInboundWriter.writeInboundSettingsAck();
Http2SettingsFrame settingsFrame = parentChannel.readInbound();
assertNotNull(settingsFrame);
Http2SettingsAckFrame settingsAckFrame = parentChannel.readInbound();
assertNotNull(settingsAckFrame);
// Handshake
verify(frameWriter).writeSettings(eqCodecCtx(), anyHttp2Settings(), anyChannelPromise());
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project netty by netty.
the class Http2StreamChannelBootstrap method init.
private void init(Channel channel) {
ChannelPipeline p = channel.pipeline();
ChannelHandler handler = this.handler;
if (handler != null) {
p.addLast(handler);
}
final Map.Entry<ChannelOption<?>, Object>[] optionArray;
synchronized (options) {
optionArray = options.entrySet().toArray(EMPTY_OPTION_ARRAY);
}
setChannelOptions(channel, optionArray);
setAttributes(channel, attrs.entrySet().toArray(EMPTY_ATTRIBUTE_ARRAY));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project netty by netty.
the class ServerBootstrap method init.
@Override
void init(Channel channel) {
setChannelOptions(channel, newOptionsArray(), logger);
setAttributes(channel, newAttributesArray());
ChannelPipeline p = channel.pipeline();
final EventLoopGroup currentChildGroup = childGroup;
final ChannelHandler currentChildHandler = childHandler;
final Entry<ChannelOption<?>, Object>[] currentChildOptions = newOptionsArray(childOptions);
final Entry<AttributeKey<?>, Object>[] currentChildAttrs = newAttributesArray(childAttrs);
p.addLast(new ChannelInitializer<Channel>() {
@Override
public void initChannel(final Channel ch) {
final ChannelPipeline pipeline = ch.pipeline();
ChannelHandler handler = config.handler();
if (handler != null) {
pipeline.addLast(handler);
}
ch.eventLoop().execute(new Runnable() {
@Override
public void run() {
pipeline.addLast(new ServerBootstrapAcceptor(ch, currentChildGroup, currentChildHandler, currentChildOptions, currentChildAttrs));
}
});
}
});
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project netty by netty.
the class UdtNetty method main.
public static void main(final String[] args) throws Exception {
log.info("init");
TrafficControl.delay(0);
final AtomicBoolean isOn = new AtomicBoolean(true);
final InetSocketAddress addr1 = UnitHelp.localSocketAddress();
final InetSocketAddress addr2 = UnitHelp.localSocketAddress();
final ChannelHandler handler1 = new EchoMessageHandler(rate, size);
final ChannelHandler handler2 = new EchoMessageHandler(null, size);
final NioEventLoopGroup group1 = new NioEventLoopGroup(1, Executors.defaultThreadFactory(), NioUdtProvider.MESSAGE_PROVIDER);
final NioEventLoopGroup group2 = new NioEventLoopGroup(1, Executors.defaultThreadFactory(), NioUdtProvider.MESSAGE_PROVIDER);
final Bootstrap peerBoot1 = new Bootstrap();
peerBoot1.group(group1).channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS).localAddress(addr1).remoteAddress(addr2).handler(handler1);
final Bootstrap peerBoot2 = new Bootstrap();
peerBoot2.group(group2).channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS).localAddress(addr2).remoteAddress(addr1).handler(handler2);
final ChannelFuture peerFuture1 = peerBoot1.connect();
final ChannelFuture peerFuture2 = peerBoot2.connect();
CustomReporter.enable(3, TimeUnit.SECONDS);
Thread.sleep(time);
isOn.set(false);
Thread.sleep(1000);
peerFuture1.channel().close().sync();
peerFuture2.channel().close().sync();
Thread.sleep(1000);
group1.shutdownGracefully();
group2.shutdownGracefully();
Metrics.defaultRegistry().shutdown();
TrafficControl.delay(0);
log.info("done");
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project netty by netty.
the class AbstractBootstrapConfig method toString.
@Override
public String toString() {
StringBuilder buf = new StringBuilder().append(StringUtil.simpleClassName(this)).append('(');
EventLoopGroup group = group();
if (group != null) {
buf.append("group: ").append(StringUtil.simpleClassName(group)).append(", ");
}
@SuppressWarnings("deprecation") ChannelFactory<? extends C> factory = channelFactory();
if (factory != null) {
buf.append("channelFactory: ").append(factory).append(", ");
}
SocketAddress localAddress = localAddress();
if (localAddress != null) {
buf.append("localAddress: ").append(localAddress).append(", ");
}
Map<ChannelOption<?>, Object> options = options();
if (!options.isEmpty()) {
buf.append("options: ").append(options).append(", ");
}
Map<AttributeKey<?>, Object> attrs = attrs();
if (!attrs.isEmpty()) {
buf.append("attrs: ").append(attrs).append(", ");
}
ChannelHandler handler = handler();
if (handler != null) {
buf.append("handler: ").append(handler).append(", ");
}
if (buf.charAt(buf.length() - 1) == '(') {
buf.append(')');
} else {
buf.setCharAt(buf.length() - 2, ')');
buf.setLength(buf.length() - 1);
}
return buf.toString();
}
Aggregations