Home / Class/ DnsQueryContextMap Class — netty Architecture

DnsQueryContextMap Class — netty Architecture

Architecture documentation for the DnsQueryContextMap class in DnsQueryContextManager.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  908d556c_deb2_5fc9_15cb_6377ddbd1469["DnsQueryContextMap"]
  22ab3849_09e5_5cdc_61a4_76e82e98c465["DnsQueryContextManager.java"]
  908d556c_deb2_5fc9_15cb_6377ddbd1469 -->|defined in| 22ab3849_09e5_5cdc_61a4_76e82e98c465
  9e5b6f88_f286_0009_fe3a_0ff0c5ca4a51["add()"]
  908d556c_deb2_5fc9_15cb_6377ddbd1469 -->|method| 9e5b6f88_f286_0009_fe3a_0ff0c5ca4a51
  a5c0fa9e_b858_0764_17f1_4278f257653c["DnsQueryContext()"]
  908d556c_deb2_5fc9_15cb_6377ddbd1469 -->|method| a5c0fa9e_b858_0764_17f1_4278f257653c

Relationship Graph

Source Code

resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContextManager.java lines 158–189

    private static final class DnsQueryContextMap {

        private final DnsQueryIdSpace idSpace = new DnsQueryIdSpace();

        // We increment on every usage so start with -1, this will ensure we start with 0 as first id.
        private final IntObjectMap<DnsQueryContext> map = new IntObjectHashMap<DnsQueryContext>();

        synchronized int add(DnsQueryContext ctx) {
            int id = idSpace.nextId();
            if (id == -1) {
                // -1 means that we couldn't reserve an id to use. In this case return early and not store the
                // context in the map.
                return -1;
            }
            DnsQueryContext oldCtx = map.put(id, ctx);
            assert oldCtx == null;
            return id;
        }

        synchronized DnsQueryContext get(int id) {
            return map.get(id);
        }

        synchronized DnsQueryContext remove(int id) {
            DnsQueryContext result = map.remove(id);
            if (result != null) {
                idSpace.pushId(id);
            }
            assert result != null : "DnsQueryContext not found, id: "  + id;
            return result;
        }
    }

Frequently Asked Questions

What is the DnsQueryContextMap class?
DnsQueryContextMap is a class in the netty codebase, defined in resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContextManager.java.
Where is DnsQueryContextMap defined?
DnsQueryContextMap is defined in resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContextManager.java at line 158.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free