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 Type
    Method
    Description
    get(Token token)
    Gets 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.
    Adds an observation to the store using the provided token, if not already added with that token.
    void
    remove(Token token)
    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
    Set executor for this store.
    void
     
    void
     
  • Method Details

    • putIfAbsent

      Observation putIfAbsent(Token token, Observation obs)
      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 is null.
      ObservationStoreException - if observation isn't stored.
    • put

      Observation put(Token token, Observation obs)
      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 is null.
      ObservationStoreException - if observation isn't stored.
    • remove

      void remove(Token token)
      Removes the observation initiated by the request with the given token.
      Parameters:
      token - The token of the observation to remove.
    • get

      Observation get(Token token)
      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

      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.

      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

      void setExecutor(ScheduledExecutorService executor)
      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()