|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.isti.util.IstiTimeObjectCache
Class IstiTimeObjectCache implements the time object cache. The 'removeOldObjects()' method should be called on a periodic basis to remove old objects from the cache.
Nested Class Summary | |
static class |
IstiTimeObjectCache.BasicTimeObjectEntry
Basic time object entry. |
static class |
IstiTimeObjectCache.CacheInformation
Class CacheInformation holds information about the cache. |
static interface |
IstiTimeObjectCache.TimeObjectEntry
Time object entry |
static class |
IstiTimeObjectCache.VectorWithCount
Subclass of Vector that also holds a 'count' value. |
Field Summary | |
protected long |
defaultRemoveAge
|
protected long |
lastMsgTimeTracker
|
protected LogFile |
logObj
|
protected int |
maximumObjectCount
|
protected long |
maximumTotalDataSize
|
protected FifoHashtable |
objectCache
|
protected long |
tolerance
|
protected long |
totalCacheDataSize
|
protected boolean |
useLookupKeyFlag
|
Constructor Summary | |
IstiTimeObjectCache(LogFile logObj,
long tolerance)
Constructs a time object cache. |
|
IstiTimeObjectCache(LogFile logObj,
long tolerance,
boolean useLookupKeyFlag)
Constructs a time object cache. |
|
IstiTimeObjectCache(LogFile logObj,
long tolerance,
long removeAge)
Constructs a time object cache with a default remove age. |
|
IstiTimeObjectCache(LogFile logObj,
long tolerance,
long removeAge,
boolean useLookupKeyFlag)
Constructs a time object cache with a default remove age. |
Method Summary | |
void |
add(IstiTimeObjectCache.TimeObjectEntry entryObj)
Adds the time object entry. |
void |
add(long timeGenerated,
java.lang.Object dataObj,
java.lang.String keyStr)
Adds the time entry. |
protected void |
checkRemoveViaTotalDataSize()
Checks if the total-data size for the cache is above the 'maximumTotalDataSize' limit and, if so, removes entries until the total-data size is under the limit. |
void |
clearCache()
Clears all entries in the cache. |
void |
close()
Deallocates resources associated with the cache. |
boolean |
containsEntry(IstiTimeObjectCache.TimeObjectEntry entryObj)
Returns true if the cache contains an entry equal to the given entry-object. |
boolean |
containsKey(java.lang.Object keyObj)
Returns true if the cache contains an entry with a 'keyStr' equal to the given object. |
boolean |
containsObjectKey(IstiTimeObjectCache.TimeObjectEntry entryObj)
Returns true if the cache contains an entry with a 'keyStr' equal to the 'keyStr' for the given entry-object. |
java.util.Vector |
getAllObjects()
Retrieves a copy of all of the objects. |
IstiTimeObjectCache.CacheInformation |
getCacheInformation()
Returns information about the cache. |
IstiTimeObjectCache.TimeObjectEntry |
getFirstObject()
Returns the first object in the cache. |
java.util.Vector |
getFirstObjects(int numObjects)
Retrieves a copy of the first 'n' objects. |
IstiTimeObjectCache.TimeObjectEntry |
getLastObject()
Returns the last object in the cache. |
LogFile |
getLogFile()
Returns the log file. |
protected java.lang.String |
getLogPrefixString()
Gets the prefix to use for log output. |
int |
getMaximumObjectCount()
Returns the maximum-object count for the cache. |
long |
getMaximumTotalDataSize()
Returns the maximum-total-data size for the cache. |
int |
getMessageCount()
Returns the number of objects in the cache. |
IstiTimeObjectCache.VectorWithCount |
getNewerObjects(long time)
Retrieves a copy of objects that are newer or equal to the specified time. |
IstiTimeObjectCache.VectorWithCount |
getNewerObjects(long time,
int maxCount)
Retrieves a copy of objects that are newer or equal to the specified time. |
protected IstiTimeObjectCache.TimeObjectEntry |
getObject(int index)
Returns the entry at the given index. |
IstiTimeObjectCache.VectorWithCount |
getObjects(long beginTime,
long endTime)
Retrieves a copy of objects in the specified time range (inclusive). |
IstiTimeObjectCache.VectorWithCount |
getObjects(long beginTime,
long endTime,
int maxCount)
Retrieves a copy of objects in the specified time range (inclusive). |
IstiTimeObjectCache.VectorWithCount |
getOlderObjects(long time)
Retrieves a copy of objects that are older or equal to the specified time. |
IstiTimeObjectCache.VectorWithCount |
getOlderObjects(long time,
int maxCount)
Retrieves a copy of objects that are older or equal to the specified time. |
long |
getTotalCacheDataSize()
Returns the total-data size for the cache. |
boolean |
getUseLookupKeyFlag()
Returns the 'useLookupKeyFlag' flag value. |
boolean |
isEmpty()
Returns the status of whether or not the cache is empty. |
boolean |
removeOldObjects()
Removes old objects from the cache with the default remove age. |
boolean |
removeOldObjects(long removeAge)
Removes old objects using the specified remove age. |
void |
setDefaultRemoveAge(long ageVal)
Sets the remove-age value used by the no-parameter version of 'removeOldObjects()'. |
void |
setMaximumObjectCount(int val)
Sets the maximum-object count for the cache. |
void |
setMaximumTotalDataSize(long val)
Sets the maximum-total-data size for the cache. |
int |
size()
Returns the number of entries in the cache. |
protected IstiTimeObjectCache.VectorWithCount |
subListVector(long beginTime,
long endTime,
int maxCount)
Retrieves a sub list of objects. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final LogFile logObj
protected final boolean useLookupKeyFlag
protected long tolerance
protected long defaultRemoveAge
protected int maximumObjectCount
protected long maximumTotalDataSize
protected long totalCacheDataSize
protected final FifoHashtable objectCache
protected long lastMsgTimeTracker
Constructor Detail |
public IstiTimeObjectCache(LogFile logObj, long tolerance, long removeAge, boolean useLookupKeyFlag)
logObj
- log file object to use or null for no logging.tolerance
- number of milliseconds for time tolerance
that is used with time checksremoveAge
- number of milliseconds to keep objects in the cache
or 0 for no default.useLookupKeyFlag
- true to use the "keyStr" parameter (when
adding) as a table-lookup key (which forces cache entries to have
unique "keyStr" values).public IstiTimeObjectCache(LogFile logObj, long tolerance, long removeAge)
logObj
- log file object to use or null for no logging.tolerance
- number of milliseconds for time tolerance
that is used with time checksremoveAge
- number of milliseconds to keep objects in the cache
or 0 for no default.public IstiTimeObjectCache(LogFile logObj, long tolerance, boolean useLookupKeyFlag)
logObj
- log file object to use or null for no logging.tolerance
- number of milliseconds for time tolerance
that is used with time checksuseLookupKeyFlag
- true to use the "keyStr" parameter (when
adding) as a table-lookup key (which forces cache entries to have
unique "keyStr" values).public IstiTimeObjectCache(LogFile logObj, long tolerance)
logObj
- log file object to use or null for no logging.tolerance
- number of milliseconds for time tolerance
that is used with time checksMethod Detail |
public void add(long timeGenerated, java.lang.Object dataObj, java.lang.String keyStr)
timeGenerated
- the time the message was generateddataObj
- data object.keyStr
- message string.public java.util.Vector getAllObjects()
public java.util.Vector getFirstObjects(int numObjects)
numObjects
- the maximum number of objects to return.
public IstiTimeObjectCache.TimeObjectEntry getFirstObject()
public IstiTimeObjectCache.TimeObjectEntry getLastObject()
public LogFile getLogFile()
public boolean getUseLookupKeyFlag()
public IstiTimeObjectCache.VectorWithCount getNewerObjects(long time, int maxCount)
time
- time in milliseconds
included, false otherwisemaxCount
- the maximum number of objects to be returned,
or 0 for no limit.
public IstiTimeObjectCache.VectorWithCount getNewerObjects(long time)
time
- time in milliseconds
included, false otherwise
public IstiTimeObjectCache.VectorWithCount getObjects(long beginTime, long endTime, int maxCount)
beginTime
- begin time in milliseconds or 0 for start of cacheendTime
- end time in milliseconds or 0 for end of cache.maxCount
- the maximum number of objects to be returned,
or 0 for no limit.
public IstiTimeObjectCache.VectorWithCount getObjects(long beginTime, long endTime)
beginTime
- begin time in milliseconds or 0 for start of cacheendTime
- end time in milliseconds or 0 for end of cache.
public IstiTimeObjectCache.VectorWithCount getOlderObjects(long time, int maxCount)
time
- time in milliseconds.maxCount
- the maximum number of objects to be returned,
or 0 for no limit.
public IstiTimeObjectCache.VectorWithCount getOlderObjects(long time)
time
- time in milliseconds.
public boolean removeOldObjects(long removeAge)
removeAge
- number of milliseconds to keep objects in the cache.
public boolean removeOldObjects()
protected void checkRemoveViaTotalDataSize()
public void clearCache()
public void setDefaultRemoveAge(long ageVal)
ageVal
- the remove-age values to use, in milliseconds.public void setMaximumObjectCount(int val)
val
- the maximum-object count for the cache, or 0 for
no maximum-object count limit (the default).public int getMaximumObjectCount()
public void setMaximumTotalDataSize(long val)
val
- the maximum-total-data size for the cache, or 0 for
no maximum-total-data size limit (the default).public long getMaximumTotalDataSize()
public long getTotalCacheDataSize()
public int getMessageCount()
public IstiTimeObjectCache.CacheInformation getCacheInformation()
public void add(IstiTimeObjectCache.TimeObjectEntry entryObj)
entryObj
- time-entry object.public boolean containsKey(java.lang.Object keyObj)
keyObj
- the key object to use.
public boolean containsObjectKey(IstiTimeObjectCache.TimeObjectEntry entryObj)
entryObj
- the entry-object to use.
public boolean containsEntry(IstiTimeObjectCache.TimeObjectEntry entryObj)
entryObj
- the entry-object to use.
public int size()
public boolean isEmpty()
protected java.lang.String getLogPrefixString()
protected IstiTimeObjectCache.TimeObjectEntry getObject(int index)
index
- index of the entry.
java.lang.ArrayIndexOutOfBoundsException
- if the index is negative
or not less than the current size of the cache.protected IstiTimeObjectCache.VectorWithCount subListVector(long beginTime, long endTime, int maxCount)
beginTime
- minimum time (in milliseconds, inclusive) for
returned objects, or 0 for start of cache.endTime
- maximum time (in milliseconds, inclusive) for
returned objects, or 0 for end of cache.maxCount
- the maximum number of objects to be returned,
or 0 for no limit.
public void close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |