[infinispan-issues] [JBoss JIRA] (ISPN-4958) DefaultCacheManager startCaches do not restart stopped caches
Mathieu Lachance (JIRA)
issues at jboss.org
Mon Nov 10 08:28:30 EST 2014
Mathieu Lachance created ISPN-4958:
--------------------------------------
Summary: DefaultCacheManager startCaches do not restart stopped caches
Key: ISPN-4958
URL: https://issues.jboss.org/browse/ISPN-4958
Project: Infinispan
Issue Type: Feature Request
Components: Core
Affects Versions: 7.0.0.Final, 5.2.7.Final
Reporter: Mathieu Lachance
using DefaultCacheManager#startCaches do not start a previously stopped cache:
{code}
CacheManager cacheManager = new DefaultCacheManager();
cacheManager.startCaches("abc");
Cache cache = cacheManager.getCache("abc");
cache.stop();
cacheManager.startCaches("abc");
cache = cacheManager.getCache("abc);
cache.get("def"); // trow IllegalStateException
{code}
{quote}
java.lang.IllegalStateException: Cache 'XXXX' is in 'TERMINATED' state and so it does not accept new invocations. Either restart it or recreate the cache container.
at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:110)
at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:92)
at org.infinispan.commands.AbstractVisitor.visitGetKeyValueCommand(AbstractVisitor.java:104)
at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:58)
at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:343)
at org.infinispan.CacheImpl.get(CacheImpl.java:289)
at org.infinispan.CacheImpl.get(CacheImpl.java:281)
{quote}
I think the issue is in the thread that will call the {{createCache(cacheName)}}.
By looking at the 7.0.0.Final source code:
{code}
String threadName = "CacheStartThread," + globalConfiguration.transport().nodeName() + "," + cacheName;
Thread thread = new Thread(threadName) {
@Override
public void run() {
try {
createCache(cacheName);
} catch (RuntimeException e) {
exception.set(e);
} catch (Throwable t) {
exception.set(new RuntimeException(t));
}
}
};
{code}
I think we should do instead the following:
{code}
String threadName = "CacheStartThread," + globalConfiguration.transport().nodeName() + "," + cacheName;
Thread thread = new Thread(threadName) {
@Override
public void run() {
try {
Cache cache = getCache(cacheName, false);
if (cache == null) {
createCache(cacheName);
}
else {
if (!ComponentStatus.RUNNING.equals(cache.getStatus())) {
cache.start();
}
}
} catch (RuntimeException e) {
exception.set(e);
} catch (Throwable t) {
exception.set(new RuntimeException(t));
}
}
};
{code}
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
More information about the infinispan-issues
mailing list