|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.isti.util.IstiMessageCachedArchive
public class IstiMessageCachedArchive
Class IstiMessageCachedArchive implements an ArchiveManager with a front-end cache. The 'removeOldObjects()' method should be called on a periodic basis to remove old objects from the cache and archive.
Nested Class Summary | |
---|---|
class |
IstiMessageCachedArchive.AddMessageWorkerThread
Class AddMessageWorkerThread fetches message objects from the queue and adds them to the cache and archive. |
static interface |
IstiMessageCachedArchive.ArchivableMsgObjEntry
Interface ArchivableMsgObjEntry combines the MessageObjectEntry and Archivable interfaces. |
static class |
IstiMessageCachedArchive.BasicArchivableMsgObjEntry
Abstract class BasicArchivableMsgObjEntry is an extension of the message- object-entry class that also implements the 'Archivable' interface. |
Field Summary | |
---|---|
protected java.util.Vector |
addMessageQueueVec
|
protected IstiMessageCachedArchive.AddMessageWorkerThread |
addMessageWorkerThreadObj
|
protected ArchiveManager |
archiveMgrObj
|
protected long |
archiveRemoveAgeMilliSecs
|
protected long |
cacheRemoveAgeMilliSecs
|
protected boolean |
closingCacheArchiveFlag
|
protected java.lang.Object |
dataAccessSyncObj
|
protected LogFile |
logObj
|
protected long |
maxRequestAgeMilliSecs
|
protected IstiMessageObjectCache |
messageCacheObj
|
Constructor Summary | |
---|---|
IstiMessageCachedArchive(ArchiveManager archiveMgrObj,
LogFile logObj,
long tolerance,
int cacheRemoveAgeSecs,
int archiveRemoveAgeSecs,
int maxRequestAgeSecs)
Constructs a cached-archive object. |
|
IstiMessageCachedArchive(ArchiveManager archiveMgrObj,
LogFile logObj,
long tolerance,
int cacheRemoveAgeSecs,
int archiveRemoveAgeSecs,
int maxRequestAgeSecs,
boolean useLookupKeyFlag)
Constructs a cached-archive object. |
|
IstiMessageCachedArchive(ArchiveManager archiveMgrObj,
LogFile logObj,
long tolerance,
int cacheRemoveAgeSecs,
int cacheMaxObjectCount,
long cacheMaxTotalDataSize,
int archiveRemoveAgeSecs,
int maxRequestAgeSecs)
Constructs a cached-archive object. |
|
IstiMessageCachedArchive(ArchiveManager archiveMgrObj,
LogFile logObj,
long tolerance,
int cacheRemoveAgeSecs,
int cacheMaxObjectCount,
long cacheMaxTotalDataSize,
int archiveRemoveAgeSecs,
int maxRequestAgeSecs,
boolean useLookupKeyFlag)
Constructs a cached-archive object. |
Method Summary | |
---|---|
void |
addArchivableMsgObj(IstiMessageCachedArchive.ArchivableMsgObjEntry archivableMsgObj)
Adds the given message object to the cache and to the archive. |
boolean |
cacheContains(IstiMessageCachedArchive.ArchivableMsgObjEntry archivableMsgObj)
Determines whether or not a message object "equal" to the given message object is contained in the cache. |
void |
close()
Closes the archive and cache. |
protected void |
doAddArchivableMsgObj(IstiMessageCachedArchive.ArchivableMsgObjEntry archivableMsgObj)
Performs the work of adding the given message object to the cache and to the archive. |
int |
getCacheSize()
Returns the number of entries in the cache. |
java.lang.Object |
getDataAccessSyncObj()
Returns the Object used to thread-synchronize the cached and archived data. |
IstiMessageCachedArchive.ArchivableMsgObjEntry |
getLastArchiveMessageObj()
Returns the newest message object entered into the archive. |
long |
getLastArchiveMsgNum()
Returns the message number for the newest message entered into the archive. |
IstiMessageCachedArchive.ArchivableMsgObjEntry |
getLastCacheMessageObj()
Returns the newest message object entered into the cache. |
long |
getLastCacheMsgNum()
Returns the message number for the newest message entered into the cache. |
IstiMessageCachedArchive.ArchivableMsgObjEntry |
getLastMessageObj()
Returns the newest message object entered into the cache or archive. |
long |
getLastMsgNumber()
Returns the message number for the newest message entered into the cache or archive. |
protected java.lang.String |
getLogPrefixString()
Returns the prefix to use for log output. |
IstiMessageObjectCache |
getMessageCacheObj()
Returns the message cache. |
IstiTimeObjectCache.VectorWithCount |
getMessages(long beginTime,
long beginMsgNum,
long endTime,
long endMsgNum)
Retrieves a copy of messages in the specified time range (inclusive). |
IstiTimeObjectCache.VectorWithCount |
getMessages(long beginTime,
long beginMsgNum,
long endTime,
long endMsgNum,
int maxCount)
Retrieves a copy of messages in the specified time range (inclusive). |
IstiTimeObjectCache.VectorWithCount |
getMessages(long beginTime,
long beginMsgNum,
long endTime,
long endMsgNum,
int maxCount,
boolean cacheOnlyFlag)
Retrieves a copy of messages in the specified time range (inclusive). |
IstiTimeObjectCache.VectorWithCount |
getNewerMessages(long time,
long msgNum)
Returns a list of messages newer or equal to the specified time value or later than the specified message number. |
IstiTimeObjectCache.VectorWithCount |
getNewerMessages(long time,
long msgNum,
int maxCount)
Returns a list of messages newer or equal to the specified time value or later than the specified message number. |
IstiTimeObjectCache.VectorWithCount |
getNewerMessages(long time,
long msgNum,
int maxCount,
boolean cacheOnlyFlag)
Returns a list of messages newer or equal to the specified time value or later than the specified message number. |
IstiTimeObjectCache.VectorWithCount |
getOlderMessages(long time,
long msgNum)
Returns a list of messages older or equal to the specified time value or sooner than the specified message number. |
IstiTimeObjectCache.VectorWithCount |
getOlderMessages(long time,
long msgNum,
int maxCount)
Returns a list of messages older or equal to the specified time value or sooner than the specified message number. |
boolean |
isAddMessageQueueEmpty()
Returns the is-empty status of the add-message queue. |
boolean |
isCacheEmpty()
Returns the status of whether or not the cache is empty. |
void |
preloadCacheFromArchive()
Performs the initial loading of the cache from existing items in the archive. |
boolean |
removeOldObjects()
Removes old objects from the cache and archive. |
void |
setArchiveRemoveAgeSecs(int ageInSecs)
Modifies the remove-from-archive age used by the 'removeOldObjects()' method. |
void |
setCacheMaxObjectCount(int val)
Modifies the maximum-object count for the cache. |
void |
setCacheMaxTotalDataSize(long val)
Modifies the maximum-total-data size for the cache. |
void |
setCacheRemoveAgeSecs(int ageInSecs)
Modifies the remove-from-cache age used by the 'removeOldObjects()' and 'preloadCacheFromArchive()' methods. |
void |
setMaxRequestAgeSecs(int ageInSecs)
Modifies the max-request age used by the 'get...Messages()' methods. |
boolean |
waitForAddMessageQueueEmpty(long maxWaitMs)
Waits for the add-message queue to be empty, up to the specified amount of time. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final IstiMessageObjectCache messageCacheObj
protected final ArchiveManager archiveMgrObj
protected long cacheRemoveAgeMilliSecs
protected long archiveRemoveAgeMilliSecs
protected long maxRequestAgeMilliSecs
protected final LogFile logObj
protected final java.lang.Object dataAccessSyncObj
protected final java.util.Vector addMessageQueueVec
protected final IstiMessageCachedArchive.AddMessageWorkerThread addMessageWorkerThreadObj
protected boolean closingCacheArchiveFlag
Constructor Detail |
---|
public IstiMessageCachedArchive(ArchiveManager archiveMgrObj, LogFile logObj, long tolerance, int cacheRemoveAgeSecs, int cacheMaxObjectCount, long cacheMaxTotalDataSize, int archiveRemoveAgeSecs, int maxRequestAgeSecs, boolean useLookupKeyFlag)
archiveMgrObj
- an ArchiveManager object configured to
archive a subclass of 'ArchivableMsgObjEntry'.logObj
- log file object to use or null for no logging.tolerance
- number of milliseconds for time tolerance
that is used with time checkscacheRemoveAgeSecs
- the number of seconds to keep objects
in the cache.cacheMaxObjectCount
- the maximum-object count for the cache,
or 0 for no limit.cacheMaxTotalDataSize
- the maximum-total-data size for the
cache, or 0 for no limit.archiveRemoveAgeSecs
- the number of seconds to keep objects
in the archive, or 0 for "infinity".maxRequestAgeSecs
- maximum age (in seconds) for messages
returned via the 'get...Messages()' methods, or 0 for no limit.useLookupKeyFlag
- true to use the "dataStr" parameter (when
adding) as a table-lookup key (which forces cache entries to have
unique "dataStr" values).public IstiMessageCachedArchive(ArchiveManager archiveMgrObj, LogFile logObj, long tolerance, int cacheRemoveAgeSecs, int archiveRemoveAgeSecs, int maxRequestAgeSecs, boolean useLookupKeyFlag)
archiveMgrObj
- an ArchiveManager object configured to
archive a subclass of 'ArchivableMsgObjEntry'.logObj
- log file object to use or null for no logging.tolerance
- number of milliseconds for time tolerance
that is used with time checkscacheRemoveAgeSecs
- the number of seconds to keep objects
in the cache.archiveRemoveAgeSecs
- the number of seconds to keep objects
in the archive, or 0 for "infinity".maxRequestAgeSecs
- maximum age (in seconds) for messages
returned via the 'get...Messages()' methods, or 0 for no limit.useLookupKeyFlag
- true to use the "dataStr" parameter (when
adding) as a table-lookup key (which forces cache entries to have
unique "dataStr" values).public IstiMessageCachedArchive(ArchiveManager archiveMgrObj, LogFile logObj, long tolerance, int cacheRemoveAgeSecs, int cacheMaxObjectCount, long cacheMaxTotalDataSize, int archiveRemoveAgeSecs, int maxRequestAgeSecs)
archiveMgrObj
- an ArchiveManager object configured to
archive a subclass of 'ArchivableMsgObjEntry'.logObj
- log file object to use or null for no logging.tolerance
- number of milliseconds for time tolerance
that is used with time checkscacheRemoveAgeSecs
- the number of seconds to keep objects
in the cache.cacheMaxObjectCount
- the maximum-object count for the cache,
or 0 for no limit.cacheMaxTotalDataSize
- the maximum-total-data size for the
cache, or 0 for no limit.archiveRemoveAgeSecs
- the number of seconds to keep objects
in the archive, or 0 for "infinity".maxRequestAgeSecs
- maximum age (in seconds) for messages
returned via the 'get...Messages()' methods, or 0 for no limit.public IstiMessageCachedArchive(ArchiveManager archiveMgrObj, LogFile logObj, long tolerance, int cacheRemoveAgeSecs, int archiveRemoveAgeSecs, int maxRequestAgeSecs)
archiveMgrObj
- an ArchiveManager object configured to
archive a subclass of 'ArchivableMsgObjEntry'.logObj
- log file object to use or null for no logging.tolerance
- number of milliseconds for time tolerance
that is used with time checkscacheRemoveAgeSecs
- the number of seconds to keep objects
in the cache.archiveRemoveAgeSecs
- the number of seconds to keep objects
in the archive, or 0 for "infinity".maxRequestAgeSecs
- maximum age (in seconds) for messages
returned via the 'get...Messages()' methods, or 0 for no limit.Method Detail |
---|
public void addArchivableMsgObj(IstiMessageCachedArchive.ArchivableMsgObjEntry archivableMsgObj)
archivableMsgObj
- an 'ArchivableMsgObjEntry' object containing
the message data to be added.protected void doAddArchivableMsgObj(IstiMessageCachedArchive.ArchivableMsgObjEntry archivableMsgObj) throws java.io.IOException
archivableMsgObj
- an 'ArchivableMsgObjEntry' object containing
the message data to be added.
java.io.IOException
- if the archive file can not be written to.public IstiTimeObjectCache.VectorWithCount getMessages(long beginTime, long beginMsgNum, long endTime, long endMsgNum, int maxCount, boolean cacheOnlyFlag)
beginTime
- begin time in milliseconds or 0 for start of cache.beginMsgNum
- begin message number.endTime
- end time in milliseconds or 0 for end of cache.endMsgNum
- end message number.maxCount
- the maximum number of messages to be returned,
or 0 for no limit.cacheOnlyFlag
- true if messages are to be fetched only from
the cache; false if messages may be fetched from the archive or
the cache.
public IstiTimeObjectCache.VectorWithCount getMessages(long beginTime, long beginMsgNum, long endTime, long endMsgNum, int maxCount)
beginTime
- begin time in milliseconds or 0 for start of cache.beginMsgNum
- begin message number.endTime
- end time in milliseconds or 0 for end of cache.endMsgNum
- end message number.maxCount
- the maximum number of messages to be returned,
or 0 for no limit.
public IstiTimeObjectCache.VectorWithCount getMessages(long beginTime, long beginMsgNum, long endTime, long endMsgNum)
beginTime
- begin time in milliseconds or 0 for start of cache.beginMsgNum
- begin message number.endTime
- end time in milliseconds or 0 for end of cache.endMsgNum
- end message number.
public IstiTimeObjectCache.VectorWithCount getNewerMessages(long time, long msgNum, int maxCount, boolean cacheOnlyFlag)
time
- time in milliseconds.msgNum
- message number.maxCount
- the maximum number of messages to be returned,
or 0 for no limit.cacheOnlyFlag
- true if messages are to be fetched only from
the cache; false if messages may be fetched from the archive or
the cache.
public IstiTimeObjectCache.VectorWithCount getNewerMessages(long time, long msgNum, int maxCount)
time
- time in milliseconds.msgNum
- message number.maxCount
- the maximum number of messages to be returned,
or 0 for no limit.
public IstiTimeObjectCache.VectorWithCount getNewerMessages(long time, long msgNum)
time
- time in milliseconds.msgNum
- message number.
public IstiTimeObjectCache.VectorWithCount getOlderMessages(long time, long msgNum, int maxCount)
time
- time in milliseconds.msgNum
- message number.maxCount
- the maximum number of messages to be returned,
or 0 for no limit.
public IstiTimeObjectCache.VectorWithCount getOlderMessages(long time, long msgNum)
time
- time in milliseconds.msgNum
- message number.
public void preloadCacheFromArchive()
public boolean removeOldObjects()
public boolean cacheContains(IstiMessageCachedArchive.ArchivableMsgObjEntry archivableMsgObj)
archivableMsgObj
- an 'ArchivableMsgObjEntry' object to use.
public boolean isCacheEmpty()
public int getCacheSize()
public IstiMessageCachedArchive.ArchivableMsgObjEntry getLastCacheMessageObj()
public IstiMessageCachedArchive.ArchivableMsgObjEntry getLastArchiveMessageObj()
public IstiMessageCachedArchive.ArchivableMsgObjEntry getLastMessageObj()
public long getLastCacheMsgNum()
public long getLastArchiveMsgNum()
public long getLastMsgNumber()
public void setCacheRemoveAgeSecs(int ageInSecs)
ageInSecs
- the age to use, in seconds.public void setCacheMaxObjectCount(int val)
val
- the maximum-object count for the cache, or 0 for
no maximum-object count limit (the default).public void setCacheMaxTotalDataSize(long val)
val
- the maximum-total-data size for the cache, or 0 for
no maximum-total-data size limit (the default).public void setArchiveRemoveAgeSecs(int ageInSecs)
ageInSecs
- the age to use, in seconds.public void setMaxRequestAgeSecs(int ageInSecs)
ageInSecs
- the age to use, in seconds.public boolean isAddMessageQueueEmpty()
public boolean waitForAddMessageQueueEmpty(long maxWaitMs)
maxWaitMs
- the maximum number of milliseconds to wait for
the queue to be empty, or 0 to wait indefinitely.
public java.lang.Object getDataAccessSyncObj()
public IstiMessageObjectCache getMessageCacheObj()
public void close()
protected java.lang.String getLogPrefixString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |