public class InfinispanStore<K,T extends PersistentBase> extends DataStoreBase<K,T>
InfinispanStore
is the primary class
responsible for directing Gora CRUD operations to Infinispan.This class delegate
most operations, e.g., initialization, creation and deletion to (Infinispan caches),
via InfinispanClient
.
To specify the Infinispan deployment, include parameter infinispan.connectionstring
in gora.properties with the list of servers, e.g., "127.0.0.1:11222,127.0.0.1:11223".Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
autoCreateSchema, beanFactory, conf, datumReader, datumWriter, fieldMap, keyClass, persistentClass, properties, schema
Constructor and Description |
---|
InfinispanStore()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the DataStore.
|
void |
createSchema()
Creates the optional schema or table (or similar) in the datastore
to hold the objects.
|
boolean |
delete(K key)
Deletes the object with the given key
|
long |
deleteByQuery(Query<K,T> query)
Deletes all the objects matching the query.
|
void |
deleteSchema()
Deletes the underlying schema or table (or similar) in the datastore
that holds the objects.
|
Result<K,T> |
execute(Query<K,T> query)
Execute the query and return the result.
|
void |
flush()
Forces the write caches to be flushed.
|
T |
get(K key)
Returns the object corresponding to the given key fetching all the fields.
|
T |
get(K key,
String[] fields)
Returns the object corresponding to the given key.
|
InfinispanClient<K,T> |
getClient() |
List<PartitionQuery<K,T>> |
getPartitions(Query<K,T> query)
Split the query per infinispan node resulting in a list of queries.
|
String |
getPrimaryFieldName() |
int |
getPrimaryFieldPos() |
String |
getSchemaName()
In Infinispan, Schemas are referred to as caches.
|
void |
initialize(Class<K> keyClass,
Class<T> persistentClass,
Properties properties)
Initialize the data store by reading the credentials, setting the client's properties up and
reading the mapping file.
|
Query<K,T> |
newQuery()
Constructs and returns a new Query.
|
void |
put(K key,
T obj)
Inserts the persistent object with the given key.
|
boolean |
schemaExists()
Returns whether the schema that holds the data exists in the datastore.
|
void |
setPrimaryFieldName(String name) |
void |
setPrimaryFieldPos(int p) |
equals, getBeanFactory, getConf, getFields, getFieldsToQuery, getKeyClass, getOrCreateConf, getPersistentClass, getSchemaName, newKey, newPersistent, readFields, setBeanFactory, setConf, setKeyClass, setPersistentClass, truncateSchema, write
public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties)
DataStoreFactory.createDataStore(java.lang.Class<D>, java.lang.Class<K>, java.lang.Class<T>, org.apache.hadoop.conf.Configuration)
is made.initialize
in interface DataStore<K,T extends PersistentBase>
initialize
in class DataStoreBase<K,T extends PersistentBase>
keyClass
- persistentClass
- properties
- public void close()
DataStore
public void createSchema()
DataStore
public boolean delete(K key)
DataStore
key
- the key of the objectpublic long deleteByQuery(Query<K,T> query)
DataStore
query
- matching records to this query will be deletedpublic void deleteSchema()
DataStore
public Result<K,T> execute(Query<K,T> query)
query
- the query to execute.Result
object.public T get(K key)
DataStore
get
in interface DataStore<K,T extends PersistentBase>
get
in class DataStoreBase<K,T extends PersistentBase>
key
- the key of the objectpublic T get(K key, String[] fields)
DataStore
key
- the key of the objectfields
- the fields required in the object. Pass null, to retrieve all fieldspublic List<PartitionQuery<K,T>> getPartitions(Query<K,T> query) throws IOException
query
- the base query to create the partitions for. If the query
is null, then the data store returns the partitions for the default query
(returning every object)IOException
public void flush()
DataStore
public String getSchemaName()
public Query<K,T> newQuery()
DataStore
public void put(K key, T obj)
DataStore
public boolean schemaExists()
DataStore
public InfinispanClient<K,T> getClient()
public String getPrimaryFieldName()
public void setPrimaryFieldName(String name)
public int getPrimaryFieldPos()
public void setPrimaryFieldPos(int p)
Copyright © 2010-2017 The Apache Software Foundation. All Rights Reserved.