SMILA 1.0 API documentation

org.eclipse.smila.connectivity.deltaindexing.jpa.impl
Class DeltaIndexingManagerImpl

java.lang.Object
  extended by org.eclipse.smila.connectivity.deltaindexing.jpa.impl.DeltaIndexingManagerImpl
All Implemented Interfaces:
DeltaIndexingManager

public class DeltaIndexingManagerImpl
extends java.lang.Object
implements DeltaIndexingManager

The Class DeltaIndexingManagerImpl.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.smila.connectivity.deltaindexing.DeltaIndexingManager
DeltaIndexingManager.LockState
 
Field Summary
static java.lang.String CONFIGURATION_FILE
          name of configuration file.
static java.lang.String PERSISTENCE_UNIT_NAME
          Constant for the eclipseLink persistence unit name.
 
Constructor Summary
DeltaIndexingManagerImpl()
           
 
Method Summary
protected  void activate(ComponentContext context)
          Activate.
 boolean checkForUpdate(java.lang.String sessionId, ConnectivityId id, java.lang.String hash)
          checks if the hash of the current id is new or has changed (true) or not (false). // to reduce method calls mark entry as visited on return value false
 void clear()
          Clears all entries of the DeltaIndexingManager including any active sessions!
 void clear(java.lang.String sessionId)
          Clear all entries for the given sessionId.
protected  void deactivate(ComponentContext context)
          OSGi Declarative Services service deactivation method.
 void delete(java.lang.String sessionId, ConnectivityId id)
          Delete.
 boolean exists(java.lang.String dataSourceId)
          Checks if the entries for the given dataSourceId exist.
 void finish(java.lang.String sessionId)
          Finish this delta indexing session and remove the lock.
 long getEntryCount(java.lang.String dataSourceId)
          Get the number of delta indexing entries for the given dataSourceID.
 java.util.Map<java.lang.String,java.lang.Long> getEntryCounts()
          Get the number of delta indexing entries for all data sources.
 java.util.Map<java.lang.String,DeltaIndexingManager.LockState> getLockStates()
          Get an overview what data sources are locked or unlocked.
 java.lang.String init(java.lang.String dataSourceID)
          Initializes the internal state for an import of a dataSourceID and creates a session wherein it establishes a lock to avoid that the same. dataSourceID is initialized multiple times concurrently.
 java.util.Iterator<ConnectivityId> obsoleteIdIterator(java.lang.String sessionId, ConnectivityId id)
          Obsolete id iterator for id fragments of compounds.
 java.util.Iterator<ConnectivityId> obsoleteIdIterator(java.lang.String sessionId, java.lang.String dataSourceID)
          Obsolete id iterator.
 void rollback(java.lang.String sessionId)
          rolls back changes that were made in the current session between init() and finish(), it should be called before finishing process.
 void unlockDatasource(java.lang.String dataSourceID)
          Unlock the given data source and removes the sessions.
 void unlockDatasources()
          Unlock all data sources and removes all sessions.
 void visit(java.lang.String sessionId, ConnectivityId id, java.lang.String hash, boolean isCompound)
          Creates or updates the delta indexing entry. this is THE method to make the record known to DI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERSISTENCE_UNIT_NAME

public static final java.lang.String PERSISTENCE_UNIT_NAME
Constant for the eclipseLink persistence unit name.

See Also:
Constant Field Values

CONFIGURATION_FILE

public static final java.lang.String CONFIGURATION_FILE
name of configuration file. Hardcoded for now (or fallback), configuration properties should be received from configuration service later.

See Also:
Constant Field Values
Constructor Detail

DeltaIndexingManagerImpl

public DeltaIndexingManagerImpl()
Method Detail

activate

protected void activate(ComponentContext context)
                 throws java.lang.Exception
Activate.

Parameters:
context - the context
Throws:
java.lang.Exception - if any error occurs

deactivate

protected void deactivate(ComponentContext context)
                   throws java.lang.Exception
OSGi Declarative Services service deactivation method. Shuts down BPEL engine.

Parameters:
context - OSGi service component context
Throws:
java.lang.Exception - if any error occurs

init

public java.lang.String init(java.lang.String dataSourceID)
                      throws DeltaIndexingException
Initializes the internal state for an import of a dataSourceID and creates a session wherein it establishes a lock to avoid that the same. dataSourceID is initialized multiple times concurrently. It returns a unique Id for the session that a client has to use to gain access to the locked data source.

Specified by:
init in interface DeltaIndexingManager
Parameters:
dataSourceID - dataSourceID
Returns:
a String containing the sessionId
Throws:
DeltaIndexingException - the delta indexing exception
See Also:
DeltaIndexingManager.init(java.lang.String)

checkForUpdate

public boolean checkForUpdate(java.lang.String sessionId,
                              ConnectivityId id,
                              java.lang.String hash)
                       throws DeltaIndexingSessionException,
                              DeltaIndexingException
checks if the hash of the current id is new or has changed (true) or not (false). // to reduce method calls mark entry as visited on return value false

Specified by:
checkForUpdate in interface DeltaIndexingManager
Parameters:
sessionId - the id of the delta indexing session
id - the id
hash - the hash
Returns:
true, if check for update
Throws:
DeltaIndexingSessionException - if the sessionId is invalid
DeltaIndexingException - the delta indexing exception
See Also:
org.eclipse.smila.connectivity.deltaindexing.DeltaIndexingManager#checkForUpdate(String, Id, String)

visit

public void visit(java.lang.String sessionId,
                  ConnectivityId id,
                  java.lang.String hash,
                  boolean isCompound)
           throws DeltaIndexingSessionException,
                  DeltaIndexingException
Creates or updates the delta indexing entry. this is THE method to make the record known to DI. It sets the hash, the isCompound flag and marks this id as visited.

Specified by:
visit in interface DeltaIndexingManager
Parameters:
sessionId - the id of the delta indexing session
id - the id
hash - the hash
isCompound - boolean flag if the record identified by id is a compound record (true) or not (false)
Throws:
DeltaIndexingSessionException - if the sessionId is invalid
DeltaIndexingException - the delta indexing exception
See Also:
org.eclipse.smila.connectivity.deltaindexing.DeltaIndexingManager#visit(String, Id, String, boolean)

obsoleteIdIterator

public java.util.Iterator<ConnectivityId> obsoleteIdIterator(java.lang.String sessionId,
                                                             java.lang.String dataSourceID)
                                                      throws DeltaIndexingSessionException,
                                                             DeltaIndexingException
Obsolete id iterator.

Specified by:
obsoleteIdIterator in interface DeltaIndexingManager
Parameters:
sessionId - the id of the delta indexing session
dataSourceID - the data source id
Returns:
the iterator< id>
Throws:
DeltaIndexingSessionException - if the sessionId is invalid
DeltaIndexingException - the delta indexing exception
See Also:
DeltaIndexingManager.obsoleteIdIterator(String, String)

obsoleteIdIterator

public java.util.Iterator<ConnectivityId> obsoleteIdIterator(java.lang.String sessionId,
                                                             ConnectivityId id)
                                                      throws DeltaIndexingSessionException,
                                                             DeltaIndexingException
Obsolete id iterator for id fragments of compounds.

Specified by:
obsoleteIdIterator in interface DeltaIndexingManager
Parameters:
sessionId - the id of the delta indexing session
id - the id
Returns:
the iterator< id>
Throws:
DeltaIndexingSessionException - if the sessionId is invalid
DeltaIndexingException - the delta indexing exception
See Also:
org.eclipse.smila.connectivity.deltaindexing.DeltaIndexingManager#obsoleteIdIterator(String, Id)

clear

public void clear()
           throws DeltaIndexingException
Clears all entries of the DeltaIndexingManager including any active sessions! Note that this may cause exceptions in clients currently using any of the closed sessions.

Specified by:
clear in interface DeltaIndexingManager
Throws:
DeltaIndexingException - the delta indexing exception
See Also:
DeltaIndexingManager.clear()

clear

public void clear(java.lang.String sessionId)
           throws DeltaIndexingSessionException,
                  DeltaIndexingException
Clear all entries for the given sessionId. In order to call clear you first have to initialize a session calling init(). This is to avoid clearing of any locked data sources.

Specified by:
clear in interface DeltaIndexingManager
Parameters:
sessionId - the id of the delta indexing session
Throws:
DeltaIndexingSessionException - if the sessionId is invalid
DeltaIndexingException - the delta indexing exception
See Also:
DeltaIndexingManager.clear(String)

rollback

public void rollback(java.lang.String sessionId)
              throws DeltaIndexingSessionException,
                     DeltaIndexingException
rolls back changes that were made in the current session between init() and finish(), it should be called before finishing process.

Specified by:
rollback in interface DeltaIndexingManager
Parameters:
sessionId - the id of the delta indexing session
Throws:
DeltaIndexingSessionException - if the sessionId is invalid
DeltaIndexingException - the delta indexing exception
See Also:
DeltaIndexingManager.rollback(java.lang.String)

delete

public void delete(java.lang.String sessionId,
                   ConnectivityId id)
            throws DeltaIndexingSessionException,
                   DeltaIndexingException
Delete.

Specified by:
delete in interface DeltaIndexingManager
Parameters:
sessionId - the id of the delta indexing session
id - the id
Throws:
DeltaIndexingSessionException - if the sessionId is invalid
DeltaIndexingException - the delta indexing exception
See Also:
org.eclipse.smila.connectivity.deltaindexing.DeltaIndexingManager#delete(String, Id)

finish

public void finish(java.lang.String sessionId)
            throws DeltaIndexingSessionException,
                   DeltaIndexingException
Finish this delta indexing session and remove the lock.

Specified by:
finish in interface DeltaIndexingManager
Parameters:
sessionId - the id of the delta indexing session
Throws:
DeltaIndexingSessionException - if the sessionId is invalid
DeltaIndexingException - the delta indexing exception
See Also:
DeltaIndexingManager.finish(String)

unlockDatasource

public void unlockDatasource(java.lang.String dataSourceID)
                      throws DeltaIndexingException
Unlock the given data source and removes the sessions. Note that this may cause exceptions in a client currently using the closed sessions.

Specified by:
unlockDatasource in interface DeltaIndexingManager
Parameters:
dataSourceID - the data source id
Throws:
DeltaIndexingException - the delta indexing exception
See Also:
DeltaIndexingManager.unlockDatasource(String)

unlockDatasources

public void unlockDatasources()
                       throws DeltaIndexingException
Unlock all data sources and removes all sessions. Note that this may cause exceptions in clients currently using any of the closed sessions.

Specified by:
unlockDatasources in interface DeltaIndexingManager
Throws:
DeltaIndexingException - the delta indexing exception
See Also:
DeltaIndexingManager.unlockDatasources()

getLockStates

public java.util.Map<java.lang.String,DeltaIndexingManager.LockState> getLockStates()
Get an overview what data sources are locked or unlocked.

Specified by:
getLockStates in interface DeltaIndexingManager
Returns:
a map containing the dataSoureId and the LockState
See Also:
DeltaIndexingManager.getLockStates()

exists

public boolean exists(java.lang.String dataSourceId)
Checks if the entries for the given dataSourceId exist.

Specified by:
exists in interface DeltaIndexingManager
Parameters:
dataSourceId - the data source id
Returns:
true, if successful
See Also:
DeltaIndexingManager.exists(String)

getEntryCount

public long getEntryCount(java.lang.String dataSourceId)
Get the number of delta indexing entries for the given dataSourceID.

Specified by:
getEntryCount in interface DeltaIndexingManager
Parameters:
dataSourceId - the data source id
Returns:
the number of entries
See Also:
DeltaIndexingManager.getEntryCount(String)

getEntryCounts

public java.util.Map<java.lang.String,java.lang.Long> getEntryCounts()
Get the number of delta indexing entries for all data sources.

Specified by:
getEntryCounts in interface DeltaIndexingManager
Returns:
a map of dataSoureIds and the entry counts
See Also:
DeltaIndexingManager.getEntryCounts()

SMILA 1.0 API documentation