Example usage for io.netty.resolver.dns DnsQueryContext nameServerAddr

List of usage examples for io.netty.resolver.dns DnsQueryContext nameServerAddr

Introduction

In this page you can find the example usage for io.netty.resolver.dns DnsQueryContext nameServerAddr.

Prototype

InetSocketAddress nameServerAddr

To view the source code for io.netty.resolver.dns DnsQueryContext nameServerAddr.

Click Source Link

Usage

From source file:io.vertx.core.dns.impl.fix.DnsQueryContextManager.java

License:Apache License

int add(DnsQueryContext qCtx) {
    final IntObjectMap<DnsQueryContext> contexts = getOrCreateContextMap(qCtx.nameServerAddr());

    int id = ThreadLocalRandom.current().nextInt(1, 65536);
    final int maxTries = 65535 << 1;
    int tries = 0;

    synchronized (contexts) {
        for (;;) {
            if (!contexts.containsKey(id)) {
                contexts.put(id, qCtx);//www.  ja v  a  2 s .com
                return id;
            }

            id = id + 1 & 0xFFFF;

            if (++tries >= maxTries) {
                throw new IllegalStateException("query ID space exhausted: " + qCtx.question());
            }
        }
    }
}