Top Description Inners Fields Constructors Methods
io.netty.resolver.dns

pack-priv abstract Class Cache<E>

extends Object
Class Inheritance
Imports
io.netty.channel.EventLoop, io.netty.util.internal.PlatformDependent, java.util.ArrayList, .Collections, .Iterator, .List, .Map, .Map.Entry, java.util.concurrent.ConcurrentMap, .Delayed, .ScheduledFuture, .TimeUnit, java.util.concurrent.atomic.AtomicReference, .AtomicReferenceFieldUpdater

Abstract cache that automatically removes entries for a hostname once the TTL for an entry is reached.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private static final ScheduledFuture<?>
private static final AtomicReferenceFieldUpdater<Cache.Entries, ScheduledFuture<V>>
pack-priv static final int
private final ConcurrentMap<String, Cache<E>.Entries>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
cache(String hostname, E value, int ttl, EventLoop loop)

Cache a value for the given hostname that will automatically expire once the TTL is reached.

pack-priv final void
clear()

Remove everything from the cache.

pack-priv final boolean
clear(String hostname)

Clear all entries (if anything exists) for the given hostname and return true if anything was removed.

protected abstract boolean
equals(E entry, E otherEntry)

Returns true if both entries are equal.

pack-priv final List<? extends E>
get(String hostname)

Returns all caches entries for the given hostname.

protected abstract boolean
shouldReplaceAll(E entry)

Returns true if this entry should replace all other entries that are already cached for the hostname.

pack-priv final int
size()

Return the number of hostnames for which we have cached something.

protected void
sortEntries(String hostname, List<E> entries)

Sort the List for a hostname before caching these.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CANCELLEDback to summary
private static final ScheduledFuture<?> CANCELLED
FUTURE_UPDATERback to summary
private static final AtomicReferenceFieldUpdater<Cache.Entries, ScheduledFuture<V>> FUTURE_UPDATER
MAX_SUPPORTED_TTL_SECSback to summary
pack-priv static final int MAX_SUPPORTED_TTL_SECS
resolveCacheback to summary
private final ConcurrentMap<String, Cache<E>.Entries> resolveCache

Constructor Detail

Cacheback to summary
pack-priv Cache()

Method Detail

cacheback to summary
pack-priv final void cache(String hostname, E value, int ttl, EventLoop loop)

Cache a value for the given hostname that will automatically expire once the TTL is reached.

clearback to summary
pack-priv final void clear()

Remove everything from the cache.

clearback to summary
pack-priv final boolean clear(String hostname)

Clear all entries (if anything exists) for the given hostname and return true if anything was removed.

equalsback to summary
protected abstract boolean equals(E entry, E otherEntry)

Returns true if both entries are equal.

getback to summary
pack-priv final List<? extends E> get(String hostname)

Returns all caches entries for the given hostname.

shouldReplaceAllback to summary
protected abstract boolean shouldReplaceAll(E entry)

Returns true if this entry should replace all other entries that are already cached for the hostname.

sizeback to summary
pack-priv final int size()

Return the number of hostnames for which we have cached something.

sortEntriesback to summary
protected void sortEntries(String hostname, List<E> entries)

Sort the List for a hostname before caching these.

io.netty.resolver.dns back to summary

private final Class Cache.Entries

extends AtomicReference<List<E>>
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
pack-priv volatile ScheduledFuture<?>
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
Entries(String hostname)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
add(E e, int ttl, EventLoop loop)

pack-priv boolean
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
private void
Inherited from java.util.concurrent.atomic.AtomicReference:
accumulateAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndAccumulategetAndSetgetAndUpdategetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

expirationFutureback to summary
pack-priv volatile ScheduledFuture<?> expirationFuture
hostnameback to summary
private final String hostname

Constructor Detail

Entriesback to summary
pack-priv Entries(String hostname)

Method Detail

addback to summary
pack-priv void add(E e, int ttl, EventLoop loop)
clearAndCancelback to summary
pack-priv boolean clearAndCancel()
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
scheduleCacheExpirationIfNeededback to summary
private void scheduleCacheExpirationIfNeeded(int ttl, EventLoop loop)