2009-06-11 02:48:49 +02:00
|
|
|
/*
|
2012-06-04 22:31:44 +02:00
|
|
|
* Copyright 2012 The Netty Project
|
2009-06-11 02:48:49 +02:00
|
|
|
*
|
2011-12-09 06:18:34 +01:00
|
|
|
* The Netty Project licenses this file to you under the Apache License,
|
|
|
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at:
|
2009-06-11 02:48:49 +02:00
|
|
|
*
|
2012-06-04 22:31:44 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-06-11 02:48:49 +02:00
|
|
|
*
|
2009-08-28 09:15:49 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
2011-12-09 06:18:34 +01:00
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
2009-08-28 09:15:49 +02:00
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2009-06-11 02:48:49 +02:00
|
|
|
*/
|
2011-12-09 04:38:59 +01:00
|
|
|
package io.netty.channel.socket.nio;
|
2009-06-11 02:48:49 +02:00
|
|
|
|
2012-06-10 04:08:43 +02:00
|
|
|
import io.netty.buffer.ByteBuf;
|
2013-05-01 10:04:43 +02:00
|
|
|
import io.netty.buffer.ByteBufHolder;
|
|
|
|
import io.netty.channel.AddressedEnvelope;
|
|
|
|
import io.netty.channel.Channel;
|
2012-02-18 23:02:56 +01:00
|
|
|
import io.netty.channel.ChannelException;
|
2012-03-20 09:43:00 +01:00
|
|
|
import io.netty.channel.ChannelFuture;
|
2012-06-19 03:39:30 +02:00
|
|
|
import io.netty.channel.ChannelMetadata;
|
2013-09-24 11:42:58 +02:00
|
|
|
import io.netty.channel.ChannelOption;
|
2013-08-16 21:53:47 +02:00
|
|
|
import io.netty.channel.ChannelOutboundBuffer;
|
2012-12-30 17:40:24 +01:00
|
|
|
import io.netty.channel.ChannelPromise;
|
Revamp the core API to reduce memory footprint and consumption
The API changes made so far turned out to increase the memory footprint
and consumption while our intention was actually decreasing them.
Memory consumption issue:
When there are many connections which does not exchange data frequently,
the old Netty 4 API spent a lot more memory than 3 because it always
allocates per-handler buffer for each connection unless otherwise
explicitly stated by a user. In a usual real world load, a client
doesn't always send requests without pausing, so the idea of having a
buffer whose life cycle if bound to the life cycle of a connection
didn't work as expected.
Memory footprint issue:
The old Netty 4 API decreased overall memory footprint by a great deal
in many cases. It was mainly because the old Netty 4 API did not
allocate a new buffer and event object for each read. Instead, it
created a new buffer for each handler in a pipeline. This works pretty
well as long as the number of handlers in a pipeline is only a few.
However, for a highly modular application with many handlers which
handles connections which lasts for relatively short period, it actually
makes the memory footprint issue much worse.
Changes:
All in all, this is about retaining all the good changes we made in 4 so
far such as better thread model and going back to the way how we dealt
with message events in 3.
To fix the memory consumption/footprint issue mentioned above, we made a
hard decision to break the backward compatibility again with the
following changes:
- Remove MessageBuf
- Merge Buf into ByteBuf
- Merge ChannelInboundByte/MessageHandler and ChannelStateHandler into ChannelInboundHandler
- Similar changes were made to the adapter classes
- Merge ChannelOutboundByte/MessageHandler and ChannelOperationHandler into ChannelOutboundHandler
- Similar changes were made to the adapter classes
- Introduce MessageList which is similar to `MessageEvent` in Netty 3
- Replace inboundBufferUpdated(ctx) with messageReceived(ctx, MessageList)
- Replace flush(ctx, promise) with write(ctx, MessageList, promise)
- Remove ByteToByteEncoder/Decoder/Codec
- Replaced by MessageToByteEncoder<ByteBuf>, ByteToMessageDecoder<ByteBuf>, and ByteMessageCodec<ByteBuf>
- Merge EmbeddedByteChannel and EmbeddedMessageChannel into EmbeddedChannel
- Add SimpleChannelInboundHandler which is sometimes more useful than
ChannelInboundHandlerAdapter
- Bring back Channel.isWritable() from Netty 3
- Add ChannelInboundHandler.channelWritabilityChanges() event
- Add RecvByteBufAllocator configuration property
- Similar to ReceiveBufferSizePredictor in Netty 3
- Some existing configuration properties such as
DatagramChannelConfig.receivePacketSize is gone now.
- Remove suspend/resumeIntermediaryDeallocation() in ByteBuf
This change would have been impossible without @normanmaurer's help. He
fixed, ported, and improved many parts of the changes.
2013-05-28 13:40:19 +02:00
|
|
|
import io.netty.channel.RecvByteBufAllocator;
|
2013-02-01 09:02:26 +01:00
|
|
|
import io.netty.channel.nio.AbstractNioMessageChannel;
|
2012-02-18 23:02:56 +01:00
|
|
|
import io.netty.channel.socket.DatagramChannelConfig;
|
2012-05-24 17:57:10 +02:00
|
|
|
import io.netty.channel.socket.DatagramPacket;
|
2012-05-31 11:49:39 +02:00
|
|
|
import io.netty.channel.socket.InternetProtocolFamily;
|
2013-01-11 06:03:27 +01:00
|
|
|
import io.netty.util.internal.PlatformDependent;
|
2013-05-01 10:04:43 +02:00
|
|
|
import io.netty.util.internal.StringUtil;
|
2009-06-11 02:48:49 +02:00
|
|
|
|
|
|
|
import java.io.IOException;
|
2009-06-11 08:10:46 +02:00
|
|
|
import java.net.InetAddress;
|
2009-06-11 02:48:49 +02:00
|
|
|
import java.net.InetSocketAddress;
|
2009-06-11 08:10:46 +02:00
|
|
|
import java.net.NetworkInterface;
|
2012-03-20 09:43:00 +01:00
|
|
|
import java.net.SocketAddress;
|
2012-04-02 11:07:11 +02:00
|
|
|
import java.net.SocketException;
|
2012-05-24 17:57:10 +02:00
|
|
|
import java.nio.ByteBuffer;
|
2009-06-11 02:48:49 +02:00
|
|
|
import java.nio.channels.DatagramChannel;
|
2012-04-02 11:07:11 +02:00
|
|
|
import java.nio.channels.MembershipKey;
|
2012-05-24 17:57:10 +02:00
|
|
|
import java.nio.channels.SelectionKey;
|
2014-03-13 06:46:05 +01:00
|
|
|
import java.nio.channels.spi.SelectorProvider;
|
2012-04-02 11:07:11 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2009-06-11 02:48:49 +02:00
|
|
|
|
|
|
|
/**
|
2013-05-01 10:04:43 +02:00
|
|
|
* An NIO datagram {@link Channel} that sends and receives an
|
|
|
|
* {@link AddressedEnvelope AddressedEnvelope<ByteBuf, SocketAddress>}.
|
|
|
|
*
|
|
|
|
* @see AddressedEnvelope
|
|
|
|
* @see DatagramPacket
|
2009-06-11 02:48:49 +02:00
|
|
|
*/
|
2012-06-08 12:28:12 +02:00
|
|
|
public final class NioDatagramChannel
|
|
|
|
extends AbstractNioMessageChannel implements io.netty.channel.socket.DatagramChannel {
|
2009-06-11 02:48:49 +02:00
|
|
|
|
Revamp the core API to reduce memory footprint and consumption
The API changes made so far turned out to increase the memory footprint
and consumption while our intention was actually decreasing them.
Memory consumption issue:
When there are many connections which does not exchange data frequently,
the old Netty 4 API spent a lot more memory than 3 because it always
allocates per-handler buffer for each connection unless otherwise
explicitly stated by a user. In a usual real world load, a client
doesn't always send requests without pausing, so the idea of having a
buffer whose life cycle if bound to the life cycle of a connection
didn't work as expected.
Memory footprint issue:
The old Netty 4 API decreased overall memory footprint by a great deal
in many cases. It was mainly because the old Netty 4 API did not
allocate a new buffer and event object for each read. Instead, it
created a new buffer for each handler in a pipeline. This works pretty
well as long as the number of handlers in a pipeline is only a few.
However, for a highly modular application with many handlers which
handles connections which lasts for relatively short period, it actually
makes the memory footprint issue much worse.
Changes:
All in all, this is about retaining all the good changes we made in 4 so
far such as better thread model and going back to the way how we dealt
with message events in 3.
To fix the memory consumption/footprint issue mentioned above, we made a
hard decision to break the backward compatibility again with the
following changes:
- Remove MessageBuf
- Merge Buf into ByteBuf
- Merge ChannelInboundByte/MessageHandler and ChannelStateHandler into ChannelInboundHandler
- Similar changes were made to the adapter classes
- Merge ChannelOutboundByte/MessageHandler and ChannelOperationHandler into ChannelOutboundHandler
- Similar changes were made to the adapter classes
- Introduce MessageList which is similar to `MessageEvent` in Netty 3
- Replace inboundBufferUpdated(ctx) with messageReceived(ctx, MessageList)
- Replace flush(ctx, promise) with write(ctx, MessageList, promise)
- Remove ByteToByteEncoder/Decoder/Codec
- Replaced by MessageToByteEncoder<ByteBuf>, ByteToMessageDecoder<ByteBuf>, and ByteMessageCodec<ByteBuf>
- Merge EmbeddedByteChannel and EmbeddedMessageChannel into EmbeddedChannel
- Add SimpleChannelInboundHandler which is sometimes more useful than
ChannelInboundHandlerAdapter
- Bring back Channel.isWritable() from Netty 3
- Add ChannelInboundHandler.channelWritabilityChanges() event
- Add RecvByteBufAllocator configuration property
- Similar to ReceiveBufferSizePredictor in Netty 3
- Some existing configuration properties such as
DatagramChannelConfig.receivePacketSize is gone now.
- Remove suspend/resumeIntermediaryDeallocation() in ByteBuf
This change would have been impossible without @normanmaurer's help. He
fixed, ported, and improved many parts of the changes.
2013-05-28 13:40:19 +02:00
|
|
|
private static final ChannelMetadata METADATA = new ChannelMetadata(true);
|
2014-03-23 10:09:41 +01:00
|
|
|
private static final SelectorProvider DEFAULT_SELECTOR_PROVIDER = SelectorProvider.provider();
|
2012-06-19 03:39:30 +02:00
|
|
|
|
2012-05-24 17:57:10 +02:00
|
|
|
private final DatagramChannelConfig config;
|
|
|
|
|
2014-04-15 06:40:15 +02:00
|
|
|
private Map<InetAddress, List<MembershipKey>> memberships;
|
Revamp the core API to reduce memory footprint and consumption
The API changes made so far turned out to increase the memory footprint
and consumption while our intention was actually decreasing them.
Memory consumption issue:
When there are many connections which does not exchange data frequently,
the old Netty 4 API spent a lot more memory than 3 because it always
allocates per-handler buffer for each connection unless otherwise
explicitly stated by a user. In a usual real world load, a client
doesn't always send requests without pausing, so the idea of having a
buffer whose life cycle if bound to the life cycle of a connection
didn't work as expected.
Memory footprint issue:
The old Netty 4 API decreased overall memory footprint by a great deal
in many cases. It was mainly because the old Netty 4 API did not
allocate a new buffer and event object for each read. Instead, it
created a new buffer for each handler in a pipeline. This works pretty
well as long as the number of handlers in a pipeline is only a few.
However, for a highly modular application with many handlers which
handles connections which lasts for relatively short period, it actually
makes the memory footprint issue much worse.
Changes:
All in all, this is about retaining all the good changes we made in 4 so
far such as better thread model and going back to the way how we dealt
with message events in 3.
To fix the memory consumption/footprint issue mentioned above, we made a
hard decision to break the backward compatibility again with the
following changes:
- Remove MessageBuf
- Merge Buf into ByteBuf
- Merge ChannelInboundByte/MessageHandler and ChannelStateHandler into ChannelInboundHandler
- Similar changes were made to the adapter classes
- Merge ChannelOutboundByte/MessageHandler and ChannelOperationHandler into ChannelOutboundHandler
- Similar changes were made to the adapter classes
- Introduce MessageList which is similar to `MessageEvent` in Netty 3
- Replace inboundBufferUpdated(ctx) with messageReceived(ctx, MessageList)
- Replace flush(ctx, promise) with write(ctx, MessageList, promise)
- Remove ByteToByteEncoder/Decoder/Codec
- Replaced by MessageToByteEncoder<ByteBuf>, ByteToMessageDecoder<ByteBuf>, and ByteMessageCodec<ByteBuf>
- Merge EmbeddedByteChannel and EmbeddedMessageChannel into EmbeddedChannel
- Add SimpleChannelInboundHandler which is sometimes more useful than
ChannelInboundHandlerAdapter
- Bring back Channel.isWritable() from Netty 3
- Add ChannelInboundHandler.channelWritabilityChanges() event
- Add RecvByteBufAllocator configuration property
- Similar to ReceiveBufferSizePredictor in Netty 3
- Some existing configuration properties such as
DatagramChannelConfig.receivePacketSize is gone now.
- Remove suspend/resumeIntermediaryDeallocation() in ByteBuf
This change would have been impossible without @normanmaurer's help. He
fixed, ported, and improved many parts of the changes.
2013-05-28 13:40:19 +02:00
|
|
|
private RecvByteBufAllocator.Handle allocHandle;
|
|
|
|
|
2014-03-23 10:09:41 +01:00
|
|
|
private static DatagramChannel newSocket(SelectorProvider provider) {
|
2012-05-24 17:57:10 +02:00
|
|
|
try {
|
2014-03-13 06:46:05 +01:00
|
|
|
/**
|
|
|
|
* Use the {@link SelectorProvider} to open {@link SocketChannel} and so remove condition in
|
|
|
|
* {@link SelectorProvider#provider()} which is called by each DatagramChannel.open() otherwise.
|
|
|
|
*
|
|
|
|
* See <a href="See https://github.com/netty/netty/issues/2308">#2308</a>.
|
|
|
|
*/
|
2014-03-23 10:09:41 +01:00
|
|
|
return provider.openDatagramChannel();
|
2012-05-24 17:57:10 +02:00
|
|
|
} catch (IOException e) {
|
|
|
|
throw new ChannelException("Failed to open a socket.", e);
|
|
|
|
}
|
2012-04-03 12:04:33 +02:00
|
|
|
}
|
2012-05-24 17:57:10 +02:00
|
|
|
|
2014-03-23 10:09:41 +01:00
|
|
|
private static DatagramChannel newSocket(SelectorProvider provider, InternetProtocolFamily ipFamily) {
|
2012-05-31 11:49:39 +02:00
|
|
|
if (ipFamily == null) {
|
2014-03-23 10:09:41 +01:00
|
|
|
return newSocket(provider);
|
2012-05-31 11:49:39 +02:00
|
|
|
}
|
|
|
|
|
2014-01-30 07:00:53 +01:00
|
|
|
checkJavaVersion();
|
2012-05-31 11:49:39 +02:00
|
|
|
|
|
|
|
try {
|
2014-03-23 10:09:41 +01:00
|
|
|
return provider.openDatagramChannel(ProtocolFamilyConverter.convert(ipFamily));
|
2012-05-31 11:49:39 +02:00
|
|
|
} catch (IOException e) {
|
|
|
|
throw new ChannelException("Failed to open a socket.", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-30 07:00:53 +01:00
|
|
|
private static void checkJavaVersion() {
|
|
|
|
if (PlatformDependent.javaVersion() < 7) {
|
|
|
|
throw new UnsupportedOperationException("Only supported on java 7+.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-23 19:24:20 +01:00
|
|
|
/**
|
|
|
|
* Create a new instance which will use the Operation Systems default {@link InternetProtocolFamily}.
|
|
|
|
*/
|
2012-05-24 17:57:10 +02:00
|
|
|
public NioDatagramChannel() {
|
2014-03-23 10:09:41 +01:00
|
|
|
this(newSocket(DEFAULT_SELECTOR_PROVIDER));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance using the given {@link SelectorProvider}
|
|
|
|
* which will use the Operation Systems default {@link InternetProtocolFamily}.
|
|
|
|
*/
|
|
|
|
public NioDatagramChannel(SelectorProvider provider) {
|
|
|
|
this(newSocket(provider));
|
2011-11-02 19:17:10 +01:00
|
|
|
}
|
|
|
|
|
2012-12-23 19:24:20 +01:00
|
|
|
/**
|
|
|
|
* Create a new instance using the given {@link InternetProtocolFamily}. If {@code null} is used it will depend
|
|
|
|
* on the Operation Systems default which will be chosen.
|
|
|
|
*/
|
2012-05-31 11:49:39 +02:00
|
|
|
public NioDatagramChannel(InternetProtocolFamily ipFamily) {
|
2014-03-23 10:09:41 +01:00
|
|
|
this(newSocket(DEFAULT_SELECTOR_PROVIDER, ipFamily));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance using the given {@link SelectorProvider} and {@link InternetProtocolFamily}.
|
|
|
|
* If {@link InternetProtocolFamily} is {@code null} it will depend on the Operation Systems default
|
|
|
|
* which will be chosen.
|
|
|
|
*/
|
|
|
|
public NioDatagramChannel(SelectorProvider provider, InternetProtocolFamily ipFamily) {
|
|
|
|
this(newSocket(provider, ipFamily));
|
2012-05-31 11:49:39 +02:00
|
|
|
}
|
|
|
|
|
2012-12-23 19:24:20 +01:00
|
|
|
/**
|
|
|
|
* Create a new instance from the given {@link DatagramChannel}.
|
|
|
|
*/
|
2012-05-24 17:57:10 +02:00
|
|
|
public NioDatagramChannel(DatagramChannel socket) {
|
2013-07-09 07:49:06 +02:00
|
|
|
super(null, socket, SelectionKey.OP_READ);
|
2013-01-01 08:49:21 +01:00
|
|
|
config = new NioDatagramChannelConfig(this, socket);
|
2009-06-11 02:48:49 +02:00
|
|
|
}
|
|
|
|
|
2012-06-19 03:39:30 +02:00
|
|
|
@Override
|
|
|
|
public ChannelMetadata metadata() {
|
|
|
|
return METADATA;
|
|
|
|
}
|
|
|
|
|
2012-05-24 17:57:10 +02:00
|
|
|
@Override
|
|
|
|
public DatagramChannelConfig config() {
|
|
|
|
return config;
|
|
|
|
}
|
2009-06-11 02:48:49 +02:00
|
|
|
|
2012-03-29 17:07:19 +02:00
|
|
|
@Override
|
2014-07-02 12:04:11 +02:00
|
|
|
@SuppressWarnings("deprecation")
|
2012-05-24 17:57:10 +02:00
|
|
|
public boolean isActive() {
|
|
|
|
DatagramChannel ch = javaChannel();
|
2013-09-24 11:42:58 +02:00
|
|
|
return ch.isOpen() && (
|
2014-07-02 12:04:11 +02:00
|
|
|
config.getOption(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION) && isRegistered()
|
2013-09-24 11:42:58 +02:00
|
|
|
|| ch.socket().isBound());
|
2012-03-29 17:07:19 +02:00
|
|
|
}
|
|
|
|
|
2012-06-19 03:43:38 +02:00
|
|
|
@Override
|
|
|
|
public boolean isConnected() {
|
|
|
|
return javaChannel().isConnected();
|
|
|
|
}
|
|
|
|
|
2012-03-06 19:26:32 +01:00
|
|
|
@Override
|
2012-05-24 17:57:10 +02:00
|
|
|
protected DatagramChannel javaChannel() {
|
|
|
|
return (DatagramChannel) super.javaChannel();
|
2012-03-06 19:26:32 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2012-05-24 17:57:10 +02:00
|
|
|
protected SocketAddress localAddress0() {
|
|
|
|
return javaChannel().socket().getLocalSocketAddress();
|
2009-06-11 02:48:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-05-24 17:57:10 +02:00
|
|
|
protected SocketAddress remoteAddress0() {
|
|
|
|
return javaChannel().socket().getRemoteSocketAddress();
|
2009-06-11 02:48:49 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2012-05-24 17:57:10 +02:00
|
|
|
protected void doBind(SocketAddress localAddress) throws Exception {
|
2012-05-24 18:32:14 +02:00
|
|
|
javaChannel().socket().bind(localAddress);
|
2012-05-24 17:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean doConnect(SocketAddress remoteAddress,
|
|
|
|
SocketAddress localAddress) throws Exception {
|
|
|
|
if (localAddress != null) {
|
|
|
|
javaChannel().socket().bind(localAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean success = false;
|
|
|
|
try {
|
|
|
|
javaChannel().connect(remoteAddress);
|
|
|
|
success = true;
|
|
|
|
return true;
|
|
|
|
} finally {
|
|
|
|
if (!success) {
|
|
|
|
doClose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void doFinishConnect() throws Exception {
|
|
|
|
throw new Error();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void doDisconnect() throws Exception {
|
|
|
|
javaChannel().disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void doClose() throws Exception {
|
|
|
|
javaChannel().close();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
Remove MessageList from public API and change ChannelInbound/OutboundHandler accordingly
I must admit MesageList was pain in the ass. Instead of forcing a
handler always loop over the list of messages, this commit splits
messageReceived(ctx, list) into two event handlers:
- messageReceived(ctx, msg)
- mmessageReceivedLast(ctx)
When Netty reads one or more messages, messageReceived(ctx, msg) event
is triggered for each message. Once the current read operation is
finished, messageReceivedLast() is triggered to tell the handler that
the last messageReceived() was the last message in the current batch.
Similarly, for outbound, write(ctx, list) has been split into two:
- write(ctx, msg)
- flush(ctx, promise)
Instead of writing a list of message with a promise, a user is now
supposed to call write(msg) multiple times and then call flush() to
actually flush the buffered messages.
Please note that write() doesn't have a promise with it. You must call
flush() to get notified on completion. (or you can use writeAndFlush())
Other changes:
- Because MessageList is completely hidden, codec framework uses
List<Object> instead of MessageList as an output parameter.
2013-07-08 12:03:40 +02:00
|
|
|
protected int doReadMessages(List<Object> buf) throws Exception {
|
2012-05-24 17:57:10 +02:00
|
|
|
DatagramChannel ch = javaChannel();
|
Revamp the core API to reduce memory footprint and consumption
The API changes made so far turned out to increase the memory footprint
and consumption while our intention was actually decreasing them.
Memory consumption issue:
When there are many connections which does not exchange data frequently,
the old Netty 4 API spent a lot more memory than 3 because it always
allocates per-handler buffer for each connection unless otherwise
explicitly stated by a user. In a usual real world load, a client
doesn't always send requests without pausing, so the idea of having a
buffer whose life cycle if bound to the life cycle of a connection
didn't work as expected.
Memory footprint issue:
The old Netty 4 API decreased overall memory footprint by a great deal
in many cases. It was mainly because the old Netty 4 API did not
allocate a new buffer and event object for each read. Instead, it
created a new buffer for each handler in a pipeline. This works pretty
well as long as the number of handlers in a pipeline is only a few.
However, for a highly modular application with many handlers which
handles connections which lasts for relatively short period, it actually
makes the memory footprint issue much worse.
Changes:
All in all, this is about retaining all the good changes we made in 4 so
far such as better thread model and going back to the way how we dealt
with message events in 3.
To fix the memory consumption/footprint issue mentioned above, we made a
hard decision to break the backward compatibility again with the
following changes:
- Remove MessageBuf
- Merge Buf into ByteBuf
- Merge ChannelInboundByte/MessageHandler and ChannelStateHandler into ChannelInboundHandler
- Similar changes were made to the adapter classes
- Merge ChannelOutboundByte/MessageHandler and ChannelOperationHandler into ChannelOutboundHandler
- Similar changes were made to the adapter classes
- Introduce MessageList which is similar to `MessageEvent` in Netty 3
- Replace inboundBufferUpdated(ctx) with messageReceived(ctx, MessageList)
- Replace flush(ctx, promise) with write(ctx, MessageList, promise)
- Remove ByteToByteEncoder/Decoder/Codec
- Replaced by MessageToByteEncoder<ByteBuf>, ByteToMessageDecoder<ByteBuf>, and ByteMessageCodec<ByteBuf>
- Merge EmbeddedByteChannel and EmbeddedMessageChannel into EmbeddedChannel
- Add SimpleChannelInboundHandler which is sometimes more useful than
ChannelInboundHandlerAdapter
- Bring back Channel.isWritable() from Netty 3
- Add ChannelInboundHandler.channelWritabilityChanges() event
- Add RecvByteBufAllocator configuration property
- Similar to ReceiveBufferSizePredictor in Netty 3
- Some existing configuration properties such as
DatagramChannelConfig.receivePacketSize is gone now.
- Remove suspend/resumeIntermediaryDeallocation() in ByteBuf
This change would have been impossible without @normanmaurer's help. He
fixed, ported, and improved many parts of the changes.
2013-05-28 13:40:19 +02:00
|
|
|
DatagramChannelConfig config = config();
|
|
|
|
RecvByteBufAllocator.Handle allocHandle = this.allocHandle;
|
|
|
|
if (allocHandle == null) {
|
|
|
|
this.allocHandle = allocHandle = config.getRecvByteBufAllocator().newHandle();
|
|
|
|
}
|
|
|
|
ByteBuf data = allocHandle.allocate(config.getAllocator());
|
2013-01-01 16:03:18 +01:00
|
|
|
boolean free = true;
|
|
|
|
try {
|
2013-10-16 09:53:26 +02:00
|
|
|
ByteBuffer nioData = data.internalNioBuffer(data.writerIndex(), data.writableBytes());
|
|
|
|
int pos = nioData.position();
|
2013-05-01 10:04:43 +02:00
|
|
|
InetSocketAddress remoteAddress = (InetSocketAddress) ch.receive(nioData);
|
2013-01-01 16:03:18 +01:00
|
|
|
if (remoteAddress == null) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-05-01 10:04:43 +02:00
|
|
|
|
2013-10-16 09:53:26 +02:00
|
|
|
int readBytes = nioData.position() - pos;
|
Revamp the core API to reduce memory footprint and consumption
The API changes made so far turned out to increase the memory footprint
and consumption while our intention was actually decreasing them.
Memory consumption issue:
When there are many connections which does not exchange data frequently,
the old Netty 4 API spent a lot more memory than 3 because it always
allocates per-handler buffer for each connection unless otherwise
explicitly stated by a user. In a usual real world load, a client
doesn't always send requests without pausing, so the idea of having a
buffer whose life cycle if bound to the life cycle of a connection
didn't work as expected.
Memory footprint issue:
The old Netty 4 API decreased overall memory footprint by a great deal
in many cases. It was mainly because the old Netty 4 API did not
allocate a new buffer and event object for each read. Instead, it
created a new buffer for each handler in a pipeline. This works pretty
well as long as the number of handlers in a pipeline is only a few.
However, for a highly modular application with many handlers which
handles connections which lasts for relatively short period, it actually
makes the memory footprint issue much worse.
Changes:
All in all, this is about retaining all the good changes we made in 4 so
far such as better thread model and going back to the way how we dealt
with message events in 3.
To fix the memory consumption/footprint issue mentioned above, we made a
hard decision to break the backward compatibility again with the
following changes:
- Remove MessageBuf
- Merge Buf into ByteBuf
- Merge ChannelInboundByte/MessageHandler and ChannelStateHandler into ChannelInboundHandler
- Similar changes were made to the adapter classes
- Merge ChannelOutboundByte/MessageHandler and ChannelOperationHandler into ChannelOutboundHandler
- Similar changes were made to the adapter classes
- Introduce MessageList which is similar to `MessageEvent` in Netty 3
- Replace inboundBufferUpdated(ctx) with messageReceived(ctx, MessageList)
- Replace flush(ctx, promise) with write(ctx, MessageList, promise)
- Remove ByteToByteEncoder/Decoder/Codec
- Replaced by MessageToByteEncoder<ByteBuf>, ByteToMessageDecoder<ByteBuf>, and ByteMessageCodec<ByteBuf>
- Merge EmbeddedByteChannel and EmbeddedMessageChannel into EmbeddedChannel
- Add SimpleChannelInboundHandler which is sometimes more useful than
ChannelInboundHandlerAdapter
- Bring back Channel.isWritable() from Netty 3
- Add ChannelInboundHandler.channelWritabilityChanges() event
- Add RecvByteBufAllocator configuration property
- Similar to ReceiveBufferSizePredictor in Netty 3
- Some existing configuration properties such as
DatagramChannelConfig.receivePacketSize is gone now.
- Remove suspend/resumeIntermediaryDeallocation() in ByteBuf
This change would have been impossible without @normanmaurer's help. He
fixed, ported, and improved many parts of the changes.
2013-05-28 13:40:19 +02:00
|
|
|
data.writerIndex(data.writerIndex() + readBytes);
|
|
|
|
allocHandle.record(readBytes);
|
|
|
|
|
2013-05-01 10:04:43 +02:00
|
|
|
buf.add(new DatagramPacket(data, localAddress(), remoteAddress));
|
2013-01-01 16:03:18 +01:00
|
|
|
free = false;
|
|
|
|
return 1;
|
|
|
|
} catch (Throwable cause) {
|
2013-03-05 21:41:19 +01:00
|
|
|
PlatformDependent.throwException(cause);
|
|
|
|
return -1;
|
2013-01-01 16:03:18 +01:00
|
|
|
} finally {
|
|
|
|
if (free) {
|
2013-05-01 10:04:43 +02:00
|
|
|
data.release();
|
2013-01-01 16:03:18 +01:00
|
|
|
}
|
|
|
|
}
|
2012-05-24 17:57:10 +02:00
|
|
|
}
|
|
|
|
|
2012-05-25 15:16:25 +02:00
|
|
|
@Override
|
2013-08-16 21:53:47 +02:00
|
|
|
protected boolean doWriteMessage(Object msg, ChannelOutboundBuffer in) throws Exception {
|
2013-05-01 10:04:43 +02:00
|
|
|
final Object m;
|
|
|
|
final SocketAddress remoteAddress;
|
2013-08-16 21:53:47 +02:00
|
|
|
ByteBuf data;
|
2013-07-18 13:59:14 +02:00
|
|
|
if (msg instanceof AddressedEnvelope) {
|
2013-05-01 10:04:43 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
2013-07-18 13:59:14 +02:00
|
|
|
AddressedEnvelope<Object, SocketAddress> envelope = (AddressedEnvelope<Object, SocketAddress>) msg;
|
2013-05-01 10:04:43 +02:00
|
|
|
remoteAddress = envelope.recipient();
|
|
|
|
m = envelope.content();
|
|
|
|
} else {
|
2013-07-18 13:59:14 +02:00
|
|
|
m = msg;
|
2013-05-01 10:04:43 +02:00
|
|
|
remoteAddress = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m instanceof ByteBufHolder) {
|
|
|
|
data = ((ByteBufHolder) m).content();
|
|
|
|
} else if (m instanceof ByteBuf) {
|
|
|
|
data = (ByteBuf) m;
|
|
|
|
} else {
|
2013-07-18 13:59:14 +02:00
|
|
|
throw new UnsupportedOperationException("unsupported message type: " + StringUtil.simpleClassName(msg));
|
2013-05-01 10:04:43 +02:00
|
|
|
}
|
|
|
|
|
2012-08-30 07:04:13 +02:00
|
|
|
int dataLen = data.readableBytes();
|
2013-07-18 13:59:14 +02:00
|
|
|
if (dataLen == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:08:20 +01:00
|
|
|
ByteBuffer nioData = data.nioBuffer();
|
2012-06-02 10:30:55 +02:00
|
|
|
|
2013-05-01 10:04:43 +02:00
|
|
|
final int writtenBytes;
|
|
|
|
if (remoteAddress != null) {
|
|
|
|
writtenBytes = javaChannel().send(nioData, remoteAddress);
|
|
|
|
} else {
|
|
|
|
writtenBytes = javaChannel().write(nioData);
|
|
|
|
}
|
2012-05-24 17:57:10 +02:00
|
|
|
|
2014-07-02 12:04:11 +02:00
|
|
|
return writtenBytes > 0;
|
2009-06-11 02:48:49 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2013-02-01 09:02:26 +01:00
|
|
|
public InetSocketAddress localAddress() {
|
|
|
|
return (InetSocketAddress) super.localAddress();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public InetSocketAddress remoteAddress() {
|
|
|
|
return (InetSocketAddress) super.remoteAddress();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-04-02 11:57:32 +02:00
|
|
|
public ChannelFuture joinGroup(InetAddress multicastAddress) {
|
2012-12-30 17:40:24 +01:00
|
|
|
return joinGroup(multicastAddress, newPromise());
|
2012-05-24 17:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-12-30 17:40:24 +01:00
|
|
|
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
2012-05-24 17:57:10 +02:00
|
|
|
try {
|
|
|
|
return joinGroup(
|
|
|
|
multicastAddress,
|
|
|
|
NetworkInterface.getByInetAddress(localAddress().getAddress()),
|
2012-12-30 17:40:24 +01:00
|
|
|
null, promise);
|
2012-04-02 11:07:11 +02:00
|
|
|
} catch (SocketException e) {
|
2012-12-30 17:40:24 +01:00
|
|
|
promise.setFailure(e);
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
2012-12-30 17:40:24 +01:00
|
|
|
return promise;
|
2009-06-11 08:10:46 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2012-05-24 17:57:10 +02:00
|
|
|
public ChannelFuture joinGroup(
|
|
|
|
InetSocketAddress multicastAddress, NetworkInterface networkInterface) {
|
2012-12-30 17:40:24 +01:00
|
|
|
return joinGroup(multicastAddress, networkInterface, newPromise());
|
2009-06-11 08:10:46 +02:00
|
|
|
}
|
|
|
|
|
2012-05-24 17:57:10 +02:00
|
|
|
@Override
|
|
|
|
public ChannelFuture joinGroup(
|
|
|
|
InetSocketAddress multicastAddress, NetworkInterface networkInterface,
|
2012-12-30 17:40:24 +01:00
|
|
|
ChannelPromise promise) {
|
|
|
|
return joinGroup(multicastAddress.getAddress(), networkInterface, null, promise);
|
2012-05-24 17:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ChannelFuture joinGroup(
|
|
|
|
InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) {
|
2012-12-30 17:40:24 +01:00
|
|
|
return joinGroup(multicastAddress, networkInterface, source, newPromise());
|
2012-05-24 17:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ChannelFuture joinGroup(
|
|
|
|
InetAddress multicastAddress, NetworkInterface networkInterface,
|
2012-12-30 17:40:24 +01:00
|
|
|
InetAddress source, ChannelPromise promise) {
|
2012-05-24 17:57:10 +02:00
|
|
|
|
2014-01-30 07:00:53 +01:00
|
|
|
checkJavaVersion();
|
2012-05-24 17:57:10 +02:00
|
|
|
|
2014-01-30 07:00:53 +01:00
|
|
|
if (multicastAddress == null) {
|
|
|
|
throw new NullPointerException("multicastAddress");
|
|
|
|
}
|
2012-04-02 15:25:40 +02:00
|
|
|
|
2014-01-30 07:00:53 +01:00
|
|
|
if (networkInterface == null) {
|
|
|
|
throw new NullPointerException("networkInterface");
|
|
|
|
}
|
2012-05-24 17:57:10 +02:00
|
|
|
|
2014-01-30 07:00:53 +01:00
|
|
|
try {
|
|
|
|
MembershipKey key;
|
|
|
|
if (source == null) {
|
|
|
|
key = javaChannel().join(multicastAddress, networkInterface);
|
|
|
|
} else {
|
|
|
|
key = javaChannel().join(multicastAddress, networkInterface, source);
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
2014-01-30 07:00:53 +01:00
|
|
|
|
|
|
|
synchronized (this) {
|
2014-04-15 06:40:15 +02:00
|
|
|
List<MembershipKey> keys = null;
|
|
|
|
if (memberships == null) {
|
|
|
|
memberships = new HashMap<InetAddress, List<MembershipKey>>();
|
|
|
|
} else {
|
|
|
|
keys = memberships.get(multicastAddress);
|
|
|
|
}
|
2014-01-30 07:00:53 +01:00
|
|
|
if (keys == null) {
|
|
|
|
keys = new ArrayList<MembershipKey>();
|
|
|
|
memberships.put(multicastAddress, keys);
|
|
|
|
}
|
|
|
|
keys.add(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
promise.setSuccess();
|
|
|
|
} catch (Throwable e) {
|
|
|
|
promise.setFailure(e);
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
2014-01-30 07:00:53 +01:00
|
|
|
|
2012-12-30 17:40:24 +01:00
|
|
|
return promise;
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
2012-05-24 17:57:10 +02:00
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2012-04-02 11:57:32 +02:00
|
|
|
public ChannelFuture leaveGroup(InetAddress multicastAddress) {
|
2012-12-30 17:40:24 +01:00
|
|
|
return leaveGroup(multicastAddress, newPromise());
|
2012-05-24 17:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-12-30 17:40:24 +01:00
|
|
|
public ChannelFuture leaveGroup(InetAddress multicastAddress, ChannelPromise promise) {
|
2012-04-02 11:07:11 +02:00
|
|
|
try {
|
2012-06-08 12:28:12 +02:00
|
|
|
return leaveGroup(
|
2012-12-30 17:40:24 +01:00
|
|
|
multicastAddress, NetworkInterface.getByInetAddress(localAddress().getAddress()), null, promise);
|
2012-04-02 11:07:11 +02:00
|
|
|
} catch (SocketException e) {
|
2012-12-30 17:40:24 +01:00
|
|
|
promise.setFailure(e);
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
2012-12-30 17:40:24 +01:00
|
|
|
return promise;
|
2009-06-11 08:10:46 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2012-05-24 17:57:10 +02:00
|
|
|
public ChannelFuture leaveGroup(
|
|
|
|
InetSocketAddress multicastAddress, NetworkInterface networkInterface) {
|
2012-12-30 17:40:24 +01:00
|
|
|
return leaveGroup(multicastAddress, networkInterface, newPromise());
|
2009-06-11 08:10:46 +02:00
|
|
|
}
|
2012-02-18 23:02:56 +01:00
|
|
|
|
2012-05-24 17:57:10 +02:00
|
|
|
@Override
|
|
|
|
public ChannelFuture leaveGroup(
|
|
|
|
InetSocketAddress multicastAddress,
|
2012-12-30 17:40:24 +01:00
|
|
|
NetworkInterface networkInterface, ChannelPromise promise) {
|
|
|
|
return leaveGroup(multicastAddress.getAddress(), networkInterface, null, promise);
|
2012-05-24 17:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ChannelFuture leaveGroup(
|
|
|
|
InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) {
|
2012-12-30 17:40:24 +01:00
|
|
|
return leaveGroup(multicastAddress, networkInterface, source, newPromise());
|
2012-05-24 17:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ChannelFuture leaveGroup(
|
|
|
|
InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source,
|
2012-12-30 17:40:24 +01:00
|
|
|
ChannelPromise promise) {
|
2014-01-30 07:00:53 +01:00
|
|
|
checkJavaVersion();
|
|
|
|
|
2012-05-24 17:57:10 +02:00
|
|
|
if (multicastAddress == null) {
|
|
|
|
throw new NullPointerException("multicastAddress");
|
|
|
|
}
|
|
|
|
if (networkInterface == null) {
|
|
|
|
throw new NullPointerException("networkInterface");
|
|
|
|
}
|
|
|
|
|
|
|
|
synchronized (this) {
|
|
|
|
if (memberships != null) {
|
|
|
|
List<MembershipKey> keys = memberships.get(multicastAddress);
|
|
|
|
if (keys != null) {
|
|
|
|
Iterator<MembershipKey> keyIt = keys.iterator();
|
|
|
|
|
|
|
|
while (keyIt.hasNext()) {
|
|
|
|
MembershipKey key = keyIt.next();
|
|
|
|
if (networkInterface.equals(key.networkInterface())) {
|
2012-06-08 12:28:12 +02:00
|
|
|
if (source == null && key.sourceAddress() == null ||
|
|
|
|
source != null && source.equals(key.sourceAddress())) {
|
2012-05-24 17:57:10 +02:00
|
|
|
key.drop();
|
|
|
|
keyIt.remove();
|
|
|
|
}
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
|
|
|
}
|
2012-05-24 17:57:10 +02:00
|
|
|
if (keys.isEmpty()) {
|
|
|
|
memberships.remove(multicastAddress);
|
|
|
|
}
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-24 17:57:10 +02:00
|
|
|
|
2012-12-30 17:40:24 +01:00
|
|
|
promise.setSuccess();
|
|
|
|
return promise;
|
2012-05-24 17:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Block the given sourceToBlock address for the given multicastAddress on the given networkInterface
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public ChannelFuture block(
|
|
|
|
InetAddress multicastAddress, NetworkInterface networkInterface,
|
|
|
|
InetAddress sourceToBlock) {
|
2012-12-30 17:40:24 +01:00
|
|
|
return block(multicastAddress, networkInterface, sourceToBlock, newPromise());
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
2012-05-24 17:57:10 +02:00
|
|
|
|
2012-04-02 11:07:11 +02:00
|
|
|
/**
|
|
|
|
* Block the given sourceToBlock address for the given multicastAddress on the given networkInterface
|
|
|
|
*/
|
2012-05-24 17:57:10 +02:00
|
|
|
@Override
|
|
|
|
public ChannelFuture block(
|
|
|
|
InetAddress multicastAddress, NetworkInterface networkInterface,
|
2012-12-30 17:40:24 +01:00
|
|
|
InetAddress sourceToBlock, ChannelPromise promise) {
|
2014-01-30 07:00:53 +01:00
|
|
|
checkJavaVersion();
|
2012-05-24 17:57:10 +02:00
|
|
|
|
2014-01-30 07:00:53 +01:00
|
|
|
if (multicastAddress == null) {
|
|
|
|
throw new NullPointerException("multicastAddress");
|
|
|
|
}
|
|
|
|
if (sourceToBlock == null) {
|
|
|
|
throw new NullPointerException("sourceToBlock");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (networkInterface == null) {
|
|
|
|
throw new NullPointerException("networkInterface");
|
|
|
|
}
|
|
|
|
synchronized (this) {
|
|
|
|
if (memberships != null) {
|
|
|
|
List<MembershipKey> keys = memberships.get(multicastAddress);
|
|
|
|
for (MembershipKey key: keys) {
|
|
|
|
if (networkInterface.equals(key.networkInterface())) {
|
|
|
|
try {
|
|
|
|
key.block(sourceToBlock);
|
|
|
|
} catch (IOException e) {
|
|
|
|
promise.setFailure(e);
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-30 07:00:53 +01:00
|
|
|
promise.setSuccess();
|
|
|
|
return promise;
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
2012-05-24 17:57:10 +02:00
|
|
|
|
2012-04-02 11:07:11 +02:00
|
|
|
/**
|
|
|
|
* Block the given sourceToBlock address for the given multicastAddress
|
2012-05-24 17:57:10 +02:00
|
|
|
*
|
2012-04-02 11:07:11 +02:00
|
|
|
*/
|
2012-05-24 17:57:10 +02:00
|
|
|
@Override
|
2012-04-02 11:57:32 +02:00
|
|
|
public ChannelFuture block(InetAddress multicastAddress, InetAddress sourceToBlock) {
|
2012-12-30 17:40:24 +01:00
|
|
|
return block(multicastAddress, sourceToBlock, newPromise());
|
2012-04-02 11:07:11 +02:00
|
|
|
}
|
2012-05-24 17:57:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Block the given sourceToBlock address for the given multicastAddress
|
|
|
|
*
|
|
|
|
*/
|
2012-03-20 09:43:00 +01:00
|
|
|
@Override
|
2012-05-24 17:57:10 +02:00
|
|
|
public ChannelFuture block(
|
2012-12-30 17:40:24 +01:00
|
|
|
InetAddress multicastAddress, InetAddress sourceToBlock, ChannelPromise promise) {
|
2012-05-24 17:57:10 +02:00
|
|
|
try {
|
|
|
|
return block(
|
|
|
|
multicastAddress,
|
|
|
|
NetworkInterface.getByInetAddress(localAddress().getAddress()),
|
2012-12-30 17:40:24 +01:00
|
|
|
sourceToBlock, promise);
|
2012-05-24 17:57:10 +02:00
|
|
|
} catch (SocketException e) {
|
2012-12-30 17:40:24 +01:00
|
|
|
promise.setFailure(e);
|
2012-03-20 09:43:00 +01:00
|
|
|
}
|
2012-12-30 17:40:24 +01:00
|
|
|
return promise;
|
2012-03-20 09:43:00 +01:00
|
|
|
}
|
2014-02-18 10:08:20 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected ChannelOutboundBuffer newOutboundBuffer() {
|
|
|
|
return NioDatagramChannelOutboundBuffer.newInstance(this);
|
|
|
|
}
|
2014-04-10 08:27:27 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void setReadPending(boolean readPending) {
|
|
|
|
super.setReadPending(readPending);
|
|
|
|
}
|
2009-06-11 02:48:49 +02:00
|
|
|
}
|