Class TSpace<K,V>
java.lang.Object
org.jpos.space.TSpace<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
AutoCloseable, Runnable, LocalSpace<K,V>, Space<K, V>, Loggeable
TSpace implementation
- Since:
- !.4.9
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MapBacking map keyed by user-supplied keys; values are entries or lists of entries.static final longPeriodic interval, in milliseconds, between background GC sweeps.protected TSpacePer-key space listeners; itself aTSpaceso it inherits the dispatch model. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(Object key, SpaceListener listener) add a SpaceListener associated with a given keyvoidaddListener(Object key, SpaceListener listener, long timeout) add a SpaceListener associated with a given key for a given period of time.voiddump(PrintStream p, String indent) Dumps a human-readable representation of this object to the print stream.booleanReturns true if any of the given keys are present in the space.booleanReturns true if any of the given keys become available within the timeout.voidgc()Sweeps the short-lived expirable set, and the long-lived set when its sweep interval has elapsed.unstandard method (required for space replication) - use with careReturns a space-separated list of every key currently stored.Returns the set of all keys currently present in the space.Take an entry from the space, waiting forever until one exists.Take an entry from the space, waiting a limited amount of time until one exists.In probe takes an entry from the space if one exists, return null otherwise.booleanisEmpty()Indicates whether the space currently holds any entries.voidnotifyListeners(Object key, Object value) Notifies every listener registered againstkeyof an entry change.voidNrd (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 (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.voidWrite a new entry into the SpacevoidWrite a new entry into the Space, with an timeout valuevoidWrite a new entry at the head of a queue.voidWrite a new entry at the head of the queue with a timeout valuevoidWrite a single entry at the head of the queue discarding the other entriesvoidWrite a single entry at the head of the queue discarding the other entries, with timeout.Read an entry from the space, waiting forever until one exists.Read an entry from the space, waiting a limited amount of time until one exists.Read probe reads an entry from the space if one exists, return null otherwise.voidremoveListener(Object key, SpaceListener listener) removes a SpaceListener associated with a given keyvoidrun()voidsetEntries(Map entries) unstandard method (required for space replication) - use with careintReturns the number of entries queued under the given key.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Loggeable
dumpModifier and TypeMethodDescriptiondefault voiddump(PrintStream p, String indent, LogRenderer.Type type) Dumps a representation of this object using the specified renderer type.
-
Field Details
-
entries
-
sl
-
GCDELAY
Periodic interval, in milliseconds, between background GC sweeps.- See Also:
-
-
Constructor Details
-
TSpace
public TSpace()Default constructor.
-
-
Method Details
-
out
-
out
-
rdp
-
inp
-
in
-
in
-
rd
-
rd
-
nrd
Description copied from interface:SpaceNrd (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
Description copied from interface:SpaceNrd (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. -
run
-
gc
Sweeps the short-lived expirable set, and the long-lived set when its sweep interval has elapsed. -
size
Description copied from interface:LocalSpaceReturns the number of entries queued under the given key.- Specified by:
sizein interfaceLocalSpace<K,V> - Parameters:
key- the key to query- Returns:
- number of entries in a given key
-
addListener
Description copied from interface:LocalSpaceadd a SpaceListener associated with a given key- Specified by:
addListenerin interfaceLocalSpace<K,V> - Parameters:
key- Entry's keylistener- a SpaceListener
-
addListener
Description copied from interface:LocalSpaceadd a SpaceListener associated with a given key for a given period of time. Warning: not supported by all space implementations.- Specified by:
addListenerin interfaceLocalSpace<K,V> - Parameters:
key- Entry's keylistener- a SpaceListenertimeout- listener registration timeout in millis
-
removeListener
Description copied from interface:LocalSpaceremoves a SpaceListener associated with a given key- Specified by:
removeListenerin interfaceLocalSpace<K,V> - Parameters:
key- Entry's keylistener- the SpaceListener
-
isEmpty
Indicates whether the space currently holds any entries.- Returns:
trueif no entries are stored
-
getKeySet
Description copied from interface:LocalSpaceReturns the set of all keys currently present in the space.- Specified by:
getKeySetin interfaceLocalSpace<K,V> - Returns:
- Set containing all keys in Space
-
getKeysAsString
Returns a space-separated list of every key currently stored.- Returns:
- all keys, joined by single-space separators
-
dump
-
notifyListeners
Notifies every listener registered againstkeyof an entry change.- Parameters:
key- entry keyvalue- the value just written ornullwhen entries were removed
-
push
-
push
-
put
-
put
Description copied from interface:SpaceWrite a single entry at the head of the queue discarding the other entries, with timeout. -
existAny
-
existAny
Description copied from interface:SpaceReturns true if any of the given keys become available within the timeout. -
getEntries
unstandard method (required for space replication) - use with care- Returns:
- underlying entry map
-
setEntries
unstandard method (required for space replication) - use with care- Parameters:
entries- underlying entry map
-