proai.cache
Class RecordCache

java.lang.Object
  extended by java.lang.Thread
      extended by proai.cache.RecordCache
All Implemented Interfaces:
java.lang.Runnable

public class RecordCache
extends java.lang.Thread

Main application interface for working with items in the cache, whether in the database or on disk.

Author:
Chris Wilper

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.lang.String[] EXAMPLE_SCHEMAS
           
static java.lang.String OAI_RECORD_SCHEMA_URL
           
static java.lang.String PROP_BASEDIR
           
static java.lang.String PROP_DB_DRIVERCLASSNAME
           
static java.lang.String PROP_DB_MYSQL_TRICKLING
           
static java.lang.String PROP_DB_PASSWORD
           
static java.lang.String PROP_DB_URL
           
static java.lang.String PROP_DB_USERNAME
           
static java.lang.String PROP_MAXCOMMITQUEUESIZE
           
static java.lang.String PROP_MAXFAILEDRETRIES
           
static java.lang.String PROP_MAXRECORDSPERTRANS
           
static java.lang.String PROP_MAXWORKBATCHSIZE
           
static java.lang.String PROP_MAXWORKERS
           
static java.lang.String PROP_OAIDRIVERCLASSNAME
           
static java.lang.String PROP_POLLINGENABLED
           
static java.lang.String PROP_POLLSECONDS
           
static java.lang.String PROP_SCHEMADIR
           
static java.lang.String PROP_VALIDATEUPDATES
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RecordCache(org.apache.commons.dbcp.BasicDataSource pool, DDLConverter ddlc, boolean mySQLTrickling, boolean backslashIsEscape, boolean pollingEnabled, OAIDriver driver, int pollSeconds, java.io.File baseDir, int maxWorkers, int maxWorkBatchSize, int maxFailedRetries, int maxCommitQueueSize, int maxRecordsPerTransaction, boolean validateUpdates, java.io.File schemaDir)
           
RecordCache(java.util.Properties props)
           
 
Method Summary
 void close()
           
 void finalize()
          Ensure close has occurred at GC-time.
 boolean formatExists(java.lang.String mdPrefix)
           
protected static java.sql.Connection getConnection()
          Get a connection from the pool.
 java.io.File getFile(java.lang.String cachePath)
           
 Writable getIdentifyContent()
           
 Writable getMetadataFormatsContent(java.lang.String identifier)
           
 Writable getRecordContent(java.lang.String identifier, java.lang.String metadataPrefix)
          Return the specified record, or null if it doesn't exist.
 CloseableIterator<CachedContent> getRecordsContent(java.util.Date from, java.util.Date until, java.lang.String prefix, java.lang.String set, boolean identifiers)
           
 CloseableIterator<java.lang.String[]> getRecordsPaths(java.util.Date from, java.util.Date until, java.lang.String prefix, java.lang.String set)
           
 CloseableIterator<SetInfo> getSetInfoContent()
           
 CloseableIterator<java.lang.String[]> getSetInfoPaths()
           
 boolean itemExists(java.lang.String identifier)
           
protected static void releaseConnection(java.sql.Connection conn)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OAI_RECORD_SCHEMA_URL

public static final java.lang.String OAI_RECORD_SCHEMA_URL
See Also:
Constant Field Values

EXAMPLE_SCHEMAS

public static final java.lang.String[] EXAMPLE_SCHEMAS

PROP_BASEDIR

public static final java.lang.String PROP_BASEDIR
See Also:
Constant Field Values

PROP_OAIDRIVERCLASSNAME

public static final java.lang.String PROP_OAIDRIVERCLASSNAME
See Also:
Constant Field Values

PROP_POLLSECONDS

public static final java.lang.String PROP_POLLSECONDS
See Also:
Constant Field Values

PROP_POLLINGENABLED

public static final java.lang.String PROP_POLLINGENABLED
See Also:
Constant Field Values

PROP_MAXWORKERS

public static final java.lang.String PROP_MAXWORKERS
See Also:
Constant Field Values

PROP_MAXWORKBATCHSIZE

public static final java.lang.String PROP_MAXWORKBATCHSIZE
See Also:
Constant Field Values

PROP_MAXFAILEDRETRIES

public static final java.lang.String PROP_MAXFAILEDRETRIES
See Also:
Constant Field Values

PROP_MAXCOMMITQUEUESIZE

public static final java.lang.String PROP_MAXCOMMITQUEUESIZE
See Also:
Constant Field Values

PROP_MAXRECORDSPERTRANS

public static final java.lang.String PROP_MAXRECORDSPERTRANS
See Also:
Constant Field Values

PROP_SCHEMADIR

public static final java.lang.String PROP_SCHEMADIR
See Also:
Constant Field Values

PROP_VALIDATEUPDATES

public static final java.lang.String PROP_VALIDATEUPDATES
See Also:
Constant Field Values

PROP_DB_URL

public static final java.lang.String PROP_DB_URL
See Also:
Constant Field Values

PROP_DB_DRIVERCLASSNAME

public static final java.lang.String PROP_DB_DRIVERCLASSNAME
See Also:
Constant Field Values

PROP_DB_MYSQL_TRICKLING

public static final java.lang.String PROP_DB_MYSQL_TRICKLING
See Also:
Constant Field Values

PROP_DB_USERNAME

public static final java.lang.String PROP_DB_USERNAME
See Also:
Constant Field Values

PROP_DB_PASSWORD

public static final java.lang.String PROP_DB_PASSWORD
See Also:
Constant Field Values
Constructor Detail

RecordCache

public RecordCache(java.util.Properties props)
            throws ServerException
Throws:
ServerException

RecordCache

public RecordCache(org.apache.commons.dbcp.BasicDataSource pool,
                   DDLConverter ddlc,
                   boolean mySQLTrickling,
                   boolean backslashIsEscape,
                   boolean pollingEnabled,
                   OAIDriver driver,
                   int pollSeconds,
                   java.io.File baseDir,
                   int maxWorkers,
                   int maxWorkBatchSize,
                   int maxFailedRetries,
                   int maxCommitQueueSize,
                   int maxRecordsPerTransaction,
                   boolean validateUpdates,
                   java.io.File schemaDir)
            throws ServerException
Throws:
ServerException
Method Detail

getConnection

protected static java.sql.Connection getConnection()
                                            throws java.sql.SQLException
Get a connection from the pool.

Throws:
java.sql.SQLException

releaseConnection

protected static void releaseConnection(java.sql.Connection conn)

getFile

public java.io.File getFile(java.lang.String cachePath)

getRecordContent

public Writable getRecordContent(java.lang.String identifier,
                                 java.lang.String metadataPrefix)
                          throws ServerException
Return the specified record, or null if it doesn't exist.

Throws:
ServerException

getIdentifyContent

public Writable getIdentifyContent()
                            throws ServerException
Throws:
ServerException

getMetadataFormatsContent

public Writable getMetadataFormatsContent(java.lang.String identifier)
                                   throws ServerException
Throws:
ServerException

getSetInfoContent

public CloseableIterator<SetInfo> getSetInfoContent()
                                             throws ServerException
Throws:
ServerException

getSetInfoPaths

public CloseableIterator<java.lang.String[]> getSetInfoPaths()
                                                      throws ServerException
Throws:
ServerException

getRecordsContent

public CloseableIterator<CachedContent> getRecordsContent(java.util.Date from,
                                                          java.util.Date until,
                                                          java.lang.String prefix,
                                                          java.lang.String set,
                                                          boolean identifiers)
                                                   throws ServerException
Throws:
ServerException

getRecordsPaths

public CloseableIterator<java.lang.String[]> getRecordsPaths(java.util.Date from,
                                                             java.util.Date until,
                                                             java.lang.String prefix,
                                                             java.lang.String set)
                                                      throws ServerException
Throws:
ServerException

formatExists

public boolean formatExists(java.lang.String mdPrefix)
                     throws ServerException
Throws:
ServerException

itemExists

public boolean itemExists(java.lang.String identifier)
                   throws ServerException
Throws:
ServerException

close

public void close()
           throws ServerException
Throws:
ServerException

finalize

public void finalize()
              throws ServerException
Ensure close has occurred at GC-time.

Overrides:
finalize in class java.lang.Object
Throws:
ServerException