public class CacheUtil extends Object
| Constructor and Description |
|---|
CacheUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
closeCache()
Closes the
Cache. |
static com.gemstone.gemfire.cache.Cache |
createCache()
Creates and returns a
Cache. |
static com.gemstone.gemfire.cache.Cache |
createCache(String cacheXmlFile)
Creates and returns a
Cache. |
static com.gemstone.gemfire.cache.Region |
createClientRegion(String cacheDescriptName,
String regionDescriptName,
String xmlFile)
Create a region either by creating the client cache with a declarative xml file
or create the region programmatically.
|
static com.gemstone.gemfire.cache.Region |
createRegion(CacheDefinition cacheDef,
RegionDefinition regDef,
String xmlFile)
Create a region either by creating the cache with a declarative xml file
or create the region programmatically.
|
static com.gemstone.gemfire.cache.Region |
createRegion(com.gemstone.gemfire.cache.Region parentRegion,
String regionName,
com.gemstone.gemfire.cache.RegionAttributes regionAttributes)
Creates and returns a
Region with the specified simple name
and region attributes as a subregion of the specified region, if one does
not already exist with the same name and attributes. |
static com.gemstone.gemfire.cache.Region |
createRegion(String regionName)
Creates and returns a
Region with the specified simple name
and default region attributes in the cache, if one does not already
exist with the same name and attributes. |
static com.gemstone.gemfire.cache.Region |
createRegion(String regionName,
com.gemstone.gemfire.cache.RegionAttributes regionAttributes)
Creates and returns a root
Region with the specified simple name
and region attributes in the cache, if one does not already exist
with the same name and attributes. |
static com.gemstone.gemfire.cache.Region |
createRegion(String cacheDescriptName,
String regionDescriptName,
String xmlFile)
Create a region either by creating the cache with a declarative xml file
or create the region programmatically.
|
static void |
defineObjectAttributes(com.gemstone.gemfire.cache.Region region,
Object name)
Defines an entry in the specified region with the specified
name, using the default attributes for the region.
|
static void |
destroyRegion(com.gemstone.gemfire.cache.Region region)
Calls destroyRegion() on the given region.
|
static void |
disconnect()
Disconnect from the distributed system.
|
static Object |
get(com.gemstone.gemfire.cache.Region region,
Object name)
Returns the object with the specified name from the specified
Region. |
static com.gemstone.gemfire.cache.Cache |
getCache()
Returns the
Cache for this VM, if any, or null if it does not exist. |
static String |
getContentString(com.gemstone.gemfire.cache.Region region,
boolean recursive)
Gets the prettified contents of the specified region as a string.
|
static com.gemstone.gemfire.distributed.DistributedMember |
getMemberId()
Returns the DistributedMember for the current cache
|
static Set |
getMembers()
Returns a collection of the current distribution members
|
static com.gemstone.gemfire.cache.query.QueryService |
getQueryService()
Returns the QueryService from the current cache
|
static com.gemstone.gemfire.cache.Region |
getRegion(com.gemstone.gemfire.cache.Region region,
String regionName)
Returns the
Region with the specified simple or global name
from the specified parent region. |
static com.gemstone.gemfire.cache.Region |
getRegion(String regionName)
Returns the
Region with the specified simple or global name
from the cache. |
static com.gemstone.gemfire.cache.RegionAttributes |
getRegionAttributes(com.gemstone.gemfire.cache.Region region)
Calls getRegionAttributes() on the given region.
|
static void |
invalidateRegion(com.gemstone.gemfire.cache.Region region)
Calls invalidateRegion() on the given region.
|
static boolean |
isAdminOnlyMember(com.gemstone.gemfire.distributed.DistributedMember mbr)
Returns true if the given DistributedMember is admin-only
|
static boolean |
isLocatorMember(com.gemstone.gemfire.distributed.DistributedMember mbr)
Returns true if the given DistributedMember is a locator
|
static boolean |
isLonerMember(com.gemstone.gemfire.distributed.DistributedMember mbr)
Returns true if the given DistributedMember is loner (no peer-to-peer cache)
|
static boolean |
isNormalMember(com.gemstone.gemfire.distributed.DistributedMember mbr)
Returns true if the given DistributedMember is normal (not admin or loner)
|
static Set |
nameSet(com.gemstone.gemfire.cache.Region region,
boolean aBool)
Returns the names (keys) of a given
Region |
static void |
put(com.gemstone.gemfire.cache.Region region,
Object name,
Object obj)
Puts the specified object at the specified name in the specified
Region |
static void |
recoverableReplace(com.gemstone.gemfire.cache.Region region,
Object name,
Object obj)
Replaces the object with the specified name from the specified
Region
with a different object. |
static Set |
regionSet(com.gemstone.gemfire.cache.Region region,
boolean aBool)
Calls subregions() on the given region.
|
static void |
replace(com.gemstone.gemfire.cache.Region region,
Object name,
Object obj)
Replaces the object with the specified name from the specified
Region
with a different object. |
static void |
setCache(com.gemstone.gemfire.cache.Cache c) |
public static com.gemstone.gemfire.cache.Cache createCache(String cacheXmlFile)
Cache. Returns the existing cache if it was
previously created and is still open. This method is synchronized and is
safe for use by concurrent threads.
The distributed system used is the one specified for the hydra client VM
via ClientPrms.gemfireNames.
HydraRuntimeException - if there is a problem creating the cache.public static com.gemstone.gemfire.cache.Cache createCache()
Cache. Returns the existing cache if it was
previously created and is still open. This method is synchronized and is
safe for use by concurrent threads.
The distributed system used is the one specified for the hydra client VM
via ClientPrms.gemfireNames.
HydraRuntimeException - if there is a problem creating the cache.public static void setCache(com.gemstone.gemfire.cache.Cache c)
public static com.gemstone.gemfire.cache.Cache getCache()
Cache for this VM, if any, or null if it does not exist.public static void closeCache()
Cache. Does nothing if the cache does not exist.public static void disconnect()
public static Set getMembers()
DistributedMemberpublic static com.gemstone.gemfire.distributed.DistributedMember getMemberId()
public static boolean isAdminOnlyMember(com.gemstone.gemfire.distributed.DistributedMember mbr)
public static boolean isLocatorMember(com.gemstone.gemfire.distributed.DistributedMember mbr)
public static boolean isNormalMember(com.gemstone.gemfire.distributed.DistributedMember mbr)
public static boolean isLonerMember(com.gemstone.gemfire.distributed.DistributedMember mbr)
public static com.gemstone.gemfire.cache.Region createRegion(String regionName)
Region with the specified simple name
and default region attributes in the cache, if one does not already
exist with the same name and attributes. This method is synchronized
and is safe for use by concurrent threads.regionName - the name of the region.regionType - the type of the region.HydraRuntimeException - if the cache has not been created, or
there is a problem creating the region, or
the region already exists but has different attributes.public static com.gemstone.gemfire.cache.Region createRegion(String regionName, com.gemstone.gemfire.cache.RegionAttributes regionAttributes)
Region with the specified simple name
and region attributes in the cache, if one does not already exist
with the same name and attributes. This method is synchronized and is safe
for use by concurrent threads.regionName - the name of the region.regionAttributes - the attributes for the region.HydraRuntimeException - if the cache has not been created, or
there is a problem creating the region, or
the region already exists but has different attributes.public static com.gemstone.gemfire.cache.Region createRegion(com.gemstone.gemfire.cache.Region parentRegion,
String regionName,
com.gemstone.gemfire.cache.RegionAttributes regionAttributes)
Region with the specified simple name
and region attributes as a subregion of the specified region, if one does
not already exist with the same name and attributes. This method is
synchronized and is safe for use by concurrent threads.parentRegion - the region in which to create the subregion.regionName - the name of the region.regionAttributes - the attributes for the region.HydraRuntimeException - if there is a problem creating the region or if
the region already exists but has different attributes.public static com.gemstone.gemfire.cache.Region createRegion(CacheDefinition cacheDef, RegionDefinition regDef, String xmlFile)
cacheDef - The CacheDefinition to use to create the cache.regDef - The RegionDefinition to use if the region is created
programmatically.xmlFile - The xmlFile to use if the region is created with the xml file.
Note: This can only honor CachePrms.useDeclarativeXmlFile or the xmlFile
parameter if we are not already connected. If we already have a connection
to the distributed system, then creating the cache will use any declarative
xml file used when the connection was established, if any declarative xml file
was set during the connect. See the comments in the code below.public static com.gemstone.gemfire.cache.Region createRegion(String cacheDescriptName, String regionDescriptName, String xmlFile)
cacheDescriptName - The name of the cache description to use to create
the cache.regionDescriptName - The name of the region description to use if the
region is created programmatically.xmlFile - The xmlFile to use if the region is created with the xml file.
Note: This can only honor CachePrms.useDeclarativeXmlFile or the xmlFile
parameter if we are not already connected. If we already have a connection
to the distributed system, then creating the cache will use any declarative
xml file used when the connection was established, if any declarative xml file
was set during the connect. See the comments in the code below.public static com.gemstone.gemfire.cache.Region createClientRegion(String cacheDescriptName, String regionDescriptName, String xmlFile)
cacheDescriptName - The name of the client cache description to use to create
the cache.regionDescriptName - The name of the client region description to use if the
region is created programmatically.xmlFile - The xmlFile to use if the region is created with the xml file.
Note: This can only honor CachePrms.useDeclarativeXmlFile or the xmlFile
parameter if we are not already connected. If we already have a connection
to the distributed system, then creating the cache will use any declarative
xml file used when the connection was established, if any declarative xml file
was set during the connect. See the comments in the code below.public static com.gemstone.gemfire.cache.Region getRegion(String regionName)
Region with the specified simple or global name
from the cache.regionName - the name of the region.public static com.gemstone.gemfire.cache.Region getRegion(com.gemstone.gemfire.cache.Region region,
String regionName)
Region with the specified simple or global name
from the specified parent region.region - the parent region from which to get the region.regionName - the name of the region.public static com.gemstone.gemfire.cache.query.QueryService getQueryService()
public static Object get(com.gemstone.gemfire.cache.Region region, Object name)
Region.region - the region from which to get the object.name - the name of the object to get.public static void put(com.gemstone.gemfire.cache.Region region,
Object name,
Object obj)
Regionregion - the region in which to put the object.name - the name of the object.obj - the object to put at the name.public static void replace(com.gemstone.gemfire.cache.Region region,
Object name,
Object obj)
Region
with a different object. Complains if any cache-related exception occurs.region - the region from which to replace the object.name - the name of the object to replace.obj - the object to install at the name.HydraRuntimeException - if any CacheException occurs.put(Region, Object, Object)public static void recoverableReplace(com.gemstone.gemfire.cache.Region region,
Object name,
Object obj)
Region
with a different object. Gives the application a chance to retry on stale
reads and ownership timeouts.region - the region from which to replace the object.name - the name of the object to replace.obj - the object to install at the name.StaleReadException - if a stale read occurs due to contention, to give
the app a chance to retry.OwnershipException - if a timeout occurs getting ownership, to give
the app a chance to retry.HydraRuntimeException - if any other CacheException occurs.public static String getContentString(com.gemstone.gemfire.cache.Region region, boolean recursive)
region - the region whose contents to print.recursive - whether or not to print subregions recursively.public static void defineObjectAttributes(com.gemstone.gemfire.cache.Region region,
Object name)
region.create(name, null).region - the region in which to define the object entry.name - the name to give the object entry.public static Set nameSet(com.gemstone.gemfire.cache.Region region, boolean aBool)
Regionregion - the region on which to call keys()aBool - Whether or not to recurse over subregions. Note that this
functionality is not support in GemFire 3.0.Region.keys()public static Set regionSet(com.gemstone.gemfire.cache.Region region, boolean aBool)
region - the region on which to call subregions()aBool - the argument to subregions()public static com.gemstone.gemfire.cache.RegionAttributes getRegionAttributes(com.gemstone.gemfire.cache.Region region)
region - the region on which to call getRegionAttributes()public static void invalidateRegion(com.gemstone.gemfire.cache.Region region)
region - the region on which to call invalidateRegion()public static void destroyRegion(com.gemstone.gemfire.cache.Region region)
region - the region on which to call destroyRegion()Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.