|
GemFire 6.0.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.gemstone.gemfire.cache.RegionFactory<K,V>
public class RegionFactory<K,V>
RegionFactory is a factory that encapsulates the following
four steps to simplify Region creation.
DistributedSystemCacheRegionAttributes using a
AttributesFactoryRegion using the Cache
RegionFactory simplifies these steps into one class and
potentially one step:
final Region portfolios = new RegionFactory().setScope(Scope.DISTRIBUTED_ACK)
.setCacheLoader(new PortfolioDBLoader())
.setValueConstraint(Portfolio.class).setKeyConstraint(Integer.class)
.create("Portfolios");
or if you already have a Region that has many similar
attributes to the one you would like to create, you can do this:
final Region persistentPortfolios = new RegionFactory(portfolios.getAttributes())
.setDiskDirs(new File[] {new File("/stor1/port1.persist"),
new File("/stor2/port2.persis")})
.setDiskWriteAttributes(new new DiskWriteAttributes())
.create("Portfolios");
or you can refer to a collection of attributes already defined in a cache.xml
file:
final Region lruToDiskPortfolios = new RegionFactory("persistent")
.create("Portfolios");
Where persistent is defined in a cache.xml file in this way:
<region-attributes id="persistent" persist-backup="true" mirror-type="keys-values">
<disk-write-attributes>
<asynchronous-writes bytes-threshold="1000" time-interval="30"/>
</disk-write-attributes>
<eviction-attributes>
<lru-entry-count maximum="1000" action="overflow-to-disk"/>
</eviction-attributes>
</region-attributes>
DistributedSystem.connect(java.util.Properties),
CacheFactory.create(com.gemstone.gemfire.distributed.DistributedSystem),
AttributesFactory.create(),
Cache.createRegion(java.lang.String, com.gemstone.gemfire.cache.RegionAttributes) | Constructor Summary | |
|---|---|
RegionFactory()
Constructs a RegionFactory by creating a DistributedSystem and a Cache. |
|
RegionFactory(Properties distributedSystemProperties)
Constructs a RegionFactory by creating a DistributedSystem and a Cache. |
|
RegionFactory(Properties distributedSystemProperties,
RegionAttributes<K,V> regionAttributes)
Constructs a RegionFactory by creating a DistributedSystem and a Cache. |
|
RegionFactory(Properties distributedSystemProperties,
String regionAttributesId)
Constructs a RegionFactory by creating a DistributedSystem and a Cache. |
|
RegionFactory(RegionAttributes<K,V> regionAttributes)
Constructs a RegionFactory by creating a DistributedSystem and a Cache. |
|
RegionFactory(String regionAttributesId)
Constructs a RegionFactory by creating a DistributedSystem and a Cache. |
|
| Method Summary | |
|---|---|
RegionFactory<K,V> |
addCacheListener(CacheListener<K,V> aListener)
Adds a cache listener to the end of the list of cache listeners on this factory. |
Region<K,V> |
create(String name)
Creates a region using a DistributedSystem, Cache, and
the configuration contained in this RegionFactory. |
RegionFactory<K,V> |
initCacheListeners(CacheListener<K,V>[] newListeners)
Removes all cache listeners and then adds each listener in the specified array. |
RegionFactory<K,V> |
setCacheLoader(CacheLoader<K,V> cacheLoader)
Sets the cache loader for the next RegionAttributes created. |
RegionFactory<K,V> |
setCacheWriter(CacheWriter<K,V> cacheWriter)
Sets the cache writer for the next RegionAttributes created. |
RegionFactory<K,V> |
setConcurrencyLevel(int concurrencyLevel)
Sets the concurrency level tof the next RegionAttributes
created. |
RegionFactory<K,V> |
setCustomEntryIdleTimeout(CustomExpiry<K,V> custom)
Sets the custom idleTimeout for the next RegionAttributes
created. |
RegionFactory<K,V> |
setCustomEntryTimeToLive(CustomExpiry<K,V> custom)
Sets the custom timeToLive expiration method for the next RegionAttributes created. |
RegionFactory<K,V> |
setDataPolicy(DataPolicy dataPolicy)
Sets the data policy for the next RegionAttributes created. |
RegionFactory<K,V> |
setDiskDirs(File[] diskDirs)
Sets the directories to which the region's data are written. |
RegionFactory<K,V> |
setDiskDirsAndSizes(File[] diskDirs,
int[] diskSizes)
Sets the directories to which the region's data are written and also set their sizes in megabytes |
RegionFactory<K,V> |
setDiskWriteAttributes(DiskWriteAttributes attrs)
Returns whether or not disk writes are asynchronous. |
RegionFactory<K,V> |
setEarlyAck(boolean earlyAck)
Sets for this region whether or not acks are sent after an update is processed. |
RegionFactory<K,V> |
setEnableAsyncConflation(boolean value)
Sets whether or not conflation is enabled for sending messages to async peers. |
RegionFactory<K,V> |
setEnableBridgeConflation(boolean value)
Deprecated. as of 5.7, use setEnableSubscriptionConflation(boolean) |
RegionFactory<K,V> |
setEnableConflation(boolean value)
Deprecated. as of 5.0, use setEnableSubscriptionConflation(boolean) |
RegionFactory<K,V> |
setEnableGateway(boolean value)
Sets whether or not updates are sent to defined Gateways. |
RegionFactory<K,V> |
setEnableSubscriptionConflation(boolean value)
Deprecated. as of 5.7, use setEnableSubscriptionConflation(boolean) |
RegionFactory<K,V> |
setEnableWAN(boolean value)
Deprecated. as of 5.0, use setEnableGateway(boolean) |
RegionFactory<K,V> |
setEntryIdleTimeout(ExpirationAttributes idleTimeout)
Sets the idleTimeout expiration attributes for region entries for the next RegionAttributes created. |
RegionFactory<K,V> |
setEntryTimeToLive(ExpirationAttributes timeToLive)
Sets the timeToLive expiration attributes for region entries for the next RegionAttributes created. |
RegionFactory<K,V> |
setEvictionAttributes(EvictionAttributes evictionAttributes)
Sets the eviction attributes that controls growth of the Region to be created. |
RegionFactory<K,V> |
setGatewayHubId(String id)
Sets the id of the GatewayHub to which this region sends events. |
RegionFactory<K,V> |
setIgnoreJTA(boolean flag)
Sets whether operations on this region should be controlled by JTA transactions or not |
RegionFactory<K,V> |
setIndexMaintenanceSynchronous(boolean synchronous)
Sets how indexes on this region are kept current. |
RegionFactory<K,V> |
setInitialCapacity(int initialCapacity)
Sets the entry initial capacity for the next RegionAttributes
created. |
RegionFactory<K,V> |
setKeyConstraint(Class<K> keyConstraint)
Sets the key constraint for the next RegionAttributes
created. |
RegionFactory<K,V> |
setLoadFactor(float loadFactor)
Sets the entry load factor for the next RegionAttributes
created. |
RegionFactory<K,V> |
setLockGrantor(boolean isLockGrantor)
Sets whether this region should become lock grantor. |
RegionFactory<K,V> |
setMembershipAttributes(MembershipAttributes ra)
Sets the MembershipAttributes that describe the membership
roles required for reliable access to the region. |
RegionFactory<K,V> |
setMulticastEnabled(boolean value)
Sets whether distributed operations on this region should attempt to use multicast. |
RegionFactory<K,V> |
setPartitionAttributes(PartitionAttributes partition)
Sets the PartitionAttributes that describe how the region is
partitioned among members of the distributed system. |
RegionFactory<K,V> |
setPoolName(String poolName)
Sets the pool name attribute. |
void |
setPublisher(boolean v)
Sets whether or not this region should be considered a publisher. |
RegionFactory<K,V> |
setRegionIdleTimeout(ExpirationAttributes idleTimeout)
Sets the idleTimeout expiration attributes for the region itself for the next RegionAttributes created. |
RegionFactory<K,V> |
setRegionTimeToLive(ExpirationAttributes timeToLive)
Sets the timeToLive expiration attributes for the region itself for the next RegionAttributes created. |
RegionFactory<K,V> |
setScope(Scope scopeType)
Sets the scope for the next RegionAttributes created. |
RegionFactory<K,V> |
setStatisticsEnabled(boolean statisticsEnabled)
Sets whether statistics are enabled for this region and its entries. |
RegionFactory<K,V> |
setSubscriptionAttributes(SubscriptionAttributes sa)
Sets the kind of interest this region has in events occuring in other caches that define the region by the same name. |
RegionFactory<K,V> |
setValueConstraint(Class<V> valueConstraint)
Sets the value constraint for the next RegionAttributes
created. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RegionFactory()
throws CacheWriterException,
RegionExistsException,
TimeoutException,
ClientNotReadyException
CacheException - if unable to connect the DistributedSystem or create a Cache
CacheWriterException
RegionExistsException
TimeoutException
ClientNotReadyException
public RegionFactory(RegionAttributes<K,V> regionAttributes)
throws CacheWriterException,
RegionExistsException,
TimeoutException,
ClientNotReadyException
CacheException - if unable to connect the DistributedSystem or create a Cache
CacheWriterException
RegionExistsException
TimeoutException
ClientNotReadyException
public RegionFactory(String regionAttributesId)
throws CacheWriterException,
RegionExistsException,
TimeoutException,
ClientNotReadyException
regionAttributesId - that identifies a set of RegionAttributes in the cache-xml file.
IllegalArgumentException - if there are no attributes associated with the id
CacheException - if unable to connect the DistributedSystem or create a Cache
CacheWriterException
RegionExistsException
TimeoutException
ClientNotReadyExceptionCache.getRegionAttributes(java.lang.String)
public RegionFactory(Properties distributedSystemProperties)
throws CacheWriterException,
RegionExistsException,
TimeoutException,
ClientNotReadyException
distributedSystemProperties - an instance of Properties containing
DistributedSystemThrows:
CacheException - if unable to connect the DistributedSystem or create a Cache
CacheWriterException
RegionExistsException
TimeoutException
ClientNotReadyException
public RegionFactory(Properties distributedSystemProperties,
RegionAttributes<K,V> regionAttributes)
throws CacheWriterException,
RegionExistsException,
TimeoutException,
ClientNotReadyException
distributedSystemProperties - properties used to either find or create a DistributedSystem.regionAttributes - the initial Region configuration for this RegionFactory.
CacheException - if unable to connect the DistributedSystem or create a Cache
CacheWriterException
RegionExistsException
TimeoutException
ClientNotReadyException
public RegionFactory(Properties distributedSystemProperties,
String regionAttributesId)
throws CacheWriterException,
RegionExistsException,
TimeoutException,
ClientNotReadyException
distributedSystemProperties - properties used to either find or create a DistributedSystem.regionAttributesId - the identifier for set of RegionAttributes in the cache.xml file
used as the initial Region configuration for this RegionFactory.
IllegalArgumentException - if there are no attributes associated with the id
CacheException - if unable to connect the DistributedSystem or create a Cache
CacheWriterException
RegionExistsException
TimeoutException
ClientNotReadyException| Method Detail |
|---|
public RegionFactory<K,V> setCacheLoader(CacheLoader<K,V> cacheLoader)
RegionAttributes created.
cacheLoader - the cache loader or null if no loader
AttributesFactory.setCacheLoader(com.gemstone.gemfire.cache.CacheLoader) public RegionFactory<K,V> setCacheWriter(CacheWriter<K,V> cacheWriter)
RegionAttributes created.
cacheWriter - the cache writer or null if no cache writer
AttributesFactory.setCacheWriter(com.gemstone.gemfire.cache.CacheWriter) public RegionFactory<K,V> addCacheListener(CacheListener<K,V> aListener)
aListener - the cache listener to add
IllegalArgumentException - if aListener is nullAttributesFactory.addCacheListener(com.gemstone.gemfire.cache.CacheListener) public RegionFactory<K,V> initCacheListeners(CacheListener<K,V>[] newListeners)
RegionAttributes created.
newListeners - a possibly null or empty array of listeners to add to this factory.
IllegalArgumentException - if the newListeners array has a null elementAttributesFactory.initCacheListeners(com.gemstone.gemfire.cache.CacheListener[]) public RegionFactory<K,V> setEvictionAttributes(EvictionAttributes evictionAttributes)
evictionAttributes - for the Region to create
public RegionFactory<K,V> setEntryIdleTimeout(ExpirationAttributes idleTimeout)
RegionAttributes created.
idleTimeout - the idleTimeout ExpirationAttributes for entries in this region
IllegalArgumentException - if idleTimeout is nullAttributesFactory.setEntryIdleTimeout(com.gemstone.gemfire.cache.ExpirationAttributes)public RegionFactory<K,V> setCustomEntryIdleTimeout(CustomExpiry<K,V> custom)
RegionAttributes
created.
custom - the custom method
AttributesFactory.setCustomEntryIdleTimeout(CustomExpiry)public RegionFactory<K,V> setEntryTimeToLive(ExpirationAttributes timeToLive)
RegionAttributes created.
timeToLive - the timeToLive ExpirationAttributes for entries in this region
IllegalArgumentException - if timeToLive is nullAttributesFactory.setEntryTimeToLive(com.gemstone.gemfire.cache.ExpirationAttributes)public RegionFactory<K,V> setCustomEntryTimeToLive(CustomExpiry<K,V> custom)
RegionAttributes created.
custom - the custom method
AttributesFactory.setCustomEntryTimeToLive(CustomExpiry)public RegionFactory<K,V> setRegionIdleTimeout(ExpirationAttributes idleTimeout)
RegionAttributes created.
idleTimeout - the ExpirationAttributes for this region idleTimeout
IllegalArgumentException - if idleTimeout is nullAttributesFactory.setRegionIdleTimeout(com.gemstone.gemfire.cache.ExpirationAttributes)public RegionFactory<K,V> setRegionTimeToLive(ExpirationAttributes timeToLive)
RegionAttributes created.
timeToLive - the ExpirationAttributes for this region timeToLive
IllegalArgumentException - if timeToLive is nullAttributesFactory.setRegionTimeToLive(com.gemstone.gemfire.cache.ExpirationAttributes)public RegionFactory<K,V> setScope(Scope scopeType)
RegionAttributes created.
scopeType - the type of Scope to use for the region
IllegalArgumentException - if scopeType is nullAttributesFactory.setScope(com.gemstone.gemfire.cache.Scope)public RegionFactory<K,V> setDataPolicy(DataPolicy dataPolicy)
RegionAttributes created.
dataPolicy - The type of mirroring to use for the region
IllegalArgumentException - if dataPolicy is nullAttributesFactory.setDataPolicy(com.gemstone.gemfire.cache.DataPolicy)public RegionFactory<K,V> setEarlyAck(boolean earlyAck)
earlyAck - set to true for the acknowledgement to be sent prior to processing the update
AttributesFactory.setEarlyAck(boolean)public RegionFactory<K,V> setMulticastEnabled(boolean value)
value - true to enable multicast
AttributesFactory.setMulticastEnabled(boolean)public RegionFactory<K,V> setPoolName(String poolName)
If this attribute is set to null or ""
then the connection pool is disabled causing regions that use these attributes
to be communicate with peers instead of servers.
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.
poolName - the name of the connection pool to use; if null
or "" then the connection pool attribute is disabled for regions
using these attributes.
IllegalStateException - if a cache loader or cache writer has already
been set.@Deprecated public RegionFactory<K,V> setEnableWAN(boolean value)
setEnableGateway(boolean)
Gateways.
value - true to enable Gateway
public RegionFactory<K,V> setEnableGateway(boolean value)
Gateways.
value - true to enable Gateway
AttributesFactory.setEnableGateway(boolean)public void setPublisher(boolean v)
public RegionFactory<K,V> setEnableAsyncConflation(boolean value)
value - true to enable async conflation
AttributesFactory.setEnableAsyncConflation(boolean)@Deprecated public RegionFactory<K,V> setEnableConflation(boolean value)
value - true to enable bridge conflation
@Deprecated public RegionFactory<K,V> setEnableBridgeConflation(boolean value)
value - true to enable bridge conflation
AttributesFactory.setEnableBridgeConflation(boolean)@Deprecated public RegionFactory<K,V> setEnableSubscriptionConflation(boolean value)
value - true to enable subscription conflation
AttributesFactory.setEnableSubscriptionConflation(boolean)public RegionFactory<K,V> setKeyConstraint(Class<K> keyConstraint)
RegionAttributes
created. 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 a ClassCastException to be thrown.
keyConstraint - The Class to constrain the keys to, or null if no constraint
IllegalArgumentException - if keyConstraint is a class denoting a primitive
typeAttributesFactory.setKeyConstraint(java.lang.Class) public RegionFactory<K,V> setValueConstraint(Class<V> valueConstraint)
RegionAttributes
created. 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 a ClassCastException to be thrown.
valueConstraint - The Class to constrain the values to, or null if no constraint
IllegalArgumentException - if valueConstraint is a class denoting a primitive
typeAttributesFactory.setValueConstraint(java.lang.Class) public RegionFactory<K,V> setInitialCapacity(int initialCapacity)
RegionAttributes
created. This value is used in initializing the map that holds the entries.
initialCapacity - the initial capacity of the entry map
IllegalArgumentException - if initialCapacity is negative.HashMap,
AttributesFactory.setInitialCapacity(int)public RegionFactory<K,V> setLoadFactor(float loadFactor)
RegionAttributes
created. This value is used in initializing the map that holds the entries.
loadFactor - the load factor of the entry map
IllegalArgumentException - if loadFactor is nonpositiveHashMap,
AttributesFactory.setLoadFactor(float)public RegionFactory<K,V> setConcurrencyLevel(int concurrencyLevel)
RegionAttributes
created. This value is used in initializing the map that holds the entries.
concurrencyLevel - the concurrency level of the entry map
IllegalArgumentException - if concurrencyLevel is nonpositiveAttributesFactory.setConcurrencyLevel(int)public RegionFactory<K,V> setDiskWriteAttributes(DiskWriteAttributes attrs)
Region.writeToDisk(),
AttributesFactory.setDiskWriteAttributes(com.gemstone.gemfire.cache.DiskWriteAttributes)public RegionFactory<K,V> setDiskDirs(File[] diskDirs)
IllegalArgumentException - if a directory does not existAttributesFactory.setDiskDirs(java.io.File[])
public RegionFactory<K,V> setDiskDirsAndSizes(File[] diskDirs,
int[] diskSizes)
IllegalArgumentException - if a dir does not exist or the length of the size array
does not match to the length of the dir arrayAttributesFactory.setDiskDirsAndSizes(java.io.File[], int[])public RegionFactory<K,V> setPartitionAttributes(PartitionAttributes partition)
PartitionAttributes that describe how the region is
partitioned among members of the distributed system.
AttributesFactory.setPartitionAttributes(com.gemstone.gemfire.cache.PartitionAttributes)public RegionFactory<K,V> setMembershipAttributes(MembershipAttributes ra)
MembershipAttributes that describe the membership
roles required for reliable access to the region.
ra - the MembershipAttributes to use
AttributesFactory.setMembershipAttributes(com.gemstone.gemfire.cache.MembershipAttributes)public RegionFactory<K,V> setIndexMaintenanceSynchronous(boolean synchronous)
synchronous - whether indexes are maintained in a synchronized fashion
public RegionFactory<K,V> setStatisticsEnabled(boolean statisticsEnabled)
statisticsEnabled - whether statistics are enabled
AttributesFactory.setStatisticsEnabled(boolean)public RegionFactory<K,V> setIgnoreJTA(boolean flag)
public RegionFactory<K,V> setLockGrantor(boolean isLockGrantor)
isLockGrantor - whether this region should become lock grantor
AttributesFactory.setLockGrantor(boolean)public RegionFactory<K,V> setSubscriptionAttributes(SubscriptionAttributes sa)
sa - the attributes decribing the interest
AttributesFactory.setSubscriptionAttributes(SubscriptionAttributes)public RegionFactory<K,V> setGatewayHubId(String id)
GatewayHub to which this region sends events.
id - the id of the GatewayHub
AttributesFactory.setGatewayHubId(String)
public Region<K,V> create(String name)
throws CacheExistsException,
RegionExistsException,
CacheWriterException,
TimeoutException,
ClientNotReadyException
DistributedSystem, Cache, and
the configuration contained in this RegionFactory. Validation of the
provided attributes may cause exceptions to be thrown if there are problems
with the configuration data.
name - the name of the region to create
LeaseExpiredException - if lease expired on distributed lock for Scope.GLOBAL
RegionExistsException - if a region, shared or unshared, is already in this cache
TimeoutException - if timed out getting distributed lock for Scope.GLOBAL
CacheClosedException - if the cache is closed
IllegalStateException - if the supplied RegionAttributes is incompatible with this region
in another cache in the distributed system (see
AttributesFactory for compatibility rules)
CacheExistsException
CacheWriterException
ClientNotReadyExceptionCache.createRegion(java.lang.String, com.gemstone.gemfire.cache.RegionAttributes)
|
GemFire 6.0.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||