Package com.j_spaces.core.sadapter
Interface IStorageAdapter
- All Known Implementing Classes:
BlobStoreStorageAdapter,MemorySA,SynchronizationStorageAdapter,SyncHybridStorageAdapter,TieredStorageSA
public interface IStorageAdapter
IStorageAdapter is an interface that should be implemented by the Storage adapter.
The IStorageAdapter interface contains methods for storing and retrieving entries and notify
templates and to provide storage services to the engine .
All IStorageAdapter methods ( except init ) gets StorageAdapterContext object as the first parameter, which holds the connection information to the storage-adapter.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddIndexes(String typeName, SpaceIndex[] indexes) voidcommit(ServerTransaction xtn, boolean anyUpdates) Performs commit to transaction- delete taken entries, commit new entries.intcount(ITemplateHolder template, String[] subClasses) Returns the number of entries that match the template.Class<?>getEntries(Context context, Object[] ids, String typeName, IEntryHolder[] templates) Gets a map of entries from the storage adaptergetEntry(Context context, String uid, String classname, IEntryHolder template) Gets an entry object from the storage adapter.voidInitializes the SA for work (first API called by engine)initialLoad(Context context, ITemplateHolder template, InitialLoadInfo initialLoadInfo) voidinsertEntry(Context context, IEntryHolder entryHolder, boolean origin, boolean shouldReplicate) Inserts a new entry to the SA storage.voidintroduceDataType(ITypeDesc typeDesc) booleanIf returns true - then the storage adapter is read-only and can't be written to.makeEntriesIter(ITemplateHolder template, long SCNFilter, long leaseFilter, IServerTypeDesc[] subClasses) Returns an iterator with entries that match the template, and the other parameters.voidprepare(Context context, ServerTransaction xtn, ArrayList<IEntryHolder> pLocked, boolean singleParticipant, Map<String, Object> partialUpdatesAndInPlaceUpdatesInfo, boolean shouldReplicate) Performs prepare to transaction- write to SA all new entries under the xtn, mark taken entries under the xtnvoidremoveEntry(Context context, IEntryHolder entryHolder, boolean origin, boolean fromLeaseExpiration, boolean shouldReplicate) Removes an entry from the SA storage.voidrollback(ServerTransaction xtn, boolean anyUpdates) Performs rollback to transaction- rewrite taken entries, remove new entries.voidshutDown()called by the engine after all connections have been closed.booleanbooleanDenotes whether the implementing class has an implementation for {@ #getEntries(Object[], String, IEntryHolder[])}booleanvoidupdateEntry(Context context, IEntryHolder updatedEntry, boolean updateRedoLog, boolean origin, boolean[] partialUpdateValuesIndicators) updates an entry.
-
Method Details
-
initialize
Initializes the SA for work (first API called by engine) If initMode is WARM : SA is required to set its internal working tables and environment to the state recorded in its persistent storage, and verify that all the SA space-related data is in consistent state. If initMode is COLD : SA is required to clean its internal state.- Throws:
SAException- - In case a SQL error occurred.
-
initialLoad
ISAdapterIterator initialLoad(Context context, ITemplateHolder template, InitialLoadInfo initialLoadInfo) throws SAException - Throws:
SAException
-
insertEntry
void insertEntry(Context context, IEntryHolder entryHolder, boolean origin, boolean shouldReplicate) throws SAException Inserts a new entry to the SA storage.- Parameters:
entryHolder- entry to insert- Throws:
SAException
-
updateEntry
void updateEntry(Context context, IEntryHolder updatedEntry, boolean updateRedoLog, boolean origin, boolean[] partialUpdateValuesIndicators) throws SAException updates an entry.- Parameters:
updatedEntry- new content, same UID and class- Throws:
SAException
-
removeEntry
void removeEntry(Context context, IEntryHolder entryHolder, boolean origin, boolean fromLeaseExpiration, boolean shouldReplicate) throws SAException Removes an entry from the SA storage.- Parameters:
entryHolder- entry to remove- Throws:
SAException
-
prepare
void prepare(Context context, ServerTransaction xtn, ArrayList<IEntryHolder> pLocked, boolean singleParticipant, Map<String, Object> partialUpdatesAndInPlaceUpdatesInfo, boolean shouldReplicate) throws SAExceptionPerforms prepare to transaction- write to SA all new entries under the xtn, mark taken entries under the xtn- Parameters:
xtn- transaction to preparepLocked- a vector of all entries locked (written or taken) under the xtnsingleParticipant- - if true, a transactional SA needs to do all the transaction related operations in one DB transaction and the prepare is actually the commit (no other transaction related APIs will be called for this xtn)- Throws:
SAException
-
rollback
Performs rollback to transaction- rewrite taken entries, remove new entries.- Parameters:
xtn- transaction to roll-backanyUpdates- true if any updates performed under tjis xtn- Throws:
SAException
-
getEntry
IEntryHolder getEntry(Context context, String uid, String classname, IEntryHolder template) throws SAException Gets an entry object from the storage adapter.- Parameters:
uid- ID of the entry to getclassname- class of the entry to gettemplate- selection template,may be null, currently used by cacheload/cachestore in order to pass primery key fields when GS uid is not saved in an external DB- Returns:
- IEntryHolder
- Throws:
SAException
-
getEntries
Map<String,IEntryHolder> getEntries(Context context, Object[] ids, String typeName, IEntryHolder[] templates) throws SAException Gets a map of entries from the storage adapter- Parameters:
ids- the ids of the entries to gettypeName- type of the entries to gettemplates- templates matching the ids of the entries to get- Returns:
- A map between entries uid and the entry holder returning null from this method implies this operation is not supported by the underlying storage mechanism and other methods for obtaining these entries should be applied.
- Throws:
SAException
-
makeEntriesIter
ISAdapterIterator<IEntryHolder> makeEntriesIter(ITemplateHolder template, long SCNFilter, long leaseFilter, IServerTypeDesc[] subClasses) throws SAException Returns an iterator with entries that match the template, and the other parameters.- Parameters:
template- - the entries should match that template.SCNFilter- - if != 0 gets only templates that are <= from SCNFilter.leaseFilter- if != 0 gets only templates that have expiration_time >= leaseFilter.subClasses- - array of sub classes of the template, the entries should belong to a subcalss.- Returns:
- ISadapterIterator
- Throws:
SAException
-
commit
Performs commit to transaction- delete taken entries, commit new entries.- Parameters:
xtn- transaction to commitanyUpdates- true if any updates performed under tjis xtn- Throws:
SAException
-
count
Returns the number of entries that match the template.- Parameters:
template- - the entries should match the template.subClasses- - subclassesof the template, the entries can be in one of them.- Returns:
- int - number of entries that match the parameters.
- Throws:
SAException
-
shutDown
called by the engine after all connections have been closed. if the ShotDownString property is set- the string is executed by the SA- Throws:
SAException
-
isReadOnly
boolean isReadOnly()If returns true - then the storage adapter is read-only and can't be written to. -
supportsExternalDB
boolean supportsExternalDB() -
supportsPartialUpdate
boolean supportsPartialUpdate() -
supportsGetEntries
boolean supportsGetEntries()Denotes whether the implementing class has an implementation for {@ #getEntries(Object[], String, IEntryHolder[])} -
introduceDataType
-
getSynchronizationInterceptor
SpaceSynchronizationEndpoint getSynchronizationInterceptor() -
getDataClass
Class<?> getDataClass() -
addIndexes
- Throws:
SAException
-