public class LocatorStorageAlgorithm extends Algorithm
Algorithm
that stores all the inserted objects into additional
storage. The insert/delete operations are intercepted by the wrapper algorithm and
used to update the local storage. The modification operations are then passed the encapsulated
algorithm for processing.
The GetObjectByLocatorOperation
and GetObjectsByLocatorsOperation
are handled
by the wrapper by accessing the indexed storage. All the other query operations
are handled by the encapsulated algorithm.Algorithm.AlgorithmConstructor
log, maximalConcurrentOperations
Constructor and Description |
---|
LocatorStorageAlgorithm(Algorithm encapsulatedAlgorithm,
StorageIndexed<LocalAbstractObject> storage)
Creates a new locator-storage algorithm wrapper for the given algorithm.
|
LocatorStorageAlgorithm(Algorithm encapsulatedAlgorithm,
java.lang.String metaobjectName,
StorageIndexed<LocalAbstractObject> storage)
Creates a new locator-storage algorithm wrapper for the given algorithm.
|
LocatorStorageAlgorithm(Algorithm encapsulatedAlgorithm,
java.lang.String dbConnUrl,
java.lang.String tableName,
java.lang.Class<?>[] cacheClasses)
Creates a new locator-db-storage algorithm wrapper for the given algorithm.
|
LocatorStorageAlgorithm(Algorithm encapsulatedAlgorithm,
java.lang.String metaobjectName,
java.lang.String dbConnUrl,
java.lang.String tableName,
java.lang.Class<?>[] cacheClasses)
Creates a new locator-db-storage algorithm wrapper for the given algorithm.
|
Modifier and Type | Method and Description |
---|---|
void |
bulkInsertOperation(BulkInsertOperation op)
Implementation of the bulk-insert operation.
|
void |
deleteByLocatorOperation(DeleteByLocatorOperation op)
Implementation of the delete-by-locator operation.
|
void |
deleteOperation(DeleteOperation op)
Implementation of the delete operation.
|
void |
destroy()
Destroy this algorithm.
|
void |
finalize()
Finalize the algorithm.
|
Algorithm |
getAlgorithm()
Returns the encapsulated algorithm.
|
void |
getRandomObjects(GetRandomObjectsQueryOperation op)
Implementation of the get-random-objects operation
The objects are retrieved using the internal storage.
|
void |
insertOperation(InsertOperation op)
Implementation of the insert operation.
|
void |
objectByLocator(GetObjectByLocatorOperation op)
Implementation of the get-by-locator operation.
|
void |
objectsByLocators(GetObjectsByLocatorsOperation op)
Implementation of the get-by-multiple-locators operation.
|
void |
processOperation(AbstractOperation op)
Implementation of a generic operation.
|
java.lang.String |
toString() |
afterStoreToFile, backgroundExecuteOperation, backgroundExecuteOperationIndependent, backgroundExecuteOperationWithStatistics, beforeStoreToFile, createBackgroundExecutionCallable, execute, executeMethodWithStringArguments, executeOperation, executeUsingNavDir, getAllRunningOperations, getAnnotatedConstructors, getAnnotatedConstructorsArray, getConstructorArgumentDescriptions, getConstructorDescription, getConstructorDescriptionSimple, getExecutorParamClasses, getFirstSupportedOperation, getName, getObjectClass, getObjectCount, getOperationStatistics, getOperationsThreadPool, getOperationSubClasses, getQueryAnswer, getQueryAnswer, getRunningOperationById, getRunningOperationsCount, getSupportedOperations, getSupportedOperations, methodExecute, resetOperationStatistics, restoreFromFile, restoreFromFile, setExecutedOperationsLogVerbosity, setOperationsThreadPool, setupStatsAndExecuteOperation, statisticsAfterOperation, statisticsBeforeOperation, storeToFile, terminateOperation, terminateOperation, waitBackgroundExecution
public LocatorStorageAlgorithm(Algorithm encapsulatedAlgorithm, java.lang.String metaobjectName, StorageIndexed<LocalAbstractObject> storage) throws java.lang.IllegalArgumentException
metaobjectName
parameter is set.encapsulatedAlgorithm
- the algorithm to wrapmetaobjectName
- the name of the MetaObject
encapsulated object to index in the algorithm (if null the whole object is indexed)storage
- the storage used for indexed retrieval of the objectsjava.lang.IllegalArgumentException
- if the prototype returned by getExecutorParamClasses
has no itemspublic LocatorStorageAlgorithm(Algorithm encapsulatedAlgorithm, StorageIndexed<LocalAbstractObject> storage) throws java.lang.IllegalArgumentException
encapsulatedAlgorithm
- the algorithm to wrapstorage
- the storage used for indexed retrieval of the objectsjava.lang.IllegalArgumentException
- if the prototype returned by getExecutorParamClasses
has no itemspublic LocatorStorageAlgorithm(Algorithm encapsulatedAlgorithm, java.lang.String metaobjectName, java.lang.String dbConnUrl, java.lang.String tableName, java.lang.Class<?>[] cacheClasses) throws java.lang.IllegalArgumentException, java.sql.SQLException
Note that the locator-storage stores the objects as-is while the
algorithm can index only one of the encapsulated objects if the
metaobjectName
parameter is set.
encapsulatedAlgorithm
- the algorithm to wrapmetaobjectName
- the name of the MetaObject
encapsulated object to index in the algorithm (if null the whole object is indexed)dbConnUrl
- the database connection URL (JDBC)tableName
- the name of the table in which to store the datacacheClasses
- the classes for the binary serializationjava.lang.IllegalArgumentException
- if the prototype returned by getExecutorParamClasses
has no itemsjava.sql.SQLException
- if there was an error connecting to the databasepublic LocatorStorageAlgorithm(Algorithm encapsulatedAlgorithm, java.lang.String dbConnUrl, java.lang.String tableName, java.lang.Class<?>[] cacheClasses) throws java.lang.IllegalArgumentException, java.sql.SQLException
encapsulatedAlgorithm
- the algorithm to wrapdbConnUrl
- the database connection URL (JDBC)tableName
- the name of the table in which to store the datacacheClasses
- the classes for the binary serializationjava.lang.IllegalArgumentException
- if the prototype returned by getExecutorParamClasses
has no itemsjava.sql.SQLException
- if there was an error connecting to the databasepublic void finalize() throws java.lang.Throwable
Algorithm
public void destroy() throws java.lang.Throwable
Algorithm
This implementation defaults to call Algorithm.finalize()
, but should be overridden
if the algorithm needs to differentiate between finalizing and destroying. In that case
the "super.destroy()" should not be called if finalizing is not part of destroy.
public Algorithm getAlgorithm()
public void insertOperation(InsertOperation op) throws BucketStorageException, AlgorithmMethodException, java.lang.NoSuchMethodException
op
- the insert operation to executeBucketStorageException
- if there was a problem storing the object in the internal storageAlgorithmMethodException
- if there was a problem executing the operation on the encapsulated algorithmjava.lang.NoSuchMethodException
- if the encapsulated algorithm does not support the insert operationpublic void bulkInsertOperation(BulkInsertOperation op) throws BucketStorageException, AlgorithmMethodException, java.lang.NoSuchMethodException
op
- the bulk-insert operation to executeBucketStorageException
- if there was a problem storing an object in the internal storageAlgorithmMethodException
- if there was a problem executing the operation on the encapsulated algorithmjava.lang.NoSuchMethodException
- if the encapsulated algorithm does not support the insert operationpublic void deleteOperation(DeleteOperation op) throws BucketStorageException, AlgorithmMethodException, java.lang.NoSuchMethodException
op
- the delete operation to executeBucketStorageException
- if there was a problem removing the object from the internal storageAlgorithmMethodException
- if there was a problem executing the operation on the encapsulated algorithmjava.lang.NoSuchMethodException
- if the encapsulated algorithm does not support the delete operationpublic void deleteByLocatorOperation(DeleteByLocatorOperation op) throws BucketStorageException, AlgorithmMethodException, java.lang.NoSuchMethodException
DeleteOperation
is called on the
encapsulated algorithm. If successful, the object is also removed from
the internal storage.op
- the delete-by-locator operation to executeBucketStorageException
- if there was a problem removing an object from the internal storageAlgorithmMethodException
- if there was a problem executing the operation on the encapsulated algorithmjava.lang.NoSuchMethodException
- if the encapsulated algorithm does not support the delete operationpublic void objectByLocator(GetObjectByLocatorOperation op)
op
- the get-by-locator operation to executepublic void objectsByLocators(GetObjectsByLocatorsOperation op)
op
- the get-by-multiple-locators operation to executepublic void getRandomObjects(GetRandomObjectsQueryOperation op)
op
- the get-random-objects operation to executepublic void processOperation(AbstractOperation op) throws AlgorithmMethodException, java.lang.NoSuchMethodException
op
- the generic operation to executeAlgorithmMethodException
- if the operation execution on the encapsulated algorithm has thrown an exceptionjava.lang.NoSuchMethodException
- if the operation is unsupported by the encapsulated algorithmpublic java.lang.String toString()
toString
in class java.lang.Object