Class NodeCache
- java.lang.Object
-
- org.opennms.features.kafka.producer.NodeCache
-
public class NodeCache extends Object
-
-
Constructor Summary
Constructors Constructor Description NodeCache(NodeDao nodeDao, SessionUtils sessionUtils)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setTimeoutInMs(long timeoutInMs)
void
triggerIfNeeded(long nodeId, java.util.function.Consumer<OnmsNode> consumer)
Calls the given consumer with a OnmsNode object corresponding to the given nodeId if no call has been made for this node within the configured timeout.
-
-
-
Constructor Detail
-
NodeCache
public NodeCache(NodeDao nodeDao, SessionUtils sessionUtils)
-
-
Method Detail
-
triggerIfNeeded
public void triggerIfNeeded(long nodeId, java.util.function.Consumer<OnmsNode> consumer)
Calls the given consumer with a OnmsNode object corresponding to the given nodeId if no call has been made for this node within the configured timeout. The given node object may be null if no node exists with the given node id. The callback will be done within the context of a read-only transaction. If multiple threads use this function with the same node id, it is possible that multiple callbacks occur before the timeout.- Parameters:
nodeId
- db id of the node to queryconsumer
- callback to issue with the node, if the timeout has not expired since the last callback
-
setTimeoutInMs
public void setTimeoutInMs(long timeoutInMs)
-
-