Package org.apache.geode.cache.client
Interface ClientRegionFactory<K,V>
public interface ClientRegionFactory<K,V>
A factory for constructing
client cache regions. Instances of
this interface can be created using region shortcuts by calling
ClientCache.createClientRegionFactory(ClientRegionShortcut) or using named region
attributes by calling ClientCache.createClientRegionFactory(String).
The factory can then be customized using its methods.
The final step is to produce a Region by calling create(String).
Client regions may be:
- PROXY: which pass through to server and have no local data.
- CACHING_PROXY: which fetch data from servers and cache it locally.
- LOCAL: which only have local data; they do not communicate with the servers.
ClientRegionShortcut for the shortcuts for these three types of client regions.
Example: Create a client region with a CacheListener
ClientCache c = new ClientCacheFactory().addLocator(host, port).create();
// Create local caching region that is connected to a server side region
// Add a cache listener before creating region
Region r =
c.createClientRegionFactory(CACHING_PROXY).addCacheListener(myListener).create("customers");
- Since:
- GemFire 6.5
-
Method Summary
Modifier and TypeMethodDescriptionaddCacheListener(CacheListener<K, V> aListener) Adds a cache listener to the end of the list of cache listeners on this factory.Creates a region in theClientCacheusing the configuration contained in this ClientRegionFactory.createSubregion(Region<?, ?> parent, String name) Creates a sub-region in theClientCacheusing the configuration contained in this ClientRegionFactory.initCacheListeners(CacheListener<K, V>[] newListeners) Removes all cache listeners and then adds each listener in the specified array.setCloningEnabled(boolean cloningEnable) Sets cloning on region Note: off-heap regions always behave as if cloning is enabled.setCompressor(Compressor compressor) Set the compressor to be used by this region for compressing region entry values.voidsetConcurrencyChecksEnabled(boolean concurrencyChecksEnabled) Enables or disabled concurrent modification checkssetConcurrencyLevel(int concurrencyLevel) Sets the concurrency level tof the nextRegionAttributescreated.setCustomEntryIdleTimeout(CustomExpiry<K, V> custom) Sets the custom idleTimeout for the nextRegionAttributescreated.setCustomEntryTimeToLive(CustomExpiry<K, V> custom) Sets the custom timeToLive expiration method for the nextRegionAttributescreated.setDiskStoreName(String name) Sets the DiskStore name attribute.setDiskSynchronous(boolean isSynchronous) Sets whether or not the writing to the disk is synchronous.setEntryIdleTimeout(ExpirationAttributes idleTimeout) Sets the idleTimeout expiration attributes for region entries for the nextRegionAttributescreated.setEntryTimeToLive(ExpirationAttributes timeToLive) Sets the timeToLive expiration attributes for region entries for the nextRegionAttributescreated.setEvictionAttributes(EvictionAttributes evictionAttributes) Sets the eviction attributes that controls growth of the Region to be created.setInitialCapacity(int initialCapacity) Sets the entry initial capacity for the nextRegionAttributescreated.setKeyConstraint(Class<K> keyConstraint) Sets the key constraint for the nextRegionAttributescreated.setLoadFactor(float loadFactor) Sets the entry load factor for the nextRegionAttributescreated.setPoolName(String poolName) Sets the pool name attribute.setRegionIdleTimeout(ExpirationAttributes idleTimeout) Sets the idleTimeout expiration attributes for the region itself for the nextRegionAttributescreated.setRegionTimeToLive(ExpirationAttributes timeToLive) Sets the timeToLive expiration attributes for the region itself for the nextRegionAttributescreated.setStatisticsEnabled(boolean statisticsEnabled) Sets whether statistics are enabled for this region and its entries.setValueConstraint(Class<V> valueConstraint) Sets the value constraint for the nextRegionAttributescreated.
-
Method Details
-
addCacheListener
Adds a cache listener to the end of the list of cache listeners on this factory.- Parameters:
aListener- the cache listener to add- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- ifaListeneris null- See Also:
-
initCacheListeners
Removes all cache listeners and then adds each listener in the specified array. for the nextRegionAttributescreated.- Parameters:
newListeners- a possibly null or empty array of listeners to add to this factory.- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- if thenewListenersarray has a null element- See Also:
-
setEvictionAttributes
Sets the eviction attributes that controls growth of the Region to be created.- Parameters:
evictionAttributes- for the Region to create- Returns:
- a reference to this ClientRegionFactory object
-
setEntryIdleTimeout
Sets the idleTimeout expiration attributes for region entries for the nextRegionAttributescreated.- Parameters:
idleTimeout- the idleTimeout ExpirationAttributes for entries in this region- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- if idleTimeout is null- See Also:
-
setCustomEntryIdleTimeout
Sets the custom idleTimeout for the nextRegionAttributescreated.- Parameters:
custom- the custom method- Returns:
- the receiver
- See Also:
-
setEntryTimeToLive
Sets the timeToLive expiration attributes for region entries for the nextRegionAttributescreated.- Parameters:
timeToLive- the timeToLive ExpirationAttributes for entries in this region- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- if timeToLive is null- See Also:
-
setCustomEntryTimeToLive
Sets the custom timeToLive expiration method for the nextRegionAttributescreated.- Parameters:
custom- the custom method- Returns:
- the receiver
- See Also:
-
setRegionIdleTimeout
Sets the idleTimeout expiration attributes for the region itself for the nextRegionAttributescreated.- Parameters:
idleTimeout- the ExpirationAttributes for this region idleTimeout- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- if idleTimeout is null- See Also:
-
setRegionTimeToLive
Sets the timeToLive expiration attributes for the region itself for the nextRegionAttributescreated.- Parameters:
timeToLive- the ExpirationAttributes for this region timeToLive- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- if timeToLive is null- See Also:
-
setKeyConstraint
Sets the key constraint for the nextRegionAttributescreated. Keys in the region will be constrained to this class (or subclass). Any attempt to store a key of an incompatible type in the region will cause aClassCastExceptionto be thrown.- Parameters:
keyConstraint- The Class to constrain the keys to, or null if no constraint- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- ifkeyConstraintis a class denoting a primitive type- See Also:
-
setValueConstraint
Sets the value constraint for the nextRegionAttributescreated. Values in the region will be constrained to this class (or subclass). Any attempt to store a value of an incompatible type in the region will cause aClassCastExceptionto be thrown.- Parameters:
valueConstraint- The Class to constrain the values to, or null if no constraint- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- ifvalueConstraintis a class denoting a primitive type- See Also:
-
setInitialCapacity
Sets the entry initial capacity for the nextRegionAttributescreated. This value is used in initializing the map that holds the entries.- Parameters:
initialCapacity- the initial capacity of the entry map- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- if initialCapacity is negative.- See Also:
-
setLoadFactor
Sets the entry load factor for the nextRegionAttributescreated. This value is used in initializing the map that holds the entries.- Parameters:
loadFactor- the load factor of the entry map- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- if loadFactor is nonpositive- See Also:
-
setConcurrencyLevel
Sets the concurrency level tof the nextRegionAttributescreated. This value is used in initializing the map that holds the entries.- Parameters:
concurrencyLevel- the concurrency level of the entry map- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalArgumentException- if concurrencyLevel is nonpositive- See Also:
-
setConcurrencyChecksEnabled
void setConcurrencyChecksEnabled(boolean concurrencyChecksEnabled) Enables or disabled concurrent modification checks- Parameters:
concurrencyChecksEnabled- whether to perform concurrency checks on operations- Since:
- GemFire 7.0
-
setDiskStoreName
Sets the DiskStore name attribute. This causes the region to belong to the DiskStore.- Parameters:
name- the name of the diskstore- Returns:
- a reference to this ClientRegionFactory object
- See Also:
-
setDiskSynchronous
Sets whether or not the writing to the disk is synchronous.- Parameters:
isSynchronous- boolean if true indicates synchronous writes- Returns:
- a reference to this ClientRegionFactory object
-
setStatisticsEnabled
Sets whether statistics are enabled for this region and its entries.- Parameters:
statisticsEnabled- whether statistics are enabled- Returns:
- a reference to this ClientRegionFactory object
- See Also:
-
setCloningEnabled
Sets cloning on region Note: off-heap regions always behave as if cloning is enabled.- Parameters:
cloningEnable- whether cloning is enabled on the region- Returns:
- a reference to this ClientRegionFactory object
- See Also:
-
setPoolName
Sets the pool name attribute. This causes regions that use these attributes to be a client region which communicates with the servers that the connection pool communicates with.The named connection pool must exist on the cache at the time these attributes are used to create a region. See
PoolManager.createFactory()for how to create a connection pool.- Parameters:
poolName- the name of the connection pool to use- Returns:
- a reference to this ClientRegionFactory object
- Throws:
IllegalStateException- if a cache loader or cache writer has already been set.- See Also:
-
setCompressor
Set the compressor to be used by this region for compressing region entry values.- Parameters:
compressor- a compressor- Returns:
- a reference to this RegionFactory instance
- Since:
- GemFire 8.0
-
create
Creates a region in theClientCacheusing the configuration contained in this ClientRegionFactory. Validation of the provided attributes may cause exceptions to be thrown if there are problems with the configuration data.- Parameters:
name- the name of the region to create- Returns:
- the region object
- Throws:
RegionExistsException- if a region with the given name already exists in this cacheCacheClosedException- if the cache is closed
-
createSubregion
Creates a sub-region in theClientCacheusing the configuration contained in this ClientRegionFactory. Validation of the provided attributes may cause exceptions to be thrown if there are problems with the configuration data.- Parameters:
parent- the existing region that will contain the created sub-regionname- the name of the region to create- Returns:
- the region object
- Throws:
RegionExistsException- if a region with the given name already exists in this cacheRegionDestroyedException- if the parent region has been closed or destroyedCacheClosedException- if the cache is closed- Since:
- GemFire 7.0
-