Class MemorySA

java.lang.Object
com.j_spaces.core.sadapter.MemorySA
All Implemented Interfaces:
IStorageAdapter

public class MemorySA extends Object implements 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 Details

    • MemorySA

      public MemorySA()
  • Method Details

    • initialize

      public void initialize() throws SAException
      Description copied from interface: IStorageAdapter
      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.

      Specified by:
      initialize in interface IStorageAdapter
      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:
      insertEntry in interface IStorageAdapter
      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:
      updateEntry in interface IStorageAdapter
      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:
      getEntry in interface IStorageAdapter
      Parameters:
      uid - ID of the entry to get
      classname - class of the entry to get
      template - 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:
      removeEntry in interface IStorageAdapter
      entryHolder - 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:
      makeEntriesIter in interface IStorageAdapter
      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 SAException
      Performs prepare to transaction- write to SA all new entries under the xtn, mark taken entries under the xtn
      Specified by:
      prepare in interface IStorageAdapter
      Parameters:
      xtn - transaction to prepare
      locked_entries - a vector of all entries locked (written or taken) under the xtn
      singleParticipant - - 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

      public void commit(ServerTransaction xtn, boolean anyUpdates) throws SAException
      Performs commit to transaction- delete taken entries, commit new entries.
      Specified by:
      commit in interface IStorageAdapter
      Parameters:
      xtn - transaction to commit
      anyUpdates - true if any updates performed under tjis xtn
      Throws:
      SAException
    • rollback

      public void rollback(ServerTransaction xtn, boolean anyUpdates) throws SAException
      Performs rollback to transaction- rewrite taken entries, remove new entries.
      Specified by:
      rollback in interface IStorageAdapter
      Parameters:
      xtn - transaction to roll-back
      anyUpdates - true if any updates performed under tjis xtn
      Throws:
      SAException
    • count

      public int count(ITemplateHolder template, String[] subClasses) throws SAException
      Returns the number of entries that match the template.
      Specified by:
      count in interface IStorageAdapter
      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

      public void shutDown() throws SAException
      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:
      shutDown in interface IStorageAdapter
      Throws:
      SAException
    • isReadOnly

      public boolean isReadOnly()
      Description copied from interface: IStorageAdapter
      If returns true - then the storage adapter is read-only and can't be written to.
      Specified by:
      isReadOnly in interface IStorageAdapter
    • supportsExternalDB

      public boolean supportsExternalDB()
      Specified by:
      supportsExternalDB in interface IStorageAdapter
    • supportsPartialUpdate

      public boolean supportsPartialUpdate()
      Specified by:
      supportsPartialUpdate in interface IStorageAdapter
    • initialLoad

      public ISAdapterIterator initialLoad(Context context, ITemplateHolder template, InitialLoadInfo initialLoadInfo) throws SAException
      Specified by:
      initialLoad in interface IStorageAdapter
      Throws:
      SAException
    • introduceDataType

      public void introduceDataType(ITypeDesc typeDesc)
      Specified by:
      introduceDataType in interface IStorageAdapter
    • addIndexes

      public void addIndexes(String typeName, SpaceIndex[] indexes)
      Specified by:
      addIndexes in interface IStorageAdapter
    • getSynchronizationInterceptor

      public SpaceSynchronizationEndpoint getSynchronizationInterceptor()
      Specified by:
      getSynchronizationInterceptor in interface IStorageAdapter
    • getDataClass

      public Class<?> getDataClass()
      Specified by:
      getDataClass in interface IStorageAdapter
    • getEntries

      public Map<String,IEntryHolder> getEntries(Context context, Object[] ids, String typeName, IEntryHolder[] templates) throws SAException
      Description copied from interface: IStorageAdapter
      Gets a map of entries from the storage adapter
      Specified by:
      getEntries in interface IStorageAdapter
      ids - the ids of the entries to get
      typeName - type of the entries to get
      templates - 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: IStorageAdapter
      Denotes whether the implementing class has an implementation for {@ #getEntries(Object[], String, IEntryHolder[])}
      Specified by:
      supportsGetEntries in interface IStorageAdapter