use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelException in project flink by apache.
the class NettyClient method connect.
// ------------------------------------------------------------------------
// Client connections
// ------------------------------------------------------------------------
ChannelFuture connect(final InetSocketAddress serverSocketAddress) {
checkState(bootstrap != null, "Client has not been initialized yet.");
// --------------------------------------------------------------------
// Child channel pipeline for accepted connections
// --------------------------------------------------------------------
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel channel) throws Exception {
// SSL handler should be added first in the pipeline
if (clientSSLFactory != null) {
SslHandler sslHandler = clientSSLFactory.createNettySSLHandler(channel.alloc(), serverSocketAddress.getAddress().getCanonicalHostName(), serverSocketAddress.getPort());
channel.pipeline().addLast("ssl", sslHandler);
}
channel.pipeline().addLast(protocol.getClientChannelHandlers());
}
});
try {
return bootstrap.connect(serverSocketAddress);
} catch (ChannelException e) {
if ((e.getCause() instanceof java.net.SocketException && e.getCause().getMessage().equals("Too many open files")) || (e.getCause() instanceof ChannelException && e.getCause().getCause() instanceof java.net.SocketException && e.getCause().getCause().getMessage().equals("Too many open files"))) {
throw new ChannelException("The operating system does not offer enough file handles to open the network connection. " + "Please increase the number of available file handles.", e.getCause());
} else {
throw e;
}
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelException in project netty by netty.
the class LocalChannelRegistry method register.
static LocalAddress register(Channel channel, LocalAddress oldLocalAddress, SocketAddress localAddress) {
if (oldLocalAddress != null) {
throw new ChannelException("already bound");
}
if (!(localAddress instanceof LocalAddress)) {
throw new ChannelException("unsupported address type: " + StringUtil.simpleClassName(localAddress));
}
LocalAddress addr = (LocalAddress) localAddress;
if (LocalAddress.ANY.equals(addr)) {
addr = new LocalAddress(channel);
}
Channel boundChannel = boundChannels.putIfAbsent(addr, channel);
if (boundChannel != null) {
throw new ChannelException("address already in use by: " + boundChannel);
}
return addr;
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelException in project netty by netty.
the class DiskAttribute method replace.
@Override
public Attribute replace(ByteBuf content) {
DiskAttribute attr = new DiskAttribute(getName(), baseDir, deleteOnExit);
attr.setCharset(getCharset());
if (content != null) {
try {
attr.setContent(content);
} catch (IOException e) {
throw new ChannelException(e);
}
}
return attr;
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelException in project netty by netty.
the class MemoryAttribute method replace.
@Override
public Attribute replace(ByteBuf content) {
MemoryAttribute attr = new MemoryAttribute(getName());
attr.setCharset(getCharset());
if (content != null) {
try {
attr.setContent(content);
} catch (IOException e) {
throw new ChannelException(e);
}
}
return attr;
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelException in project netty by netty.
the class NioUdtMessageConnectorChannel method doReadMessages.
@Override
protected int doReadMessages(List<Object> buf) throws Exception {
final int maximumMessageSize = config.getReceiveBufferSize();
final ByteBuf byteBuf = config.getAllocator().directBuffer(maximumMessageSize);
final int receivedMessageSize = byteBuf.writeBytes(javaChannel(), maximumMessageSize);
if (receivedMessageSize <= 0) {
byteBuf.release();
return 0;
}
if (receivedMessageSize >= maximumMessageSize) {
javaChannel().close();
throw new ChannelException("Invalid config : increase receive buffer size to avoid message truncation");
}
// delivers a message
buf.add(new UdtMessage(byteBuf));
return 1;
}
Aggregations