Interface Space<K,V>

All Superinterfaces:
AutoCloseable
All Known Subinterfaces:
LocalSpace<K,V>
All Known Implementing Classes:
JDBMSpace, JESpace, LSpace, SpaceInterceptor, SpaceLet, TSpace

public interface Space<K,V> extends AutoCloseable

Space uses concepts described in the Linda Coordination Language that eases the implementation of other jPOS components (such as Channels, Muxes, etc.), but it is not by any means an attempt to provide a full implementation.

jPOS's Space is basically a Map where each entry is a LinkedList of values that can be used as a BlockingQueue

One can place entries on a queue by calling Space.out, take them by calling Space.in and read (without taking) by calling Space.rd

Since:
2.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
     
    boolean
    existAny(K[] keys)
     
    boolean
    existAny(K[] keys, long 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

    • out

      void out(K key, V value)
      Write a new entry into the Space
      Parameters:
      key - Entry's key
      value - Object value
    • out

      void out(K key, V value, long timeout)
      Write a new entry into the Space, with an timeout value
      Parameters:
      key - Entry's key
      value - Object value
      timeout - timeout value in millis
    • in

      V in(K key)
      Take an entry from the space, waiting forever until one exists.
      Parameters:
      key - Entry's key
      Returns:
      value
    • rd

      V rd(K key)
      Read an entry from the space, waiting forever until one exists.
      Parameters:
      key - Entry's key
      Returns:
      value
    • in

      V in(K key, long timeout)
      Take an entry from the space, waiting a limited amount of time until one exists.
      Parameters:
      key - Entry's key
      timeout - millis to wait
      Returns:
      value or null
    • rd

      V rd(K key, long timeout)
      Read an entry from the space, waiting a limited amount of time until one exists.
      Parameters:
      key - Entry's key
      timeout - millis to wait
      Returns:
      value or null
    • inp

      V inp(K key)
      In probe takes an entry from the space if one exists, return null otherwise.
      Parameters:
      key - Entry's key
      Returns:
      value or null
    • rdp

      V rdp(K key)
      Read probe reads an entry from the space if one exists, return null otherwise.
      Parameters:
      key - Entry's key
      Returns:
      value or null
    • nrd

      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.
      Parameters:
      key - Entry's key
    • nrd

      V 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.
      Parameters:
      key - Entry's key
      timeout - millis to wait
      Returns:
      value or null
    • push

      void push(K key, V value)
      Write a new entry at the head of a queue.
      Parameters:
      key - Entry's key
      value - Object value
    • push

      void push(K key, V value, long timeout)
      Write a new entry at the head of the queue with a timeout value
      Parameters:
      key - Entry's key
      value - Object value
      timeout - timeout value in millis
    • existAny

      boolean existAny(K[] keys)
      Parameters:
      keys - array of keys to check
      Returns:
      true if one or more keys are available in the space
    • existAny

      boolean existAny(K[] keys, long timeout)
      Parameters:
      keys - array of keys to check
      timeout - to wait for any of the entries to become available in millis
      Returns:
      true if one or more keys are available in the space
    • put

      void put(K key, V value)
      Write a single entry at the head of the queue discarding the other entries
      Parameters:
      key - Entry's key
      value - Object value
    • put

      void put(K key, V value, long timeout)
      Write a single entry at the head of the queue discarding the other entries, with timeout.
      Parameters:
      key - Entry's key
      value - Object value
      timeout - timeout value in millis
    • close

      default void close()
      Specified by:
      close in interface AutoCloseable