public class RemoteCacheManager extends Object implements BasicCacheContainer
RemoteCache
s. Lifecycle:
In order to be able to use anRemoteCache
, the RemoteCacheManager
must be started first: beside other things, this instantiates connections to Hot Rod server(s). Starting the RemoteCacheManager
can be done either at creation by passing start==true to constructor
or by using a constructor that does that for you (see C-tor documentation); or after construction by calling RemoteCacheManager.start()
.
This is an "expensive" object, as it manages a set of persistent TCP connections to the Hot Rod servers. It is recommended
to only have one instance of this per JVM, and to cache it between calls to the server (i.e. remoteCache
operations).
RemoteCacheManager.stop()
needs to be called explicitly in order to release all the resources (e.g. threads, TCP connections).
Configuration:
The cache manager is configured through a Configuration
object passed to the constructor (there are also
"simplified" constructors that rely on default values). If migrating from a previous version of Infinispan, where Properties
were used to configure the RemoteCacheManager, please use the ConfigurationBuilder.withProperties(Properties)
method.
Below is the list of supported configuration elements:
Flag.FORCE_RETURN_VALUE
for all calls.org.infinispan.marshall.Marshaller
implementation to serialize and deserialize user objects. For portable serialization payloads, you should configure the marshaller to be ProtoStreamMarshaller
ConsistentHashFactory
. This specifies the version of the hash function and consistent hash algorithm in use, and is closely tied with the HotRod server version used.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CACHE_NAME |
static String |
HOTROD_CLIENT_PROPERTIES |
protected ClientListenerNotifier |
listenerNotifier |
protected TransportFactory |
transportFactory |
Constructor and Description |
---|
RemoteCacheManager()
Same as
RemoteCacheManager.RemoteCacheManager(boolean) and it also starts the cache. |
RemoteCacheManager(boolean start)
Same as
RemoteCacheManager.RemoteCacheManager(java.util.Properties) , but it will try to lookup the config properties in the
classpath, in a file named hotrod-client.properties. |
RemoteCacheManager(Configuration configuration)
Create a new RemoteCacheManager using the supplied
Configuration . |
RemoteCacheManager(Configuration configuration,
boolean start)
Create a new RemoteCacheManager using the supplied
Configuration . |
RemoteCacheManager(Marshaller marshaller,
Properties props)
Deprecated.
|
RemoteCacheManager(Marshaller marshaller,
Properties props,
boolean start)
Deprecated.
|
RemoteCacheManager(Marshaller marshaller,
Properties props,
boolean start,
ClassLoader classLoader,
ExecutorFactory asyncExecutorFactory)
Deprecated.
|
RemoteCacheManager(Marshaller marshaller,
Properties props,
ClassLoader classLoader)
Deprecated.
|
RemoteCacheManager(Marshaller marshaller,
Properties props,
ExecutorFactory asyncExecutorFactory)
Deprecated.
|
RemoteCacheManager(Properties props)
Deprecated.
|
RemoteCacheManager(Properties props,
boolean start)
Deprecated.
|
RemoteCacheManager(Properties props,
boolean start,
ClassLoader classLoader,
ExecutorFactory asyncExecutorFactory)
Deprecated.
|
RemoteCacheManager(Properties props,
ClassLoader classLoader)
Deprecated.
|
RemoteCacheManager(String servers)
Deprecated.
|
RemoteCacheManager(String servers,
boolean start)
Deprecated.
|
RemoteCacheManager(String servers,
boolean start,
ClassLoader classLoader)
Deprecated.
|
RemoteCacheManager(String servers,
ClassLoader classLoader)
Deprecated.
|
RemoteCacheManager(String host,
int port)
Deprecated.
|
RemoteCacheManager(String host,
int port,
boolean start)
Deprecated.
|
RemoteCacheManager(String host,
int port,
boolean start,
ClassLoader classLoader)
Deprecated.
|
RemoteCacheManager(String host,
int port,
ClassLoader classLoader)
Deprecated.
|
RemoteCacheManager(URL config)
Deprecated.
|
RemoteCacheManager(URL config,
boolean start)
Deprecated.
|
RemoteCacheManager(URL config,
boolean start,
ClassLoader classLoader)
Deprecated.
|
RemoteCacheManager(URL config,
ClassLoader classLoader)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
cacheNameBytes() |
static byte[] |
cacheNameBytes(String cacheName) |
protected <K,V> NearCacheService<K,V> |
createNearCacheService(NearCacheConfiguration cfg) |
<K,V> RemoteCache<K,V> |
getCache()
Retrieves the default cache from the remote server.
|
<K,V> RemoteCache<K,V> |
getCache(boolean forceReturnValue) |
<K,V> RemoteCache<K,V> |
getCache(String cacheName)
Retrieves a named cache from the remote server if the cache has been
defined, otherwise if the cache name is underfined, it will return null.
|
<K,V> RemoteCache<K,V> |
getCache(String cacheName,
boolean forceReturnValue) |
Configuration |
getConfiguration()
Retrieves the configuration currently in use.
|
Marshaller |
getMarshaller() |
Properties |
getProperties()
Deprecated.
|
boolean |
isStarted() |
void |
start()
Invoked on component start
|
void |
stop()
Stop the remote cache manager, disconnecting all existing connections.
|
public static final String DEFAULT_CACHE_NAME
public static final String HOTROD_CLIENT_PROPERTIES
protected TransportFactory transportFactory
protected ClientListenerNotifier listenerNotifier
public RemoteCacheManager(Configuration configuration)
Configuration
.
The RemoteCacheManager will be started automaticallyconfiguration
- the configuration to use for this RemoteCacheManagerpublic RemoteCacheManager(Configuration configuration, boolean start)
Configuration
.
The RemoteCacheManager will be started automatically only if the start parameter is trueconfiguration
- the configuration to use for this RemoteCacheManagerstart
- whether or not to start the manager on return from the constructor.@Deprecated public RemoteCacheManager(Marshaller marshaller, Properties props, boolean start)
Marshaller
for marshalling
keys and values to be send over to the remote Infinispan cluster.marshaller
- marshaller implementation to be usedprops
- other propertiesstart
- whether or not to start the manager on return from the constructor.@Deprecated public RemoteCacheManager(Marshaller marshaller, Properties props, boolean start, ClassLoader classLoader, ExecutorFactory asyncExecutorFactory)
Marshaller
for marshalling
keys and values to be send over to the remote Infinispan cluster.marshaller
- marshaller implementation to be usedprops
- other propertiesstart
- whether or not to start the manager on return from the constructor.@Deprecated public RemoteCacheManager(Marshaller marshaller, Properties props)
RemoteCacheManager.RemoteCacheManager(Marshaller, java.util.Properties, boolean)
with start = true.@Deprecated public RemoteCacheManager(Marshaller marshaller, Properties props, ExecutorFactory asyncExecutorFactory)
RemoteCacheManager.RemoteCacheManager(Marshaller, java.util.Properties, boolean)
with start = true.@Deprecated public RemoteCacheManager(Marshaller marshaller, Properties props, ClassLoader classLoader)
RemoteCacheManager.RemoteCacheManager(Marshaller, java.util.Properties, boolean)
with start = true.@Deprecated public RemoteCacheManager(Properties props, boolean start)
@Deprecated public RemoteCacheManager(Properties props, boolean start, ClassLoader classLoader, ExecutorFactory asyncExecutorFactory)
@Deprecated public RemoteCacheManager(Properties props)
RemoteCacheManager.RemoteCacheManager(java.util.Properties, boolean)
, and it also starts the cache (start==true).@Deprecated public RemoteCacheManager(Properties props, ClassLoader classLoader)
RemoteCacheManager.RemoteCacheManager(java.util.Properties, boolean)
, and it also starts the cache (start==true).public RemoteCacheManager(boolean start)
RemoteCacheManager.RemoteCacheManager(java.util.Properties)
, but it will try to lookup the config properties in the
classpath, in a file named hotrod-client.properties. If no properties can be found in the classpath, the
server tries to connect to "127.0.0.1:11222" in start.start
- whether or not to start the RemoteCacheManagerHotRodClientException
- if such a file cannot be found in the classpathpublic RemoteCacheManager()
RemoteCacheManager.RemoteCacheManager(boolean)
and it also starts the cache.@Deprecated public RemoteCacheManager(String host, int port, boolean start)
start
- whether or not to start the RemoteCacheManager.@Deprecated public RemoteCacheManager(String host, int port, boolean start, ClassLoader classLoader)
start
- whether or not to start the RemoteCacheManager.@Deprecated public RemoteCacheManager(String host, int port)
RemoteCacheManager.RemoteCacheManager(String, int, boolean)
with start=true.@Deprecated public RemoteCacheManager(String host, int port, ClassLoader classLoader)
RemoteCacheManager.RemoteCacheManager(String, int, boolean)
with start=true.@Deprecated public RemoteCacheManager(String servers, boolean start)
@Deprecated public RemoteCacheManager(String servers, boolean start, ClassLoader classLoader)
@Deprecated public RemoteCacheManager(String servers)
RemoteCacheManager.RemoteCacheManager(String, boolean)
, with start=true.@Deprecated public RemoteCacheManager(String servers, ClassLoader classLoader)
RemoteCacheManager.RemoteCacheManager(String, boolean)
, with start=true.@Deprecated public RemoteCacheManager(URL config, boolean start)
RemoteCacheManager.RemoteCacheManager(java.util.Properties)
, but it will try to lookup the config properties in
supplied URL.start
- whether or not to start the RemoteCacheManagerHotRodClientException
- if properties could not be loaded@Deprecated public RemoteCacheManager(URL config, boolean start, ClassLoader classLoader)
RemoteCacheManager.RemoteCacheManager(java.util.Properties)
, but it will try to lookup the config properties in
supplied URL.start
- whether or not to start the RemoteCacheManagerHotRodClientException
- if properties could not be loaded@Deprecated public RemoteCacheManager(URL config)
RemoteCacheManager.RemoteCacheManager(java.net.URL)
and it also starts the cache (start==true).config
- @Deprecated public RemoteCacheManager(URL config, ClassLoader classLoader)
RemoteCacheManager.RemoteCacheManager(java.net.URL)
and it also starts the cache (start==true).config
- public Configuration getConfiguration()
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.read(remoteCacheManager.getConfiguration());
// modify builder
remoteCacheManager.stop();
remoteCacheManager = new RemoteCacheManager(builder.build());
@Deprecated public Properties getProperties()
Properties p = remoteCacheManager.getProperties();
// update properties
remoteCacheManager.stop();
remoteCacheManager = new RemoteCacheManager(p);
public <K,V> RemoteCache<K,V> getCache(String cacheName)
getCache
in interface BasicCacheContainer
cacheName
- name of cache to retrievepublic <K,V> RemoteCache<K,V> getCache(String cacheName, boolean forceReturnValue)
public <K,V> RemoteCache<K,V> getCache()
getCache
in interface BasicCacheContainer
public <K,V> RemoteCache<K,V> getCache(boolean forceReturnValue)
public void start()
Lifecycle
public void stop()
public boolean isStarted()
protected <K,V> NearCacheService<K,V> createNearCacheService(NearCacheConfiguration cfg)
public Marshaller getMarshaller()
public static byte[] cacheNameBytes(String cacheName)
public static byte[] cacheNameBytes()
Copyright © 2015 JBoss, a division of Red Hat. All rights reserved.