public class BdbMultipleWorkQueues extends Object
For how the bdb keys are made, see calculateInsertKey(CrawlURI)
.
TODO: refactor, improve naming.
Constructor and Description |
---|
BdbMultipleWorkQueues(com.sleepycat.je.Database db,
com.sleepycat.bind.serial.StoredClassCatalog classCatalog)
Create the multi queue in the given environment.
|
Modifier and Type | Method and Description |
---|---|
void |
addCap(byte[] origin)
Add a dummy 'cap' entry at the given insertion key.
|
protected static com.sleepycat.je.DatabaseEntry |
calculateInsertKey(CrawlURI curi)
Calculate the insertKey that places a CrawlURI in the
desired spot.
|
protected static byte[] |
calculateOriginKey(String classKey)
Calculate the 'origin' key for a virtual queue of items
with the given classKey.
|
void |
close()
clean up
|
void |
delete(CrawlURI item)
Delete the given CrawlURI from persistent store.
|
long |
deleteMatchingFromQueue(String match,
String queue,
com.sleepycat.je.DatabaseEntry headKey)
Delete all CrawlURIs matching the given expression.
|
protected void |
forAllPendingDo(org.apache.commons.collections.Closure c)
Utility method to perform action for all pending CrawlURI instances.
|
CrawlURI |
get(com.sleepycat.je.DatabaseEntry headKey)
Get the next nearest item after the given key.
|
protected com.sleepycat.je.DatabaseEntry |
getFirstKey() |
CompositeData |
getFrom(String m,
int maxMatches,
Pattern pattern,
boolean verbose) |
protected com.sleepycat.je.OperationStatus |
getNextNearestItem(com.sleepycat.je.DatabaseEntry headKey,
com.sleepycat.je.DatabaseEntry result) |
protected static String |
insertKeyToString(com.sleepycat.je.DatabaseEntry holderKey) |
void |
put(CrawlURI curi,
boolean overwriteIfPresent)
Put the given CrawlURI in at the appropriate place.
|
protected void |
sync()
Method used by BdbFrontier during checkpointing.
|
public BdbMultipleWorkQueues(com.sleepycat.je.Database db, com.sleepycat.bind.serial.StoredClassCatalog classCatalog) throws com.sleepycat.je.DatabaseException
env
- bdb environment to useclassCatalog
- Class catalog to use.recycle
- True if we are to reuse db content if any.com.sleepycat.je.DatabaseException
public long deleteMatchingFromQueue(String match, String queue, com.sleepycat.je.DatabaseEntry headKey) throws com.sleepycat.je.DatabaseException
match
- queue
- headKey
- com.sleepycat.je.DatabaseException
com.sleepycat.je.DatabaseException
public CompositeData getFrom(String m, int maxMatches, Pattern pattern, boolean verbose) throws com.sleepycat.je.DatabaseException
m
- marker or null to start with first entrymaxMatches
- com.sleepycat.je.DatabaseException
protected com.sleepycat.je.DatabaseEntry getFirstKey() throws com.sleepycat.je.DatabaseException
com.sleepycat.je.DatabaseException
public CrawlURI get(com.sleepycat.je.DatabaseEntry headKey) throws com.sleepycat.je.DatabaseException
TODO: hold within a queue's range
headKey
- Key prefix that demarks the beginning of the range
in pendingUrisDB
we're interested in.com.sleepycat.je.DatabaseException
protected com.sleepycat.je.OperationStatus getNextNearestItem(com.sleepycat.je.DatabaseEntry headKey, com.sleepycat.je.DatabaseEntry result) throws com.sleepycat.je.DatabaseException
com.sleepycat.je.DatabaseException
public void put(CrawlURI curi, boolean overwriteIfPresent) throws com.sleepycat.je.DatabaseException
curi
- com.sleepycat.je.DatabaseException
protected static byte[] calculateOriginKey(String classKey)
classKey
- String key to derive origin byte key fromprotected static com.sleepycat.je.DatabaseEntry calculateInsertKey(CrawlURI curi)
curi
- protected static String insertKeyToString(com.sleepycat.je.DatabaseEntry holderKey)
public void delete(CrawlURI item) throws com.sleepycat.je.DatabaseException
item
- com.sleepycat.je.DatabaseException
protected void sync()
The backing bdbje database has been marked deferred write so we save on writes to disk. Means no guarantees disk will have whats in memory unless a sync is called (Calling sync on the bdbje Environment is not sufficent).
Package access only because only Frontiers of this package would ever need access.
public void close()
public void addCap(byte[] origin)
origin
- key at which to insert the capprotected void forAllPendingDo(org.apache.commons.collections.Closure c) throws com.sleepycat.je.DatabaseException
c
- Closure action to performcom.sleepycat.je.DatabaseException
Copyright © 2003-2014 Internet Archive. All Rights Reserved.