Interface LocalSpace<K,V>

Type Parameters:
K - the key type
V - the value type
All Superinterfaces:
AutoCloseable, Space<K,V>
All Known Implementing Classes:
JESpace, LSpace, TSpace

public interface LocalSpace<K,V> extends Space<K,V>
Extension of Space with blocking read/take operations and space-listener support.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addListener(K key, SpaceListener<K,V> listener)
    add a SpaceListener associated with a given key
    void
    addListener(K key, SpaceListener<K,V> listener, long timeout)
    add a SpaceListener associated with a given key for a given period of time.
    Returns the set of all keys currently present in the space.
    void
    removeListener(K key, SpaceListener<K,V> listener)
    removes a SpaceListener associated with a given key
    int
    size(K key)
    Returns the number of entries queued under the given key.

    Methods inherited from interface Space

    close, existAny, existAny, in, in, inp, nrd, nrd, out, out, push, push, put, put, rd, rd, rdp
    Modifier and Type
    Method
    Description
    default void
     
    boolean
    existAny(K[] keys)
    Returns true if any of the given keys are present in the space.
    boolean
    existAny(K[] keys, long timeout)
    Returns true if any of the given keys become available within the timeout.
    in(K key)
    Take an entry from the space, waiting forever until one exists.
    in(K key, long timeout)
    Take an entry from the space, waiting a limited amount of time until one exists.
    inp(K key)
    In probe takes an entry from the space if one exists, return null otherwise.
    void
    nrd(K key)
    Nrd (not read) waits forever until Key is not present in space.
    Resolution for expiring entries is implementation dependant, but a minimum one-second is suggested.
    nrd(K key, long timeout)
    Nrd (not read) waits up to timeout until Key is not present in space.
    Resolution for expiring entries is implementation dependant, but a minimum one-second is suggested.
    void
    out(K key, V value)
    Write a new entry into the Space
    void
    out(K key, V value, long timeout)
    Write a new entry into the Space, with an timeout value
    void
    push(K key, V value)
    Write a new entry at the head of a queue.
    void
    push(K key, V value, long timeout)
    Write a new entry at the head of the queue with a timeout value
    void
    put(K key, V value)
    Write a single entry at the head of the queue discarding the other entries
    void
    put(K key, V value, long timeout)
    Write a single entry at the head of the queue discarding the other entries, with timeout.
    rd(K key)
    Read an entry from the space, waiting forever until one exists.
    rd(K key, long timeout)
    Read an entry from the space, waiting a limited amount of time until one exists.
    rdp(K key)
    Read probe reads an entry from the space if one exists, return null otherwise.
  • Method Details

    • addListener

      void addListener(K key, SpaceListener<K,V> listener)
      add a SpaceListener associated with a given key
      Parameters:
      key - Entry's key
      listener - a SpaceListener
    • addListener

      void addListener(K key, SpaceListener<K,V> listener, long timeout)
      add a SpaceListener associated with a given key for a given period of time. Warning: not supported by all space implementations.
      Parameters:
      key - Entry's key
      listener - a SpaceListener
      timeout - listener registration timeout in millis
    • removeListener

      void removeListener(K key, SpaceListener<K,V> listener)
      removes a SpaceListener associated with a given key
      Parameters:
      key - Entry's key
      listener - the SpaceListener
    • getKeySet

      Returns the set of all keys currently present in the space.
      Returns:
      Set containing all keys in Space
    • size

      int size(K key)
      Returns the number of entries queued under the given key.
      Parameters:
      key - the key to query
      Returns:
      number of entries in a given key