Search in sources :

Example 1 with NetworkDataSourceWithAccounting

use of org.minidns.source.NetworkDataSourceWithAccounting in project minidns by MiniDNS.

the class IterativeDNSSECTest method shouldRequireLessQueries.

@IntegrationTest
public static void shouldRequireLessQueries() throws IOException {
    DNSSECClient normalCacheClient = getClient(CacheConfig.normal);
    DNSSECMessage normalCacheResult = normalCacheClient.queryDnssec(DNSSEC_DOMAIN, RR_TYPE);
    assertTrue(normalCacheResult.authenticData);
    NetworkDataSourceWithAccounting normalCacheNdswa = NetworkDataSourceWithAccounting.from(normalCacheClient);
    DNSSECClient extendedCacheClient = getClient(CacheConfig.extended);
    DNSSECMessage extendedCacheResult = extendedCacheClient.queryDnssec(DNSSEC_DOMAIN, RR_TYPE);
    assertTrue(extendedCacheResult.authenticData);
    NetworkDataSourceWithAccounting extendedCacheNdswa = NetworkDataSourceWithAccounting.from(extendedCacheClient);
    assertTrue(normalCacheNdswa.getStats().successfulQueries > extendedCacheNdswa.getStats().successfulQueries);
}
Also used : DNSSECMessage(org.minidns.dnssec.DNSSECMessage) DNSSECClient(org.minidns.dnssec.DNSSECClient) NetworkDataSourceWithAccounting(org.minidns.source.NetworkDataSourceWithAccounting)

Example 2 with NetworkDataSourceWithAccounting

use of org.minidns.source.NetworkDataSourceWithAccounting in project minidns by MiniDNS.

the class IntegrationTestTools method getClient.

public static DNSSECClient getClient(CacheConfig cacheConfig) {
    DNSCache cache;
    switch(cacheConfig) {
        case without:
            cache = null;
            break;
        case normal:
            cache = new LRUCache();
            break;
        case extended:
            cache = new ExtendedLRUCache();
            break;
        case full:
            cache = new FullLRUCache();
            break;
        default:
            throw new IllegalStateException();
    }
    DNSSECClient client = new DNSSECClient(cache);
    client.setDataSource(new NetworkDataSourceWithAccounting());
    return client;
}
Also used : ExtendedLRUCache(org.minidns.cache.ExtendedLRUCache) FullLRUCache(org.minidns.cache.FullLRUCache) ExtendedLRUCache(org.minidns.cache.ExtendedLRUCache) LRUCache(org.minidns.cache.LRUCache) FullLRUCache(org.minidns.cache.FullLRUCache) DNSSECClient(org.minidns.dnssec.DNSSECClient) DNSCache(org.minidns.DNSCache) NetworkDataSourceWithAccounting(org.minidns.source.NetworkDataSourceWithAccounting)

Example 3 with NetworkDataSourceWithAccounting

use of org.minidns.source.NetworkDataSourceWithAccounting in project minidns by MiniDNS.

the class MiniDNSStats method getStats.

public static StringBuilder getStats(AbstractDNSClient client) {
    StringBuilder sb = new StringBuilder();
    NetworkDataSourceWithAccounting ndswa = NetworkDataSourceWithAccounting.from(client);
    if (ndswa != null) {
        sb.append(ndswa.getStats().toString());
    } else {
        sb.append("Client is not using " + NetworkDataSourceWithAccounting.class.getSimpleName());
    }
    DNSCache dnsCache = client.getCache();
    if (dnsCache != null) {
        sb.append(dnsCache);
    } else {
        sb.append("Client is not using a Cache");
    }
    return sb;
}
Also used : DNSCache(org.minidns.DNSCache) NetworkDataSourceWithAccounting(org.minidns.source.NetworkDataSourceWithAccounting)

Aggregations

NetworkDataSourceWithAccounting (org.minidns.source.NetworkDataSourceWithAccounting)3 DNSCache (org.minidns.DNSCache)2 DNSSECClient (org.minidns.dnssec.DNSSECClient)2 ExtendedLRUCache (org.minidns.cache.ExtendedLRUCache)1 FullLRUCache (org.minidns.cache.FullLRUCache)1 LRUCache (org.minidns.cache.LRUCache)1 DNSSECMessage (org.minidns.dnssec.DNSSECMessage)1