Example usage for io.netty.channel.local LocalAddress id

List of usage examples for io.netty.channel.local LocalAddress id

Introduction

In this page you can find the example usage for io.netty.channel.local LocalAddress id.

Prototype

String id

To view the source code for io.netty.channel.local LocalAddress id.

Click Source Link

Usage

From source file:org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorTest.java

License:Open Source License

@Test
public void testGetInetSocketAddress() throws Exception {

    InetSocketAddress socketAddress = new InetSocketAddress(10);

    assertNotNull(NetconfServerSessionNegotiator.getHostName(socketAddress));

    assertEquals(socketAddress.getHostName(),
            NetconfServerSessionNegotiator.getHostName(socketAddress).getValue());

    socketAddress = new InetSocketAddress("TestPortInet", 20);

    assertEquals(socketAddress.getHostName(),
            NetconfServerSessionNegotiator.getHostName(socketAddress).getValue());

    assertEquals(String.valueOf(socketAddress.getPort()),
            NetconfServerSessionNegotiator.getHostName(socketAddress).getKey());

    LocalAddress localAddress = new LocalAddress("TestPortLocal");

    assertEquals(String.valueOf(localAddress.id()),
            NetconfServerSessionNegotiator.getHostName(localAddress).getValue());

    SshdSocketAddress embeddedAddress = new SshdSocketAddress("TestSshdName", 10);

}

From source file:org.vootoo.client.netty.connect.SimpleConnectionPool.java

License:Apache License

public SimpleConnectionPool(Bootstrap bootstrap, HandlerConfig handlerConfig, SocketAddress remoteAddress,
        int connectTimeout) {
    super(bootstrap, new SolrClientChannelPoolHandler(handlerConfig, remoteAddress));
    this.connectTimeout = connectTimeout;
    this.socketAddress = remoteAddress;
    if (remoteAddress instanceof InetSocketAddress) {
        InetSocketAddress inetSocketAddress = (InetSocketAddress) remoteAddress;
        host = inetSocketAddress.getAddress().getHostAddress();
        port = inetSocketAddress.getPort();
    } else if (remoteAddress instanceof LocalAddress) {
        LocalAddress localAddress = (LocalAddress) remoteAddress;
        int myPort = -1;
        try {//from www.j  av  a2s.c o m
            myPort = Integer.parseInt(localAddress.id());
        } catch (NumberFormatException e) {
        }

        host = "local";
        port = myPort;
    } else {
        throw new IllegalArgumentException("SocketAddress must be '" + InetSocketAddress.class.getName()
                + "' or '" + LocalAddress.class.getName() + "' (sub) class");
    }

    poolContext = new ConnectionPoolContext(handlerConfig.getResponsePromiseContainer());
}