JBoss Cache SVN: r5830 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/lib.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-05-12 12:45:25 -0400 (Mon, 12 May 2008)
New Revision: 5830
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/lib/jbosscache-core.jar
Log:
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/lib/jbosscache-core.jar
===================================================================
(Binary files differ)
16 years, 7 months
JBoss Cache SVN: r5829 - core/trunk/src/test/java/org/jboss/cache/optimistic.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-12 12:32:31 -0400 (Mon, 12 May 2008)
New Revision: 5829
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java
Log:
Fixed broken tests
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-05-12 16:18:11 UTC (rev 5828)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-05-12 16:32:31 UTC (rev 5829)
@@ -26,6 +26,7 @@
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionSetup;
import org.jboss.cache.xml.XmlHelper;
import org.jgroups.Address;
@@ -34,6 +35,7 @@
import org.w3c.dom.Element;
import javax.transaction.SystemException;
+import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -88,6 +90,14 @@
return createCacheWithLoader(false);
}
+ protected void setupTransactions(CacheSPI cache, Transaction tx)
+ {
+ cache.getInvocationContext().setTransaction(tx);
+ GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
+ cache.getInvocationContext().setGlobalTransaction(gtx);
+ cache.getInvocationContext().setTransactionEntry(cache.getTransactionTable().get(gtx));
+ }
+
protected CacheLoaderConfig getCacheLoaderConfig(boolean shared, boolean passivation) throws Exception
{
String xml = " <config>\n" +
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2008-05-12 16:18:11 UTC (rev 5828)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2008-05-12 16:32:31 UTC (rev 5829)
@@ -65,11 +65,8 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
-
SamplePojo pojo = new SamplePojo(21, "test");
cache.put("/one/two", "key1", pojo);
@@ -103,9 +100,7 @@
Transaction tx2 = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx2);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2, true));
+ setupTransactions(cache, tx2);
assertEquals(0, cache.getRoot().getChildrenNames().size());
mgr.commit();
@@ -117,11 +112,8 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
-
assertEquals(null, dummy.getCalledCommand());
TransactionTable table = cache.getTransactionTable();
@@ -146,9 +138,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java 2008-05-12 16:18:11 UTC (rev 5828)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java 2008-05-12 16:32:31 UTC (rev 5829)
@@ -59,8 +59,7 @@
Transaction tx = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -96,8 +95,7 @@
Transaction tx2 = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx2);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2, true));
+ setupTransactions(cache, tx2);
assertNull(cache.get("/one/two", "key1"));
mgr.commit();
@@ -109,8 +107,7 @@
Transaction tx = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -143,14 +140,14 @@
assertEquals(null, dummy.getCalledCommand());
}
+
public void testTransactionGetKeyValOverwriteNullMethod() throws Exception
{
mgr.begin();
Transaction tx = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -189,8 +186,7 @@
Transaction tx = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -204,8 +200,7 @@
mgr.begin();
Transaction tx2 = mgr.getTransaction();
// inject InvocationContext
- cache.getInvocationContext().setTransaction(tx2);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2, true));
+ setupTransactions(cache, tx2);
SamplePojo pojo2 = new SamplePojo(22, "test2");
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java 2008-05-12 16:18:11 UTC (rev 5828)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java 2008-05-12 16:32:31 UTC (rev 5829)
@@ -58,9 +58,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -95,9 +93,7 @@
Transaction tx2 = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx2);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2, true));
+ setupTransactions(cache, tx2);
assertNull(cache.get("/one/two", "key1"));
mgr.commit();
@@ -110,11 +106,8 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
-
assertEquals(null, dummy.getCalledCommand());
TransactionTable table = cache.getTransactionTable();
@@ -138,11 +131,8 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
-
SamplePojo pojo = new SamplePojo(21, "test");
cache.put("/one/two", "key1", pojo);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java 2008-05-12 16:18:11 UTC (rev 5828)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java 2008-05-12 16:32:31 UTC (rev 5829)
@@ -58,9 +58,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -94,9 +92,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -133,9 +129,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -171,9 +165,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -210,9 +202,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -224,8 +214,7 @@
//start a new transaction
mgr.begin();
Transaction tx2 = mgr.getTransaction();
- cache.getInvocationContext().setTransaction(tx2);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx2, true));
+ setupTransactions(cache, tx2);
SamplePojo pojo2 = new SamplePojo(21, "test");
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java 2008-05-12 16:18:11 UTC (rev 5828)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java 2008-05-12 16:32:31 UTC (rev 5829)
@@ -61,9 +61,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
@@ -96,9 +94,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
@@ -134,9 +130,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java 2008-05-12 16:18:11 UTC (rev 5828)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java 2008-05-12 16:32:31 UTC (rev 5829)
@@ -61,9 +61,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
@@ -98,9 +96,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
@@ -140,9 +136,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java 2008-05-12 16:18:11 UTC (rev 5828)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java 2008-05-12 16:32:31 UTC (rev 5829)
@@ -61,9 +61,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
assert null == cache.getNode("/one/two");
@@ -93,9 +91,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
Map temp = new HashMap();
@@ -131,9 +127,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
@@ -172,9 +166,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java 2008-05-12 16:18:11 UTC (rev 5828)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java 2008-05-12 16:32:31 UTC (rev 5829)
@@ -67,9 +67,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
cache.remove("/one/two", "keyOne");
@@ -98,9 +96,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
@@ -136,9 +132,7 @@
mgr.begin();
Transaction tx = mgr.getTransaction();
- // inject InvocationContext
- cache.getInvocationContext().setTransaction(tx);
- cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx, true));
+ setupTransactions(cache, tx);
SamplePojo pojo = new SamplePojo(21, "test");
Map temp = new HashMap();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java 2008-05-12 16:18:11 UTC (rev 5828)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java 2008-05-12 16:32:31 UTC (rev 5829)
@@ -53,9 +53,7 @@
entry = (OptimisticTransactionEntry) table.get(gtx);
workspace = entry.getTransactionWorkSpace();
- // set invocation context elements
- cache.getInvocationContext().setGlobalTransaction(gtx);
- cache.getInvocationContext().setTransaction(tx);
+ setupTransactions(cache, tx);
}
public void testNodeCreation() throws Exception
@@ -119,6 +117,7 @@
// we should now remove stuff from the InvocationCtx
cache.getInvocationContext().setGlobalTransaction(null);
cache.getInvocationContext().setTransaction(null);
+ cache.getInvocationContext().setTransactionEntry(null);
try
{
16 years, 7 months
JBoss Cache SVN: r5828 - benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-12 12:18:11 -0400 (Mon, 12 May 2008)
New Revision: 5828
Added:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractChartGen.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGen.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/PutGetChartGenerator.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ThroughputChartGenerator.java
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java
Log:
Added more charts
Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractChartGen.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractChartGen.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/AbstractChartGen.java 2008-05-12 16:18:11 UTC (rev 5828)
@@ -0,0 +1,18 @@
+package org.cachebench.reportgenerators;
+
+public abstract class AbstractChartGen implements ChartGen
+{
+ protected String reportDirectory;
+ protected String filenamePrefix;
+
+ public void setReportDirectory(String reportDirectory)
+ {
+ this.reportDirectory = reportDirectory;
+ }
+
+
+ public void setFileNamePrefix(String fnPrefix)
+ {
+ this.filenamePrefix = fnPrefix;
+ }
+}
Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGen.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGen.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGen.java 2008-05-12 16:18:11 UTC (rev 5828)
@@ -0,0 +1,18 @@
+package org.cachebench.reportgenerators;
+
+import java.io.IOException;
+
+/**
+ * Chart generator interface
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ */
+public interface ChartGen
+{
+
+ void setReportDirectory(String reportDirectory);
+
+ void setFileNamePrefix(String fnPrefix);
+
+ void generateChart() throws IOException;
+}
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java 2008-05-12 11:37:20 UTC (rev 5827)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ChartGenerator.java 2008-05-12 16:18:11 UTC (rev 5828)
@@ -1,25 +1,6 @@
package org.cachebench.reportgenerators;
-import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.ChartUtilities;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.plot.PlotOrientation;
-import org.jfree.chart.title.TextTitle;
-import org.jfree.data.category.CategoryDataset;
-import org.jfree.data.category.DefaultCategoryDataset;
-
-import java.awt.*;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FilenameFilter;
import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
/**
* Manual chart generator. Grabs CSVs generated by {@link org.cachebench.reportgenerators.ClusterReportGenerator} and spits out
@@ -37,21 +18,19 @@
*/
public class ChartGenerator
{
- static String reportDirectory;
- static boolean singleChart = true;
- DefaultCategoryDataset averageThroughput, totalThroughput;
- static String fnPrefix = null;
- static String chartNameAverage = "chart-averageThroughput.png", chartNameTotal = "chart-totalThroughput.png";
-
-
private static void help()
{
System.out.println("Usage:");
- System.out.println(" ChartGenerator [-reportDir <directory containing CSV files>] [-o <outputFileNamePrefix>] [-singleChart <true | false> if true, generates a single chart for all config files.]");
+ System.out.println(" ChartGenerator [-reportDir <directory containing CSV files>] [-o <outputFileNamePrefix>] [-singleChart <true | false> if true, generates a single chart for all config files.] [-chartType <putget | throughput> defaults to throughput if not specified.]");
}
public static void main(String[] args) throws IOException
{
+ String reportDirectory = null;
+ boolean singleChart = true;
+ String fnPrefix = null;
+ String chartType = "throughput";
+
long startTime = System.currentTimeMillis();
System.out.println("Welcome to the ChartGenerator.");
// the params we expect:
@@ -75,6 +54,12 @@
continue;
}
+ if (args[i].equals("-chartType"))
+ {
+ chartType = args[++i];
+ continue;
+ }
+
help();
return;
}
@@ -85,157 +70,21 @@
return;
}
if (!singleChart) throw new RuntimeException("Multiple charts not yet implemented");
- new ChartGenerator().generateChart();
- System.out.println("Finished in " + ((System.currentTimeMillis() - startTime) / 1000) + " seconds!");
- }
- private void generateChart() throws IOException
- {
- readData();
+ ChartGen gen;
- String chartAvgFileName = fnPrefix == null ? chartNameAverage : fnPrefix + "-" + chartNameAverage;
- File chartFile = new File(chartAvgFileName);
- if (chartFile.exists())
+ if (chartType.equalsIgnoreCase("putget"))
{
- chartFile.renameTo(new File(chartAvgFileName + "." + System.currentTimeMillis()));
- chartFile = new File(chartAvgFileName);
+ gen = new PutGetChartGenerator();
}
-
- ChartUtilities.saveChartAsPNG(chartFile, createChart(averageThroughput, "Report: Average throughput per cache instance", "Throughput per cache instance (reqs/sec)"), 1024, 768);
-
- String chartTotalFileName = fnPrefix == null ? chartNameTotal : fnPrefix + "-" + chartNameTotal;
- chartFile = new File(chartTotalFileName);
- if (chartFile.exists())
+ else
{
- chartFile.renameTo(new File(chartTotalFileName + "." + System.currentTimeMillis()));
- chartFile = new File(chartTotalFileName);
+ gen = new ThroughputChartGenerator();
}
- ChartUtilities.saveChartAsPNG(chartFile, createChart(totalThroughput, "Report: Total throughput for cluster", "Overall throughput (reqs/sec)"), 1024, 768);
-
- System.out.println("Charts saved as " + chartAvgFileName + " and " + chartTotalFileName);
+ gen.setReportDirectory(reportDirectory);
+ gen.setFileNamePrefix(fnPrefix);
+ gen.generateChart();
+ System.out.println("Finished in " + ((System.currentTimeMillis() - startTime) / 1000) + " seconds!");
}
-
- private JFreeChart createChart(CategoryDataset data, String title, String yLabel)
- {
- JFreeChart chart = ChartFactory.createLineChart(title, "Cluster size (number of cache instances)", yLabel, data, PlotOrientation.VERTICAL, true, false, false);
- chart.addSubtitle(new TextTitle("Generated on " + new Date() + " by The CacheBenchFwk"));
- chart.setBorderVisible(true);
- chart.setAntiAlias(true);
- chart.setTextAntiAlias(true);
- chart.setBackgroundPaint(new Color(0x61, 0x9e, 0xa1));
- return chart;
- }
-
- private void readData() throws IOException
- {
- File file = new File(reportDirectory);
- if (!file.exists() || !file.isDirectory())
- throw new IllegalArgumentException("Report directory " + reportDirectory + " does not exist or is not a directory!");
-
- File[] files = file.listFiles(new FilenameFilter()
- {
- public boolean accept(File dir, String name)
- {
- return name.toUpperCase().endsWith(".CSV");
- }
- });
-
- averageThroughput = new DefaultCategoryDataset();
- totalThroughput = new DefaultCategoryDataset();
- for (File f : files)
- {
- readData(f);
- }
-
- sort(averageThroughput);
- sort(totalThroughput);
- }
-
- /**
- * Crappy that the JFReechart data set doesn't order columns and rows by default or even as an option. Need to do this manually.
- *
- * @param data
- */
- private void sort(DefaultCategoryDataset data)
- {
- SortedMap<Comparable, SortedMap<Comparable, Number>> raw = new TreeMap<Comparable, SortedMap<Comparable, Number>>();
- for (int i = 0; i < data.getRowCount(); i++)
- {
- Comparable row = data.getRowKey(i);
- SortedMap<Comparable, Number> rowData = new TreeMap<Comparable, Number>();
- for (int j = 0; j < data.getColumnCount(); j++)
- {
- Comparable column = data.getColumnKey(j);
- Number value = data.getValue(i, j);
- rowData.put(column, value);
- }
- raw.put(row, rowData);
- }
-
- data.clear();
- for (Comparable row : raw.keySet())
- {
- Map<Comparable, Number> rowData = raw.get(row);
- for (Comparable column : rowData.keySet())
- {
- data.addValue(rowData.get(column), row, column);
- }
- }
- }
-
-
- private void readData(File f) throws IOException
- {
- // chop up the file name to get productAndConfiguration and clusterSize.
- Integer clusterSize = 0;
- DescriptiveStatistics stats = DescriptiveStatistics.newInstance();
- // file name is in the format data_<cache-product>_<cache-cfg.xml>_<cluster-size>.csv
-
- StringTokenizer strtok = new StringTokenizer(f.getName(), "_");
- strtok.nextToken(); // this is the "data-" bit
- String productNameAndConfiguration = strtok.nextToken() + "(" + strtok.nextToken();
- // chop off the trailing ".xml"
- if (productNameAndConfiguration.toUpperCase().endsWith(".XML"))
- productNameAndConfiguration = productNameAndConfiguration.substring(0, productNameAndConfiguration.length() - 4);
- productNameAndConfiguration += ")";
-
- // cluster size
- String cS = strtok.nextToken();
- if (cS.toUpperCase().endsWith(".CSV")) cS = cS.substring(0, cS.length() - 4);
- clusterSize = Integer.parseInt(cS);
-
- // now read the data.
- String line = null;
- BufferedReader br = new BufferedReader(new FileReader(f));
- while ((line = br.readLine()) != null)
- {
- double throughput = getThroughput(line);
- if (throughput != -1) stats.addValue(throughput);
- }
-
- averageThroughput.addValue(stats.getMean(), productNameAndConfiguration, clusterSize);
- totalThroughput.addValue(stats.getSum(), productNameAndConfiguration, clusterSize);
- }
-
- private double getThroughput(String line)
- {
- // To be a valid line, the line should be comma delimited
- StringTokenizer strTokenizer = new StringTokenizer(line, ",");
- if (strTokenizer.countTokens() < 2) return -1;
-
- // we want the 3rd element which is throughput
- strTokenizer.nextToken();
- strTokenizer.nextToken();
- String candidate = strTokenizer.nextToken();
- try
- {
- return Double.parseDouble(candidate);
- }
- catch (NumberFormatException nfe)
- {
- return -1;
- }
- }
-
}
Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/PutGetChartGenerator.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/PutGetChartGenerator.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/PutGetChartGenerator.java 2008-05-12 16:18:11 UTC (rev 5828)
@@ -0,0 +1,190 @@
+package org.cachebench.reportgenerators;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.labels.CategoryItemLabelGenerator;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.renderer.category.BarRenderer3D;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.category.DefaultCategoryDataset;
+
+import java.awt.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.text.NumberFormat;
+import java.util.Date;
+import java.util.StringTokenizer;
+
+/**
+ * Generates average and total throughput. Used for parsing reports generated with a ClusterReportGenerator.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ */
+public class PutGetChartGenerator extends AbstractChartGen
+{
+ private DefaultCategoryDataset putData, getData;
+ private String putChartName = "PutChart.png", getChartName = "GetChart.png";
+
+ public void generateChart() throws IOException
+ {
+ readData();
+
+ String putChartNameToUse = filenamePrefix == null ? putChartName : filenamePrefix + "-" + putChartName;
+ File chartFile = new File(putChartNameToUse);
+ if (chartFile.exists())
+ {
+ chartFile.renameTo(new File(putChartNameToUse + "." + System.currentTimeMillis()));
+ chartFile = new File(putChartNameToUse);
+ }
+
+ ChartUtilities.saveChartAsPNG(chartFile, createChart("Report: Comparing Cache PUT (WRITE) performance", putData), 800, 800);
+
+ String getChartNameToUse = filenamePrefix == null ? getChartName : filenamePrefix + "-" + getChartName;
+ chartFile = new File(getChartNameToUse);
+ if (chartFile.exists())
+ {
+ chartFile.renameTo(new File(getChartNameToUse + "." + System.currentTimeMillis()));
+ chartFile = new File(getChartNameToUse);
+ }
+
+ ChartUtilities.saveChartAsPNG(chartFile, createChart("Report: Comparing Cache GET (READ) performance", getData), 800, 800);
+
+ System.out.println("Charts saved as " + putChartNameToUse + " and " + getChartNameToUse);
+ }
+
+ private JFreeChart createChart(String title, DefaultCategoryDataset data)
+ {
+ JFreeChart chart = ChartFactory.createBarChart3D(title, "Cache operation", "Average time (�-seconds)", data, PlotOrientation.VERTICAL, true, false, false);
+ BarRenderer3D renderer = (BarRenderer3D) chart.getCategoryPlot().getRenderer();
+ renderer.setBaseItemLabelsVisible(true);
+
+ final NumberFormat fmt = NumberFormat.getNumberInstance();
+ fmt.setMaximumFractionDigits(2);
+ fmt.setMinimumFractionDigits(2);
+
+ renderer.setBaseItemLabelGenerator(new CategoryItemLabelGenerator()
+ {
+
+ public String generateRowLabel(CategoryDataset categoryDataset, int i)
+ {
+ return null;
+ }
+
+ public String generateColumnLabel(CategoryDataset categoryDataset, int i)
+ {
+ return null;
+ }
+
+ public String generateLabel(CategoryDataset categoryDataset, int product, int operation)
+ {
+ String retval;
+ try
+ {
+ retval = fmt.format(categoryDataset.getValue(product, operation)) + " �s";
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ retval = e.toString();
+ }
+ return retval;
+ }
+ });
+
+ chart.addSubtitle(new TextTitle("Generated on " + new Date() + " by The CacheBenchFwk"));
+ chart.setBorderVisible(true);
+ chart.setAntiAlias(true);
+ chart.setTextAntiAlias(true);
+ chart.setBackgroundPaint(new Color(0x61, 0x9e, 0xa1));
+ return chart;
+ }
+
+ private void readData() throws IOException
+ {
+ File file = new File(reportDirectory);
+ if (!file.exists() || !file.isDirectory())
+ throw new IllegalArgumentException("Report directory " + reportDirectory + " does not exist or is not a directory!");
+
+ File[] files = file.listFiles(new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.toUpperCase().endsWith(".CSV");
+ }
+ });
+
+ putData = new DefaultCategoryDataset();
+ getData = new DefaultCategoryDataset();
+
+ for (File f : files)
+ {
+ readData(f);
+ }
+
+ //sort(averageThroughput);
+ }
+
+ private void readData(File f) throws IOException
+ {
+ String productName = f.getName();
+ if (productName.startsWith("data_"))
+ {
+ productName = productName.substring(5);
+ }
+
+ if (productName.indexOf(".xml") > 0)
+ {
+ productName = productName.substring(0, productName.indexOf(".xml"));
+ }
+
+ // now the contects of this file:
+
+ String line = null;
+ BufferedReader br = new BufferedReader(new FileReader(f));
+ double avgPut = -1, avgGet = -1;
+
+ while ((line = br.readLine()) != null && avgPut == -1 && avgGet == -1)
+ {
+ double[] tmp = getAveragePutAndGet(line);
+ avgPut = tmp[0];
+ avgGet = tmp[1];
+ }
+
+ br.close();
+
+ putData.addValue(avgPut, productName, "PUT");
+ getData.addValue(avgGet, productName, "GET");
+ }
+
+ private double[] getAveragePutAndGet(String line)
+ {
+ // To be a valid line, the line should be comma delimited
+ StringTokenizer strTokenizer = new StringTokenizer(line, ",");
+ if (strTokenizer.countTokens() < 7) return new double[]{-1, -1};
+
+ // 8th token is avg put
+ // 9th token is avg get
+ for (int i = 0; i < 7; i++) strTokenizer.nextToken();
+
+ String putStr = strTokenizer.nextToken();
+ String getStr = strTokenizer.nextToken();
+
+ double[] results = new double[2];
+ try
+ {
+ results[0] = Double.parseDouble(putStr) * 1000;
+ results[1] = Double.parseDouble(getStr) * 1000;
+ return results;
+ }
+ catch (NumberFormatException nfe)
+ {
+ return new double[]{-1, -1};
+ }
+ }
+
+}
Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ThroughputChartGenerator.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ThroughputChartGenerator.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ThroughputChartGenerator.java 2008-05-12 16:18:11 UTC (rev 5828)
@@ -0,0 +1,183 @@
+package org.cachebench.reportgenerators;
+
+import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.category.DefaultCategoryDataset;
+
+import java.awt.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
+/**
+ * Generates average and total throughput. Used for parsing reports generated with a ClusterReportGenerator.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ */
+public class ThroughputChartGenerator extends AbstractChartGen
+{
+ private DefaultCategoryDataset averageThroughput, totalThroughput;
+ private String chartNameAverage = "chart-averageThroughput.png", chartNameTotal = "chart-totalThroughput.png";
+
+ public void generateChart() throws IOException
+ {
+ readData();
+
+ String chartAvgFileName = filenamePrefix == null ? chartNameAverage : filenamePrefix + "-" + chartNameAverage;
+ File chartFile = new File(chartAvgFileName);
+ if (chartFile.exists())
+ {
+ chartFile.renameTo(new File(chartAvgFileName + "." + System.currentTimeMillis()));
+ chartFile = new File(chartAvgFileName);
+ }
+
+ ChartUtilities.saveChartAsPNG(chartFile, createChart(averageThroughput, "Report: Average throughput per cache instance", "Throughput per cache instance (reqs/sec)"), 1024, 768);
+
+ String chartTotalFileName = filenamePrefix == null ? chartNameTotal : filenamePrefix + "-" + chartNameTotal;
+ chartFile = new File(chartTotalFileName);
+ if (chartFile.exists())
+ {
+ chartFile.renameTo(new File(chartTotalFileName + "." + System.currentTimeMillis()));
+ chartFile = new File(chartTotalFileName);
+ }
+
+ ChartUtilities.saveChartAsPNG(chartFile, createChart(totalThroughput, "Report: Total throughput for cluster", "Overall throughput (reqs/sec)"), 1024, 768);
+
+ System.out.println("Charts saved as " + chartAvgFileName + " and " + chartTotalFileName);
+ }
+
+ private JFreeChart createChart(CategoryDataset data, String title, String yLabel)
+ {
+ JFreeChart chart = ChartFactory.createLineChart(title, "Cluster size (number of cache instances)", yLabel, data, PlotOrientation.VERTICAL, true, false, false);
+ chart.addSubtitle(new TextTitle("Generated on " + new Date() + " by The CacheBenchFwk"));
+ chart.setBorderVisible(true);
+ chart.setAntiAlias(true);
+ chart.setTextAntiAlias(true);
+ chart.setBackgroundPaint(new Color(0x61, 0x9e, 0xa1));
+ return chart;
+ }
+
+ private void readData() throws IOException
+ {
+ File file = new File(reportDirectory);
+ if (!file.exists() || !file.isDirectory())
+ throw new IllegalArgumentException("Report directory " + reportDirectory + " does not exist or is not a directory!");
+
+ File[] files = file.listFiles(new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.toUpperCase().endsWith(".CSV");
+ }
+ });
+
+ averageThroughput = new DefaultCategoryDataset();
+ totalThroughput = new DefaultCategoryDataset();
+ for (File f : files)
+ {
+ readData(f);
+ }
+
+ sort(averageThroughput);
+ sort(totalThroughput);
+ }
+
+ /**
+ * Crappy that the JFReechart data set doesn't order columns and rows by default or even as an option. Need to do this manually.
+ *
+ * @param data
+ */
+ private void sort(DefaultCategoryDataset data)
+ {
+ SortedMap<Comparable, SortedMap<Comparable, Number>> raw = new TreeMap<Comparable, SortedMap<Comparable, Number>>();
+ for (int i = 0; i < data.getRowCount(); i++)
+ {
+ Comparable row = data.getRowKey(i);
+ SortedMap<Comparable, Number> rowData = new TreeMap<Comparable, Number>();
+ for (int j = 0; j < data.getColumnCount(); j++)
+ {
+ Comparable column = data.getColumnKey(j);
+ Number value = data.getValue(i, j);
+ rowData.put(column, value);
+ }
+ raw.put(row, rowData);
+ }
+
+ data.clear();
+ for (Comparable row : raw.keySet())
+ {
+ Map<Comparable, Number> rowData = raw.get(row);
+ for (Comparable column : rowData.keySet())
+ {
+ data.addValue(rowData.get(column), row, column);
+ }
+ }
+ }
+
+
+ private void readData(File f) throws IOException
+ {
+ // chop up the file name to get productAndConfiguration and clusterSize.
+ Integer clusterSize = 0;
+ DescriptiveStatistics stats = DescriptiveStatistics.newInstance();
+ // file name is in the format data_<cache-product>_<cache-cfg.xml>_<cluster-size>.csv
+
+ StringTokenizer strtok = new StringTokenizer(f.getName(), "_");
+ strtok.nextToken(); // this is the "data-" bit
+ String productNameAndConfiguration = strtok.nextToken() + "(" + strtok.nextToken();
+ // chop off the trailing ".xml"
+ if (productNameAndConfiguration.toUpperCase().endsWith(".XML"))
+ productNameAndConfiguration = productNameAndConfiguration.substring(0, productNameAndConfiguration.length() - 4);
+ productNameAndConfiguration += ")";
+
+ // cluster size
+ String cS = strtok.nextToken();
+ if (cS.toUpperCase().endsWith(".CSV")) cS = cS.substring(0, cS.length() - 4);
+ clusterSize = Integer.parseInt(cS);
+
+ // now read the data.
+ String line = null;
+ BufferedReader br = new BufferedReader(new FileReader(f));
+ while ((line = br.readLine()) != null)
+ {
+ double throughput = getThroughput(line);
+ if (throughput != -1) stats.addValue(throughput);
+ }
+
+ averageThroughput.addValue(stats.getMean(), productNameAndConfiguration, clusterSize);
+ totalThroughput.addValue(stats.getSum(), productNameAndConfiguration, clusterSize);
+ }
+
+ private double getThroughput(String line)
+ {
+ // To be a valid line, the line should be comma delimited
+ StringTokenizer strTokenizer = new StringTokenizer(line, ",");
+ if (strTokenizer.countTokens() < 2) return -1;
+
+ // we want the 3rd element which is throughput
+ strTokenizer.nextToken();
+ strTokenizer.nextToken();
+ String candidate = strTokenizer.nextToken();
+ try
+ {
+ return Double.parseDouble(candidate);
+ }
+ catch (NumberFormatException nfe)
+ {
+ return -1;
+ }
+ }
+
+}
16 years, 7 months
JBoss Cache SVN: r5827 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-12 07:37:20 -0400 (Mon, 12 May 2008)
New Revision: 5827
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
Log:
Fixed registering of GTX and TE in InvocationContext
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-05-12 10:05:55 UTC (rev 5826)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-05-12 11:37:20 UTC (rev 5827)
@@ -967,6 +967,11 @@
if (TransactionTable.isValid(tx) && transactions.put(tx, NULL) == null)
{
gtx = txTable.getCurrentTransaction(tx, true);
+ if (ctx.getGlobalTransaction() == null)
+ {
+ ctx.setGlobalTransaction(gtx);
+ ctx.setTransactionEntry(txTable.get(gtx));
+ }
if (gtx.isRemote())
{
// should be no need to register a handler since this a remotely initiated globalTransaction
16 years, 7 months
JBoss Cache SVN: r5826 - core/trunk/src/main/java/org/jboss/cache/factories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-05-12 06:05:55 -0400 (Mon, 12 May 2008)
New Revision: 5826
Modified:
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
Log:
fixed finding of strt/stop methods
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-09 18:14:06 UTC (rev 5825)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-12 10:05:55 UTC (rev 5826)
@@ -501,7 +501,7 @@
em.component = c;
em.method = m;
em.priority = m.getAnnotation(Stop.class).priority();
- c.startMethods.add(em);
+ c.stopMethods.add(em);
}
methods = ReflectionUtil.getAllMethods(c.instance.getClass(), Destroy.class);
@@ -511,7 +511,7 @@
em.component = c;
em.method = m;
em.priority = m.getAnnotation(Destroy.class).priority();
- c.startMethods.add(em);
+ c.destroyMethods.add(em);
}
}
}
@@ -718,6 +718,8 @@
Collections.sort(startMethods);
// fire all START methods according to priority
+
+
for (PrioritizedMethod em : startMethods) em.invoke();
addShutdownHook();
16 years, 7 months
JBoss Cache SVN: r5825 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 14:14:06 -0400 (Fri, 09 May 2008)
New Revision: 5825
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
Log:
JBCACHE-1328 - profile and optimise TxTable lookups
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-05-09 18:14:06 UTC (rev 5825)
@@ -52,7 +52,7 @@
}
ctx.setTransaction(tx);
ctx.setGlobalTransaction(gtx);
- ctx.setTransactionEntry(txTable.get(gtx));
+ if (gtx != null) ctx.setTransactionEntry(txTable.get(gtx));
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-05-09 18:14:06 UTC (rev 5825)
@@ -113,10 +113,17 @@
try
{
- Transaction tx = getTransaction();
- GlobalTransaction realGtx = getGlobalTransaction(tx, gtx);
- if (tx == null && realGtx != null && realGtx.isRemote()) tx = txTable.getLocalTransaction(gtx);
- setTransactionalContext(tx, realGtx, ctx);
+ if (txManager != null)
+ {
+ Transaction tx = getTransaction();
+ GlobalTransaction realGtx = getGlobalTransaction(tx, gtx);
+ if (tx == null && realGtx != null && realGtx.isRemote()) tx = txTable.getLocalTransaction(gtx);
+ setTransactionalContext(tx, realGtx, ctx);
+ }
+ else
+ {
+ setTransactionalContext(null, null, ctx);
+ }
if (optionOverride != null)
{
16 years, 7 months
JBoss Cache SVN: r5824 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 13:57:36 -0400 (Fri, 09 May 2008)
New Revision: 5824
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
Log:
JBCACHE-1328 - profile and optimise TxTable lookups
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -13,6 +13,7 @@
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Transaction;
@@ -33,6 +34,7 @@
private Transaction transaction;
private GlobalTransaction globalTransaction;
+ private TransactionEntry transactionEntry;
private Option optionOverrides;
// defaults to true.
private boolean originLocal = true;
@@ -108,6 +110,26 @@
}
/**
+ * @return the transaction entry associated with the current transaction, or null if the current thread is not associated with a transaction.
+ * @since 2.2.0
+ */
+ public TransactionEntry getTransactionEntry()
+ {
+ return transactionEntry;
+ }
+
+ /**
+ * Sets the transaction entry to be associated with the current thread.
+ *
+ * @param transactionEntry transaction entry to set
+ * @since 2.2.0
+ */
+ public void setTransactionEntry(TransactionEntry transactionEntry)
+ {
+ this.transactionEntry = transactionEntry;
+ }
+
+ /**
* Retrieves the global transaction associated with this invocation
*
* @return the global transaction associated with this invocation
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -285,7 +285,7 @@
private void prepareCacheLoader(InvocationContext ctx) throws Throwable
{
GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry entry = txTable.get(gtx);
+ TransactionEntry entry = ctx.getTransactionEntry();
if (entry == null)
{
throw new Exception("entry for transaction " + gtx + " not found in transaction table");
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -108,8 +108,7 @@
Transaction tx = ctx.getTransaction();
if (tx != null)
{
- GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry te = txTable.get(gtx);
+ TransactionEntry te = ctx.getTransactionEntry();
if (te != null)
{
if (te.isForceAsyncReplication()) sync = false;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -52,6 +52,7 @@
}
ctx.setTransaction(tx);
ctx.setGlobalTransaction(gtx);
+ ctx.setTransactionEntry(txTable.get(gtx));
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -28,7 +28,6 @@
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
@@ -92,7 +91,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, true, false, txTable.get(ctx.getGlobalTransaction()), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, false, true, false, ctx.getTransactionEntry(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -102,7 +101,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, useCacheStore, !useCacheStore, txTable.get(ctx.getGlobalTransaction()), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, useCacheStore, !useCacheStore, ctx.getTransactionEntry(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -114,9 +113,9 @@
{
if (command.getTo() != null)
{
- loadIfNeeded(ctx, command.getTo(), null, false, false, true, txTable.get(ctx.getGlobalTransaction()), false, true, false);
+ loadIfNeeded(ctx, command.getTo(), null, false, false, true, ctx.getTransactionEntry(), false, true, false);
}
- loadIfNeeded(ctx, command.getFqn(), null, false, false, true, txTable.get(ctx.getGlobalTransaction()), true, true, false);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, true, ctx.getTransactionEntry(), true, true, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -126,7 +125,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, true, txTable.get(ctx.getGlobalTransaction()), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, true, ctx.getTransactionEntry(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -137,7 +136,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, false, true, txTable.get(ctx.getGlobalTransaction()), false, false, !usingOptimisticInvalidation);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, true, ctx.getTransactionEntry(), false, false, !usingOptimisticInvalidation);
}
return invokeNextInterceptor(ctx, command);
}
@@ -148,7 +147,7 @@
Fqn fqn = command.getFqn();
if (fqn != null)
{
- loadIfNeeded(ctx, fqn, null, false, false, false, txTable.get(ctx.getGlobalTransaction()), false, false, true);
+ loadIfNeeded(ctx, fqn, null, false, false, false, ctx.getTransactionEntry(), false, false, true);
NodeSPI n = dataContainer.peek(fqn, true, true);
loadChildren(fqn, n, false, false, ctx);
}
@@ -161,7 +160,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, true, false, true, txTable.get(ctx.getGlobalTransaction()), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, true, false, true, ctx.getTransactionEntry(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -171,7 +170,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, true, false, true, txTable.get(ctx.getGlobalTransaction()), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, true, false, true, ctx.getTransactionEntry(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -183,7 +182,7 @@
if (trace) log.trace("Removing temporarily created nodes from treecache");
// this needs to be done in reverse order.
- List list = txTable.get(ctx.getGlobalTransaction()).getDummyNodesCreatedByCacheLoader();
+ List list = ctx.getTransactionEntry().getDummyNodesCreatedByCacheLoader();
if (list != null && list.size() > 0)
{
ListIterator i = list.listIterator(list.size());
@@ -208,7 +207,7 @@
{
if (configuration.isNodeLockingOptimistic() && command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, false, false, txTable.get(ctx.getGlobalTransaction()), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, false, ctx.getTransactionEntry(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -218,7 +217,7 @@
{
if (command.getFqn() != null && !useCacheStore)
{
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, false, txTable.get(ctx.getGlobalTransaction()), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, false, ctx.getTransactionEntry(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -229,7 +228,7 @@
Fqn fqn = command.getFqn();
if (fqn != null && !useCacheStore)
{
- loadIfNeeded(ctx, fqn, null, false, true, false, txTable.get(ctx.getGlobalTransaction()), false, false, false);
+ loadIfNeeded(ctx, fqn, null, false, true, false, ctx.getTransactionEntry(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -268,7 +267,7 @@
}
// if (!initNode && !wasRemovedInTx(fqn, ctx.getGlobalTransaction()))
- if (!wasRemovedInTx(fqn, ctx.getGlobalTransaction()))
+ if (!wasRemovedInTx(fqn, ctx))
{
if (bypassLoadingData)
{
@@ -437,10 +436,10 @@
* transaction.
* This is O(N) WRT to the number of modifications so far.
*/
- private boolean wasRemovedInTx(Fqn fqn, GlobalTransaction t)
+ private boolean wasRemovedInTx(Fqn fqn, InvocationContext ctx)
{
- if (t == null) return false;
- TransactionEntry entry = txTable.get(t);
+ TransactionEntry entry = ctx.getTransactionEntry();
+ if (entry == null) return false;
for (ReversibleCommand txCacheCommand : entry.getCacheLoaderModifications())
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -179,7 +179,7 @@
if (inTransaction())
{
if (trace) log.trace("transactional so don't put stuff in the cloader yet.");
- prepareCacheLoader(command.getGlobalTransaction(), command.isOnePhaseCommit());
+ prepareCacheLoader(command.getGlobalTransaction(), ctx.getTransactionEntry(), command.isOnePhaseCommit());
}
return invokeNextInterceptor(ctx, command);
}
@@ -190,7 +190,7 @@
if (inTransaction())
{
if (trace) log.trace("transactional so don't put stuff in the cloader yet.");
- prepareCacheLoader(command.getGlobalTransaction(), command.isOnePhaseCommit());
+ prepareCacheLoader(command.getGlobalTransaction(), ctx.getTransactionEntry(), command.isOnePhaseCommit());
}
return invokeNextInterceptor(ctx, command);
}
@@ -346,10 +346,8 @@
return retval;
}
- private void prepareCacheLoader(GlobalTransaction gtx, boolean onePhase) throws Throwable
+ private void prepareCacheLoader(GlobalTransaction gtx, TransactionEntry entry, boolean onePhase) throws Throwable
{
-
- TransactionEntry entry = txTable.get(gtx);
if (entry == null)
{
throw new Exception("entry for transaction " + gtx + " not found in transaction table");
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -32,7 +32,6 @@
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
import org.jgroups.Address;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RspFilter;
@@ -362,11 +361,6 @@
}
}
- private TransactionEntry getTransactionEntry(GlobalTransaction gtx)
- {
- return cacheSPI.getTransactionTable().get(gtx);
- }
-
private BackupData localBackupGet(Fqn fqn, InvocationContext ctx) throws CacheException
{
GravitateResult result = cacheSPI.gravitateData(fqn, true, ctx);// a "local" gravitation
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -130,7 +130,7 @@
if (trace) log.trace("Entering InvalidationInterceptor's prepare phase");
// fetch the modifications before the transaction is committed (and thus removed from the txTable)
GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry entry = txTable.get(gtx);
+ TransactionEntry entry = ctx.getTransactionEntry();
if (entry == null) throw new IllegalStateException("cannot find transaction entry for " + gtx);
List<ReversibleCommand> modifications = new LinkedList<ReversibleCommand>(command.getModifications());
if (modifications.size() > 0)
@@ -154,7 +154,7 @@
{
// here we just record the modifications but actually do the invalidate in commit.
GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry entry = txTable.get(gtx);
+ TransactionEntry entry = ctx.getTransactionEntry();
if (entry == null) throw new IllegalStateException("cannot find transaction entry for " + gtx);
List<ReversibleCommand> modifications = new LinkedList<ReversibleCommand>(command.getModifications());
if (modifications.size() > 0)
@@ -240,7 +240,7 @@
{
try
{
- TransactionWorkspace workspace = configuration.isNodeLockingOptimistic() ? getWorkspace(gtx) : null;
+ TransactionWorkspace workspace = configuration.isNodeLockingOptimistic() ? getWorkspace(ctx) : null;
for (Fqn fqn : filterVisitor.result) invalidateAcrossCluster(fqn, workspace, defaultSynchronous, ctx);
}
catch (Throwable t)
@@ -383,9 +383,9 @@
return v;
}
- protected TransactionWorkspace getWorkspace(GlobalTransaction gtx)
+ protected TransactionWorkspace getWorkspace(InvocationContext ctx)
{
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) txTable.get(gtx);
+ OptimisticTransactionEntry entry = (OptimisticTransactionEntry) ctx.getTransactionEntry();
return entry.getTransactionWorkSpace();
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -111,7 +111,7 @@
boolean debug = log.isDebugEnabled();
GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionWorkspace workspace = getTransactionWorkspace(gtx);
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
WorkspaceNode workspaceNode;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -41,13 +41,13 @@
this.txTable = txTable;
}
- protected TransactionWorkspace getTransactionWorkspace(GlobalTransaction gtx) throws CacheException
+ protected TransactionWorkspace getTransactionWorkspace(InvocationContext ctx) throws CacheException
{
- OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) txTable.get(gtx);
+ OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) ctx.getTransactionEntry();
if (transactionEntry == null)
{
- throw new CacheException("Unable to map global transaction " + gtx + " to transaction entry when trying to retrieve transaction workspace.");
+ throw new CacheException("Unable to map global transaction " + ctx.getGlobalTransaction() + " to transaction entry when trying to retrieve transaction workspace.");
}
// try and get the workspace from the transaction
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -53,8 +53,8 @@
}
try
{
- TransactionWorkspace<?, ?> workspace = getTransactionWorkspace(gtx);
- TransactionEntry te = txTable.get(gtx);
+ TransactionWorkspace<?, ?> workspace = getTransactionWorkspace(ctx);
+ TransactionEntry te = ctx.getTransactionEntry();
if (log.isDebugEnabled()) log.debug("Locking nodes in transaction workspace for GlobalTransaction " + gtx);
for (WorkspaceNode workspaceNode : workspace.getNodes().values())
@@ -82,7 +82,7 @@
//we have failed - set to rollback and throw exception
try
{
- unlock(gtx);
+ unlock(ctx, gtx);
}
catch (Throwable t)
{
@@ -121,7 +121,7 @@
{
try
{
- unlock(getGlobalTransaction(ctx));
+ unlock(ctx, getGlobalTransaction(ctx));
}
catch (Exception e)
{
@@ -135,11 +135,11 @@
/**
* Releases all locks held by the specified global transaction.
*
- * @param gtx which holds locks
+ * @param ctx Invocation Context
*/
- private void unlock(GlobalTransaction gtx)
+ private void unlock(InvocationContext ctx, GlobalTransaction gtx)
{
- TransactionEntry entry = txTable.get(gtx);
+ TransactionEntry entry = ctx.getTransactionEntry();
entry.releaseAllLocksFIFO(gtx);
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -87,7 +87,7 @@
public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionWorkspace workspace = getTransactionWorkspace(gtx);
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, true);
if (workspaceNode != null)
{
@@ -102,7 +102,7 @@
public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionWorkspace workspace = getTransactionWorkspace(gtx);
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
if (workspaceNode != null)
{
@@ -125,7 +125,7 @@
public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionWorkspace workspace = getTransactionWorkspace(gtx);
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
if (workspaceNode != null)
{
@@ -149,7 +149,7 @@
public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionWorkspace workspace = getTransactionWorkspace(gtx);
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
if (ctx.isOriginLocal() && ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
{
@@ -168,7 +168,7 @@
public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionWorkspace workspace = getTransactionWorkspace(gtx);
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
if (workspaceNode != null)
@@ -184,7 +184,7 @@
public Object visitRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionWorkspace workspace = getTransactionWorkspace(gtx);
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
if (workspaceNode != null)
{
@@ -198,7 +198,7 @@
@Override
public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
{
- TransactionWorkspace workspace = getTransactionWorkspace(getGlobalTransaction(ctx));
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
Object result;
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, false);
@@ -222,7 +222,7 @@
@Override
public Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
{
- TransactionWorkspace workspace = getTransactionWorkspace(getGlobalTransaction(ctx));
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
Object result;
Fqn fqn = command.getFqn();
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, fqn, workspace, false, false);
@@ -245,7 +245,7 @@
@Override
public Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
{
- TransactionWorkspace workspace = getTransactionWorkspace(getGlobalTransaction(ctx));
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
Object result;
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, false);
if (workspaceNode == null)
@@ -267,7 +267,7 @@
@Override
public Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
{
- TransactionWorkspace workspace = getTransactionWorkspace(getGlobalTransaction(ctx));
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
Object result;
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, false);
if (workspaceNode == null)
@@ -289,7 +289,7 @@
@Override
public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
{
- TransactionWorkspace workspace = getTransactionWorkspace(getGlobalTransaction(ctx));
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
Object result;
WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, false);
if (workspaceNode == null)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -169,8 +169,7 @@
{
return invokeNextInterceptor(ctx, command);
}
- GlobalTransaction gtx = getGlobalTransaction(ctx);
- if (command.isPutForExternalRead()) txTable.get(gtx).setForceAsyncReplication(true);
+ if (command.isPutForExternalRead()) ctx.getTransactionEntry().setForceAsyncReplication(true);
return invokeNextInterceptor(ctx, command);
}
@@ -196,7 +195,7 @@
// Map method calls to data versioned equivalents.
// See JBCACHE-843 and docs/design/DataVersioning.txt
//TODO: 2.2.0: make the visitor a field
- DataVersionPopulator populator = new DataVersionPopulator(getTransactionWorkspace(gtx));
+ DataVersionPopulator populator = new DataVersionPopulator(getTransactionWorkspace(ctx));
List<ReversibleCommand> clonedModifications = new ArrayList<ReversibleCommand>(command.getModifications().size());
for (ReversibleCommand command1 : command.getModifications())
{
@@ -388,12 +387,12 @@
}
- protected TransactionWorkspace getTransactionWorkspace(GlobalTransaction gtx) throws CacheException
+ protected TransactionWorkspace getTransactionWorkspace(InvocationContext ctx) throws CacheException
{
- OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) txTable.get(gtx);
+ OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) ctx.getTransactionEntry();
if (transactionEntry == null)
{
- throw new CacheException("unable to map global transaction " + gtx + " to transaction entry");
+ throw new CacheException("unable to map global transaction " + ctx + " to transaction entry");
}
// try and get the workspace from the transaction
return transactionEntry.getTransactionWorkSpace();
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -68,7 +68,7 @@
@Override
public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
{
- TransactionWorkspace workspace = getTransactionWorkspace(getGlobalTransaction(ctx));
+ TransactionWorkspace workspace = getTransactionWorkspace(ctx);
// There is no guarantee that this collection is in any order!
Collection<WorkspaceNode> nodes = workspace.getNodes().values();
@@ -146,7 +146,7 @@
TransactionWorkspace workspace;
try
{
- workspace = getTransactionWorkspace(gtx);
+ workspace = getTransactionWorkspace(ctx);
}
catch (CacheException e)
{
@@ -260,7 +260,7 @@
public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
TransactionWorkspace workspace;
- workspace = getTransactionWorkspace(getGlobalTransaction(ctx));
+ workspace = getTransactionWorkspace(ctx);
workspace.clearNodes();
return invokeNextInterceptor(ctx, command);
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -103,7 +103,7 @@
Fqn childFqn = Fqn.fromElements(childName);
NodeSPI childNode = n.getChildDirect(childFqn);
if (childNode == null) childNode = n.addChildDirect(childFqn);
- lockManager.manageReverseRemove(ctx.getGlobalTransaction(), childNode, true, null);
+ lockManager.manageReverseRemove(ctx, childNode, true, null);
n = childNode;
}
}
@@ -122,7 +122,7 @@
if (!command.isOnePhaseCommit()) return invokeNextInterceptor(ctx, command);
// commit propagated up from the tx interceptor
- commit(ctx.getGlobalTransaction());
+ commit(ctx.getTransactionEntry(), ctx.getGlobalTransaction());
Object retVal = invokeNextInterceptor(ctx, command);
txTable.cleanup(ctx.getGlobalTransaction());
return retVal;
@@ -131,7 +131,7 @@
@Override
public Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
- commit(command.getGlobalTransaction());
+ commit(ctx.getTransactionEntry(), command.getGlobalTransaction());
if (trace) log.trace("bypassed locking as method commit() doesn't require locking");
Object retVal = invokeNextInterceptor(ctx, command);
txTable.cleanup(command.getGlobalTransaction());
@@ -141,7 +141,7 @@
@Override
public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
- TransactionEntry entry = txTable.get(command.getGlobalTransaction());
+ TransactionEntry entry = ctx.getTransactionEntry();
if (trace)
{
log.trace("called to rollback cache with GlobalTransaction=" + command.getGlobalTransaction());
@@ -180,7 +180,7 @@
lockManager.lock(ctx, command.getFqn(), NodeLock.LockType.WRITE, false, timeout, true, false, null, false);
if (ctx.getGlobalTransaction() != null)
{
- txTable.get(ctx.getGlobalTransaction()).addRemovedNode(command.getFqn());
+ ctx.getTransactionEntry().addRemovedNode(command.getFqn());
}
lockManager.acquireLocksOnChildren(dataContainer.peek(command.getFqn(), true, false), NodeLock.LockType.WRITE, ctx);
}
@@ -213,7 +213,7 @@
TransactionEntry entry = null;
if (ctx.getGlobalTransaction() != null)
{
- entry = txTable.get(ctx.getGlobalTransaction());
+ entry = ctx.getTransactionEntry();
entry.addRemovedNode(command.getFqn());
for (NodeSPI nodeSPI : createdNodes)
{
@@ -308,10 +308,9 @@
/**
* Remove all locks held by <tt>tx</tt>, remove the transaction from the transaction table
*/
- private void commit(GlobalTransaction gtx)
+ private void commit(TransactionEntry entry, GlobalTransaction gtx)
{
if (trace) log.trace("committing cache with gtx " + gtx);
- TransactionEntry entry = txTable.get(gtx);
if (entry == null)
{
log.error("entry for transaction " + gtx + " not found (maybe already committed)");
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -72,7 +72,7 @@
Object returnValue = invokeNextInterceptor(ctx, command);
if (command.isPutForExternalRead())
{
- txTable.get(command.getGlobalTransaction()).setForceAsyncReplication(true);
+ ctx.getTransactionEntry().setForceAsyncReplication(true);
}
return returnValue;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -349,23 +349,20 @@
// entry for TX in txTable, the modifications
// below will need this entry to add their modifications
// under the GlobalTx key
- TransactionEntry entry;
- if (txTable.get(gtx) == null)
+ TransactionEntry entry = txTable.get(gtx);
+ if (entry == null)
{
// create a new transaction entry
entry = configuration.isNodeLockingOptimistic() ? new OptimisticTransactionEntry(ltx) : new TransactionEntry(ltx);
log.debug("creating new tx entry");
txTable.put(gtx, entry);
+ ctx.setTransactionEntry(entry);
if (trace) log.trace("TxTable contents: " + txTable);
}
- else
- {
- entry = txTable.get(gtx);
- }
setTransactionalContext(ltx, gtx, ctx);
// register a sync handler for this tx.
- registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx), ctx, entry);
+ registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx), ctx);
if (configuration.isNodeLockingOptimistic())
{
@@ -469,7 +466,7 @@
if (optionOverride != null
&& (optionOverride.isForceAsynchronous() || optionOverride.isForceSynchronous()))
{
- TransactionEntry entry = txTable.get(ctx.getGlobalTransaction());
+ TransactionEntry entry = ctx.getTransactionEntry();
if (entry != null)
{
if (optionOverride.isForceAsynchronous())
@@ -803,7 +800,7 @@
log.warn("Commit failed. Clearing stale locks.");
try
{
- cleanupStaleLocks(gtx);
+ cleanupStaleLocks(ctx);
}
catch (RuntimeException re)
{
@@ -823,12 +820,12 @@
}
- private void cleanupStaleLocks(GlobalTransaction gtx) throws Throwable
+ private void cleanupStaleLocks(InvocationContext ctx) throws Throwable
{
- TransactionEntry entry = txTable.get(gtx);
+ TransactionEntry entry = ctx.getTransactionEntry();
if (entry != null)
{
- entry.releaseAllLocksLIFO(gtx);
+ entry.releaseAllLocksLIFO(ctx.getGlobalTransaction());
}
}
@@ -986,7 +983,7 @@
}
// see the comment in the LocalSyncHandler for the last isOriginLocal param.
LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx, tx, !ctx.isOriginLocal());
- registerHandler(tx, myHandler, ctx, txTable.get(gtx));
+ registerHandler(tx, myHandler, ctx);
}
}
else if ((gtx = (GlobalTransaction) rollbackTransactions.get(tx)) != null)
@@ -1008,9 +1005,9 @@
* @param handler
* @throws Exception
*/
- private void registerHandler(Transaction tx, Synchronization handler, InvocationContext ctx, TransactionEntry entry) throws Exception
+ private void registerHandler(Transaction tx, Synchronization handler, InvocationContext ctx) throws Exception
{
- OrderedSynchronizationHandler orderedHandler = entry.getOrderedSynchronizationHandler(); //OrderedSynchronizationHandler.getInstance(tx);
+ OrderedSynchronizationHandler orderedHandler = ctx.getTransactionEntry().getOrderedSynchronizationHandler(); //OrderedSynchronizationHandler.getInstance(tx);
if (trace) log.trace("registering for TX completion: SynchronizationHandler(" + handler + ")");
@@ -1161,6 +1158,7 @@
modifications = entry.getModifications();
ctx = invocationContextContainer.get();
+ ctx.setTransactionEntry(entry);
if (ctx.isOptionsUninitialised() && entry.getOption() != null) ctx.setOptionOverrides(entry.getOption());
assertCanContinue();
@@ -1179,6 +1177,7 @@
}
entry = txTable.get(gtx);
+ ctx.setTransactionEntry(entry);
if (ctx.isOptionsUninitialised() && entry != null && entry.getOption() != null)
{
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -148,7 +148,7 @@
// actually acquire the lock we need. This method blocks.
acquireNodeLock(ctx, currentNode, owner, gtx, lockTypeRequired, timeout);
- manageReverseRemove(gtx, currentNode, reverseRemoveCheck, createdNodes);
+ manageReverseRemove(ctx, currentNode, reverseRemoveCheck, createdNodes);
// make sure the lock we acquired isn't on a deleted node/is an orphan!!
// look into invalidated nodes as well
NodeSPI repeek = dataContainer.peek(currentNodeFqn, true, true);
@@ -257,18 +257,18 @@
* Test if this node needs to be 'undeleted'
* reverse the "remove" if the node has been previously removed in the same tx, if this operation is a put()
*/
- public void manageReverseRemove(GlobalTransaction gtx, NodeSPI childNode, boolean reverseRemoveCheck, List createdNodes)
+ public void manageReverseRemove(InvocationContext ctx, NodeSPI childNode, boolean reverseRemoveCheck, List createdNodes)
{
- if (gtx != null) //if no tx then reverse remove does not make sense
+ if (ctx.getGlobalTransaction() != null) //if no tx then reverse remove does not make sense
{
Fqn fqn = childNode.getFqn();
- TransactionEntry entry = txTable.get(gtx);
+ TransactionEntry entry = ctx.getTransactionEntry();
boolean needToReverseRemove = reverseRemoveCheck && childNode.isDeleted() && isNodeRemovedInCurrentTransaction(entry, fqn);
if (!needToReverseRemove) return;
childNode.markAsDeleted(false);
//if we'll rollback the tx data should be added to the node again
Map oldData = new HashMap(childNode.getDataDirect());
- PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(gtx, fqn, oldData, false, false);
+ PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(ctx.getGlobalTransaction(), fqn, oldData, false, false);
// txTable.get(gtx).addUndoOperation(command); --- now need to make sure this is added to the normal mods list instead
entry.addModification(command);
//we're prepared for rollback, now reset the node
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -52,6 +52,8 @@
*/
protected final Map<GlobalTransaction, TransactionEntry> gtx2EntryMap = new ConcurrentHashMap<GlobalTransaction, TransactionEntry>();
+ protected final Map<GlobalTransaction, Transaction> gtx2TxMap = new ConcurrentHashMap<GlobalTransaction, Transaction>();
+
private TransactionManager transactionManager = null;
private RPCManager rpcManager;
@@ -101,9 +103,7 @@
}
/**
- * Returns the local transaction associated with a GlobalTransaction. Not
- * very efficient as the values have to be iterated over, don't use
- * frequently
+ * Returns the local transaction associated with a GlobalTransaction.
*
* @param gtx The GlobalTransaction
* @return Transaction. The local transaction associated with a given
@@ -112,20 +112,8 @@
*/
public Transaction getLocalTransaction(GlobalTransaction gtx)
{
- if (gtx == null)
- return null;
- Transaction localTx;
- GlobalTransaction globalTx;
- for (Map.Entry<Transaction, GlobalTransaction> entry : tx2gtxMap.entrySet())
- {
- localTx = entry.getKey();
- globalTx = entry.getValue();
- if (gtx.equals(globalTx))
- {
- return localTx;
- }
- }
- return null;
+ if (gtx == null) return null;
+ return gtx2TxMap.get(gtx);
}
/**
@@ -160,6 +148,7 @@
return;
}
tx2gtxMap.put(tx, gtx);
+ gtx2TxMap.put(gtx, tx);
}
/**
@@ -190,6 +179,7 @@
public TransactionEntry remove(GlobalTransaction tx)
{
if (tx == null) return null;
+ gtx2TxMap.remove(tx);
return gtx2EntryMap.remove(tx);
}
@@ -205,6 +195,7 @@
public void remove(GlobalTransaction gtx, Transaction tx)
{
+ gtx2TxMap.remove(gtx);
gtx2EntryMap.remove(gtx);
tx2gtxMap.remove(tx);
}
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java 2008-05-09 17:14:22 UTC (rev 5823)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java 2008-05-09 17:57:36 UTC (rev 5824)
@@ -219,7 +219,7 @@
@Override
public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
{
- TransactionWorkspace w = getTransactionWorkspace(ctx.getGlobalTransaction());
+ TransactionWorkspace w = getTransactionWorkspace(ctx);
Map nodeMap = w.getNodes();
for (Iterator i = nodeMap.keySet().iterator(); i.hasNext();)
{
16 years, 7 months
JBoss Cache SVN: r5823 - core/trunk/src/main/java/org/jboss/cache/commands/read.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 13:14:22 -0400 (Fri, 09 May 2008)
New Revision: 5823
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
Log:
Breaks Maven site builds
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-05-09 17:06:27 UTC (rev 5822)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-05-09 17:14:22 UTC (rev 5823)
@@ -67,6 +67,7 @@
* @param ctx invocation context
* @return a {@link org.jboss.cache.buddyreplication.GravitateResult} containing node data, as well as information on whether this was found in a primary or backup tree.
*/
+ @SuppressWarnings("unchecked")
public Object perform(InvocationContext ctx)
{
// for now, perform a very simple series of getData calls.
@@ -100,7 +101,6 @@
Fqn backupRoot = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, childName);
if (BuddyFqnTransformer.isDeadBackupRoot(backupRoot))
{
- @SuppressWarnings("unchecked")
Set<Integer> deadChildNames = new TreeSet<Integer>(spi.getChildrenNames(backupRoot));
Integer[] elems = deadChildNames.toArray(new Integer[deadChildNames.size()]);
16 years, 7 months
JBoss Cache SVN: r5822 - core/trunk/src/test/java/org/jboss/cache/profiling.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 13:06:27 -0400 (Fri, 09 May 2008)
New Revision: 5822
Added:
core/trunk/src/test/java/org/jboss/cache/profiling/ConstructionTest.java
Modified:
core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
Log:
Added profiling tests
Added: core/trunk/src/test/java/org/jboss/cache/profiling/ConstructionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ConstructionTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ConstructionTest.java 2008-05-09 17:06:27 UTC (rev 5822)
@@ -0,0 +1,38 @@
+package org.jboss.cache.profiling;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.testng.annotations.Test;
+
+/**
+ * Profile LOCAL mode operation
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.2.0
+ */
+@Test(groups = "profiling")
+public class ConstructionTest
+{
+ Cache cache;
+ private static final int WARMUP = 1000;
+ private static final int LOOPS = 5000;
+
+ public void testConstruction() throws InterruptedException
+ {
+ for (int i = 0; i < WARMUP; i++) new DefaultCacheFactory().createCache();
+ System.out.println("Finished warmup.");
+ System.gc();
+ Thread.sleep(1000);
+ System.out.println("Starting test");
+ doConstructionTest();
+ }
+
+ public void doConstructionTest()
+ {
+ for (int i = 0; i < LOOPS; i++)
+ {
+ new DefaultCacheFactory().createCache();
+ if (i % 100 == 0) System.out.println("In loop num " + i);
+ }
+ }
+}
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2008-05-09 17:06:20 UTC (rev 5821)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2008-05-09 17:06:27 UTC (rev 5822)
@@ -48,6 +48,19 @@
private Log log = LogFactory.getLog(ProfileTest.class);
+ public void testLocalModePess() throws Exception
+ {
+ cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+ runCompleteTest();
+ }
+
+ public void testLocalModeOpt() throws Exception
+ {
+ cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.OPTIMISTIC);
+ runCompleteTest();
+ }
+
public void testReplSync() throws Exception
{
runCompleteTest();
16 years, 7 months
JBoss Cache SVN: r5821 - in core/trunk/src/main/java/org/jboss/cache: util/reflect and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 13:06:20 -0400 (Fri, 09 May 2008)
New Revision: 5821
Removed:
core/trunk/src/main/java/org/jboss/cache/util/reflect/CachedMethod.java
Modified:
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java
Log:
Removed unnecessary class
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-09 12:32:19 UTC (rev 5820)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-09 17:06:20 UTC (rev 5821)
@@ -16,7 +16,6 @@
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.util.BeanUtils;
-import org.jboss.cache.util.reflect.CachedMethod;
import org.jboss.cache.util.reflect.ReflectionUtil;
import javax.management.MBeanServerFactory;
@@ -25,7 +24,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -72,9 +70,6 @@
// component and method containers
final Map<String, Component> componentLookup = new HashMap<String, Component>();
- final List<PrioritizedMethod> startMethods = new ArrayList<PrioritizedMethod>();
- final List<PrioritizedMethod> stopMethods = new ArrayList<PrioritizedMethod>();
- final List<PrioritizedMethod> destroyMethods = new ArrayList<PrioritizedMethod>();
CacheStatus state = CacheStatus.INSTANTIATED;
@@ -88,7 +83,6 @@
*/
private boolean invokedFromShutdownHook;
-
/**
* Creates an instance of the component registry. The configuration passed in is automatically registered.
*
@@ -132,10 +126,12 @@
{
try
{
- List<CachedMethod> methods = ReflectionUtil.getAllCachedMethods(target.getClass(), Inject.class);
+ // don't use the reflection cache for wireDependencies calls since these are not managed by the ComponentRegistry
+ // and may be invoked at any time, even after the cache starts.
+ List<Method> methods = ReflectionUtil.getAllMethods(target.getClass(), Inject.class);
// search for anything we need to inject
- for (CachedMethod method : methods) invokeInjectionMethod(target, method);
+ for (Method method : methods) invokeInjectionMethod(target, method);
}
catch (Exception e)
{
@@ -208,6 +204,7 @@
{
if (trace) log.trace("Replacing old component " + old + " with new instance " + component);
old.instance = component;
+ old.methodsScanned = false;
c = old;
if (state == CacheStatus.STARTED) populateLifecycleMethods();
@@ -234,13 +231,13 @@
protected void addComponentDependencies(Component c)
{
Class type = c.instance.getClass();
- List<CachedMethod> methods = ReflectionUtil.getAllCachedMethods(type, Inject.class);
+ List<Method> methods = ReflectionUtil.getAllMethods(type, Inject.class);
c.injectionMethods.clear();
- for (CachedMethod m : methods) c.injectionMethods.add(m);
+ c.injectionMethods.addAll(methods);
}
@SuppressWarnings("unchecked")
- protected void invokeInjectionMethod(Object o, CachedMethod m)
+ protected void invokeInjectionMethod(Object o, Method m)
{
Class[] dependencies = m.getParameterTypes();
Object[] params = new Object[dependencies.length];
@@ -250,7 +247,7 @@
params[i] = getOrCreateComponent(dependencies[i]);
}
- ReflectionUtil.invokeAccessibly(o, m.getMethod(), params);
+ ReflectionUtil.invokeAccessibly(o, m, params);
}
/**
@@ -478,54 +475,46 @@
*/
private void populateLifecycleMethods()
{
- // cache a list of the start annotated methods
- startMethods.clear();
for (Component c : componentLookup.values())
{
- List<Method> methods = ReflectionUtil.getAllMethods(c.instance.getClass(), Start.class);
- for (Method m : methods)
+ if (!c.methodsScanned)
{
- PrioritizedMethod em = new PrioritizedMethod();
- em.component = c;
- em.method = m;
- em.priority = m.getAnnotation(Start.class).priority();
- startMethods.add(em);
- }
- }
+ c.methodsScanned = true;
+ c.startMethods.clear();
+ c.stopMethods.clear();
+ c.destroyMethods.clear();
- // cache a list of the stop annotated methods
- stopMethods.clear();
- for (Component c : componentLookup.values())
- {
- List<Method> methods = ReflectionUtil.getAllMethods(c.instance.getClass(), Stop.class);
- for (Method m : methods)
- {
- PrioritizedMethod em = new PrioritizedMethod();
- em.component = c;
- em.method = m;
- em.priority = m.getAnnotation(Stop.class).priority();
- stopMethods.add(em);
- }
- }
+ List<Method> methods = ReflectionUtil.getAllMethods(c.instance.getClass(), Start.class);
+ for (Method m : methods)
+ {
+ PrioritizedMethod em = new PrioritizedMethod();
+ em.component = c;
+ em.method = m;
+ em.priority = m.getAnnotation(Start.class).priority();
+ c.startMethods.add(em);
+ }
- // cache a list of the destroy annotated methods
- destroyMethods.clear();
- for (Component c : componentLookup.values())
- {
- List<Method> methods = ReflectionUtil.getAllMethods(c.instance.getClass(), Destroy.class);
- for (Method m : methods)
- {
- PrioritizedMethod em = new PrioritizedMethod();
- em.component = c;
- em.method = m;
- em.priority = m.getAnnotation(Destroy.class).priority();
- destroyMethods.add(em);
+ methods = ReflectionUtil.getAllMethods(c.instance.getClass(), Stop.class);
+ for (Method m : methods)
+ {
+ PrioritizedMethod em = new PrioritizedMethod();
+ em.component = c;
+ em.method = m;
+ em.priority = m.getAnnotation(Stop.class).priority();
+ c.startMethods.add(em);
+ }
+
+ methods = ReflectionUtil.getAllMethods(c.instance.getClass(), Destroy.class);
+ for (Method m : methods)
+ {
+ PrioritizedMethod em = new PrioritizedMethod();
+ em.component = c;
+ em.method = m;
+ em.priority = m.getAnnotation(Destroy.class).priority();
+ c.startMethods.add(em);
+ }
}
}
-
- Collections.sort(startMethods);
- Collections.sort(stopMethods);
- Collections.sort(destroyMethods);
}
/**
@@ -722,6 +711,12 @@
// first cache all start, stop and destroy methods.
populateLifecycleMethods();
+ List<PrioritizedMethod> startMethods = new ArrayList<PrioritizedMethod>(componentLookup.size());
+ for (Component c : componentLookup.values()) startMethods.addAll(c.startMethods);
+
+ // sort the start methods by priority
+ Collections.sort(startMethods);
+
// fire all START methods according to priority
for (PrioritizedMethod em : startMethods) em.invoke();
@@ -776,6 +771,11 @@
// if this is called from a source other than the shutdown hook, deregister the shutdown hook.
if (!invokedFromShutdownHook && shutdownHook != null) Runtime.getRuntime().removeShutdownHook(shutdownHook);
+ List<PrioritizedMethod> stopMethods = new ArrayList<PrioritizedMethod>(componentLookup.size());
+ for (Component c : componentLookup.values()) stopMethods.addAll(c.stopMethods);
+
+ Collections.sort(stopMethods);
+
// fire all STOP methods according to priority
for (PrioritizedMethod em : stopMethods) em.invoke();
@@ -792,6 +792,11 @@
resetNonVolatile();
+ List<PrioritizedMethod> destroyMethods = new ArrayList<PrioritizedMethod>(componentLookup.size());
+ for (Component c : componentLookup.values()) destroyMethods.addAll(c.destroyMethods);
+
+ Collections.sort(destroyMethods);
+
// fire all DESTROY methods according to priority
for (PrioritizedMethod em : destroyMethods) em.invoke();
@@ -878,10 +883,14 @@
* The name of the component
*/
String name;
+ boolean methodsScanned;
/**
* List of injection methods used to inject dependencies into the component
*/
- List<CachedMethod> injectionMethods = new LinkedList<CachedMethod>();
+ List<Method> injectionMethods = new ArrayList<Method>(2);
+ List<PrioritizedMethod> startMethods = new ArrayList<PrioritizedMethod>(2);
+ List<PrioritizedMethod> stopMethods = new ArrayList<PrioritizedMethod>(2);
+ List<PrioritizedMethod> destroyMethods = new ArrayList<PrioritizedMethod>(2);
/**
* If true, then this component is not flushed before starting the ComponentRegistry.
*/
@@ -902,7 +911,7 @@
*/
public void injectDependencies()
{
- for (CachedMethod m : injectionMethods) invokeInjectionMethod(instance, m);
+ for (Method m : injectionMethods) invokeInjectionMethod(instance, m);
}
}
Deleted: core/trunk/src/main/java/org/jboss/cache/util/reflect/CachedMethod.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/reflect/CachedMethod.java 2008-05-09 12:32:19 UTC (rev 5820)
+++ core/trunk/src/main/java/org/jboss/cache/util/reflect/CachedMethod.java 2008-05-09 17:06:20 UTC (rev 5821)
@@ -1,39 +0,0 @@
-package org.jboss.cache.util.reflect;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-
-/**
- * A cached Method object, so that calls to getParameterTypes, getAnnotations, etc are cached.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 2.1.0
- */
-public class CachedMethod
-{
- Method method;
- Class[] parameterTypes;
- Annotation[][] parameterAnnotations;
-
- public CachedMethod(Method method)
- {
- this.method = method;
- this.parameterTypes = method.getParameterTypes();
- this.parameterAnnotations = method.getParameterAnnotations();
- }
-
- public Method getMethod()
- {
- return method;
- }
-
- public Class[] getParameterTypes()
- {
- return parameterTypes;
- }
-
- public Annotation[][] getParameterAnnotations()
- {
- return parameterAnnotations;
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java 2008-05-09 12:32:19 UTC (rev 5820)
+++ core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java 2008-05-09 17:06:20 UTC (rev 5821)
@@ -38,21 +38,6 @@
}
/**
- * Returns a set of Methods that contain the given method annotation. This includes all public, protected, package and private
- * methods, as well as those of superclasses. Note that this does *not* include overridden methods.
- *
- * @param c class to inspect
- * @param annotationType the type of annotation to look for
- * @return List of Method objects that require injection.
- */
- public static List<CachedMethod> getAllCachedMethods(Class c, Class<? extends Annotation> annotationType)
- {
- List<CachedMethod> annotated = new LinkedList<CachedMethod>();
- inspectRecursivelyCached(c, annotated, annotationType);
- return annotated;
- }
-
- /**
* Inspects a class and it's superclasses (all the way to {@link Object} for method instances that contain a given annotation.
* This even identifies private, package and protected methods, not just public ones.
*
@@ -76,29 +61,6 @@
}
/**
- * Inspects a class and it's superclasses (all the way to {@link Object} for method instances that contain a given annotation.
- * This even identifies private, package and protected methods, not just public ones.
- *
- * @param c
- * @param s
- * @param annotationType
- */
- private static void inspectRecursivelyCached(Class c, List<CachedMethod> s, Class<? extends Annotation> annotationType)
- {
- // Superclass first
- if (!c.equals(Object.class)) inspectRecursivelyCached(c.getSuperclass(), s, annotationType);
-
- for (Method m : c.getDeclaredMethods())
- {
- // don't bother if this method has already been overridden by a subclass
- if (!alreadyFoundCached(m, s) && m.isAnnotationPresent(annotationType))
- {
- s.add(new CachedMethod(m));
- }
- }
- }
-
- /**
* Tests whether a method has already been found, i.e., overridden.
*
* @param m method to inspect
@@ -116,24 +78,6 @@
return false;
}
- /**
- * Tests whether a method has already been found, i.e., overridden.
- *
- * @param m method to inspect
- * @param s collection of methods found
- * @return true a method with the same signature already exists.
- */
- private static boolean alreadyFoundCached(Method m, Collection<CachedMethod> s)
- {
- for (CachedMethod found : s)
- {
- if (m.getName().equals(found.getMethod().getName()) &&
- Arrays.equals(m.getParameterTypes(), found.getParameterTypes()))
- return true;
- }
- return false;
- }
-
public static void setValue(Object instance, String fieldName, Object value)
{
try
16 years, 7 months