[hornetq-commits] JBoss hornetq SVN: r8357 - branches/ClebertTemporary/src/main/org/hornetq/core/postoffice/impl.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Nov 21 00:48:07 EST 2009
Author: clebert.suconic at jboss.com
Date: 2009-11-21 00:48:07 -0500 (Sat, 21 Nov 2009)
New Revision: 8357
Modified:
branches/ClebertTemporary/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java
Log:
Fixing DuplicateIDCache test
Modified: branches/ClebertTemporary/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java
===================================================================
--- branches/ClebertTemporary/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java 2009-11-21 05:33:45 UTC (rev 8356)
+++ branches/ClebertTemporary/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java 2009-11-21 05:48:07 UTC (rev 8357)
@@ -144,7 +144,7 @@
storageManager.storeDuplicateID(address, duplID, recordID);
}
- addToCacheInMemory(duplID, recordID);
+ addToCacheInMemory(duplID, recordID, null);
}
else
{
@@ -161,11 +161,12 @@
}
}
- private synchronized void addToCacheInMemory(final byte[] duplID, final long recordID) throws Exception
+
+ private synchronized void addToCacheInMemory(final byte[] duplID, final long recordID, final Executor journalExecutor) throws Exception
{
cache.add(new ByteArrayHolder(duplID));
- Pair<ByteArrayHolder, Long> id;
+ final Pair<ByteArrayHolder, Long> id;
if (pos < ids.size())
{
@@ -179,7 +180,28 @@
// reclaimed
id.a = new ByteArrayHolder(duplID);
- storageManager.deleteDuplicateID(id.b);
+ if (journalExecutor != null)
+ {
+ // We can't execute any IO inside the Journal callback, so taking it outside
+ journalExecutor.execute(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ storageManager.deleteDuplicateID(id.b);
+ }
+ catch (Exception e)
+ {
+ log.warn("Error on deleting duplicate cache");
+ }
+ }
+ });
+ }
+ else
+ {
+ storageManager.deleteDuplicateID(id.b);
+ }
id.b = recordID;
}
@@ -215,21 +237,14 @@
{
if (!done)
{
- executor.execute(new Runnable()
+ try
{
- public void run()
- {
- try
- {
- addToCacheInMemory(duplID, recordID);
- }
- catch (Exception e)
- {
- log.warn(e.getMessage());
- }
- }
- });
-
+ addToCacheInMemory(duplID, recordID, executor);
+ }
+ catch (Exception shouldNotHappen)
+ {
+ // if you pass an executor to addtoCache, an exception will never happen here
+ }
done = true;
}
}
More information about the hornetq-commits
mailing list