|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
com.tangosol.net.CacheFactory
public abstract class CacheFactory
Factory for the Coherence™ cache product.
One of the most common functions provided by the CacheFactory is ability to obtain an instance of a cache. There are various cache services and cache topologies that are supported by Coherence.
To get a cache reference use thegetCache(String, ClassLoader)
or
getCache(String)
methods.
This approach that has a lot of advantages over service type specific methods described further below because:
DistributedCache service provides the means for handling a collection
of resources distributed (partitioned) across a cluster with concurrent
access control.
The following factory methods return an instance of Distributed Cache
service:
getDistributedCache()
,
getDistributedCache(String)
,
getDistributedCache(String, ClassLoader)
ReplicatedCache service provides the means for handling a collection
of resources replicated across a cluster with concurrent access control
based on the lease model. Each member of the cluster running
the ReplicatedCache service holds a Map of resources that is replicated
by all members of the cluster. The resources are Serializable (or Coherence
"XML-izable") objects. In order for a member of the cluster to get a
resource from the cache for a purpose of an update or addition of a
resource to the cache, it must first obtain a lease for that resource.
At any given time for every given resource there is a single member
serving as an arbiter for that resource. This approach ensures the full
synchronization of data across the entire cluster. Full failover support
is also provided by ensuring that each cluster member has an up-to-date
copy of the data and by automatically assigning a new arbiter for each
resource that previously was arbited by a member that left the cluster.
The following factory methods return an instance of Replicated Cache
service:
getReplicatedCache()
,
getReplicatedCache(String)
,
getReplicatedCache(String, ClassLoader)
OptimisticCache is a clustered cache implementation similar to the
ReplicatedCache implementation, but without any concurrency control.
This implementation has the highest possible throughput. It also allows
to use an alternative underlying store for the cached data (for example,
a MRU/MFU-based cache). However, if two cluster members are independently
pruning or purging the underlying local stores, it is possible that a
cluster member may have a different store content than that held by
another cluster member.
The following factory methods return an instance of
Optimistic Cache service:
getOptimisticCache()
,
getOptimisticCache(String)
,
getOptimisticCache(String, ClassLoader)
releaseCache(NamedCache)
to release
the associated resources. To destroy all instances of the cache
across the cluster, use destroyCache(NamedCache)
.
Other services:
Invocation service provides the means for invoking and monitoring
execution of classes on specified nodes across a cluster.
The following factory method returns an instance of Invocation
service:
getInvocationService(String)
Nested Class Summary | |
---|---|
static class |
CacheFactory.LoggingWriter
Inner class for over-riding the destination of log(), out() and err() calls on the Base class. |
Field Summary | |
---|---|
static int |
LOG_ALWAYS
It is expected that items with a log level of 0 will always be logged. |
static int |
LOG_DEBUG
As of Coherence 3.2, the default logging level is 5, so using the level of 5 will show up in the logs by default as a debug message. |
static int |
LOG_ERR
Log level 1 indicates an error. |
static int |
LOG_INFO
Log level 1 indicates information that should likely be logged. |
static int |
LOG_MAX
The maximum logging level indicator. |
static int |
LOG_MIN
The minimum logging level indicator. |
static int |
LOG_QUIET
As of Coherence 3.2, the default logging level is 5, so using a level higher than 5 will be "quiet" by default, meaning that it will not show up in the logs unless the configured logging level is increased. |
static int |
LOG_WARN
Log level 1 indicates a warning. |
static String |
PRODUCT
The product name string. |
static String |
VERSION
Software version string. |
Constructor Summary | |
---|---|
CacheFactory()
|
Method Summary | |
---|---|
static boolean |
commitTransactionCollection(Collection collCaches,
int cRetry)
Commit the transaction represented by a collection of TransactionMap objects. |
static void |
destroyCache(NamedCache map)
Releases and destroys the specified NamedCache. |
static Cluster |
ensureCluster()
Obtain a Cluster object running Coherence services. |
static NamedCache |
getCache(String sName)
Return an instance of a cache configured by the current ConfigurableCacheFactory. |
static NamedCache |
getCache(String sName,
ClassLoader loader)
Return an instance of a cache configured by the current ConfigurableCacheFactory. |
static Cluster |
getCluster()
Return a Cluster object for Coherence services. |
static XmlElement |
getClusterConfig()
Return the default cluster configuration as defined by the "cluster-config" element in the tangosol-coherence.xml configuration file. |
static ConfigurableCacheFactory |
getConfigurableCacheFactory()
Obtain the ConfigurableCacheFactory singleton using the configuration info from the "configurablecache-factory-config" element located in the tangosol-coherence.xml configuration file. |
static XmlElement |
getConfigurableCacheFactoryConfig()
Return the default configurable cache factory configuration as defined by the "configurable-cache-factory-config" element in the tangosol-coherence.xml configuration file. |
static NamedCache |
getDistributedCache()
Deprecated. As of Coherence 3.3, use getService(String).ensureCache(null, null) instead |
static NamedCache |
getDistributedCache(String sName)
Deprecated. As of Coherence 3.3, use getCache(String) instead |
static NamedCache |
getDistributedCache(String sName,
ClassLoader loader)
Deprecated. As of Coherence 3.3, use getCache(String, ClassLoader) instead |
static XmlElement |
getDistributedCacheConfig()
Return the default distributed cache configuration. |
static CacheService |
getDistributedCacheService(String sName)
Deprecated. As of Coherence 3.3, use getService(String)
instead |
static CacheService |
getDistributedCacheService(String sName,
BackingMapManager manager)
Deprecated. As of Coherence 3.3, deprecated with no replacement |
static InvocationService |
getInvocationService(String sName)
Deprecated. As of Coherence 3.3, use getService(String)
instead |
static CacheService |
getLocalCacheService(String sName)
Deprecated. As of Coherence 3.3, use getService(String)
instead |
static CacheService |
getLocalCacheService(String sName,
BackingMapManager manager)
Deprecated. As of Coherence 3.3, deprecated with no replacement |
static TransactionMap |
getLocalTransaction(NamedCache map)
Factory method returning an instance of the TransactionMap that is based on the specified NamedCache and is local to this JVM. |
static XmlElement |
getLoggingConfig()
Return the configuration info for the logging facility as defined by the "logging-config" element in the tangosol-coherence.xml configuration file. |
static XmlElement |
getManagementConfig()
Return the management framework configuration. |
static NamedCache |
getOptimisticCache()
Deprecated. As of Coherence 3.3, use getService(String).ensureCache(null, null) instead |
static NamedCache |
getOptimisticCache(String sName)
Deprecated. As of Coherence 3.3, use getCache(String) instead |
static NamedCache |
getOptimisticCache(String sName,
ClassLoader loader)
Deprecated. As of Coherence 3.3, use getCache(String, ClassLoader) instead |
static CacheService |
getOptimisticCacheService(String sName)
Deprecated. As of Coherence 3.3, use getService(String)
instead |
static CacheService |
getOptimisticCacheService(String sName,
BackingMapManager manager)
Deprecated. As of Coherence 3.3, deprecated with no replacement |
static NamedCache |
getReplicatedCache()
Deprecated. As of Coherence 3.3, use getService(String).ensureCache(null, null) instead |
static NamedCache |
getReplicatedCache(String sName)
Deprecated. As of Coherence 3.3, use getCache(String) instead |
static NamedCache |
getReplicatedCache(String sName,
ClassLoader loader)
Deprecated. As of Coherence 3.3, use getCache(String, ClassLoader) instead |
static XmlElement |
getReplicatedCacheConfig()
Return the default replicated cache configuration. |
static CacheService |
getReplicatedCacheService(String sName)
Deprecated. As of Coherence 3.3, use getService(String)
instead |
static CacheService |
getReplicatedCacheService(String sName,
BackingMapManager manager)
Deprecated. As of Coherence 3.3, deprecated with no replacement |
static XmlElement |
getSecurityConfig()
Return the security framework configuration. |
static Service |
getService(String sName)
Return an instance of a service configured by the current ConfigurableCacheFactory. |
static XmlElement |
getServiceConfig(String sServiceType)
Return the configuration for the specified service type. |
static void |
initLogging()
Initialize the console logging. |
static boolean |
isLogEnabled(int nSeverity)
Check if a message of the specified severity level will be logged using the Coherence logging facility. |
static void |
log(String sMessage,
int nSeverity)
Log a message using Coherence logging facility which is driven by the "logging-config" element located in the tangosol-coherence.xml configuration file. |
static void |
main(String[] asArg)
Invoke the Coherence command line tool. |
static void |
releaseCache(NamedCache map)
Release local resources associated with the specified instance of the cache. |
static void |
rollbackTransactionCollection(Collection collCaches)
Roll back the transaction represented by a collection of TransactionMap objects. |
static void |
setConfigurableCacheFactory(ConfigurableCacheFactory factory)
Specify a singleton of ConfigurableCacheFactory. |
static void |
shutdown()
Shutdown all clustered services. |
Field Detail |
---|
public static final String PRODUCT
public static final String VERSION
public static final int LOG_MIN
public static final int LOG_MAX
public static final int LOG_ALWAYS
public static final int LOG_ERR
public static final int LOG_WARN
public static final int LOG_INFO
public static final int LOG_DEBUG
public static final int LOG_QUIET
Constructor Detail |
---|
public CacheFactory()
Method Detail |
---|
public static NamedCache getReplicatedCache()
getService(String).ensureCache(null, null)
instead
public static NamedCache getReplicatedCache(String sName)
getCache(String)
instead
sName
- cache name (unique across the cluster). If the
NamedCache with the specified name already exists, a
reference to the same object will be returned
public static NamedCache getReplicatedCache(String sName, ClassLoader loader)
getCache(String, ClassLoader)
instead
sName
- cache name (unique across the cluster). If the
NamedCache with the specified name already exists, a
reference to the same object will be returnedloader
- ClassLoader that should be used to deserialize objects
inserted in the map by other members of the cluster
public static CacheService getReplicatedCacheService(String sName)
getService(String)
instead
sName
- service name (unique across the cluster). If the service
with the specified name already exists, the reference
to the same service will be returned. If the name is not
specified the default service name will be used
public static CacheService getReplicatedCacheService(String sName, BackingMapManager manager)
Note: If the underlying backing map can be modified by anything other than the ReplicatedCacheService itself (e.g. if the Map automatically expires its entries periodically or size-limits its contents), the service does not prevent any such modifications regardless of locks that are placed.
sName
- service name (unique across the cluster). If the
service with the specified name already exists, the
reference to the same service will be returned. If the
name is not specified the default service name will be
usedmanager
- a BackingMapManager that will be used to create
underlying stores for the cached data. If not
specified, SafeHashMap
objects will be used for
all local maps.
public static NamedCache getOptimisticCache()
getService(String).ensureCache(null, null)
instead
public static NamedCache getOptimisticCache(String sName)
getCache(String)
instead
sName
- cache name (unique across the cluster). If the NamedCache
with the specified name already exists, a reference to
the same object will be returned
public static NamedCache getOptimisticCache(String sName, ClassLoader loader)
getCache(String, ClassLoader)
instead
sName
- cache name (unique across the cluster). If the
NamedCache with the specified name already exists, a
reference to the same object will be returnedloader
- ClassLoader that should be used to deserialize objects
inserted in the map by other members of the cluster
public static CacheService getOptimisticCacheService(String sName)
getService(String)
instead
sName
- service name (unique across the cluster). If the service
with the specified name already exists, the reference
to the same service will be returned. If the name is not
specified the default service name will be used
public static CacheService getOptimisticCacheService(String sName, BackingMapManager manager)
LocalCache
implementation can be used.
sName
- service name (unique across the cluster). If the
service with the specified name already exists, the
reference to the same service will be returned. If the
name is not specified the default service name will be
usedmanager
- a BackingMapManager that will be used to create
underlying stores for the cached data. If not
specified, SafeHashMap
objects will be used for
all local maps.
public static NamedCache getDistributedCache()
getService(String).ensureCache(null, null)
instead
public static NamedCache getDistributedCache(String sName)
getCache(String)
instead
sName
- cache name (unique across the cluster); if the NamedCache
with the specified name already exists, a reference to
the same object will be returned
public static NamedCache getDistributedCache(String sName, ClassLoader loader)
getCache(String, ClassLoader)
instead
sName
- cache name (unique across the cluster); if the
NamedCache with the specified name already exists, a
reference to the same object will be returnedloader
- ClassLoader that should be used to deserialize objects
inserted in the map by other members of the cluster
public static CacheService getDistributedCacheService(String sName)
getService(String)
instead
sName
- service name (unique across the cluster). If the service
with the specified name already exists, the reference
to the same service will be returned. If the name is not
specified the default service name will be used
public static CacheService getDistributedCacheService(String sName, BackingMapManager manager)
LocalCache
implementation can be used.
sName
- service name (unique across the cluster). If the
service with the specified name already exists, the
reference to the same service will be returned. If the
name is not specified the default service name will be
usedmanager
- a BackingMapManager that will be used to create
underlying stores for the cached data. If not
specified, SafeHashMap
objects will be used for
all local maps.
public static CacheService getLocalCacheService(String sName)
getService(String)
instead
sName
- service name (unique across the cluster). If the service
with the specified name already exists, the reference
to the same service will be returned. If the name is not
specified the default service name will be used
public static CacheService getLocalCacheService(String sName, BackingMapManager manager)
LocalCache
implementation can be used.
sName
- service name (unique across the cluster). If the
service with the specified name already exists, the
reference to the same service will be returned. If the
name is not specified the default service name will be
usedmanager
- a BackingMapManager that will be used to create
underlying stores for the cached data. If not
specified, SafeHashMap
objects will be used for
all local maps.
public static ConfigurableCacheFactory getConfigurableCacheFactory()
public static void setConfigurableCacheFactory(ConfigurableCacheFactory factory)
factory
- an instance of ConfigurableCacheFactorypublic static Service getService(String sName)
ConfigurableCacheFactory.ensureService(String)
method.
sName
- service name (unique for a given configurable cache
factory). If the Service with the specified name
already exists, a reference to the same object will be
returned
public static NamedCache getCache(String sName)
ConfigurableCacheFactory.ensureCache(String, ClassLoader)
method.
sName
- cache name (unique for a given configurable cache
factory). If the NamedCache with the specified name
already exists, a reference to the same object will be
returned
public static NamedCache getCache(String sName, ClassLoader loader)
ConfigurableCacheFactory.ensureCache(String, ClassLoader)
method.
sName
- cache name (unique for a given configurable cache
factory). If the NamedCache with the specified name
already exists, a reference to the same object will be
returnedloader
- ClassLoader that should be used to deserialize objects
inserted in the map by other members of the cluster
public static TransactionMap getLocalTransaction(NamedCache map)
Note: TransactionMap instance returned by this method will also
implement the NamedCache interface, allowing a client code to chain
local transaction by using the returned TransactionMap as a parameter
for another getLocalTransaction()
call.
map
- the NamedCache object to be used as a base for transaction
public static boolean commitTransactionCollection(Collection collCaches, int cRetry)
collCaches
- a collection of TransactionMap objectscRetry
- the number of times [0..100] to retry a stage of the
transaction if a concurrency conflict occurs
public static void rollbackTransactionCollection(Collection collCaches)
collCaches
- a collection of TransactionMap objectspublic static InvocationService getInvocationService(String sName)
getService(String)
instead
sName
- service name (unique across the cluster). If the service
with the specified name already exists, the reference
to the same service will be returned. If the name is not
specified the default service name will be used
public static Cluster getCluster()
public static Cluster ensureCluster()
public static void shutdown()
public static void releaseCache(NamedCache map)
getReplicatedCache, getOptimisticCache
).
Releasing a NamedCache reference makes it no longer usable, but does not affect the content of the cache. In other words, all other references to the cache will still be valid, and the cache data is not affected by releasing the reference.
The reference that is released using this method can no longer be used; any attempt to use the reference will result in an exception.
The purpose for releasing a cache reference is to allow the cache implementation to release the ClassLoader used to deserialize items in the cache. The cache implementation ensures that all references to that ClassLoader are released. This implies that objects in the cache that were loaded by that ClassLoader will be re-serialized to release their hold on that ClassLoader. The result is that the ClassLoader can be garbage-collected by Java in situations where the cache is operating in an application server and applications are dynamically loaded and unloaded.
map
- the NamedCache object to be releasedCacheService.releaseCache(NamedCache)
,
destroyCache(NamedCache)
public static void destroyCache(NamedCache map)
Warning: This method is used to completely destroy the specified cache across the cluster. All references in the entire cluster to this cache will be invalidated, the cached data will be cleared, and all resources will be released.
map
- the NamedCache object to be destroyedCacheService.destroyCache(NamedCache)
,
releaseCache(NamedCache)
public static void log(String sMessage, int nSeverity)
sMessage
- a message to lognSeverity
- the severity of the logged message;
0=default, 1=error; 2=warning; 3=info; 4-9=debugpublic static boolean isLogEnabled(int nSeverity)
nSeverity
- the severity of a message
log(java.lang.String, int)
public static XmlElement getClusterConfig()
public static XmlElement getReplicatedCacheConfig()
getServiceConfig(String)
public static XmlElement getDistributedCacheConfig()
getServiceConfig(String)
public static XmlElement getLoggingConfig()
public static XmlElement getConfigurableCacheFactoryConfig()
public static XmlElement getSecurityConfig()
public static XmlElement getManagementConfig()
public static XmlElement getServiceConfig(String sServiceType)
sServiceType
- the service type
public static void initLogging()
public static void main(String[] asArg) throws Exception
Exception
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |