Package org.springframework.data.gemfire
Class PeerRegionFactoryBean<K,V>
java.lang.Object
org.springframework.data.gemfire.support.AbstractFactoryBeanSupport<Region<K,V>>
org.springframework.data.gemfire.ResolvableRegionFactoryBean<K,V>
org.springframework.data.gemfire.ConfigurableRegionFactoryBean<K,V>
org.springframework.data.gemfire.PeerRegionFactoryBean<K,V>
- All Implemented Interfaces:
Aware,BeanClassLoaderAware,BeanFactoryAware,BeanNameAware,DisposableBean,FactoryBean<Region<K,,V>> InitializingBean,Lifecycle,Phased,SmartLifecycle,EvictingRegionFactoryBean,ExpiringRegionFactoryBean<K,V>
- Direct Known Subclasses:
GenericRegionFactoryBean,LocalRegionFactoryBean,PartitionedRegionFactoryBean,ReplicatedRegionFactoryBean
public abstract class PeerRegionFactoryBean<K,V>
extends ConfigurableRegionFactoryBean<K,V>
implements DisposableBean, EvictingRegionFactoryBean, ExpiringRegionFactoryBean<K,V>, SmartLifecycle
Spring
FactoryBean and abstract base class extended by other SDG FactoryBeans
used to construct, configure and initialize peer Regions.
This FactoryBean allows for very easy and flexible creation of peer Regions.
For client Regions, see the ClientRegionFactoryBean.- Author:
- Costin Leau, David Turanski, John Blum
- See Also:
-
CacheCacheListenerCacheLoaderCacheWriterCustomExpiryDataPolicyDiskStoreEvictionAttributesExpirationAttributesGemFireCachePartitionAttributesRegionRegionAttributesRegionFactoryRegionShortcutScopeAsyncEventQueueGatewaySenderCompressorDisposableBeanSmartLifecycleConfigurableRegionFactoryBeanResolvableRegionFactoryBeanClientRegionFactoryBeanEvictingRegionFactoryBeanExpiringRegionFactoryBeanRegionConfigurer
-
Field Summary
Fields inherited from class org.springframework.data.gemfire.ResolvableRegionFactoryBean
CREATING_REGION_LOG_MESSAGE, REGION_FOUND_LOG_MESSAGE, REGION_NOT_FOUND_ERROR_MESSAGEFields inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
DEFAULT_SINGLETONFields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTEFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAsyncEventQueueIds(String[] asyncEventQueueIds) Registers the array ofAsyncEventQueues(AEQ) with thisRegionbyIDby appending to the already existing, registered AEQs for thisRegion.voidaddAsyncEventQueues(AsyncEventQueue[] asyncEventQueues) Registers the array ofAsyncEventQueues(AEQ) with thisRegionby appending to the already existing, registered AEQs for thisRegion.voidaddGatewaySenders(GatewaySender[] gatewaySenders) Registers the array ofGatewaySenderswith thisRegionby appending to the already existing, registeredGatewaySendersfor thisRegion.voidaddGatewaySendersIds(String[] gatewaySenderIds) Registers the array ofGatewaySenderIDswith thisRegionby appending to the already existing, registeredGatewaySendersfor thisRegion.protected RegionFactory<K,V> configure(RegionFactory<K, V> regionFactory) Configures theRegionFactorybased on the configuration settings of thisPeerRegionFactoryBean.createRegion(GemFireCache gemfireCache, String regionName) protected RegionFactory<K,V> createRegionFactory(Cache cache) Create a new instance ofRegionFactoryinitialized with the givenCachethat is then used to construct, configure and initialize theRegionspecified by thisPeerRegionFactoryBean.voiddestroy()Closes and destroys thisRegion.Returns theRegionAttributesused to configure thisRegion.intgetPhase()getScope()Returns the configuredRegionShortcut.booleanprotected booleanReturns true when the user explicitly specified a value for the persistent attribute and it is false.booleanReturns a boolean value indicating whether off-heap memory use was enabled for thisRegion.protected booleanReturns true when the user explicitly specified a value for the persistent attribute and it is true.booleanbooleanprotected <K,V> void mergePartitionAttributes(RegionFactory<K, V> regionFactory, RegionAttributes<K, V> regionAttributes) Merges theRegionAttributesinto theRegionFactory.protected <K,V> RegionFactory<K, V> mergeRegionAttributes(RegionFactory<K, V> regionFactory, RegionAttributes<K, V> regionAttributes) Intelligently merges the given RegionAttributes with the configuration setting of the RegionFactory.protected RegionFactory<K,V> postProcess(RegionFactory<K, V> regionFactory) Post-process theRegionFactoryused to create theRegionspecified by thisPeerRegionFactoryBeanduring initialization.protected voidresolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, String dataPolicy) Validates the configured Data Policy and may override it, taking into account the 'persistent' attribute and constraints for the Region type.protected voidresolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) Validates and sets the Data Policy on the RegionFactory used to create and configure the Region from this FactoryBean.protected booleanvoidsetAsyncEventQueueIds(String[] asyncEventQueueIds) voidsetAsyncEventQueues(AsyncEventQueue[] asyncEventQueues) Configures an array ofAsyncEventQueuesfor thisRegion, which are used to perform asynchronous data access operations, e.g.voidsetAttributes(RegionAttributes<K, V> attributes) Sets theRegionAttributesused to configure thisRegion.voidsetCacheListeners(CacheListener<K, V>[] cacheListeners) ConfiguresCacheListenersused to listen for entry events on thisRegion.voidsetCacheLoader(CacheLoader<K, V> cacheLoader) Configures theCacheLoaderused by thisRegionto perform synchronous read-through data access operations to an underlying, external data source.voidsetCacheWriter(CacheWriter<K, V> cacheWriter) Configures theCacheWriterused by thisRegionto perform synchronous write-through data access operations to an underlying, external data source.voidsetClose(boolean close) Configure whether to close this Region during shutdown.voidsetCompressor(Compressor compressor) Configures theCompressorused to compress thisRegion'sdata.voidsetCustomEntryIdleTimeout(CustomExpiry<K, V> customEntryIdleTimeout) voidsetCustomEntryTimeToLive(CustomExpiry<K, V> customEntryTimeToLive) voidsetDataPolicy(DataPolicy dataPolicy) Configure theDataPolicyfor thisRegion.voidsetDestroy(boolean destroy) Configure whether to destroy thisRegionduring shutdown.voidsetDiskStoreName(String diskStoreName) voidsetEntryIdleTimeout(ExpirationAttributes entryIdleTimeout) voidsetEntryTimeToLive(ExpirationAttributes entryTimeToLive) voidsetEvictionAttributes(EvictionAttributes evictionAttributes) voidsetGatewaySenderIds(String[] gatewaySenderIds) Configures theGatewaySendersbyIDused to send data and events from thisRegionto a matchingRegionin a remote cluster.voidsetGatewaySenders(GatewaySender[] gatewaySenders) Configures theGatewaySendersused to send data and events from thisRegionto a matchingRegionin a remote cluster.voidsetKeyConstraint(Class<K> keyConstraint) voidsetOffHeap(Boolean offHeap) Configures thisRegionwith the capability to store data in off-heap memory.voidsetPersistent(Boolean persistent) Configures whether to enable persistence for thisRegion.voidsetRegionIdleTimeout(ExpirationAttributes regionIdleTimeout) voidsetRegionTimeToLive(ExpirationAttributes regionTimeToLive) voidvoidsetShortcut(RegionShortcut shortcut) Configures theRegionwith the givenRegionShortcut.voidsetStatisticsEnabled(Boolean statisticsEnabled) voidsetValueConstraint(Class<V> valueConstraint) voidstart()voidstop()voidMethods inherited from class org.springframework.data.gemfire.ConfigurableRegionFactoryBean
afterPropertiesSet, applyRegionConfigurers, applyRegionConfigurers, applyRegionConfigurers, getCompositeRegionConfigurer, setRegionConfigurers, setRegionConfigurersMethods inherited from class org.springframework.data.gemfire.ResolvableRegionFactoryBean
getCache, getLookupEnabled, getObject, getObjectType, getParent, getRegion, isLookupEnabled, loadSnapshot, postProcess, resolveRegionName, setCache, setLookupEnabled, setName, setParent, setRegion, setRegionName, setSnapshotMethods inherited from class org.springframework.data.gemfire.support.AbstractFactoryBeanSupport
getBeanClassLoader, getBeanFactory, getBeanName, getLogger, getOptionalLogger, isDebugLoggingEnabled, isErrorLoggingEnabled, isInfoLoggingEnabled, isSingleton, isWarnLoggingEnabled, logDebug, logDebug, logError, logError, logInfo, logInfo, logWarning, logWarning, newLogger, setBeanClassLoader, setBeanFactory, setBeanName
-
Constructor Details
-
PeerRegionFactoryBean
public PeerRegionFactoryBean()
-
-
Method Details
-
createRegion
- Overrides:
createRegionin classResolvableRegionFactoryBean<K,V> - Parameters:
gemfireCache- reference to theGemFireCache.regionName-nameof the newRegion.- Returns:
- a new
Regionwith the givenname. - See Also:
-
createRegionFactory
Create a new instance ofRegionFactoryinitialized with the givenCachethat is then used to construct, configure and initialize theRegionspecified by thisPeerRegionFactoryBean.- Parameters:
cache- reference to theCache.- Returns:
- a
RegionFactoryused to construct, configure and initialize theRegionspecified by thisPeerRegionFactoryBean. - See Also:
-
configure
Configures theRegionFactorybased on the configuration settings of thisPeerRegionFactoryBean.- Parameters:
regionFactory-RegionFactoryto configure- Returns:
- the given
RegionFactory. - See Also:
-
postProcess
Post-process theRegionFactoryused to create theRegionspecified by thisPeerRegionFactoryBeanduring initialization. TheRegionFactoryhas been already constructed, configured and initialized by thisPeerRegionFactoryBeanbefore this method gets invoked.- Parameters:
regionFactory-RegionFactoryused to create theRegion.- Returns:
- the given
RegionFactory. - See Also:
-
mergeRegionAttributes
protected <K,V> RegionFactory<K,V> mergeRegionAttributes(RegionFactory<K, V> regionFactory, RegionAttributes<K, V> regionAttributes) Intelligently merges the given RegionAttributes with the configuration setting of the RegionFactory. This method is used to merge the RegionAttributes and PartitionAttributes with the RegionFactory that is created when the user specified a RegionShortcut. This method gets called by the createRegionFactory method depending upon the value passed to the Cache.createRegionFactory() method (i.e. whether there was a RegionShortcut specified or not).- Type Parameters:
K- the Class type fo the Region key.V- the Class type of the Region value.- Parameters:
regionFactory- the GemFire RegionFactory used to configure and create the Region that is the product of this PeerRegionFactoryBean.regionAttributes- the RegionAttributes containing the Region configuration settings to merge to the RegionFactory.- Returns:
- the RegionFactory with the configuration settings of the RegionAttributes merged.
- See Also:
-
isUserSpecifiedEvictionAttributes(org.apache.geode.cache.RegionAttributes)validateRegionAttributes(org.apache.geode.cache.RegionAttributes)RegionAttributesRegionFactory
-
mergePartitionAttributes
protected <K,V> void mergePartitionAttributes(RegionFactory<K, V> regionFactory, RegionAttributes<K, V> regionAttributes) Merges theRegionAttributesinto theRegionFactory.- Parameters:
regionFactory-RegionFactoryto configure.regionAttributes-RegionAttributesused to configure theRegionFactoryif not null.- See Also:
-
isNotPersistent
protected boolean isNotPersistent()Returns true when the user explicitly specified a value for the persistent attribute and it is false. If the persistent attribute was not explicitly specified, then the persistence setting is implicitly undefined and will be determined by the Data Policy.- Returns:
- true when the user specified an explicit value for the persistent attribute and it is false; false otherwise.
- See Also:
-
isPersistent
protected boolean isPersistent()Returns true when the user explicitly specified a value for the persistent attribute and it is true. If the persistent attribute was not explicitly specified, then the persistence setting is implicitly undefined and will be determined by the Data Policy.- Returns:
- true when the user specified an explicit value for the persistent attribute and it is true; false otherwise.
- See Also:
-
resolveDataPolicy
protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) Validates and sets the Data Policy on the RegionFactory used to create and configure the Region from this FactoryBean.- Parameters:
regionFactory- the RegionFactory used by this FactoryBean to create and configure the Region.persistent- a boolean value indicating whether the Region should be persistent and persist it's data to disk.dataPolicy- the configured Data Policy for the Region.- See Also:
-
resolveDataPolicy
protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, String dataPolicy) Validates the configured Data Policy and may override it, taking into account the 'persistent' attribute and constraints for the Region type.- Parameters:
regionFactory- the GemFire RegionFactory used to create the desired Region.persistent- a boolean value indicating whether the Region should persist it's data to disk.dataPolicy- requested Data Policy as set by the user in the Spring GemFire configuration meta-data.- See Also:
-
destroy
Closes and destroys thisRegion.- Specified by:
destroyin interfaceDisposableBean- Throws:
Exception- ifdestroy()fails.- See Also:
-
setAsyncEventQueues
Configures an array ofAsyncEventQueuesfor thisRegion, which are used to perform asynchronous data access operations, e.g. asynchronous, write-behind operations. This method clears any existing, registeredAsyncEventQueues(AEQ) already associated with thisRegion. UseaddAsyncEventQueues(AsyncEventQueue[])oraddAsyncEventQueueIds(String[])to append to the existing AEQs already registered instead.- Parameters:
asyncEventQueues- array ofAsyncEventQueuesregistered with and used by thisRegionto perform asynchronous data access operations.- See Also:
-
setAsyncEventQueueIds
Configures an array ofAsyncEventQueues(AEQ) for thisRegionbyAEQ ID. This method clears any existing, registeredAsyncEventQueues(AEQ) already associated with thisRegionby AEQ ID. UseaddAsyncEventQueues(AsyncEventQueue[])oraddAsyncEventQueueIds(String[])to append to the existing AEQs already registered instead. oraddAsyncEventQueueIds(String[])to append to the existing AEQs already registered instead. -
addAsyncEventQueues
Registers the array ofAsyncEventQueues(AEQ) with thisRegionby appending to the already existing, registered AEQs for thisRegion.- Parameters:
asyncEventQueues- array ofAsyncEventQueuesto register with thisRegion.- See Also:
-
addAsyncEventQueueIds
Registers the array ofAsyncEventQueues(AEQ) with thisRegionbyIDby appending to the already existing, registered AEQs for thisRegion.- Parameters:
asyncEventQueueIds- array ofAsyncEventQueueIDsto register with thisRegion.- See Also:
-
setAttributes
Sets theRegionAttributesused to configure thisRegion. SpecifyingRegionAttributesallows full control in configuring variousRegionsettings. Used only when theRegionis created and not when theRegionis looked up.- Parameters:
attributes-RegionAttributesused to configure thisRegion.- See Also:
-
getAttributes
Returns theRegionAttributesused to configure thisRegion.- Returns:
- the
RegionAttributesused to configure thisRegion. - See Also:
-
setCacheListeners
ConfiguresCacheListenersused to listen for entry events on thisRegion. Used only when a newRegionis created and notlooked up. Overrides theRegionsettings specified inRegionAttributesset withsetAttributes(RegionAttributes).- Parameters:
cacheListeners- arrayCacheListenersto register with thisRegion.- See Also:
-
setCacheLoader
Configures theCacheLoaderused by thisRegionto perform synchronous read-through data access operations to an underlying, external data source. Used only when a newRegionis created and notlooked up. Overrides theRegionsettings specified inRegionAttributesset withsetAttributes(RegionAttributes).- Parameters:
cacheLoader-CacheLoaderto register for thisRegion.- See Also:
-
setCacheWriter
Configures theCacheWriterused by thisRegionto perform synchronous write-through data access operations to an underlying, external data source. Used only when a newRegionis created and notlooked up. Overrides theRegionsettings specified inRegionAttributesset withsetAttributes(RegionAttributes).- Parameters:
cacheWriter-CacheWriterto register for thisRegion.- See Also:
-
setClose
public void setClose(boolean close) Configure whether to close this Region during shutdown. Defaults to true.- Parameters:
close- boolean value indicating whether thisRegionshould be closed during shutdown.- See Also:
-
setCompressor
Configures theCompressorused to compress thisRegion'sdata.- Parameters:
compressor-Compressorused to compress thisRegion'sdata.- See Also:
-
setCustomEntryIdleTimeout
- Specified by:
setCustomEntryIdleTimeoutin interfaceExpiringRegionFactoryBean<K,V>
-
setCustomEntryTimeToLive
- Specified by:
setCustomEntryTimeToLivein interfaceExpiringRegionFactoryBean<K,V>
-
setDestroy
public void setDestroy(boolean destroy) Configure whether to destroy thisRegionduring shutdown. Defaults to false.- Parameters:
destroy- value indicating whether thisRegionshould be destroyed during shutdown.- See Also:
-
setDataPolicy
Configure theDataPolicyfor thisRegion.- Parameters:
dataPolicy-DataPolicyused when configuring thisRegion.- Since:
- 1.4.0
- See Also:
-
getDataPolicy
- Returns:
- the configured, resolved
DataPolicyused by thisRegion. - Throws:
IllegalStateException- if theDataPolicyhas not been configured or is not resolvable.- See Also:
-
setDiskStoreName
-
setEntryIdleTimeout
- Specified by:
setEntryIdleTimeoutin interfaceExpiringRegionFactoryBean<K,V>
-
setEntryTimeToLive
- Specified by:
setEntryTimeToLivein interfaceExpiringRegionFactoryBean<K,V>
-
setEvictionAttributes
- Specified by:
setEvictionAttributesin interfaceEvictingRegionFactoryBean
-
setGatewaySenders
Configures theGatewaySendersused to send data and events from thisRegionto a matchingRegionin a remote cluster. This method clears all existing, registeredGatewaySendersalready associated with thisRegion. UseaddGatewaySenders(GatewaySender[])oraddGatewaySendersIds(String[])to append to the existing, registeredGatewaySendersfor thisRegion.- Parameters:
gatewaySenders-GatewaySendersused to send data and events from thisRegionto a matchingRegionin a remote cluster.- See Also:
-
setGatewaySenderIds
Configures theGatewaySendersbyIDused to send data and events from thisRegionto a matchingRegionin a remote cluster. This method clears all existing, registeredGatewaySendersalready associated with thisRegion. UseaddGatewaySenders(GatewaySender[])oraddGatewaySendersIds(String[])to append to the existing, registeredGatewaySendersfor thisRegion.- Parameters:
gatewaySenderIds-Stringarray containingGatewaySenderIDsto register with thisRegion.- See Also:
-
addGatewaySenders
Registers the array ofGatewaySenderswith thisRegionby appending to the already existing, registeredGatewaySendersfor thisRegion.- Parameters:
gatewaySenders- array ofGatewaySendersto register with thisRegion.- See Also:
-
addGatewaySendersIds
Registers the array ofGatewaySenderIDswith thisRegionby appending to the already existing, registeredGatewaySendersfor thisRegion.- Parameters:
gatewaySenderIds- array ofGatewaySenderIDsto register with thisRegion.- See Also:
-
setOffHeap
Configures thisRegionwith the capability to store data in off-heap memory. -
getOffHeap
-
isOffHeap
public boolean isOffHeap()Returns a boolean value indicating whether off-heap memory use was enabled for thisRegion.- Returns:
- a boolean value indicating whether off-heap memory use was enabled for
this
Region. - See Also:
-
setKeyConstraint
-
setPersistent
-
setRegionIdleTimeout
- Specified by:
setRegionIdleTimeoutin interfaceExpiringRegionFactoryBean<K,V>
-
setRegionTimeToLive
- Specified by:
setRegionTimeToLivein interfaceExpiringRegionFactoryBean<K,V>
-
setScope
-
getScope
-
setShortcut
Configures theRegionwith the givenRegionShortcut.- Parameters:
shortcut-RegionShortcutused to configure pre-defined defaults for theRegion.- See Also:
-
getShortcut
Returns the configuredRegionShortcut.- Returns:
- the configured
RegionShortcut. - See Also:
-
setStatisticsEnabled
-
getStatisticsEnabled
-
isStatisticsEnabled
public boolean isStatisticsEnabled() -
resolveStatisticsEnabled
protected boolean resolveStatisticsEnabled() -
setValueConstraint
-
start
public void start() -
stop
- Specified by:
stopin interfaceSmartLifecycle
-
stop
public void stop() -
isRunning
public boolean isRunning() -
getPhase
public int getPhase()- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartupin interfaceSmartLifecycle
-