Class InMemoryObservationStore

java.lang.Object
org.eclipse.californium.core.observe.InMemoryObservationStore
All Implemented Interfaces:
ObservationStore

public final class InMemoryObservationStore extends Object implements ObservationStore
An observation store that keeps all observations in-memory.
  • Constructor Details

    • InMemoryObservationStore

      public InMemoryObservationStore(org.eclipse.californium.elements.config.Configuration config)
  • Method Details

    • setExecutor

      public void setExecutor(ScheduledExecutorService executor)
      Description copied from interface: ObservationStore
      Set executor for this store. Executor is not managed by the store, it must be shutdown externally, if the resource should be freed.
      Specified by:
      setExecutor in interface ObservationStore
      Parameters:
      executor - intended to be used for rare executing timers (e.g. cleanup tasks).
    • putIfAbsent

      public Observation putIfAbsent(Token key, Observation obs)
      Description copied from interface: ObservationStore
      Adds an observation to the store using the provided token, if not already added with that token. Preserve previous stored observation with that token.
      Specified by:
      putIfAbsent in interface ObservationStore
      Parameters:
      key - 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.
    • put

      public Observation put(Token key, Observation obs)
      Description copied from interface: ObservationStore
      Adds an observation to the store using the provided token. Potentially replaces previous stored observation with that token.
      Specified by:
      put in interface ObservationStore
      Parameters:
      key - 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.
    • get

      public Observation get(Token token)
      Description copied from interface: ObservationStore
      Gets the observation initiated by the request with the given token.
      Specified by:
      get in interface ObservationStore
      Parameters:
      token - The token of the initiating request.
      Returns:
      The corresponding observation or null if no observation is registered for the given token.
    • remove

      public void remove(Token token)
      Description copied from interface: ObservationStore
      Removes the observation initiated by the request with the given token.
      Specified by:
      remove in interface ObservationStore
      Parameters:
      token - The token of the observation to remove.
    • isEmpty

      public boolean isEmpty()
      Checks if this store is empty.
      Returns:
      true if this store does not contain any observations.
    • getSize

      public int getSize()
      Gets the number of observations currently held in this store.
      Returns:
      The number of observations.
    • clear

      public void clear()
      Removes all observations from this store.
    • setContext

      public void setContext(Token token, org.eclipse.californium.elements.EndpointContext ctx)
      Description copied from interface: ObservationStore
      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.

      Specified by:
      setContext in interface ObservationStore
      Parameters:
      token - The token of the observation to set the context on.
      ctx - The context to set.
    • start

      public void start()
      Specified by:
      start in interface ObservationStore
    • stop

      public void stop()
      Specified by:
      stop in interface ObservationStore