org.compass.needle.gigaspaces.datasource
Class CompassDataSource

java.lang.Object
  extended by org.compass.needle.gigaspaces.datasource.CompassDataSource
All Implemented Interfaces:
com.gigaspaces.datasource.BulkDataPersister, com.gigaspaces.datasource.DataPersister<Object>, com.gigaspaces.datasource.DataProvider<Object>, com.gigaspaces.datasource.ManagedDataSource<Object>

public class CompassDataSource
extends Object
implements com.gigaspaces.datasource.DataPersister<Object>, com.gigaspaces.datasource.BulkDataPersister

A Compass data source to be used with GigaSpaces mirror.

GigaSpaces mirror allows to mirror changes done to the Space into an external data source in a reliable async manner. The Compass data source allows to mirror changes done to the Space into the search engine using Compass.

This extenal data source can be injected with a Compass instance, or it can be configured using the extenal data source proeprties configuration to create a Compass instance. The proeprty compass-config-file will point to Compass configuration file.

Author:
kimchy

Field Summary
static String COMPASS_CFG_PROPERTY
           
 
Fields inherited from interface com.gigaspaces.datasource.ManagedDataSource
DATA_CLASS_PROPS, NUMBER_OF_PARTITIONS, STATIC_PARTITION_NUMBER
 
Constructor Summary
CompassDataSource()
           
 
Method Summary
 int count(Object template)
          Count number of object in the data source that match given template.
 void executeBulk(List<com.gigaspaces.datasource.BulkItem> bulkItems)
          Execute given bulk of operations.
 void init(Properties properties)
           
 com.gigaspaces.datasource.DataIterator<Object> initialLoad()
          Creates and returns an iterator over all the entries that should be loaded into space.
 com.gigaspaces.datasource.DataIterator<Object> iterator(Object template)
          Create an iterator over all objects that match the given template.
 Object read(Object template)
          Read one object that matches the given template.
 void remove(Object object)
          Remove the given object from the data store
 void removeBatch(List<Object> objects)
          Remove given objects from the data store.
 void setCompass(Compass compass)
           
 void shutdown()
           
 void update(Object object)
          Update the given object in the data store
 void updateBatch(List<Object> objects)
          Update given objects in the data store.
 void write(Object object)
          Write given new object to the data store
 void writeBatch(List<Object> objects)
          Write given new objects to the data store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPASS_CFG_PROPERTY

public static final String COMPASS_CFG_PROPERTY
See Also:
Constant Field Values
Constructor Detail

CompassDataSource

public CompassDataSource()
Method Detail

setCompass

public void setCompass(Compass compass)

init

public void init(Properties properties)
          throws com.gigaspaces.datasource.DataSourceException
Specified by:
init in interface com.gigaspaces.datasource.ManagedDataSource<Object>
Throws:
com.gigaspaces.datasource.DataSourceException

shutdown

public void shutdown()
              throws com.gigaspaces.datasource.DataSourceException
Specified by:
shutdown in interface com.gigaspaces.datasource.ManagedDataSource<Object>
Throws:
com.gigaspaces.datasource.DataSourceException

write

public void write(Object object)
           throws com.gigaspaces.datasource.DataSourceException
Write given new object to the data store

Specified by:
write in interface com.gigaspaces.datasource.DataPersister<Object>
Throws:
com.gigaspaces.datasource.DataSourceException

update

public void update(Object object)
            throws com.gigaspaces.datasource.DataSourceException
Update the given object in the data store

Specified by:
update in interface com.gigaspaces.datasource.DataPersister<Object>
Throws:
com.gigaspaces.datasource.DataSourceException

remove

public void remove(Object object)
            throws com.gigaspaces.datasource.DataSourceException
Remove the given object from the data store

Specified by:
remove in interface com.gigaspaces.datasource.DataPersister<Object>
Throws:
com.gigaspaces.datasource.DataSourceException

writeBatch

public void writeBatch(List<Object> objects)
                throws com.gigaspaces.datasource.DataSourceException
Write given new objects to the data store.

If the implementation uses transactions, all the objects must be written in one transaction.

Specified by:
writeBatch in interface com.gigaspaces.datasource.DataPersister<Object>
Throws:
com.gigaspaces.datasource.DataSourceException

updateBatch

public void updateBatch(List<Object> objects)
                 throws com.gigaspaces.datasource.DataSourceException
Update given objects in the data store.

If the implementation uses transactions, all the objects must be updated in one transaction.

* This operation is not currently supported by the space.

Throws:
com.gigaspaces.datasource.DataSourceException

removeBatch

public void removeBatch(List<Object> objects)
                 throws com.gigaspaces.datasource.DataSourceException
Remove given objects from the data store.

If the implementation uses transactions, All the objects must be removed in one transaction.

This operation is not currently supported by the space.

Throws:
com.gigaspaces.datasource.DataSourceException

executeBulk

public void executeBulk(List<com.gigaspaces.datasource.BulkItem> bulkItems)
                 throws com.gigaspaces.datasource.DataSourceException
Execute given bulk of operations. Each BulkItem contains one of the following operation -

WRITE - given object should be inserted to the data store,
UPDATE - given object should be updated in the data store,
REMOVE - given object should be deleted from the data store

If the implementation uses transactions,
all the bulk operations must be executed in one transaction.

Specified by:
executeBulk in interface com.gigaspaces.datasource.BulkDataPersister
Throws:
com.gigaspaces.datasource.DataSourceException

read

public Object read(Object template)
            throws com.gigaspaces.datasource.DataSourceException
Read one object that matches the given template.
Used by the space for read templates with UID.

Specified by:
read in interface com.gigaspaces.datasource.DataProvider<Object>
Throws:
com.gigaspaces.datasource.DataSourceException

iterator

public com.gigaspaces.datasource.DataIterator<Object> iterator(Object template)
                                                        throws com.gigaspaces.datasource.DataSourceException
Create an iterator over all objects that match the given template.
Note: null value can be passed - in case of a null template or at initial space load

Specified by:
iterator in interface com.gigaspaces.datasource.DataProvider<Object>
Throws:
com.gigaspaces.datasource.DataSourceException

count

public int count(Object template)
          throws com.gigaspaces.datasource.DataSourceException
Count number of object in the data source that match given template.
Note: null value can be passed - in case of a null template.

Throws:
com.gigaspaces.datasource.DataSourceException

initialLoad

public com.gigaspaces.datasource.DataIterator<Object> initialLoad()
                                                           throws com.gigaspaces.datasource.DataSourceException
Creates and returns an iterator over all the entries that should be loaded into space.

Specified by:
initialLoad in interface com.gigaspaces.datasource.ManagedDataSource<Object>
Returns:
a DataIterator or null if no data should be loaded into space
Throws:
com.gigaspaces.datasource.DataSourceException


Copyright (c) 2004-2009 The Compass Project.