Package org.jpos.space
Class JDBMSpace<K,V>
- java.lang.Object
-
- java.util.TimerTask
-
- org.jpos.space.JDBMSpace<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
autoCommit
static long
GCDELAY
protected jdbm.htree.HTree
htree
protected java.lang.String
name
protected jdbm.RecordManager
recman
protected static jdbm.helper.Serializer
refSerializer
protected static java.util.Map<java.lang.String,Space>
spaceRegistrar
-
Constructor Summary
Constructors Modifier Constructor Description protected
JDBMSpace(java.lang.String name, java.lang.String filename)
protected constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
close this space - use with carevoid
commit()
force commitboolean
existAny(java.lang.Object[] keys)
boolean
existAny(java.lang.Object[] keys, long timeout)
void
gc()
garbage collector.java.lang.String
getKeys()
static JDBMSpace
getSpace()
static JDBMSpace
getSpace(java.lang.String name)
creates a named JDBMSpace (filename used for storage is the same as the given name)static JDBMSpace
getSpace(java.lang.String name, java.lang.String filename)
creates a named JDBMSpaceV
in(java.lang.Object key)
Take an entry from the space, waiting forever until one exists.V
in(java.lang.Object key, long timeout)
Take an entry from the space, waiting forever until one exists.V
inp(java.lang.Object key)
In probe takes an entry from the space if one exists, return null otherwise.void
nrd(java.lang.Object 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.V
nrd(java.lang.Object 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 Spacevoid
out(K key, V value, long timeout)
Write a new entry into the Space The entry will timeout after the specified periodvoid
push(java.lang.Object key, java.lang.Object value, long timeout)
Write a new entry into the Space at the head of a queue The entry will timeout after the specified periodvoid
push(K key, V value)
Write a new entry at the head of a queue.void
put(K key, V value)
Write a single entry at the head of the queue discarding the other entriesvoid
put(K key, V value, long timeout)
Write a single entry at the head of the queue discarding the other entries, with timeout.V
rd(java.lang.Object key)
Read an entry from the space, waiting forever until one exists.V
rd(java.lang.Object key, long timeout)
Read an entry from the space, waiting a limited amount of time until one exists.V
rdp(java.lang.Object key)
Read probe reads an entry from the space if one exists, return null otherwise.void
rollback()
force rollbackvoid
run()
void
setAutoCommit(boolean b)
Use with utmost care and at your own risk.long
size(java.lang.Object key)
-
-
-
Field Detail
-
htree
protected jdbm.htree.HTree htree
-
recman
protected jdbm.RecordManager recman
-
refSerializer
protected static final jdbm.helper.Serializer refSerializer
-
spaceRegistrar
protected static final java.util.Map<java.lang.String,Space> spaceRegistrar
-
autoCommit
protected boolean autoCommit
-
name
protected java.lang.String name
-
GCDELAY
public static final long GCDELAY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JDBMSpace
protected JDBMSpace(java.lang.String name, java.lang.String filename)
protected constructor.- Parameters:
name
- Space Namefilename
- underlying JDBM filename
-
-
Method Detail
-
getSpace
public static JDBMSpace getSpace(java.lang.String name)
creates a named JDBMSpace (filename used for storage is the same as the given name)- Parameters:
name
- the Space name- Returns:
- reference to named JDBMSpace
-
getSpace
public static JDBMSpace getSpace(java.lang.String name, java.lang.String filename)
creates a named JDBMSpace- Parameters:
name
- the Space namefilename
- the storage file name- Returns:
- reference to named JDBMSpace
-
setAutoCommit
public void setAutoCommit(boolean b)
Use with utmost care and at your own risk. If you are to perform several operations on the space you should synchronize on the space, i.e:synchronized (sp) { sp.setAutoCommit (false); sp.out (..., ...) sp.out (..., ...) ... ... sp.inp (...); sp.commit (); // or sp.rollback (); sp.setAutoCommit (true); }
- Parameters:
b
- true or false
-
commit
public void commit()
force commit
-
rollback
public void rollback()
force rollback
-
close
public void close()
close this space - use with care
-
out
public void out(K key, V value, long timeout)
Write a new entry into the Space The entry will timeout after the specified period
-
push
public void push(K key, V value)
Description copied from interface:Space
Write a new entry at the head of a queue.
-
push
public void push(java.lang.Object key, java.lang.Object value, long timeout)
Write a new entry into the Space at the head of a queue The entry will timeout after the specified period
-
rdp
public V rdp(java.lang.Object key)
Read probe reads an entry from the space if one exists, return null otherwise.
-
inp
public V inp(java.lang.Object key)
In probe takes an entry from the space if one exists, return null otherwise.
-
in
public V in(java.lang.Object key)
Description copied from interface:Space
Take an entry from the space, waiting forever until one exists.
-
in
public V in(java.lang.Object key, long timeout)
Take an entry from the space, waiting forever until one exists.
-
rd
public V rd(java.lang.Object key)
Read an entry from the space, waiting forever until one exists.
-
rd
public V rd(java.lang.Object key, long timeout)
Read an entry from the space, waiting a limited amount of time until one exists.
-
nrd
public void nrd(java.lang.Object key)
Description copied from interface:Space
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
public V nrd(java.lang.Object key, long timeout)
Description copied from interface:Space
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.
-
size
public long size(java.lang.Object key)
- Parameters:
key
- the Key- Returns:
- aproximately queue size
-
existAny
public boolean existAny(java.lang.Object[] keys)
-
existAny
public boolean existAny(java.lang.Object[] keys, long timeout)
-
put
public void put(K key, V value, long timeout)
Description copied from interface:Space
Write a single entry at the head of the queue discarding the other entries, with timeout.
-
put
public void put(K key, V value)
Description copied from interface:Space
Write a single entry at the head of the queue discarding the other entries
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Specified by:
run
in classjava.util.TimerTask
-
gc
public void gc()
garbage collector. removes expired entries
-
getKeys
public java.lang.String getKeys()
-
-