public class SimpleCache<T> extends Object implements SnapshotCache<T>
SimpleCache provides a default implementation of SnapshotCache. It maintains a single versioned
Snapshot per node group. For the protocol to work correctly in ADS mode, EDS/RDS requests are responded to
only when all resources in the snapshot xDS response are named as part of the request. It is expected that the CDS
response names all EDS clusters, and the LDS response names all RDS routes in a snapshot, to ensure that Envoy makes
the request for all EDS clusters or RDS routes eventually.
The snapshot can be partial, e.g. only include RDS or EDS resources.
| Constructor and Description |
|---|
SimpleCache(NodeGroup<T> groups)
Constructs a simple cache.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
clearSnapshot(T group)
Clears the most recently set
Snapshot and associated metadata for the given node group. |
Watch |
createWatch(boolean ads,
Discovery.DiscoveryRequest request,
Set<String> knownResourceNames,
Consumer<Response> responseConsumer)
Returns a new configuration resource
Watch for the given discovery request. |
Snapshot |
getSnapshot(T group)
Returns the most recently set
Snapshot for the given node group. |
Collection<T> |
groups()
Returns all known
Base.Node groups. |
void |
setSnapshot(T group,
Snapshot snapshot)
Set the
Snapshot for the given node group. |
StatusInfo |
statusInfo(T group)
Returns the current
StatusInfo for the given Base.Node group. |
public boolean clearSnapshot(T group)
Snapshot and associated metadata for the given node group.
Should only be called when the Snapshot will no longer be needed, e.g. when there
are no open watches for the group.
Implementations are free to ignore this call should it possibly leave the cache in a bad
state, e.g. causing watches to hang waiting for Snapshot options that will never happen.
clearSnapshot in interface SnapshotCache<T>group - group identifierpublic Watch createWatch(boolean ads, Discovery.DiscoveryRequest request, Set<String> knownResourceNames, Consumer<Response> responseConsumer)
Watch for the given discovery request.createWatch in interface ConfigWatcherads - is the watch for an ADS request?request - the discovery request (node, names, etc.) to use to generate the watchknownResourceNames - resources that are already known to the callerresponseConsumer - the response handler, used to process outgoing response messagespublic Snapshot getSnapshot(T group)
Snapshot for the given node group.getSnapshot in interface SnapshotCache<T>group - group identifierpublic Collection<T> groups()
Base.Node groups.public void setSnapshot(T group, Snapshot snapshot)
Snapshot for the given node group. Snapshots should have distinct versions and be internally
consistent (i.e. all referenced resources must be included in the snapshot).setSnapshot in interface SnapshotCache<T>group - group identifiersnapshot - a versioned collection of node config datapublic StatusInfo statusInfo(T group)
StatusInfo for the given Base.Node group.statusInfo in interface Cache<T>group - the node group whose status is being fetchedCopyright © 2018 The Envoy Project. All rights reserved.