Class MPv3.Cache
java.lang.Object
org.snmp4j.mp.MPv3.Cache
- Enclosing class:
MPv3
The
Cache stores state reference information for the MPv3.- Version:
- 3.4.0
- Author:
- Frank Fock
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddEntry(StateReference<?> entry) Adds aStateReferenceto the cache.booleanconsumeEntry(MessageID messageID, StateReference<?> expectedEntry) Removes the cache entry with the supplied message ID from the cache, but only if it is still the same entry instance that has been looked up before withgetEntry(MessageID, boolean).booleandeleteEntry(PduHandle pduHandle) Delete the cache entry with the suppliedPduHandle.Gets the cache entry with the supplied ID from the cache.Pop the cache entry with the supplied ID from the cache.
-
Constructor Details
-
Cache
protected Cache()
-
-
Method Details
-
addEntry
Adds aStateReferenceto the cache. ThePduHandleof the supplied entry will be set tonullwhen the new entry is already part of the cache, because the cache uses aWeakHashMapinternally which uses thePduHandleas key. If the new entry equals an existing entry except of the message ID then the new message ID will be added to the existing entry.- Parameters:
entry- the state reference to add.- Returns:
SnmpConstants.SNMP_MP_DOUBLED_MESSAGEif the entry already exists,SnmpConstants.SNMP_MP_MATCH_ERRORif any of the message IDs of the supplied entry is already associated with another live cache entry (since 3.13.0), andSnmpConstants.SNMP_MP_OKon success.
-
consumeEntry
Removes the cache entry with the supplied message ID from the cache, but only if it is still the same entry instance that has been looked up before withgetEntry(MessageID, boolean).This provides the atomicity needed to validate a received response or report against a cache entry without consuming that entry when the validation fails: a mismatching message leaves the entry in place for the legitimate response, while a matching message consumes it exactly once, even if two matching messages are processed concurrently.
- Parameters:
messageID- the message ID of the entry to consume.expectedEntry- the entry instance that is expected to be found formessageID.- Returns:
trueif the entry has been removed by this call. ThePduHandleofexpectedEntryis restored in that case.- Since:
- 3.13.0
-
deleteEntry
-
getEntry
Gets the cache entry with the supplied ID from the cache.- Parameters:
messageID- a message ID.removeFoundEntry- iftrue, the found entry will be removed from the cache before it is returned, otherwise it is returned only.- Returns:
- a
MPv3.CacheEntryinstance with the given message ID ornullif such an entry cannot be found. - Since:
- 3.4.0
-
popEntry
Pop the cache entry with the supplied ID from the cache.- Parameters:
messageID- a message ID.- Returns:
- a
MPv3.CacheEntryinstance with the given message ID ornullif such an entry cannot be found. If a cache entry is returned, the same is removed from the cache.
-