- java.lang.Object
-
- org.snmp4j.mp.MPv3.Cache
-
- Enclosing class:
- MPv3
protected static class MPv3.Cache extends java.lang.Object
TheCache
stores state reference information for the MPv3.- Version:
- 3.4.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<PduHandle,StateReference<?>>
entries
private java.util.Map<MessageID,java.lang.ref.WeakReference<PduHandle>>
msgIdToPduHandleMapping
-
Constructor Summary
Constructors Modifier Constructor Description protected
Cache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addEntry(StateReference<?> entry)
Adds aStateReference
to the cache.boolean
deleteEntry(PduHandle pduHandle)
Delete the cache entry with the suppliedPduHandle
.StateReference<?>
getEntry(MessageID messageID, boolean removeFoundEntry)
Gets the cache entry with the supplied ID from the cache.StateReference<?>
popEntry(MessageID messageID)
Pop the cache entry with the supplied ID from the cache.
-
-
-
Field Detail
-
entries
private java.util.Map<PduHandle,StateReference<?>> entries
-
-
Method Detail
-
addEntry
public int addEntry(StateReference<?> entry)
Adds aStateReference
to the cache. ThePduHandle
of the supplied entry will be set tonull
when the new entry is already part of the cache, because the cache uses aWeakHashMap
internally which uses thePduHandle
as 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_MESSAGE
if the entry already exists andSnmpConstants.SNMP_MP_OK
on success.
-
deleteEntry
public boolean deleteEntry(PduHandle pduHandle)
Delete the cache entry with the suppliedPduHandle
.- Parameters:
pduHandle
- a pduHandle.- Returns:
true
if an entry has been deleted,false
otherwise.
-
getEntry
public StateReference<?> getEntry(MessageID messageID, boolean removeFoundEntry)
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.CacheEntry
instance with the given message ID ornull
if such an entry cannot be found. - Since:
- 3.4.0
-
popEntry
public StateReference<?> popEntry(MessageID messageID)
Pop the cache entry with the supplied ID from the cache.- Parameters:
messageID
- a message ID.- Returns:
- a
MPv3.CacheEntry
instance with the given message ID ornull
if such an entry cannot be found. If a cache entry is returned, the same is removed from the cache.
-
-