public class SharedIteratorSpaceDataSourceDecorator extends SpaceDataSource implements ISharedDataIteratorSourceStateChangedListener<Object>
SpaceDataSource with additional property, concurrent request for an iterator
which is based on the same query will only open one underlying iterator against the decorates
provider, this iterator will be shared amont the concurrent requests as if each of them has its
own iterator. the purpose is to reduce the load on the data source.| Constructor and Description |
|---|
SharedIteratorSpaceDataSourceDecorator(SpaceDataSource spaceDataSource,
long timeToLive)
Create a new instance
|
| Modifier and Type | Method and Description |
|---|---|
Object |
getById(DataSourceIdQuery idQuery)
This method is invoked whenever the space needs to read an entry from the data source
according to its Id.
|
DataIterator<Object> |
getDataIterator(DataSourceQuery query)
This method is invoked whenever the space needs to read data which matches the provided
DataSourceQuery from the space data source. |
DataIterator<Object> |
getDataIteratorByIds(DataSourceIdsQuery idsQuery)
This method is invoked whenever the space needs to read several entries from the data source
according to their ids.
|
DataIterator<Object> |
initialDataLoad()
This method is invoked after
SpaceDataSource.initialMetadataLoad() and is used for pre fetching data
from the data source on space initialization. |
DataIterator<SpaceTypeDescriptor> |
initialMetadataLoad()
This method is invoked on space initialization (before
SpaceDataSource.initialDataLoad() is invoked)
and is used for introducing data types kept in the data source to the space. |
void |
onClosed(SharedDataIteratorSource<Object> sender)
Triggered when the iterator source is closed
|
void |
onExpired(SharedDataIteratorSource<Object> sender)
Triggered when the iterator source is expired
|
void |
shutdown() |
boolean |
supportsInheritance()
Determines whether this implementation supports types inheritance.
|
public SharedIteratorSpaceDataSourceDecorator(SpaceDataSource spaceDataSource, long timeToLive)
sqlDataProvider - provider to decoratetimeToLive - liveness time of a created mediators, once this time expired this
mediator will not be used for new iterator creationspublic DataIterator<Object> getDataIterator(DataSourceQuery query)
SpaceDataSourceDataSourceQuery from the space data source. If this implementation doesn't supports types inheritance this method will be invoked for each type in the inheritance tree of the queried type.
The implementation's type inheritance support can be determined
by overriding the SpaceDataSource.supportsInheritance() method.
getDataIterator in class SpaceDataSourcequery - The DataSourceQuery to get results for.DataIterator instance contains results for the provided DataSourceQuery.public void shutdown()
throws DataSourceException
DataSourceExceptionpublic void onClosed(SharedDataIteratorSource<Object> sender)
ISharedDataIteratorSourceStateChangedListeneronClosed in interface ISharedDataIteratorSourceStateChangedListener<Object>sender - shared data iterator source that triggered the eventpublic void onExpired(SharedDataIteratorSource<Object> sender)
ISharedDataIteratorSourceStateChangedListeneronExpired in interface ISharedDataIteratorSourceStateChangedListener<Object>sender - shared data iterator source that triggered the eventpublic DataIterator<Object> initialDataLoad()
SpaceDataSourceSpaceDataSource.initialMetadataLoad() and is used for pre fetching data
from the data source on space initialization. The returned DataIterator instance
should contain POJOs or SpaceDocuments which their type was previously introduced to
the space on SpaceDataSource.initialMetadataLoad() invocation.
initialDataLoad in class SpaceDataSourceDataIterator instance which contains all data to be written to Space upon
its initialization - null is treated as an empty iterator.public DataIterator<SpaceTypeDescriptor> initialMetadataLoad()
SpaceDataSourceSpaceDataSource.initialDataLoad() is invoked)
and is used for introducing data types kept in the data source to the space. Please note that derived types should be returned after their super types from the iterator.
It is
possible to create a SpaceTypeDescriptor using SpaceTypeDescriptorBuilder.
initialMetadataLoad in class SpaceDataSourceDataIterator instance which contains all SpaceTypeDescriptor
instances to be introduced to the Space upon its initialization - null is treated as an empty
iterator.public Object getById(DataSourceIdQuery idQuery)
SpaceDataSourceThe returned value can be either a POJO or a SpaceDocument
instance.
The default implementation of this method is delegated to the SpaceDataSource.getDataIterator(DataSourceQuery) method so if the data source does not have an optimized
way of reading an entity by its Id - the default implementation may suffice.
getById in class SpaceDataSourceidQuery - The DataSourceIdQuery to get a result for.SpaceDataSource which matches the provided DataSourceIdQuery.public DataIterator<Object> getDataIteratorByIds(DataSourceIdsQuery idsQuery)
SpaceDataSourceThe returned values can be either POJOs or SpaceDocument
instances.
The default implementation of this method is delegated to the SpaceDataSource.getById(DataSourceIdQuery) method for each id, so if the data source does not have an
optimized way of reading an serveral entities by their ids - the default implementation may
suffice.
getDataIteratorByIds in class SpaceDataSourceidsQuery - The DataSourceIdsQuery to get a result for.DataIterator instance contains results for the provided DataSourceIdsQuery.public boolean supportsInheritance()
SpaceDataSourceIf types inheritance is
not supported - SpaceDataSource.getDataIterator(DataSourceQuery) will be invoked for each derived
type of the query's data type. Otherwise a single SpaceDataSource.getDataIterator(DataSourceQuery)
invocation will be made for the query.
supportsInheritance in class SpaceDataSourceSpaceDataSource implementation supports types inheritance,
otherwise false.Copyright © GigaSpaces.