Class JESpace<K,V>
java.lang.Object
org.jpos.util.Log
org.jpos.space.JESpace<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
AutoCloseable, Runnable, LocalSpace<K,V>, PersistentSpace, Space<K, V>, Loggeable, LogSource
public class JESpace<K,V>
extends Log
implements LocalSpace<K,V>, PersistentSpace, Loggeable, Runnable
BerkeleyDB Jave Edition based persistent space implementation
- Since:
- 1.6.5
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPersistent entity used by the garbage collector to track expiring Ref entries.static classPersistent entity representing a single space entry (key/value with optional expiration). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longDefault lock timeout in milliseconds.static final longDefault transaction timeout in milliseconds.static final longDelay in milliseconds between GC runs.Fields inherited from class Log
DEBUG, defaultTags, ERROR, FATAL, INFO, logger, realm, TRACE, WARNModifier and TypeFieldDescriptionstatic final StringLevel constant for debug events.Default tags applied to everyLogEventcreated by thisLog.static final StringLevel constant for error events.static final StringLevel constant for fatal events.static final StringLevel constant for informational events.protected LoggerLogger receiving the events produced by thisLog.protected StringRealm associated with events emitted through thisLog.static final StringLevel constant for trace events.static final StringLevel constant for warning events. -
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.voidclose()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()Runs a garbage-collection pass removing expired entries from the BDB JE store.Returns the set of all keys currently present in the space.static JESpaceReturns (or creates) the named JESpace using the name as the storage path.static JESpaceReturns (or creates) the named JESpace stored at the given path.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.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 valuevoidRemoves all existing entries for the key then writes a single entry (head-of-queue replacement).voidWrite 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()intReturns the number of entries queued under the given key.Methods inherited from class Log
applyDefaultTags, createDebug, createDebug, createError, createError, createFatal, createFatal, createInfo, createInfo, createLogEvent, createLogEvent, createTrace, createTrace, createWarn, createWarn, debug, debug, error, error, fatal, fatal, getDefaultTags, getLog, getLogger, getRealm, info, info, removeDefaultTag, setDefaultTag, setDefaultTags, setLogger, setLogger, setRealm, trace, trace, warn, warnModifier and TypeMethodDescriptionprotected LogEventapplyDefaultTags(LogEvent evt) Decoratesevtwith thisLog's default tags, if any.Creates an empty debug-level event.createDebug(Object detail) Creates a debug-level event with the given payload.Creates an empty error-level event.createError(Object detail) Creates an error-level event with the given payload.Creates an empty fatal-level event.createFatal(Object detail) Creates a fatal-level event with the given payload.Creates an empty info-level event.createInfo(Object detail) Creates an info-level event with the given payload.createLogEvent(String level) Creates a newLogEventat the given level decorated with thisLog's default tags.createLogEvent(String level, Object detail) Creates a newLogEventat the given level with an initial payload.Creates an empty trace-level event.createTrace(Object detail) Creates a trace-level event with the given payload.Creates an empty warning-level event.createWarn(Object detail) Creates a warning-level event with the given payload.voidLogs a debug event with the given detail.voidLogs a debug event with the given detail and an additional payload.voidLogs an error event with the given detail.voidLogs an error event with the given detail and an additional payload.voidLogs a fatal event with the given detail.voidLogs a fatal event with the given detail and an additional payload.Returns an unmodifiable snapshot of the current default tags.static LogConvenience factory returning aLogbound to the given logger name and realm.Returns the underlying logger.getRealm()Returns the realm associated with events emitted through thisLog.voidLogs an info event with the given detail.voidLogs an info event with the given detail and an additional payload.voidremoveDefaultTag(String key) Removes a previously-registered default tag.voidsetDefaultTag(String key, String value) Sets a default tag on every event produced by thisLog; anullvalue removes the entry.voidsetDefaultTags(Map<String, String> tags) Replaces the entire set of default tags.voidReplaces the underlying logger, leaving the realm unchanged.voidReplaces the underlying logger and realm.voidReplaces the realm associated with emitted events.voidLogs a trace event with the given detail.voidLogs a trace event with the given detail and an additional payload.voidLogs a warning event with the given detail.voidLogs a warning event with the given detail and an additional payload.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
-
GC_DELAY
-
DEFAULT_TXN_TIMEOUT
-
DEFAULT_LOCK_TIMEOUT
-
-
Constructor Details
-
JESpace
Constructs a JESpace with the given name and path/parameter string.- Parameters:
name- the space name (also used as the entity store name)params- comma-separated parameters; first element is the directory path- Throws:
SpaceError- if the BerkeleyDB environment or store cannot be opened
-
-
Method Details
-
out
-
out
-
push
-
push
-
rdp
-
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. -
inp
-
existAny
-
existAny
Description copied from interface:SpaceReturns true if any of the given keys become available within the timeout. -
put
Description copied from interface:SpaceWrite a single entry at the head of the queue discarding the other entries, with timeout. -
put
-
gc
Runs a garbage-collection pass removing expired entries from the BDB JE store.- Throws:
com.sleepycat.je.DatabaseException- on BDB error
-
run
-
close
-
getSpace
-
getSpace
-
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
-
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
-
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
-
dump
-