Package com.j_spaces.core.sadapter
Class MemorySA
java.lang.Object
com.j_spaces.core.sadapter.MemorySA
- All Implemented Interfaces:
IStorageAdapter
MemorySA is a mostly empty SA that is used for memory based space, it "implements"
IStorageAdapter interface.
The entries/templates are stored in the cache-manager-
Constructor Summary
Constructors -
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> locked_entries, 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.
-
Constructor Details
-
MemorySA
public MemorySA()
-
-
Method Details
-
initialize
Description copied from interface:IStorageAdapterInitializes 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.- Specified by:
initializein interfaceIStorageAdapter- Throws:
SAException- - In case a SQL error occurred.
-
insertEntry
public void insertEntry(Context context, IEntryHolder entryHolder, boolean origin, boolean shouldReplicate) throws SAException Inserts a new entry to the SA storage.- Specified by:
insertEntryin interfaceIStorageAdapter- Parameters:
entryHolder- entry to insert- Throws:
SAException
-
updateEntry
public void updateEntry(Context context, IEntryHolder updatedEntry, boolean updateRedoLog, boolean origin, boolean[] partialUpdateValuesIndicators) throws SAException updates an entry.- Specified by:
updateEntryin interfaceIStorageAdapter- Parameters:
updatedEntry- new content, same UID and class- Throws:
SAException
-
getEntry
public IEntryHolder getEntry(Context context, String uid, String classname, IEntryHolder template) throws SAException Gets an entry object from the storage adapter.- Specified by:
getEntryin interfaceIStorageAdapter- 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
-
removeEntry
public void removeEntry(Context context, IEntryHolder entryHolder, boolean origin, boolean fromLeaseExpiration, boolean shouldReplicate) throws SAException Removes an entry from the SA storage.- Specified by:
removeEntryin interfaceIStorageAdapterentryHolder- entry to remove- Throws:
SAException
-
makeEntriesIter
public ISAdapterIterator makeEntriesIter(ITemplateHolder template, long SCNFilter, long leaseFilter, IServerTypeDesc[] subClasses) throws SAException Returns an iterator with entries that match the template, and the other parameters.- Specified by:
makeEntriesIterin interfaceIStorageAdapter- 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
-
prepare
public void prepare(Context context, ServerTransaction xtn, ArrayList<IEntryHolder> locked_entries, 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- Specified by:
preparein interfaceIStorageAdapter- Parameters:
xtn- transaction to preparelocked_entries- 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
-
commit
Performs commit to transaction- delete taken entries, commit new entries.- Specified by:
commitin interfaceIStorageAdapter- Parameters:
xtn- transaction to commitanyUpdates- true if any updates performed under tjis xtn- Throws:
SAException
-
rollback
Performs rollback to transaction- rewrite taken entries, remove new entries.- Specified by:
rollbackin interfaceIStorageAdapter- Parameters:
xtn- transaction to roll-backanyUpdates- true if any updates performed under tjis xtn- Throws:
SAException
-
count
Returns the number of entries that match the template.- Specified by:
countin interfaceIStorageAdapter- 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- Specified by:
shutDownin interfaceIStorageAdapter- Throws:
SAException
-
isReadOnly
public boolean isReadOnly()Description copied from interface:IStorageAdapterIf returns true - then the storage adapter is read-only and can't be written to.- Specified by:
isReadOnlyin interfaceIStorageAdapter
-
supportsExternalDB
public boolean supportsExternalDB()- Specified by:
supportsExternalDBin interfaceIStorageAdapter
-
supportsPartialUpdate
public boolean supportsPartialUpdate()- Specified by:
supportsPartialUpdatein interfaceIStorageAdapter
-
initialLoad
public ISAdapterIterator initialLoad(Context context, ITemplateHolder template, InitialLoadInfo initialLoadInfo) throws SAException - Specified by:
initialLoadin interfaceIStorageAdapter- Throws:
SAException
-
introduceDataType
- Specified by:
introduceDataTypein interfaceIStorageAdapter
-
addIndexes
- Specified by:
addIndexesin interfaceIStorageAdapter
-
getSynchronizationInterceptor
- Specified by:
getSynchronizationInterceptorin interfaceIStorageAdapter
-
getDataClass
- Specified by:
getDataClassin interfaceIStorageAdapter
-
getEntries
public Map<String,IEntryHolder> getEntries(Context context, Object[] ids, String typeName, IEntryHolder[] templates) throws SAException Description copied from interface:IStorageAdapterGets a map of entries from the storage adapter- Specified by:
getEntriesin interfaceIStorageAdapterids- 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
-
supportsGetEntries
public boolean supportsGetEntries()Description copied from interface:IStorageAdapterDenotes whether the implementing class has an implementation for {@ #getEntries(Object[], String, IEntryHolder[])}- Specified by:
supportsGetEntriesin interfaceIStorageAdapter
-