Example usage for io.netty.channel ChannelException ChannelException

List of usage examples for io.netty.channel ChannelException ChannelException

Introduction

In this page you can find the example usage for io.netty.channel ChannelException ChannelException.

Prototype

public ChannelException(String message, Throwable cause) 

Source Link

Document

Creates a new exception.

Usage

From source file:com.leekli.demo.utils.ReflectiveChannelFactory.java

License:Apache License

@Override
public T newChannel() {
    try {//from ww w . j  a  va2 s.  c  om
        return clazz.newInstance();
    } catch (Throwable t) {
        throw new ChannelException("Unable to create Channel from class " + clazz, t);
    }
}

From source file:com.linkedin.mitm.proxy.ProxyServer.java

License:Open Source License

/**
 * Start proxy server//from www . j ava 2 s .c  o  m
 * */
public void start() throws InterruptedException {
    ServerBootstrap serverBootstrap = new ServerBootstrap();
    serverBootstrap.group(_acceptorGroup, _upstreamWorkerGroup);
    serverBootstrap.channelFactory(new ChannelFactory<ServerChannel>() {
        @Override
        public ServerChannel newChannel() {
            return new NioServerSocketChannel();
        }
    });
    serverBootstrap.childHandler(new ProxyInitializer(this));

    //bind
    ChannelFuture future = serverBootstrap.bind(_host, _port);

    //wait for the future
    future.awaitUninterruptibly();
    if (!future.isSuccess()) {
        future.channel().closeFuture().awaitUninterruptibly();
        throw new ChannelException(String.format("Failed to bind to: %s:%d", _host, _port), future.cause());
    } else {
        _allChannels.add(future.channel());
    }
}

From source file:org.fiware.kiara.netty.NioDatagramChannelFactory.java

License:Open Source License

@Override
public NioDatagramChannel newChannel() {
    try {//from  w  w w.  java 2  s.c om
        return new NioDatagramChannel(ipFamily);
    } catch (Throwable t) {
        throw new ChannelException("Unable to create Channel from class NioDatagramChannel", t);
    }
}

From source file:org.fusesource.hawtdispatch.netty.HawtServerSocketChannel.java

License:Apache License

private static java.nio.channels.ServerSocketChannel newSocket() {
    try {//from   w  w w.  j a va  2  s.  c  o  m
        return java.nio.channels.ServerSocketChannel.open();
    } catch (IOException e) {
        throw new ChannelException("Failed to open a server socket.", e);
    }
}

From source file:org.fusesource.hawtdispatch.netty.HawtSocketChannel.java

License:Apache License

private static java.nio.channels.SocketChannel newSocket() {
    try {/*from ww  w .j  a va 2 s .co m*/
        return java.nio.channels.SocketChannel.open();
    } catch (IOException e) {
        throw new ChannelException("Failed to open a socket.", e);
    }
}

From source file:org.fusesource.hawtdispatch.netty.HawtSocketChannel.java

License:Apache License

/**
 * Create a new instance//w  ww. java2s . com
 *
 * @param parent the {@link Channel} which created this instance or {@code null} if it was created by the user
 * @param id     the id to use for this instance or {@code null} if a new one should be generated
 * @param socket the {@link java.nio.channels.SocketChannel} which will be used
 */
public HawtSocketChannel(HawtServerSocketChannel parent, Integer id, java.nio.channels.SocketChannel socket) {
    super(parent, id, socket);
    try {
        socket.configureBlocking(false);
    } catch (IOException e) {
        try {
            socket.close();
        } catch (IOException e2) {
            if (logger.isWarnEnabled()) {
                logger.warn("Failed to close a partially initialized socket.", e2);
            }
        }

        throw new ChannelException("Failed to enter non-blocking mode.", e);
    }
    config = new DefaultSocketChannelConfig(this, socket.socket());
}

From source file:org.opendaylight.tcpmd5.netty.MD5NioServerSocketChannel.java

License:Open Source License

private static ServerSocketChannel newChannel() {
    try {/*  ww  w  .  j  av  a 2  s. co  m*/
        return ServerSocketChannel.open();
    } catch (IOException e) {
        throw new ChannelException("Failed to instantiate channel", e);
    }
}

From source file:org.opendaylight.tcpmd5.netty.MD5NioSocketChannel.java

License:Open Source License

private static SocketChannel newChannel() {
    try {/*w  ww  .ja  va2 s  .c o m*/
        return SocketChannel.open();
    } catch (IOException e) {
        throw new ChannelException("Failed to instantiate channel", e);
    }
}

From source file:org.opendaylight.tcpmd5.netty.NettyKeyAccess.java

License:Open Source License

@Override
public KeyMapping getKeys() {
    try {/*from ww  w .j  a v  a 2 s  . c  o m*/
        return delegate.getKeys();
    } catch (IOException e) {
        throw new ChannelException("Failed to set channel MD5 signature keys", e);
    }
}

From source file:org.opendaylight.tcpmd5.netty.NettyKeyAccess.java

License:Open Source License

@Override
public void setKeys(final KeyMapping keys) {
    try {//from w w w .  j a  va2  s . c  o  m
        delegate.setKeys(keys);
    } catch (IOException e) {
        throw new ChannelException("Failed to set channel MD5 signature key", e);
    }
}