@Component(value="LocalStorageService") @Scope(value="prototype") public class LocalStorageServiceImpl extends Object implements StorageService
| Modifier and Type | Field and Description |
|---|---|
static String |
BAG_EXTENSION |
static String |
FORCE_REBUILD_COMMAND |
PARTITION_PROPERTY| Constructor and Description |
|---|
LocalStorageServiceImpl(String instanceId,
String bagName) |
| Modifier and Type | Method and Description |
|---|---|
void |
closeService()
Closes the service and all its used resources
|
void |
ensureIndex(CompositeIndexField indexField,
boolean isUnique,
IndexField... valueFields)
Ensures an index with a composite key (multiple fields) is present.
|
void |
ensureIndex(IndexField indexField,
boolean isUnique,
IndexField... valueFields)
Ensures an index with the given field is present.
|
void |
flush()
An operation that can be called to guarantee all changes are flushed to the disk.
|
String |
getBagName()
Gets the name of the bag that this storage service represents
|
long |
getDiskSize()
Gets the size on the disk (if the flushing strategy is async could misrepresent the real number)
|
QueryResult |
getEntities(RequestContext context)
This retrieves all items from storage with an iterator, the documents are only loaded once the iterator is used.
|
QueryResult |
getEntities(RequestContext context,
int max)
This retrieves all items from storage with an iterator, the documents are only loaded
once the iterator is used.
|
SimpleEntity |
getEntityById(RequestContext requestContext,
String id)
Retrieve a specific entity from storage by the given unique document id
|
List<String> |
getIndexNames()
Gets a list of all present index names
|
String |
getInstanceId()
Gets the instance this bag belongs to
|
PartitioningManager |
getPartitionManager() |
long |
getSize()
Gets the amount of items stored
|
void |
initializePartitions() |
void |
insertEntity(RequestContext context,
SimpleEntity entity)
This inserts the entity into the storage and indexes
|
void |
openService(Configuration configuration)
Opens the service and all the resources required.
|
void |
remove()
Removes the bag and all related resources from the storage location
|
void |
removeEntity(RequestContext context,
SimpleEntity entity)
This removes and entity from storage and the indexes
|
void |
removeEntity(RequestContext context,
String internalId)
This removes the entity based on the internal id of the entity
|
void |
removeIndex(String indexName)
Removes the index with the given name
|
QueryResult |
search(RequestContext context,
BlockOperation blockOperation,
SearchLimit limit,
List<SortParameter> params)
This is the query entrypoint, all API queries are translated into a Query Object Model which can be executed on the
indexes and be sorted after all index queries have been resolved
|
void |
setBagInsertOperation(DataOperation bagInsertOperation) |
void |
setBagRemoveOperation(DataOperation bagRemoveOperation) |
void |
setBagUpdateOperation(DataOperation bagUpdateOperation) |
void |
setGenerator(IdGenerator generator) |
void |
setIndexManagerFactory(IndexManagerFactory indexManagerFactory) |
void |
setMetadataStore(MetadataStore metadataStore) |
void |
setPartitionManager(PartitioningManager partitionManager) |
void |
setRecordWriterFactoryLoader(RecordWriterFactoryLoader recordWriterFactoryLoader) |
String |
toString() |
void |
updateEntity(RequestContext context,
SimpleEntity entity)
This updates the entity in the storage and indexes if needed
|
public static final String BAG_EXTENSION
public static final String FORCE_REBUILD_COMMAND
public String getBagName()
StorageServicegetBagName in interface StorageServicepublic String getInstanceId()
StorageServicegetInstanceId in interface StorageServicepublic void closeService()
throws JasDBStorageException
StorageServicecloseService in interface StorageServiceJasDBStorageException - If unable to cleanly close the resourcespublic void flush()
throws JasDBStorageException
StorageServiceflush in interface StorageServiceJasDBStorageException - If unable to flush the changes to the diskpublic void openService(Configuration configuration) throws JasDBStorageException
StorageServiceopenService in interface StorageServiceconfiguration - The configurationJasDBStorageException - If unable to open the storage servicepublic void remove()
throws JasDBStorageException
StorageServiceremove in interface StorageServiceJasDBStorageException - If unable to remove the bag and related resourcespublic PartitioningManager getPartitionManager()
getPartitionManager in interface StorageServicepublic void initializePartitions()
throws JasDBStorageException
initializePartitions in interface StorageServiceJasDBStorageExceptionpublic void insertEntity(RequestContext context, SimpleEntity entity) throws JasDBStorageException
StorageServiceinsertEntity in interface StorageServicecontext - The request contextentity - The entity to store in the storage and which is used to populate the indexesJasDBStorageException - If unable to insert the entity or the indexespublic void removeEntity(RequestContext context, SimpleEntity entity) throws JasDBStorageException
StorageServiceremoveEntity in interface StorageServicecontext - The request contextentity - The entity to remove from the storage and the indexesJasDBStorageException - If unable to remove the entity from the indexes or storagepublic void removeEntity(RequestContext context, String internalId) throws JasDBStorageException
StorageServiceremoveEntity in interface StorageServicecontext - The request contextinternalId - The entity to remove the storage and indexesJasDBStorageException - If unable to remove the entity from the indexes or storagepublic void updateEntity(RequestContext context, SimpleEntity entity) throws JasDBStorageException
StorageServiceupdateEntity in interface StorageServicecontext - The request contextentity - The entity to updateJasDBStorageException - If unable to updatepublic long getSize()
throws JasDBStorageException
StorageServicegetSize in interface StorageServiceJasDBStorageException - If unable to retrieve the amount of stored itemspublic long getDiskSize()
throws JasDBStorageException
StorageServicegetDiskSize in interface StorageServiceJasDBStorageException - If unable to return the amount of used disk spacepublic SimpleEntity getEntityById(RequestContext requestContext, String id) throws JasDBStorageException
StorageServicegetEntityById in interface StorageServicerequestContext - The request contextid - The unique documentId of the itemJasDBStorageException - If unable to retrieve the item from storagepublic QueryResult getEntities(RequestContext context) throws JasDBStorageException
StorageServicegetEntities in interface StorageServiceJasDBStorageException - If unable to load the iterator over all documentspublic QueryResult getEntities(RequestContext context, int max) throws JasDBStorageException
StorageServicegetEntities in interface StorageServicemax - The maximum amount of records to retrieveJasDBStorageException - If unable to load the iterator over all documentspublic QueryResult search(RequestContext context, BlockOperation blockOperation, SearchLimit limit, List<SortParameter> params) throws JasDBStorageException
StorageServicesearch in interface StorageServicecontext - THe request contextblockOperation - The main blockoperation, the parent item in the Query Object Model.limit - The limits of the given queryparams - The sorting paramaters to be applied to the resultsetJasDBStorageException - If unable to execute the search querypublic void ensureIndex(IndexField indexField, boolean isUnique, IndexField... valueFields) throws JasDBStorageException
StorageServiceensureIndex in interface StorageServiceindexField - The field to be indexedisUnique - True If the field needs to have a unique constraint, False if notvalueFields - The value fields to be added to the index, can be used to improve sorting performance or secondary queriesJasDBStorageException - If unable to ensure the index existspublic void ensureIndex(CompositeIndexField indexField, boolean isUnique, IndexField... valueFields) throws JasDBStorageException
StorageServiceensureIndex in interface StorageServiceindexField - The indexed composite fieldsisUnique - True If the field needs to have a unique constraint, False if notvalueFields - The value fields to be added to the index, can be used to improve sorting performance or secondary queriesJasDBStorageException - If unable to ensure the index existspublic List<String> getIndexNames() throws JasDBStorageException
StorageServicegetIndexNames in interface StorageServiceJasDBStorageException - If unable to retrieve the list of index namespublic void removeIndex(String indexName) throws JasDBStorageException
StorageServiceremoveIndex in interface StorageServiceindexName - The name of the index to be removedJasDBStorageException - If unable to remove the indexpublic void setRecordWriterFactoryLoader(RecordWriterFactoryLoader recordWriterFactoryLoader)
public void setPartitionManager(PartitioningManager partitionManager)
public void setGenerator(IdGenerator generator)
public void setBagInsertOperation(DataOperation bagInsertOperation)
public void setBagRemoveOperation(DataOperation bagRemoveOperation)
public void setBagUpdateOperation(DataOperation bagUpdateOperation)
public void setIndexManagerFactory(IndexManagerFactory indexManagerFactory)
public void setMetadataStore(MetadataStore metadataStore)
Copyright © 2015. All rights reserved.