Author: clebert.suconic(a)jboss.com
Date: 2011-03-31 14:18:25 -0400 (Thu, 31 Mar 2011)
New Revision: 10435
Modified:
trunk/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
Log:
https://issues.jboss.org/browse/HORNETQ-664 - avoiding blocking on page and transactions
Modified: trunk/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2011-03-31 14:30:13
UTC (rev 10434)
+++ trunk/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java 2011-03-31 18:18:25
UTC (rev 10435)
@@ -885,24 +885,10 @@
currentPage.write(pagedMessage);
- if (tx != null)
+ if (sync || tx != null)
{
- SyncPageStoreTX syncPage =
(SyncPageStoreTX)tx.getProperty(TransactionPropertyIndexes.PAGE_SYNC);
- if (syncPage == null)
- {
- syncPage = new SyncPageStoreTX();
- tx.putProperty(TransactionPropertyIndexes.PAGE_SYNC, syncPage);
- tx.addOperation(syncPage);
- }
- syncPage.addStore(this);
+ sync();
}
- else
- {
- if (sync)
- {
- sync();
- }
- }
return true;
}
@@ -957,63 +943,6 @@
}
}
- private static class SyncPageStoreTX extends TransactionOperationAbstract
- {
- Set<PagingStore> storesToSync = new HashSet<PagingStore>();
-
- public void addStore(PagingStore store)
- {
- storesToSync.add(store);
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.transaction.TransactionOperation#beforePrepare(org.hornetq.core.transaction.Transaction)
- */
- public void beforePrepare(Transaction tx) throws Exception
- {
- sync();
- }
-
- void sync() throws Exception
- {
- OperationContext originalTX = OperationContextImpl.getContext();
-
- try
- {
- // We only want to sync paging here, no need to wait for any other events
- OperationContextImpl.clearContext();
-
- for (PagingStore store : storesToSync)
- {
- store.sync();
- }
-
- // We can't perform a commit/sync on the journal before we can assure
page files are synced or we may get
- // out of sync
- OperationContext ctx = OperationContextImpl.getContext();
-
- if (ctx != null)
- {
- // if null it means there were no operations done before, hence no need to
wait any completions
- ctx.waitCompletion();
- }
- }
- finally
- {
- OperationContextImpl.setContext(originalTX);
- }
-
- }
-
- /* (non-Javadoc)
- * @see
org.hornetq.core.transaction.TransactionOperation#beforeCommit(org.hornetq.core.transaction.Transaction)
- */
- public void beforeCommit(Transaction tx) throws Exception
- {
- sync();
- }
- }
-
private class FinishPageMessageOperation implements TransactionOperation
{
private final PageTransactionInfo pageTransaction;