Interface ObservationStore
- All Known Implementing Classes:
InMemoryObservationStore
public interface ObservationStore
A registry for keeping information about resources observed on other peers.
The information kept in this registry is particularly intended to be shared with other instances (running on other nodes) to support failing over the processing of notifications received by another node after the original node (that initially registered the observation) has crashed.
-
Method Summary
Modifier and TypeMethodDescriptionGets the observation initiated by the request with the given token.put
(Token token, Observation obs) Adds an observation to the store using the provided token.putIfAbsent
(Token token, Observation obs) Adds an observation to the store using the provided token, if not already added with that token.void
Removes the observation initiated by the request with the given token.void
setContext
(Token token, org.eclipse.californium.elements.EndpointContext endpointContext) Sets the endpoint context on the observation initiated by the request with the given token.void
setExecutor
(ScheduledExecutorService executor) Set executor for this store.void
start()
void
stop()
-
Method Details
-
putIfAbsent
Adds an observation to the store using the provided token, if not already added with that token. Preserve previous stored observation with that token.- Parameters:
token
- unique token to add the provided observation.obs
- The observation to add.- Returns:
- the previous value associated with the specified key, or
null
if there was no mapping for the key. - Throws:
NullPointerException
- if token or observation isnull
.ObservationStoreException
- if observation isn't stored.
-
put
Adds an observation to the store using the provided token. Potentially replaces previous stored observation with that token.- Parameters:
token
- unique token to add the provided observation.obs
- The observation to add.- Returns:
- the previous value associated with the specified key, or
null
if there was no mapping for the key. - Throws:
NullPointerException
- if token or observation isnull
.ObservationStoreException
- if observation isn't stored.
-
remove
Removes the observation initiated by the request with the given token.- Parameters:
token
- The token of the observation to remove.
-
get
Gets the observation initiated by the request with the given token.- Parameters:
token
- The token of the initiating request.- Returns:
- The corresponding observation or
null
if no observation is registered for the given token.
-
setContext
Sets the endpoint context on the observation initiated by the request with the given token.This method is necessary because the endpoint context may not be known when the observation is originally registered. This is due to the fact that the information contained in the endpoint context is gathered by the transport layer when the request establishing the observation is sent to the peer.
- Parameters:
token
- The token of the observation to set the context on.endpointContext
- The context to set.
-
setExecutor
Set executor for this store. Executor is not managed by the store, it must be shutdown externally, if the resource should be freed.- Parameters:
executor
- intended to be used for rare executing timers (e.g. cleanup tasks).
-
start
void start() -
stop
void stop()
-