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

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

Introduction

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

Prototype

LocalAddress ANY

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

Click Source Link

Usage

From source file:com.lambdaworks.redis.ConnectionEventTrigger.java

License:Apache License

static SocketAddress local(ChannelHandlerContext ctx) {
    Channel channel = ctx.channel();
    if (channel != null && channel.localAddress() != null) {
        return channel.localAddress();
    }/*from   w  ww  . j ava 2 s  . c  om*/
    return LocalAddress.ANY;
}

From source file:com.lambdaworks.redis.metrics.CommandLatencyIdTest.java

License:Apache License

@Test
public void testValues() throws Exception {
    assertThat(sut.localAddress()).isEqualTo(LocalAddress.ANY);
    assertThat(sut.remoteAddress()).isEqualTo(new LocalAddress("me"));
}

From source file:com.lambdaworks.redis.metrics.DefaultCommandLatencyCollector.java

License:Apache License

private CommandLatencyId createId(SocketAddress local, SocketAddress remote, ProtocolKeyword commandType) {
    return CommandLatencyId.create(options.localDistinction() ? local : LocalAddress.ANY, remote, commandType);
}

From source file:com.lambdaworks.redis.metrics.DefaultCommandLatencyCollectorTest.java

License:Apache License

private void setupData() {
    sut.recordCommandLatency(LocalAddress.ANY, LocalAddress.ANY, CommandType.BGSAVE, MILLISECONDS.toNanos(100),
            MILLISECONDS.toNanos(1000));
    sut.recordCommandLatency(LocalAddress.ANY, LocalAddress.ANY, CommandType.BGSAVE, MILLISECONDS.toNanos(200),
            MILLISECONDS.toNanos(1000));
    sut.recordCommandLatency(LocalAddress.ANY, LocalAddress.ANY, CommandType.BGSAVE, MILLISECONDS.toNanos(300),
            MILLISECONDS.toNanos(1000));
}

From source file:in.voidma.lemming.Lemming.java

License:Open Source License

@Override
public void onLoad() {

    getLogger().log(Level.ALL, "LoadingLemming");

    // Logging/*w  w w.j  a v a2 s  .  c o m*/
    logger = getLogger();
    LemmingLogger.init(this);

    // Configuration
    saveDefaultConfig();
    reloadConfig();

    try {
        config = new LemmingConfig(this);
    } catch (Exception e) {
        // TODO: Add warnings
    }

    // Print the state of the debug mode
    if (config.isServerDebug()) {
        logger.warning("Server side debug mode is enabled!");
    }

    // And the state of the error reporter
    if (config.isServerDetailedErrorReporting()) {
        // TODO: Enable detailed reporting
        logger.warning("Server side detailed error reporting enabled!");
    }

    // ProtocolLib setup
    manager = ProtocolLibrary.getProtocolManager();

    InternalManager manager = new InternalManager();

    LemmingLibrary.init(this, config, manager);

    DedicatedServer server = (DedicatedServer) getServer();
    final ServerConnection serverConnection = server.getServerConnection();
    try {
        final List<ChannelFuture> endpoints = (List<ChannelFuture>) serverConnection.getClass()
                .getDeclaredField("g").get(serverConnection);
        final List<NetworkManager> networkManagers = (List<NetworkManager>) serverConnection.getClass()
                .getDeclaredField("h").get(serverConnection);

        ChannelFuture channelfuture;

        synchronized (endpoints) {
            channelfuture = new ServerBootstrap().channel(LocalServerChannel.class)
                    .childHandler(new ChannelInitializer<Channel>() {
                        protected void initChannel(Channel channel) throws Exception {

                            NetworkManager networkmanager = new NetworkManager(
                                    EnumProtocolDirection.SERVERBOUND);
                            networkmanager.setPacketListener(
                                    new HandshakeListener(serverConnection.d(), networkmanager));
                            networkManagers.add(networkmanager);

                            channel.pipeline().addLast("timeout", new ReadTimeoutHandler(30));
                            channel.pipeline().addLast("legacy_query", new LegacyPingHandler(serverConnection));
                            channel.pipeline().addLast("splitter", new PacketSplitter());
                            channel.pipeline().addLast("decoder",
                                    new PacketDecoder(EnumProtocolDirection.SERVERBOUND));
                            channel.pipeline().addLast("prepender", new PacketPrepender());
                            channel.pipeline().addLast("encoder",
                                    new PacketEncoder(EnumProtocolDirection.CLIENTBOUND));
                            channel.pipeline().addLast("packet_handler", networkmanager);
                        }
                    }).group(new NioEventLoopGroup(4)).localAddress(LocalAddress.ANY).bind()
                    .syncUninterruptibly();

            endpoints.add(channelfuture);
        }

        LemmingClient client = manager.newLemming().name("TotallyNotABot").address("192.168.0.10", 2344)
                .latency(20).packetLoss(3).throttling(400).create().connect();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:io.lettuce.core.protocol.CommandHandler.java

License:Apache License

private SocketAddress local() {
    if (channel.localAddress() != null) {
        return channel.localAddress();
    }
    return LocalAddress.ANY;
}