Gemfire JavaDocs_test
Interface Cache
-
- All Superinterfaces:
java.lang.AutoCloseable
,GemFireCache
,RegionService
public interface Cache extends GemFireCache
Caches are obtained from theCacheFactory.create()
method. SeeCacheFactory
for common usage patterns for creating the cache instance.When a cache is created a
DistributedSystem
is also created. This system tells the cache where to find other caches on the network and how to communicate with them. The system can also specify a "cache-xml-file" property which will cause this cache to be initialized with the contents of that file. The contents must comply with the"doc-files/cache8_0.dtd"
file and the top level element must be acache
element.When a cache will no longer be used it should be
closed
. Once itis closed
any attempt to use it or anyRegion
obtained from it will cause aCacheClosedException
to be thrown.A cache can have multiple root regions, each with a different name.
- Since:
- GemFire 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description CacheServer
addCacheServer()
Creates a new cache server, with the default configuration, that will allow clients to access this cache.void
close(boolean keepAlive)
Deprecated.as of 6.5 useClientCache.close(boolean)
instead.AsyncEventQueueFactory
createAsyncEventQueueFactory()
CreatesAsyncEventQueueFactory
for creating a AsyncEventQueueGatewayReceiverFactory
createGatewayReceiverFactory()
CreatesGatewayReceiverFactory
for creating a GatewayReceiverGatewaySenderFactory
createGatewaySenderFactory()
CreatesGatewaySenderFactory
for creating a SerialGatewaySender<K,V>
Region<K,V>createRegion(java.lang.String name, RegionAttributes<K,V> aRegionAttributes)
Deprecated.as of 6.5 usecreateRegionFactory(RegionAttributes)
instead<K,V>
RegionFactory<K,V>createRegionFactory()
Creates aRegionFactory
which can be used to specify additional attributes forRegion
creation.<K,V>
RegionFactory<K,V>createRegionFactory(java.lang.String regionAttributesId)
Creates aRegionFactory
for creating aRegion
fromRegionAttributes
mapped to this regionAttributesId<K,V>
RegionFactory<K,V>createRegionFactory(RegionAttributes<K,V> regionAttributes)
Creates aRegionFactory
for creating aRegion
from the given regionAttributes<K,V>
RegionFactory<K,V>createRegionFactory(RegionShortcut shortcut)
<K,V>
Region<K,V>createVMRegion(java.lang.String name, RegionAttributes<K,V> aRegionAttributes)
Deprecated.as of GemFire 5.0, usecreateRegion(java.lang.String, org.apache.geode.cache.RegionAttributes<K, V>)
instead.default java.util.Set<DistributedMember>
getAdminMembers()
Deprecated.as of 10.1 use themanagement
package insteadAsyncEventQueue
getAsyncEventQueue(java.lang.String id)
Returns theAsyncEventQueue
with the given id added to this Cache.java.util.Set<AsyncEventQueue>
getAsyncEventQueues()
Returns allAsyncEventQueue
s for this Cachejava.util.List<CacheServer>
getCacheServers()
Returns a collection of all of theCacheServer
s that can serve the contents of thisCache
to clients.GatewayConflictResolver
getGatewayConflictResolver()
Returns the current gateway event conflict resolverjava.util.Set<GatewayReceiver>
getGatewayReceivers()
Returns allGatewayReceiver
s for this CacheGatewaySender
getGatewaySender(java.lang.String id)
Returns theGatewaySender
with the given id added to this Cache.java.util.Set<GatewaySender>
getGatewaySenders()
Returns allGatewaySender
s for this Cache.int
getLockLease()
Gets the length, in seconds, of distributed lock leases obtained by this cache.int
getLockTimeout()
Gets the number of seconds a cache operation will wait to obtain a distributed lock lease.LogWriterI18n
getLoggerI18n()
Deprecated.as of 6.5 use getLogger().convertToLogWriterI18n() insteadjava.util.Set<DistributedMember>
getMembers()
Returns a set of the other non-administrative members in the distributed system.java.util.Set<DistributedMember>
getMembers(Region region)
Returns a set of the members in the distributed system that have the given region.int
getMessageSyncInterval()
Gets the frequency (in seconds) at which a message will be sent by the primary cache-server to all the secondary cache-server nodes to remove the events which have already been dispatched from the queue.Cache
getReconnectedCache()
Returns the new Cache if there was an auto-reconnect and the cache was recreated.int
getSearchTimeout()
Gets the number of seconds a cacheget
operation can spend searching for a value before it times out.LogWriterI18n
getSecurityLoggerI18n()
Deprecated.as of 6.5 use getSecurityLogger().convertToLogWriterI18n() insteadCacheSnapshotService
getSnapshotService()
Obtains the snapshot service to allow the cache data to be imported or exported.boolean
isReconnecting()
Test to see whether the Cache is in the process of reconnecting and recreating a new cache after it has been removed from the system by other members or has shut down due to missing Roles and is reconnecting.boolean
isServer()
Returns whether or not this cache resides in a "cache server" VM.void
readyForEvents()
Deprecated.as of 6.5 useClientCache.readyForEvents()
instead.void
setGatewayConflictResolver(GatewayConflictResolver resolver)
Adds a gateway event conflict resolution resolver.void
setIsServer(boolean isServer)
Sets whether or not thisCache
resides in a long-running "cache server" VM.void
setLockLease(int seconds)
Sets the length, in seconds, of distributed lock leases obtained by this cache.void
setLockTimeout(int seconds)
Sets the number of seconds a cache operation may wait to obtain a distributed lock lease before timing out.void
setMessageSyncInterval(int seconds)
Sets the frequency (in seconds) at which a message will be sent by the primary cache-server node to all the secondary cache-server nodes to remove the events which have already been dispatched from the queue.void
setSearchTimeout(int seconds)
Sets the number of seconds a cache get operation can spend searching for a value.void
stopReconnecting()
Force the Cache to stop reconnecting.boolean
waitUntilReconnected(long time, java.util.concurrent.TimeUnit units)
Wait for the Cache to finish reconnecting to the distributed system and recreate a new Cache.-
Methods inherited from interface org.apache.geode.cache.GemFireCache
createDiskStoreFactory, findDiskStore, getCacheTransactionManager, getCopyOnRead, getDistributedSystem, getInitializer, getInitializerProps, getJNDIContext, getLogger, getName, getPdxDiskStore, getPdxIgnoreUnreadFields, getPdxPersistent, getPdxReadSerialized, getPdxSerializer, getRegionAttributes, getResourceManager, getSecurityLogger, listRegionAttributes, loadCacheXml, registerPdxMetaData, setCopyOnRead, setRegionAttributes
-
Methods inherited from interface org.apache.geode.cache.RegionService
close, createPdxEnum, createPdxInstanceFactory, getCancelCriterion, getJsonDocumentFactory, getJsonDocumentFactory, getJsonFormatter, getQueryService, getRegion, isClosed, rootRegions
-
-
-
-
Method Detail
-
close
@Deprecated void close(boolean keepAlive)
Deprecated.as of 6.5 useClientCache.close(boolean)
instead.Terminates this object cache and releases all the resources. CallsRegion.close()
on each region in the cache. After this cache is closed, any further method call on this cache or any region object will throwCacheClosedException
, unless otherwise noted.- Parameters:
keepAlive
- whether the server should keep the durable client's queues alive for the timeout period- Throws:
CacheClosedException
- if the cache is already closed.
-
createVMRegion
@Deprecated <K,V> Region<K,V> createVMRegion(java.lang.String name, RegionAttributes<K,V> aRegionAttributes) throws RegionExistsException, TimeoutException
Deprecated.as of GemFire 5.0, usecreateRegion(java.lang.String, org.apache.geode.cache.RegionAttributes<K, V>)
instead.Creates a VM region using the specified RegionAttributes.- Type Parameters:
K
- the type of keys in the regionV
- the type of values in the region- Parameters:
name
- the name of the region to createaRegionAttributes
- the attributes of the root region- Returns:
- the region object
- Throws:
RegionExistsException
- if a region is already in this cacheLeaseExpiredException
- if lease expired on distributed lock for Scope.GLOBALTimeoutException
- if timed out getting distributed lock for Scope.GLOBALCacheClosedException
- if the cache is closedjava.lang.IllegalStateException
- If the supplied RegionAttributes violate the region creation constraints with a region of the same name in another cache in the distributed system
-
createRegion
@Deprecated <K,V> Region<K,V> createRegion(java.lang.String name, RegionAttributes<K,V> aRegionAttributes) throws RegionExistsException, TimeoutException
Deprecated.as of 6.5 usecreateRegionFactory(RegionAttributes)
insteadCreates a region using the specified RegionAttributes.- Type Parameters:
K
- the type of keys in the regionV
- the type of values in the region- Parameters:
name
- the name of the region to createaRegionAttributes
- the attributes of the root region- Returns:
- the region object
- Throws:
RegionExistsException
- if a region is already in this cacheLeaseExpiredException
- if lease expired on distributed lock for Scope.GLOBALTimeoutException
- if timed out getting distributed lock for Scope.GLOBALCacheClosedException
- if the cache is closedjava.lang.IllegalStateException
- If the supplied RegionAttributes violate the region creation constraints with a region of the same name in another cache in the distributed system- Since:
- GemFire 5.0
-
createRegionFactory
<K,V> RegionFactory<K,V> createRegionFactory()
Creates aRegionFactory
which can be used to specify additional attributes forRegion
creation.- Type Parameters:
K
- the type of keys in the regionV
- the type of values in the region- Returns:
- a
RegionFactory
which can be used to specify additional attributes forRegion
creation - Since:
- GemFire 6.5
- See Also:
createRegionFactory(RegionShortcut)
-
createRegionFactory
<K,V> RegionFactory<K,V> createRegionFactory(RegionShortcut shortcut)
- Type Parameters:
K
- the type of keys in the regionV
- the type of values in the region- Parameters:
shortcut
- the region type as defined byRegionShortcut
- Returns:
- a
RegionFactory
- Since:
- GemFire 6.5
-
createRegionFactory
<K,V> RegionFactory<K,V> createRegionFactory(java.lang.String regionAttributesId)
Creates aRegionFactory
for creating aRegion
fromRegionAttributes
mapped to this regionAttributesId- Type Parameters:
K
- the type of keys in the regionV
- the type of values in the region- Parameters:
regionAttributesId
- the Id of RegionAttributes to be used- Returns:
- a
RegionFactory
- Since:
- GemFire 6.5
- See Also:
GemFireCache.setRegionAttributes(String, RegionAttributes)
-
createRegionFactory
<K,V> RegionFactory<K,V> createRegionFactory(RegionAttributes<K,V> regionAttributes)
Creates aRegionFactory
for creating aRegion
from the given regionAttributes- Type Parameters:
K
- the type of keys in the regionV
- the type of values in the region- Parameters:
regionAttributes
- regionAttributes for the new region- Returns:
- a
RegionFactory
- Since:
- GemFire 6.5
- See Also:
createRegionFactory(RegionShortcut)
-
getLoggerI18n
@Deprecated LogWriterI18n getLoggerI18n()
Deprecated.as of 6.5 use getLogger().convertToLogWriterI18n() insteadInternal GemStone method for accessing the internationalized logging object for GemFire, useGemFireCache.getLogger()
instead. This method does not throwCacheClosedException
if the cache is closed.- Returns:
- the logging object
-
getSecurityLoggerI18n
@Deprecated LogWriterI18n getSecurityLoggerI18n()
Deprecated.as of 6.5 use getSecurityLogger().convertToLogWriterI18n() insteadInternal GemStone method for accessing the internationalized logging object for GemFire, useGemFireCache.getSecurityLogger()
instead. This method does not throwCacheClosedException
if the cache is closed.- Returns:
- the security logging object
-
getLockTimeout
int getLockTimeout()
Gets the number of seconds a cache operation will wait to obtain a distributed lock lease. This method does not throwCacheClosedException
if the cache is closed.- Returns:
- the number of seconds a cache operation will wait to obtain a distributed lock lease
-
setLockTimeout
void setLockTimeout(int seconds)
Sets the number of seconds a cache operation may wait to obtain a distributed lock lease before timing out.- Parameters:
seconds
- the number of seconds a cache operation may wait to obtain a distributed lock lease before timing out- Throws:
java.lang.IllegalArgumentException
- ifseconds
is less than zero
-
getMessageSyncInterval
int getMessageSyncInterval()
Gets the frequency (in seconds) at which a message will be sent by the primary cache-server to all the secondary cache-server nodes to remove the events which have already been dispatched from the queue.- Returns:
- The time interval in seconds
-
setMessageSyncInterval
void setMessageSyncInterval(int seconds)
Sets the frequency (in seconds) at which a message will be sent by the primary cache-server node to all the secondary cache-server nodes to remove the events which have already been dispatched from the queue.- Parameters:
seconds
- the time interval in seconds- Throws:
java.lang.IllegalArgumentException
- ifseconds
is less than zero
-
getLockLease
int getLockLease()
Gets the length, in seconds, of distributed lock leases obtained by this cache. This method does not throwCacheClosedException
if the cache is closed.- Returns:
- the length, in seconds, of distributed lock leases obtained by this cache
-
setLockLease
void setLockLease(int seconds)
Sets the length, in seconds, of distributed lock leases obtained by this cache.- Parameters:
seconds
- the length, in seconds, of distributed lock leases obtained by this cache- Throws:
java.lang.IllegalArgumentException
- ifseconds
is less than zero.
-
getSearchTimeout
int getSearchTimeout()
Gets the number of seconds a cacheget
operation can spend searching for a value before it times out. The search includes any time spent loading the object. When the search times out it causes the get to fail by throwing an exception. This method does not throwCacheClosedException
if the cache is closed.- Returns:
- the number of seconds a cache
get
operation can spend searching for a value before it times out
-
setSearchTimeout
void setSearchTimeout(int seconds)
Sets the number of seconds a cache get operation can spend searching for a value.- Parameters:
seconds
- the number of seconds a cache get operation can spend searching for a value- Throws:
java.lang.IllegalArgumentException
- ifseconds
is less than zero
-
addCacheServer
CacheServer addCacheServer()
Creates a new cache server, with the default configuration, that will allow clients to access this cache.For the default configuration see the constants in
CacheServer
.- Returns:
- the newly created
CacheServer
- Since:
- GemFire 5.7
- See Also:
CacheServer
-
getCacheServers
java.util.List<CacheServer> getCacheServers()
Returns a collection of all of theCacheServer
s that can serve the contents of thisCache
to clients.- Returns:
- a collection of all of the
CacheServer
s - Since:
- GemFire 5.7
- See Also:
addCacheServer()
-
setGatewayConflictResolver
void setGatewayConflictResolver(GatewayConflictResolver resolver)
Adds a gateway event conflict resolution resolver. This is invoked if an event is processed that comes from a different distributed system than the last event to modify the affected entry. It may alter the event or disallow the event. If it does neither the event is applied to the cache if its timestamp is newer than what is in the cache or if it is the same and the event's distributed system ID is larger than that of the last event to modify the affected entry.- Parameters:
resolver
- gateway event conflict resolution resolver- Since:
- GemFire 7.0
-
getGatewayConflictResolver
GatewayConflictResolver getGatewayConflictResolver()
Returns the current gateway event conflict resolver- Returns:
- the current gateway event conflict resolver
- Since:
- GemFire 7.0
-
setIsServer
void setIsServer(boolean isServer)
Sets whether or not thisCache
resides in a long-running "cache server" VM. A cache server may be an application VM or may be a stand-along VM.- Parameters:
isServer
- whether thisCache
resides in a long-running "cache server" VM- Since:
- GemFire 4.0
-
isServer
boolean isServer()
Returns whether or not this cache resides in a "cache server" VM.- Returns:
- whether this cache resides in a "cache server" VM
- Since:
- GemFire 4.0
- See Also:
setIsServer(boolean)
-
readyForEvents
@Deprecated void readyForEvents()
Deprecated.as of 6.5 useClientCache.readyForEvents()
instead.Notifies the server that this client is ready to receive updates. This method is used by durable clients to notify servers that they are ready to receive updates. As soon as the server receives this message, it will forward updates to this client (if necessary).Durable clients must call this method after they are done creating regions. If it is called before the client creates the regions then updates will be lost. Any time a new
Pool
is created and regions have been added to it then this method needs to be called again.- Throws:
java.lang.IllegalStateException
- if called by a non-durable client- Since:
- GemFire 5.5
-
createGatewaySenderFactory
GatewaySenderFactory createGatewaySenderFactory()
CreatesGatewaySenderFactory
for creating a SerialGatewaySender- Specified by:
createGatewaySenderFactory
in interfaceGemFireCache
- Returns:
- a
GatewaySenderFactory
- Since:
- GemFire 7.0
-
createAsyncEventQueueFactory
AsyncEventQueueFactory createAsyncEventQueueFactory()
CreatesAsyncEventQueueFactory
for creating a AsyncEventQueue- Returns:
- a
AsyncEventQueueFactory
- Since:
- GemFire 7.0
-
createGatewayReceiverFactory
GatewayReceiverFactory createGatewayReceiverFactory()
CreatesGatewayReceiverFactory
for creating a GatewayReceiver- Returns:
- a
GatewayReceiverFactory
- Since:
- GemFire 7.0
-
getGatewaySenders
java.util.Set<GatewaySender> getGatewaySenders()
Returns allGatewaySender
s for this Cache.- Returns:
- Set of GatewaySenders
- Since:
- GemFire 7.0
-
getGatewaySender
GatewaySender getGatewaySender(java.lang.String id)
Returns theGatewaySender
with the given id added to this Cache.- Parameters:
id
- the id of theGatewaySender
- Returns:
- GatewaySender with id
- Since:
- GemFire 7.0
-
getGatewayReceivers
java.util.Set<GatewayReceiver> getGatewayReceivers()
Returns allGatewayReceiver
s for this Cache- Returns:
- Set of GatewaySenders
- Since:
- GemFire 7.0
-
getAsyncEventQueues
java.util.Set<AsyncEventQueue> getAsyncEventQueues()
Returns allAsyncEventQueue
s for this Cache- Returns:
- Set of AsyncEventQueue
- Since:
- GemFire 7.0
-
getAsyncEventQueue
AsyncEventQueue getAsyncEventQueue(java.lang.String id)
Returns theAsyncEventQueue
with the given id added to this Cache.- Parameters:
id
- the id of theAsyncEventQueue
- Returns:
- AsyncEventQueue with id
- Since:
- GemFire 7.0
-
getMembers
java.util.Set<DistributedMember> getMembers()
Returns a set of the other non-administrative members in the distributed system.- Returns:
- a set of the other non-administrative members in the distributed system
- Since:
- GemFire 6.6
-
getAdminMembers
default java.util.Set<DistributedMember> getAdminMembers()
Deprecated.as of 10.1 use themanagement
package insteadReturns an empty set since deprecated Admin-only members have been removed.- Returns:
- an empty set.
- Since:
- GemFire 6.6
-
getMembers
java.util.Set<DistributedMember> getMembers(Region region)
Returns a set of the members in the distributed system that have the given region. For regions with local scope an empty set is returned.- Parameters:
region
- a Region in the cache- Returns:
- a set of the members in the distributed system that have the given region
- Since:
- GemFire 6.6
-
getSnapshotService
CacheSnapshotService getSnapshotService()
Obtains the snapshot service to allow the cache data to be imported or exported.- Returns:
- the snapshot service
-
isReconnecting
boolean isReconnecting()
Test to see whether the Cache is in the process of reconnecting and recreating a new cache after it has been removed from the system by other members or has shut down due to missing Roles and is reconnecting.This will also return true if the Cache has finished reconnecting. When reconnect has completed you can use
getReconnectedCache()
to retrieve the new cache instance.- Returns:
- true if the Cache is attempting to reconnect or has finished reconnecting
-
waitUntilReconnected
boolean waitUntilReconnected(long time, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException
Wait for the Cache to finish reconnecting to the distributed system and recreate a new Cache. This may throw a CacheClosedException if reconnect attempts fail due to an exception. The exception will detail what went wrong.- Parameters:
time
- amount of time to wait, or -1 to wait foreverunits
- time unit- Returns:
- true if the cache was reconnected
- Throws:
java.lang.InterruptedException
- if the thread is interrupted while waiting- See Also:
getReconnectedCache()
-
stopReconnecting
void stopReconnecting()
Force the Cache to stop reconnecting. If the Cache is currently connected this will disconnect and close it.
-
getReconnectedCache
Cache getReconnectedCache()
Returns the new Cache if there was an auto-reconnect and the cache was recreated.- Returns:
- the new Cache if there was an auto-reconnect and the cache was recreated
-
-