|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.impl.cm.Cm
public final class Cm
This class implements a limited document caching mechanism intended to provide cache for services that have a need for cache to search and exchange jxta documents.
Only Core Services are intended to use this mechanism.
Field Summary | |
---|---|
static long |
DEFAULT_GC_MAX_INTERVAL
|
protected File |
rootDir
file descriptor for the root of the cm |
(package private) File |
ROOTDIRBASE
the name we will use for the base directory |
Constructor Summary | |
---|---|
Cm(ThreadGroup threadGroup,
URI storeRoot,
String areaName,
long gcinterval,
boolean trackDeltas)
Constructor for cm |
|
Cm(URI storeRoot,
String areaName)
Constructor for cm |
Method Summary | |
---|---|
static String |
createTmpName(StructuredTextDocument doc)
Generates a random file name using doc hashcode |
void |
garbageCollect()
|
List<SrdiMessage.Entry> |
getDeltas(String dn)
returns all entries that are added since this method was last called |
List<SrdiMessage.Entry> |
getEntries(String dn,
boolean clearDeltas)
returns all entries that are cached |
long |
getExpirationtime(String dn,
String fn)
Returns the maximum duration in milliseconds for which this document should cached by those other than the publisher. |
protected static IndexQuery |
getIndexQuery(String value)
|
InputStream |
getInputStream(String dn,
String fn)
Returns the inputStream of a specified file, in a specified dir |
long |
getLifetime(String dn,
String fn)
Returns the relative time in milliseconds at which the file will expire. |
List<InputStream> |
getRecords(String dn,
int threshold,
List<Long> expirations)
Gets the list of all the files into the given folder |
List<InputStream> |
getRecords(String dn,
int threshold,
List<Long> expirations,
boolean purge)
|
void |
remove(String dn,
String fn)
Remove a file |
StructuredDocument |
restore(String dn,
String fn)
Restore a saved StructuredDocument. |
byte[] |
restoreBytes(String dn,
String fn)
Restore an advetisement into a byte array. |
void |
run()
|
void |
save(String dn,
String fn,
Advertisement adv)
Stores a StructuredDocument in specified dir, and file name |
void |
save(String dn,
String fn,
Advertisement adv,
long lifetime,
long expiration)
Stores a StructuredDocument in specified dir, and file name, and associated doc timeouts |
void |
save(String dn,
String fn,
byte[] data,
long lifetime,
long expiration)
Store some bytes in specified dir, and file name, and associated doc timeouts |
List<InputStream> |
search(String dn,
String attribute,
String value,
int threshold,
List<Long> expirations)
Search and recovers documents that contains at least a macthing pair of tag/value. |
void |
setTrackDeltas(boolean trackDeltas)
|
void |
stop()
stop the cm |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
final File ROOTDIRBASE
public static final long DEFAULT_GC_MAX_INTERVAL
protected File rootDir
Constructor Detail |
---|
public Cm(URI storeRoot, String areaName)
areaName
- the name of the cm sub-dir to create
NOTE: Default garbage interval once an hourstoreRoot
- store root dirpublic Cm(ThreadGroup threadGroup, URI storeRoot, String areaName, long gcinterval, boolean trackDeltas)
threadGroup
- the thread groupstoreRoot
- persistence locationgcinterval
- garbage collect max intervaltrackDeltas
- when true deltas are trackedareaName
- storage area nameMethod Detail |
---|
public String toString()
toString
in class Object
public static String createTmpName(StructuredTextDocument doc)
doc
- to hash to generate a unique name
public List<InputStream> getRecords(String dn, int threshold, List<Long> expirations)
dn
- contains the name of the folderthreshold
- the max number of resultsexpirations
- List to contain expirations
public List<InputStream> getRecords(String dn, int threshold, List<Long> expirations, boolean purge)
public void garbageCollect()
public long getLifetime(String dn, String fn)
dn
- contains the name of the folderfn
- contains the name of the file
public long getExpirationtime(String dn, String fn)
dn
- contains the name of the folderfn
- contains the name of the file
public InputStream getInputStream(String dn, String fn) throws IOException
dn
- directory namefn
- file name
IOException
- if an I/O error occurspublic void remove(String dn, String fn) throws IOException
dn
- directory namefn
- file name
IOException
- if an I/O error occurspublic StructuredDocument restore(String dn, String fn) throws IOException
dn
- directory namefn
- file name
IOException
- if an I/O error occurs
was not possible.public byte[] restoreBytes(String dn, String fn) throws IOException
dn
- directory namefn
- file name
IOException
- if an I/O error occurspublic void save(String dn, String fn, Advertisement adv) throws IOException
dn
- directory namefn
- file nameadv
- Advertisement to store
IOException
- if an I/O error occurspublic void save(String dn, String fn, Advertisement adv, long lifetime, long expiration) throws IOException
dn
- directory namefn
- file nameadv
- Advertisement to savelifetime
- Document (local) lifetime in relative msexpiration
- Document (global) expiration time in relative ms
IOException
- Thrown if there is a problem saving the document.public void save(String dn, String fn, byte[] data, long lifetime, long expiration) throws IOException
dn
- directory namefn
- file namedata
- byte array to savelifetime
- Document (local) lifetime in relative msexpiration
- Document (global) expiration time in relative ms
IOException
- Thrown if there is a problem saving the document.protected static IndexQuery getIndexQuery(String value)
public List<InputStream> search(String dn, String attribute, String value, int threshold, List<Long> expirations)
dn
- contains the name of the folder on which to
perform the searchvalue
- contains the value to search on.attribute
- attribute to search onthreshold
- thresholdexpirations
- List to contain expirations
public List<SrdiMessage.Entry> getEntries(String dn, boolean clearDeltas)
dn
- the relative dir nameclearDeltas
- if true clears the delta cache
public List<SrdiMessage.Entry> getDeltas(String dn)
dn
- the relative dir name
public void setTrackDeltas(boolean trackDeltas)
public void stop()
public void run()
run
in interface Runnable
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |