|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.rmi.server.RemoteObject | +--java.rmi.server.RemoteServer | +--java.rmi.server.UnicastRemoteObject | +--org.oreodata.AbstractDataSource | +--org.oreodata.standalone.InMemoryDataSource
A simple standalone implementation of the org.oreodata.OreoDataSource interface. All of the records are held in memory. You must specify a DATA_PATH property when configuring an instance of this data source. This must be a directory on which your process has read/write privileges. You may optionally specify the base filename. If none is specified, it will use the name of the data source. You can use the USE_XML init parameter to indicate that the data file should be stored in an XML format. If you use XML, you can specify the optional parameter ENCODING to indicate the encoding in which the XML files will be stored. The default is UTF-8. You may also specify a SNAPSHOT_FREQUENCY parameter, which says how frequently to rotate the transaction log. The default (if no value is specified) is 100. When the log is rotated, this datasource archives a snapshot+log in gzip format. Compression seems logical, since the XML format is so extremely fat and redundant!
You can set the following properties in your datasources.xml config file.
Parameter | Description | Default |
DATA_PATH | The directory in which to store the data and log files. This must be a location where your process has read/write priveleges. | This is required if FILENAME is not specified or is not an absolute path. |
FILENAME | The filename for the data file. If this is an absolute filename, it must refer to a a directory where your process has read/write priveleges. | The name of the datasource |
LOGFILE | The filename for the log file. | The data filename + _log |
SNAPSHOT_REQUENCY | The frequency (in number of logged transactions) to write a new snapshot of the data and rotate the data logfiles. | "100" |
GZIP_SNAPSHOTS | Whether to archive the most recent data file in .gz format. | "Y" |
GZIP_OLD_SNAPSHOTS | Whether to archive old snapshots in .gz format | "Y" |
GZIP_OLD_LOGS | Whether to archive old logs in .gz format | "Y" |
USE_XML | Whether to store the log and snapshot in an XML format. location of the XML files. | "N" |
ENCODING | The character encoding to write the XML files. (Only relevant if USE_XML is set to "Y" | "UTF-8quot; |
Field Summary | |
protected DataLogger |
dataLogger
|
Fields inherited from class org.oreodata.AbstractDataSource |
defaultCharEncoding, lastLogRotation, transactionCount |
Fields inherited from class java.rmi.server.RemoteObject |
ref |
Constructor Summary | |
InMemoryDataSource()
|
Method Summary | |
Record |
delete(Record record)
Delete a record. |
Record |
delete(java.lang.String type,
java.lang.Object key)
Delete a record. |
protected void |
fireDataEvent(DataEvent event)
Fire a data event to the listeners. |
Record |
get(java.lang.String type,
java.lang.Object key)
|
void |
init(java.util.Properties properties)
A method that initializes a DataSource with a set of initialization properties. |
protected void |
initDataLogger(java.util.Properties properties)
|
Record |
insert(Record record)
Adds a new record to the managed pool. |
java.util.List |
keys(java.lang.String type)
|
void |
reload(Record rec)
loads a Record without any notification to listeners or any synchronization. |
java.util.List |
select(RecordFilter filter,
RecordComparator comparator)
Fetches a list of records matching filter. |
protected boolean |
timeToRotate()
|
Record |
update(Record oldRec,
Record newRec)
Replaces an existing version of a record with a new updated version. |
Methods inherited from class org.oreodata.AbstractDataSource |
addDataListener, close, fireEvents, freeze, freeze, get, getName, handleEvent, keys, lookup, markStale, normalizeKey, reload, removeDataListener, select, setFireEvents, setUseXML, useXML, wipeCache, writeElement, writeSnapshot |
Methods inherited from class java.rmi.server.UnicastRemoteObject |
clone, exportObject, exportObject, exportObject, unexportObject |
Methods inherited from class java.rmi.server.RemoteServer |
getClientHost, getLog, setLog |
Methods inherited from class java.rmi.server.RemoteObject |
equals, getRef, hashCode, toString, toStub |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected DataLogger dataLogger
Constructor Detail |
public InMemoryDataSource() throws java.io.IOException
Method Detail |
public void init(java.util.Properties properties) throws java.io.IOException
OreoDataSource
init
in interface OreoDataSource
init
in class AbstractDataSource
java.io.IOException
protected void initDataLogger(java.util.Properties properties) throws java.io.IOException
java.io.IOException
public Record delete(Record record) throws java.io.IOException
OreoDataSource
delete
in interface OreoDataSource
delete
in class AbstractDataSource
record
- the record to delete.
java.io.IOException
public Record delete(java.lang.String type, java.lang.Object key) throws java.io.IOException
OreoDataSource
delete
in interface OreoDataSource
delete
in class AbstractDataSource
type
- the type of the record, if this is null,
then any type will do.key
- the primary key of the record to delete.
java.io.IOException
public Record update(Record oldRec, Record newRec) throws java.io.IOException
OreoDataSource
update
in interface OreoDataSource
update
in class AbstractDataSource
oldRec
- the record to replace.newRec
- the new record.
java.io.IOException
- thrown in case of any other database or
communication error.public Record insert(Record record) throws java.io.IOException
OreoDataSource
insert
in interface OreoDataSource
insert
in class AbstractDataSource
record
- the record to add
java.io.IOException
- if the record cannot be
initialized (i.e. has missing fields or invalid
field values, etc.), or in case of a low-level error.public java.util.List select(RecordFilter filter, RecordComparator comparator) throws java.io.IOException
OreoDataSource
select
in interface OreoDataSource
select
in class AbstractDataSource
filter
- the record filter, or null.comparator
- defines an ordering for the records.
java.io.IOException
public Record get(java.lang.String type, java.lang.Object key) throws java.io.IOException
type
- the type of the record, if this is null,
then any type will do.key
- the lookup key
java.io.IOException
public java.util.List keys(java.lang.String type) throws java.io.IOException
keys
in interface OreoDataSource
keys
in class AbstractDataSource
type
- the record type we are interested,
under some circumstances, this may be null.
java.io.IOException
public void reload(Record rec) throws java.io.IOException
OreoDataSource
reload
in interface OreoDataSource
reload
in class AbstractDataSource
java.io.IOException
protected void fireDataEvent(DataEvent event) throws java.io.IOException
AbstractDataSource
fireDataEvent
in class AbstractDataSource
java.io.IOException
protected boolean timeToRotate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |