private void rethrow() { if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } if (cause instanceof Error) { throw (Error) cause; } throw new ChannelException(cause); } }
public void setReceiveBufferSize(int receiveBufferSize) { try { socket.setReceiveBufferSize(receiveBufferSize); } catch (SocketException e) { throw new ChannelException(e); } }
public void setSendBufferSize(int sendBufferSize) { try { socket.setSendBufferSize(sendBufferSize); } catch (SocketException e) { throw new ChannelException(e); } }
public NetworkInterface getNetworkInterface() { if (socket instanceof MulticastSocket) { try { return ((MulticastSocket) socket).getNetworkInterface(); } catch (SocketException e) { throw new ChannelException(e); } } else { throw new UnsupportedOperationException(); } }
public boolean isReuseAddress() { try { return socket.getReuseAddress(); } catch (SocketException e) { throw new ChannelException(e); } }
public void setReceiveBufferSize(int receiveBufferSize) { try { socket.setReceiveBufferSize(receiveBufferSize); } catch (SocketException e) { throw new ChannelException(e); } }
public void setTimeToLive(int ttl) { if (socket instanceof MulticastSocket) { try { ((MulticastSocket) socket).setTimeToLive(ttl); } catch (IOException e) { throw new ChannelException(e); } } else { throw new UnsupportedOperationException(); } }
public boolean isKeepAlive() { try { return socket.getKeepAlive(); } catch (SocketException e) { throw new ChannelException(e); } }
public void setTrafficClass(int trafficClass) { try { socket.setTrafficClass(trafficClass); } catch (SocketException e) { throw new ChannelException(e); } } }
public void setTrafficClass(int trafficClass) { try { socket.setTrafficClass(trafficClass); } catch (SocketException e) { throw new ChannelException(e); } }
public int getSoLinger() { try { return socket.getSoLinger(); } catch (SocketException e) { throw new ChannelException(e); } }
public void setReceiveBufferSize(int receiveBufferSize) { try { socket.setReceiveBufferSize(receiveBufferSize); } catch (SocketException e) { throw new ChannelException(e); } }
public void setInterface(InetAddress interfaceAddress) { if (socket instanceof MulticastSocket) { try { ((MulticastSocket) socket).setInterface(interfaceAddress); } catch (SocketException e) { throw new ChannelException(e); } } else { throw new UnsupportedOperationException(); } }
public void setSendBufferSize(int sendBufferSize) { try { socket.setSendBufferSize(sendBufferSize); } catch (SocketException e) { throw new ChannelException(e); } }
public int getTrafficClass() { try { return socket.getTrafficClass(); } catch (SocketException e) { throw new ChannelException(e); } }
@Override public NetworkInterface getNetworkInterface() { if (DetectionUtil.javaVersion() < 7) { throw new UnsupportedOperationException(); } else { try { return channel.getOption(StandardSocketOptions.IP_MULTICAST_IF); } catch (IOException e) { throw new ChannelException(e); } } }
@Override public boolean isLoopbackModeDisabled() { if (DetectionUtil.javaVersion() < 7) { throw new UnsupportedOperationException(); } else { try { return channel.getOption(StandardSocketOptions.IP_MULTICAST_LOOP); } catch (IOException e) { throw new ChannelException(e); } } }
@Override public void channelDisconnected(ChannelHandlerContext context, ChannelStateEvent event) { if (log.isDebugEnabled()) { log.debug("[%s] Channel disconnected", requestDesc); } // response is non-null if we received initial chunk and then exception occurs if (response != null) { handler.exceptionCaught(response, new ChannelException("Channel disconnected")); } channel.close(); channelResourceContainer.returnResource(); if (!retVal.isDone()) { log.warn("[%s] Channel disconnected before response complete", requestDesc); retVal.setException(new ChannelException("Channel disconnected")); } }
@Override public void operationComplete(ChannelFuture future) { if (!future.isSuccess()) { channel.close(); channelResourceContainer.returnResource(); if (!retVal.isDone()) { retVal.setException( new ChannelException( StringUtils.format("[%s] Failed to write request to channel", requestDesc), future.getCause() ) ); } } } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) { final Channel channel = ctx.getChannel(); if (channel == null) { // For the case where this pipeline is not attached yet. handshakeFuture.setFailure(new ChannelException( StringUtils.format("Channel is null. The context name is [%s]", ctx.getName()) )); return; } handshakeFuture.setFailure(e.getCause()); if (channel.isOpen()) { channel.close(); } } });