@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()
StorageService
getBagName
in interface StorageService
public String getInstanceId()
StorageService
getInstanceId
in interface StorageService
public void closeService() throws JasDBStorageException
StorageService
closeService
in interface StorageService
JasDBStorageException
- If unable to cleanly close the resourcespublic void flush() throws JasDBStorageException
StorageService
flush
in interface StorageService
JasDBStorageException
- If unable to flush the changes to the diskpublic void openService(Configuration configuration) throws JasDBStorageException
StorageService
openService
in interface StorageService
configuration
- The configurationJasDBStorageException
- If unable to open the storage servicepublic void remove() throws JasDBStorageException
StorageService
remove
in interface StorageService
JasDBStorageException
- If unable to remove the bag and related resourcespublic PartitioningManager getPartitionManager()
getPartitionManager
in interface StorageService
public void initializePartitions() throws JasDBStorageException
initializePartitions
in interface StorageService
JasDBStorageException
public void insertEntity(RequestContext context, SimpleEntity entity) throws JasDBStorageException
StorageService
insertEntity
in interface StorageService
context
- 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
StorageService
removeEntity
in interface StorageService
context
- 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
StorageService
removeEntity
in interface StorageService
context
- 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
StorageService
updateEntity
in interface StorageService
context
- The request contextentity
- The entity to updateJasDBStorageException
- If unable to updatepublic long getSize() throws JasDBStorageException
StorageService
getSize
in interface StorageService
JasDBStorageException
- If unable to retrieve the amount of stored itemspublic long getDiskSize() throws JasDBStorageException
StorageService
getDiskSize
in interface StorageService
JasDBStorageException
- If unable to return the amount of used disk spacepublic SimpleEntity getEntityById(RequestContext requestContext, String id) throws JasDBStorageException
StorageService
getEntityById
in interface StorageService
requestContext
- The request contextid
- The unique documentId of the itemJasDBStorageException
- If unable to retrieve the item from storagepublic QueryResult getEntities(RequestContext context) throws JasDBStorageException
StorageService
getEntities
in interface StorageService
JasDBStorageException
- If unable to load the iterator over all documentspublic QueryResult getEntities(RequestContext context, int max) throws JasDBStorageException
StorageService
getEntities
in interface StorageService
max
- 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
StorageService
search
in interface StorageService
context
- 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
StorageService
ensureIndex
in interface StorageService
indexField
- 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
StorageService
ensureIndex
in interface StorageService
indexField
- 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
StorageService
getIndexNames
in interface StorageService
JasDBStorageException
- If unable to retrieve the list of index namespublic void removeIndex(String indexName) throws JasDBStorageException
StorageService
removeIndex
in interface StorageService
indexName
- 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.