[
http://jira.jboss.com/jira/browse/JBCACHE-1213?page=comments#action_12387109 ]
Manik Surtani commented on JBCACHE-1213:
----------------------------------------
Your cache statuses are all wrong. You should be doing something like:
if (!cache.getCacheStatus().allowInvocations())
{
// if create is needed, it will be called internally.
cache.start();
}
Checking for status == DESTROYED won't work since when it is first constructed
it's status will be INSTANTIATED. See the CacheStatus javadocs.
Furthermore, you shouldn't be starting/stopping the cache every time you need to
invoke stuff against it. This is not a client-server model but a p2p model. Restarting
your local cache instance every time will result in flushing the cache's in-memory
state and causing it to fetch state from it's neighbours on every restart. Surely not
what you want?
Finally, please make sure you post stuff like this to the user forums in future before you
raise bugs on JIRA - it adds to a lot of unnecessary noise here.
Exception thrown when connecting to a pre-exisiting cache
---------------------------------------------------------
Key: JBCACHE-1213
URL:
http://jira.jboss.com/jira/browse/JBCACHE-1213
Project: JBoss Cache
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Replication
Affects Versions: 2.0.0.GA
Environment: JBoss cache 2.0.0GA; Dependancies according to POM excluding
JGroups, using JGroups 2.5.0GA; WinXP SP2. Javba 1.6.0_02
Reporter: Carl Shelbourne
Assigned To: Manik Surtani
Priority: Minor
When attempting to connect to an existing cache, the following exceptions are thrown. The
exception appears to be thrown before the cache state has transferred to started from
either created or starting. This exception is only seen once we have connected to a cache,
disconnected from the cache, then subsequently reconnected re-using the same Cache
instance object. When the client disconnects it call Cache.stop().
The following method is used to get the cache:
private Cache getTreeCache()
{
if ( _treeCache != null )
{
if ( _treeCache.getCacheStatus() == CacheStatus.DESTROYED )
{
_treeCache.create();
_treeCache.start();
}
else if ( _treeCache.getCacheStatus() == CacheStatus.CREATED )
{
_treeCache.start();
}
}
return _treeCache;
}
And we call this to close the cache once the client has finished with it. Please note
other clients will most probably still be connected to the cache ensuring the cache state
is maintained
public void destroy()
{
if ( _treeCache != null )
{
_treeCache.stop();
_treeCache.destroy();
}
}
the cache is initially create with:
...
CacheFactory factory = DefaultCacheFactory.getInstance();
...
Cache cache = factory.createCache( config, false );
...
Exception on second and subsequent attempts to connect to cache:
WARN [Incoming Thread,192.168.106.139:1827]
(CacheImpl.java:2866:org.jboss.cache.CacheImpl:_replicate) - replication failure with
method_call MethodName: _remove; MethodIdInteger: 5; Args: (null, /alarm/6834, true)
exception
java.lang.IllegalStateException: Cache not in STARTED state!
at org.jboss.cache.CacheImpl.invokeMethod(CacheImpl.java:3929)
at org.jboss.cache.CacheImpl._replicate(CacheImpl.java:2853)
at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jgroups.blocks.MethodCall.invoke(MethodCall.java:330)
at
org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher.handle(InactiveRegionAwareRpcDispatcher.java:77)
at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:624)
at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:533)
at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:365)
at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:736)
at org.jgroups.JChannel.up(JChannel.java:1063)
at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:325)
at org.jgroups.protocols.pbcast.FLUSH.up(FLUSH.java:406)
at
org.jgroups.protocols.pbcast.STREAMING_STATE_TRANSFER.up(STREAMING_STATE_TRANSFER.java:255)
at org.jgroups.protocols.FRAG2.up(FRAG2.java:197)
at org.jgroups.protocols.pbcast.GMS.up(GMS.java:722)
at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:234)
at org.jgroups.protocols.UNICAST.up(UNICAST.java:263)
at org.jgroups.protocols.pbcast.NAKACK.handleMessage(NAKACK.java:720)
at org.jgroups.protocols.pbcast.NAKACK.up(NAKACK.java:546)
at org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:167)
at org.jgroups.protocols.FD.up(FD.java:322)
at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:298)
at org.jgroups.protocols.MERGE2.up(MERGE2.java:145)
at org.jgroups.protocols.Discovery.up(Discovery.java:220)
at org.jgroups.protocols.TP$IncomingPacket.handleMyMessage(TP.java:1486)
at org.jgroups.protocols.TP$IncomingPacket.run(TP.java:1440)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira