JBoss Cache SVN: r6931 - core/trunk/src/main/tutorial.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-14 08:07:32 -0400 (Tue, 14 Oct 2008)
New Revision: 6931
Modified:
core/trunk/src/main/tutorial/build.xml
Log:
Tutorial GUI launcher script
Modified: core/trunk/src/main/tutorial/build.xml
===================================================================
--- core/trunk/src/main/tutorial/build.xml 2008-10-14 12:01:12 UTC (rev 6930)
+++ core/trunk/src/main/tutorial/build.xml 2008-10-14 12:07:32 UTC (rev 6931)
@@ -21,44 +21,56 @@
</path>
<target name="help">
- <echo>
- ________________ _________ ______
- ______ /__ __ )____________________ __ ____/_____ _________ /______
- ___ _ /__ __ | __ \_ ___/_ ___/ _ / _ __ `/ ___/_ __ \ _ \
- / /_/ / _ /_/ // /_/ /(__ )_(__ ) / /___ / /_/ // /__ _ / / / __/
- \____/ /_____/ \____//____/ /____/ \____/ \__,_/ \___/ /_/ /_/\___/
+ <echo><![CDATA[
+ _________ _____ _
+ |_ | ___ \ / __ \ | |
+ | | |_/ / ___ ___ ___ | / \/ __ _ ___| |__ ___
+ | | ___ \/ _ \/ __/ __| | | / _` |/ __| '_ \ / _ \
+/\__/ / |_/ / (_) \__ \__ \ | \__/\ (_| | (__| | | | __/
+\____/\____/ \___/|___/___/ \____/\__,_|\___|_| |_|\___|
- ________ _____ _____ ______
- ___ __/___ ___ /________________(_)_____ ___ /
- __ / _ / / / __/ __ \_ ___/_ /_ __ `/_ /
- _ / / /_/ // /_ / /_/ / / _ / / /_/ /_ /
- /_/ \__,_/ \__/ \____//_/ /_/ \__,_/ /_/
+ _____ _ _ _
+|_ _| | | (_) | |
+ | |_ _| |_ ___ _ __ _ __ _| |
+ | | | | | __/ _ \| '__| |/ _` | |
+ | | |_| | || (_) | | | | (_| | |
+ \_/\__,_|\__\___/|_| |_|\__,_|_|
- ----------------------------------------------------------------------------
- To run the tutorial, type "ant run"
- </echo>
+
+----------------------------------------------------------
+
+To run the tutorial, type "ant run"
+
+ ]]></echo>
</target>
<target name="run">
- <echo>
- ________________ _________ ______
- ______ /__ __ )____________________ __ ____/_____ _________ /______
- ___ _ /__ __ | __ \_ ___/_ ___/ _ / _ __ `/ ___/_ __ \ _ \
- / /_/ / _ /_/ // /_/ /(__ )_(__ ) / /___ / /_/ // /__ _ / / / __/
- \____/ /_____/ \____//____/ /____/ \____/ \__,_/ \___/ /_/ /_/\___/
+ <echo><![CDATA[
+ _________ _____ _
+ |_ | ___ \ / __ \ | |
+ | | |_/ / ___ ___ ___ | / \/ __ _ ___| |__ ___
+ | | ___ \/ _ \/ __/ __| | | / _` |/ __| '_ \ / _ \
+/\__/ / |_/ / (_) \__ \__ \ | \__/\ (_| | (__| | | | __/
+\____/\____/ \___/|___/___/ \____/\__,_|\___|_| |_|\___|
- ________ _____ _____ ______
- ___ __/___ ___ /________________(_)_____ ___ /
- __ / _ / / / __/ __ \_ ___/_ /_ __ `/_ /
- _ / / /_/ // /_ / /_/ / / _ / / /_/ /_ /
- /_/ \__,_/ \__/ \____//_/ /_/ \__,_/ /_/
+ _____ _ _ _
+|_ _| | | (_) | |
+ | |_ _| |_ ___ _ __ _ __ _| |
+ | | | | | __/ _ \| '__| |/ _` | |
+ | | |_| | || (_) | | | | (_| | |
+ \_/\__,_|\__\___/|_| |_|\__,_|_|
- ----------------------------------------------------------------------------
- </echo>
+
+----------------------------------------------------------
+
+Starting GUI ...
+
+ ]]></echo>
+
<java classname="${className}" classpathref="classpath" fork="true">
<jvmarg value="${jvm.ipv4}"/>
<jvmarg value="${jvm.localhost}"/>
16 years, 2 months
JBoss Cache SVN: r6930 - core/trunk/src/main/docbook/tutorial/en.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-14 08:01:12 -0400 (Tue, 14 Oct 2008)
New Revision: 6930
Modified:
core/trunk/src/main/docbook/tutorial/en/master.xml
Log:
Updated tutorial for 3.0
Modified: core/trunk/src/main/docbook/tutorial/en/master.xml
===================================================================
--- core/trunk/src/main/docbook/tutorial/en/master.xml 2008-10-14 11:19:00 UTC (rev 6929)
+++ core/trunk/src/main/docbook/tutorial/en/master.xml 2008-10-14 12:01:12 UTC (rev 6930)
@@ -71,29 +71,26 @@
<literal>jbosscache-core-3.X.Y</literal>
.
For the sake of this tutorial, I will refer to this as
- <literal>JBossCache</literal>
+ <literal>${JBOSSCACHE_HOME}</literal>
.
</para>
- <para>The configuration files are located in the
- <literal>etc</literal>
- directory of the distribution. You can
+ <para>The configuration files are located in
+ <literal>${JBOSSCACHE_HOME}/etc</literal>. You can
modify the behavior of the cache by editing the various configuration files.
</para>
<itemizedlist>
<listitem>
<para>
- <literal>log4j.xml</literal>
- . Logging output. You can enable logging, specify log levels or
+ <literal>log4j.xml</literal> - Logging output. You can enable logging, specify log levels or
change the name and path to the log file.
</para>
</listitem>
<listitem>
<para>
- <literal>config-samples/total-replication.xml</literal>
- . Cache configuration file used for this tutorial.
+ <literal>config-samples/total-replication.xml</literal> - Cache configuration file used for this tutorial.
</para>
</listitem>
</itemizedlist>
@@ -103,47 +100,44 @@
<title>Script</title>
<para>The only script needed for this tutorial is the
- <literal>JBossCache/tutorial/build.xml</literal>
+ <literal>${JBOSSCACHE_HOME}/tutorial/build.xml</literal>
ant script. You also need to have
- <ulink url="http://ant.apache.org/">ant</ulink>
- installed for running the demo.
+ <ulink url="http://ant.apache.org/">Apache Ant</ulink>
+ installed for running the tutorial GUI.
</para>
</section>
<section>
- <title>Running The Demo GUI</title>
+ <title>Running The Tutorial GUI</title>
<para>
- The demo is run by:
- <ol>
- <li>Changing to the
- <literal>tutorial</literal>
- directory (e.g.,<literal>cd tutorial</literal>)
- </li>
- <li>And then running the ant script (e.g.,<literal>ant run</literal>)
- </li>
- </ol>
+ The GUI is run by:
+ <itemizedlist>
+ <listitem>Changing to the
+ <literal>${JBOSSCACHE_HOME}/tutorial</literal>
+ directory (e.g.,<literal>cd ${JBOSSCACHE_HOME}/tutorial</literal>)</listitem>
+ <listitem>And then running the ant script (e.g.,<literal>ant run</literal>)</listitem>
+ </itemizedlist>
</para>
<para>
This will cause a GUI window to appear, giving you a tree view of the cache in the top pane and a BeanShell
- view
- of the JVM in the lower pane.
+ view of the JVM in the lower pane.
</para>
<para>
The BeanShell view is preset with the following variables:
<itemizedlist>
<listitem>
<literal>cache</literal>
- - a reference to the Cache interface, used by the GUI instance.
+ - a reference to the <literal>org.jboss.cache.Cache</literal> interface, used by the GUI instance.
</listitem>
<listitem>
<literal>root</literal>
- - a reference to the root Node instance for the above cache.
+ - a reference to the root <literal>org.jboss.cache.Node</literal> instance for the above cache.
</listitem>
<listitem>
<literal>transactionManager</literal>
- - a reference to the registered transaction manager.
+ - a reference to the registered <literal>javax.transaction.TransactionManager</literal> instance.
</listitem>
</itemizedlist>
The references made available to the BeanShell window point to the same cache instance used by the tree view in
@@ -152,22 +146,21 @@
</para>
<para>
- To run the demo as a replicated demo, it is useful to start another command line window and run the ant script
+ To run the GUI as a replicated tutorial, it is useful to start another command line window and run the ant script
again as you did above. Now you will have two cache instances running in two separate GUIs, replicating state
- to
- each other.
+ to each other.
</para>
</section>
<section>
<title>Tutorials</title>
- Note that it is recommended that you shut down and restart the demo GUI for each of the following tutorials, to
+ Note that it is recommended that you shut down and restart the GUI for each of the following tutorials, to
ensure clean caches every time.
<section>
<title>Caches and Nodes</title>
<para>
- For this tutorial, start a single instance of the demo GUI. In this tutorial, we will:
+ For this tutorial, start a single instance of the GUI. In this tutorial, we will:
<itemizedlist>
<listitem>Create nodes under the root node.</listitem>
@@ -238,9 +231,7 @@
<literal>Cache</literal>
and
<literal>Node</literal>
- <ulink
- url="http://labs.jboss.org/portal/jbosscache/docs/index.html">API docs
- </ulink>
+ <ulink url="http://labs.jboss.org/portal/jbosscache/docs/index.html">API docs</ulink>
and try out the APIs in the BeanShell script.
</para>
</section>
@@ -248,7 +239,7 @@
<section>
<title>Replication</title>
<para>
- For this tutorial, start two instances instance of the demo GUI. Repeat the exercises in the previous
+ For this tutorial, start two instances instance of the GUI. Repeat the exercises in the previous
tutorial,
only alternating between the two GUI windows when creating/removing nodes or adding/removing data. This
demonstrates
@@ -259,7 +250,7 @@
<section>
<title>Transactions</title>
<para>
- For this tutorial, start two instances instance of the demo GUI. Repeat the exercises in the previous
+ For this tutorial, start two instances instance of the GUI. Repeat the exercises in the previous
tutorial,
only starting transactions before creating/removing nodes or adding/removing data. This will depict how
replication only occurs on transaction boundaries. Try rolling back a few transactions as well, to see how
@@ -270,7 +261,7 @@
tm = cache.getTransactionManager();
tm.begin();
// do operations here
- tm.commit(); // tm.rollback();
+ tm.commit(); // or tm.rollback();
]]></programlisting>
</section>
16 years, 2 months
JBoss Cache SVN: r6929 - core/trunk/src/test/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-14 07:19:00 -0400 (Tue, 14 Oct 2008)
New Revision: 6929
Modified:
core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
Log:
Internal cleanups
Modified: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-10-14 09:38:28 UTC (rev 6928)
+++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-10-14 11:19:00 UTC (rev 6929)
@@ -16,7 +16,8 @@
import org.jboss.cache.util.TestingUtil;
import java.io.InputStream;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -35,13 +36,12 @@
*/
private static final ThreadLocal<String> threadMcastIP = new ThreadLocal<String>()
{
-
private final AtomicInteger uniqueAddr = new AtomicInteger(11);
@Override
protected String initialValue()
{
- return "228.10.10." + String.valueOf(uniqueAddr.getAndIncrement());
+ return "228.10.10." + uniqueAddr.getAndIncrement();
}
};
@@ -50,7 +50,6 @@
*/
private static final ThreadLocal<Integer> threadMcastPort = new ThreadLocal<Integer>()
{
-
private final AtomicInteger uniquePort = new AtomicInteger(45589);
@Override
@@ -63,19 +62,17 @@
/**
* For each thread holds list of caches created using this factory.
*/
- private static final ThreadLocal<Vector<Cache>> threadCaches =
- new ThreadLocal<Vector<Cache>>()
+ private static final ThreadLocal<List<Cache>> threadCaches =
+ new ThreadLocal<List<Cache>>()
{
-
-
@Override
- protected Vector<Cache> initialValue()
+ protected List<Cache> initialValue()
{
- return new Vector<Cache>();
+ return new ArrayList<Cache>();
}
};
- private static Vector<Cache> allCaches = new Vector<Cache>();
+ private final static List<Cache> allCaches = new ArrayList<Cache>();
/**
* For each thread holds the name of the test class which executed createCache factory method.
@@ -135,14 +132,12 @@
public Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException
{
+ // - Do not print out this exception - since tests are ALSO run from IDEs on the main thread. - MANIK
+// if (!Thread.currentThread().getName().contains("pool"))
+// {
+// System.out.println("CreateCache called from wrong thread: " + Thread.currentThread().getName());
+// }
- if (!Thread.currentThread().getName().contains("pool"))
- {
- System.out.println("CreateCache called from wrong thread: " + Thread.currentThread().getName());
- //Thread.dumpStack();
- //System.exit(-1);
- }
-
checkCaches();
switch (configuration.getCacheMode())
@@ -163,7 +158,7 @@
Cache<K, V> cache = new DefaultCacheFactory<K, V>().createCache(configuration, start);
- Vector<Cache> caches = threadCaches.get();
+ List<Cache> caches = threadCaches.get();
caches.add(cache);
synchronized (allCaches)
@@ -181,7 +176,7 @@
*/
public boolean cleanUp()
{
- Vector<Cache> caches = new Vector<Cache>(threadCaches.get());
+ List<Cache> caches = new ArrayList<Cache>(threadCaches.get());
boolean ret = false;
for (Cache cache : caches)
@@ -195,14 +190,13 @@
public void removeCache(Cache c)
{
- if (!Thread.currentThread().getName().contains("pool"))
- {
- System.out.println("RemoveCache called from wrong thread.");
- //Thread.dumpStack();
- //System.exit(-1);
- }
+ // - Do not print out this exception - since tests are ALSO run from IDEs on the main thread. - MANIK
+// if (!Thread.currentThread().getName().contains("pool"))
+// {
+// System.out.println("RemoveCache called from wrong thread.");
+// }
- Vector<Cache> caches = threadCaches.get();
+ List<Cache> caches = threadCaches.get();
synchronized (allCaches)
{
if (caches.contains(c))
@@ -240,7 +234,7 @@
// System.out.println(getThreadId() + " Setting cluster name " + newClusterName);
}
- String testName = extractTestName();
+// String testName = extractTestName();
// prepend test name
/*
@@ -255,8 +249,6 @@
/**
* Updates cluster configuration to ensure mutual thread isolation.
- *
- * @param configuration Configuration to update.
*/
public String mangleClusterConfiguration(String clusterConfig)
{
@@ -299,7 +291,7 @@
m = pattern.matcher(clusterConfig);
if (m.find())
{
- String origPort = m.group().substring(m.group().indexOf("=") + 1);
+// String origPort = m.group().substring(m.group().indexOf("=") + 1);
String newPort = threadMcastPort.get().toString();
// System.out.println(getThreadId() + " Replacing mcast_port " + origPort + " with " + newPort);
clusterConfig = m.replaceFirst("mcast_port=" + newPort);
@@ -308,10 +300,10 @@
return clusterConfig;
}
- private String getThreadId()
- {
- return "[" + Thread.currentThread().getName() + "]";
- }
+// private String getThreadId()
+// {
+// return "[" + Thread.currentThread().getName() + "]";
+// }
private void checkCaches()
{
16 years, 2 months
JBoss Cache SVN: r6928 - in core/trunk/src/test/java/org/jboss/cache: util/internals and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-14 05:38:28 -0400 (Tue, 14 Oct 2008)
New Revision: 6928
Modified:
core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
Log:
Made this quieter + fixed ReplList
Modified: core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-10-14 09:23:28 UTC (rev 6927)
+++ core/trunk/src/test/java/org/jboss/cache/UnitTestCacheFactory.java 2008-10-14 09:38:28 UTC (rev 6928)
@@ -6,11 +6,6 @@
*/
package org.jboss.cache;
-import java.io.InputStream;
-import java.util.Vector;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.Configuration;
@@ -20,8 +15,13 @@
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.util.TestingUtil;
+import java.io.InputStream;
+import java.util.Vector;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
- *
* @author <a href="mailto:dpospisi@redhat.com">Dominik Pospisil (dpospisi(a)redhat.com)</a>
*/
public class UnitTestCacheFactory<K, V> implements CacheFactory<K, V>
@@ -29,64 +29,78 @@
private final Log log = LogFactory.getLog(UnitTestCacheFactory.class);
-
+
/**
- * Holds unique mcast_addr for each thread used for JGroups channel construction.
+ * Holds unique mcast_addr for each thread used for JGroups channel construction.
*/
- private static final ThreadLocal<String> threadMcastIP = new ThreadLocal<String>() {
+ private static final ThreadLocal<String> threadMcastIP = new ThreadLocal<String>()
+ {
- private final AtomicInteger uniqueAddr = new AtomicInteger(11);
- @Override protected String initialValue() {
+ private final AtomicInteger uniqueAddr = new AtomicInteger(11);
+
+ @Override
+ protected String initialValue()
+ {
return "228.10.10." + String.valueOf(uniqueAddr.getAndIncrement());
- }
+ }
};
-
+
/**
- * Holds unique mcast_port for each thread used for JGroups channel construction.
+ * Holds unique mcast_port for each thread used for JGroups channel construction.
*/
- private static final ThreadLocal<Integer> threadMcastPort = new ThreadLocal<Integer>() {
-
+ private static final ThreadLocal<Integer> threadMcastPort = new ThreadLocal<Integer>()
+ {
+
private final AtomicInteger uniquePort = new AtomicInteger(45589);
-
- @Override protected Integer initialValue() {
+
+ @Override
+ protected Integer initialValue()
+ {
return uniquePort.getAndIncrement();
- }
+ }
};
-
+
/**
- * For each thread holds list of caches created using this factory.
+ * For each thread holds list of caches created using this factory.
*/
private static final ThreadLocal<Vector<Cache>> threadCaches =
- new ThreadLocal<Vector<Cache>>() {
-
-
- @Override protected Vector<Cache> initialValue() {
- return new Vector<Cache>();
- }
- };
-
+ new ThreadLocal<Vector<Cache>>()
+ {
+
+
+ @Override
+ protected Vector<Cache> initialValue()
+ {
+ return new Vector<Cache>();
+ }
+ };
+
private static Vector<Cache> allCaches = new Vector<Cache>();
-
+
/**
* For each thread holds the name of the test class which executed createCache factory method.
*/
private static final ThreadLocal<String> threadTestName = new ThreadLocal<String>();
-
+
// factory methods
-
- public Cache<K, V> createCache() throws ConfigurationException {
+
+ public Cache<K, V> createCache() throws ConfigurationException
+ {
return createCache(true);
}
- public Cache<K, V> createCache(boolean start) throws ConfigurationException {
+ public Cache<K, V> createCache(boolean start) throws ConfigurationException
+ {
return createCache(new Configuration(), start);
}
- public Cache<K, V> createCache(String configFileName) throws ConfigurationException {
+ public Cache<K, V> createCache(String configFileName) throws ConfigurationException
+ {
return createCache(configFileName, true);
}
- public Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException {
+ public Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException
+ {
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c;
try
@@ -102,30 +116,35 @@
return createCache(c, start);
}
- public Cache<K, V> createCache(Configuration configuration) throws ConfigurationException {
+ public Cache<K, V> createCache(Configuration configuration) throws ConfigurationException
+ {
return createCache(configuration, true);
}
- public Cache<K, V> createCache(InputStream is) throws ConfigurationException {
+ public Cache<K, V> createCache(InputStream is) throws ConfigurationException
+ {
return createCache(is, true);
}
- public Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException {
+ public Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException
+ {
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c = parser.parseStream(is);
return createCache(c, start);
}
-
- public Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException {
-
- if (! Thread.currentThread().getName().contains("pool")) {
+
+ public Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException
+ {
+
+ if (!Thread.currentThread().getName().contains("pool"))
+ {
System.out.println("CreateCache called from wrong thread: " + Thread.currentThread().getName());
//Thread.dumpStack();
//System.exit(-1);
}
-
+
checkCaches();
-
+
switch (configuration.getCacheMode())
{
case LOCAL:
@@ -141,74 +160,86 @@
default:
log.info("Unknown cache mode!");
}
-
- Cache<K, V> cache = new DefaultCacheFactory<K, V>().createCache(configuration, start);
+ Cache<K, V> cache = new DefaultCacheFactory<K, V>().createCache(configuration, start);
+
Vector<Cache> caches = threadCaches.get();
caches.add(cache);
-
- synchronized (allCaches) {
+
+ synchronized (allCaches)
+ {
allCaches.add(cache);
}
return cache;
-
+
}
-
+
/**
* Destroys all caches created by this factory in the current thread.
- *
+ *
* @return true if some cleanup was actually performed
*/
- public boolean cleanUp() {
+ public boolean cleanUp()
+ {
Vector<Cache> caches = new Vector<Cache>(threadCaches.get());
boolean ret = false;
-
- for (Cache cache : caches) {
- TestingUtil.killCaches(cache);
+
+ for (Cache cache : caches)
+ {
+ TestingUtil.killCaches(cache);
ret = true;
}
return ret;
}
-
- public void removeCache(Cache c) {
-
- if (! Thread.currentThread().getName().contains("pool")) {
+
+ public void removeCache(Cache c)
+ {
+
+ if (!Thread.currentThread().getName().contains("pool"))
+ {
System.out.println("RemoveCache called from wrong thread.");
//Thread.dumpStack();
//System.exit(-1);
}
-
+
Vector<Cache> caches = threadCaches.get();
- synchronized (allCaches) {
- if (caches.contains(c)) {
+ synchronized (allCaches)
+ {
+ if (caches.contains(c))
+ {
caches.remove(c);
allCaches.remove(c);
- } else if (allCaches.contains(c)) {
+ }
+ else if (allCaches.contains(c))
+ {
System.out.println("[" + Thread.currentThread().getName() + "] WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Remove cache called from different thread.");
Thread.dumpStack();
}
}
}
-
+
/**
* Updates cluster configuration to ensure mutual thread isolation.
+ *
* @param configuration Configuration to update.
*/
- public void mangleConfiguration(Configuration configuration) {
-
- configuration.setClusterConfig(mangleClusterConfiguration(configuration.getClusterConfig()));
+ public void mangleConfiguration(Configuration configuration)
+ {
+
+ configuration.setClusterConfig(mangleClusterConfiguration(configuration.getClusterConfig()));
// Check if the cluster name contains thread id. If not, append.
// We can not just append the threadId, since some of the tests are crating instances
// using configurations derived from configurations returned by this factory.
-
+
String clusterName = configuration.getClusterName();
-
+
// append thread id
- if (clusterName.indexOf(Thread.currentThread().getName()) == -1) {
+ if (clusterName.indexOf(Thread.currentThread().getName()) == -1)
+ {
clusterName = clusterName + "-" + Thread.currentThread().getName();
// System.out.println(getThreadId() + " Setting cluster name " + newClusterName);
}
-
+
String testName = extractTestName();
// prepend test name
@@ -217,86 +248,101 @@
clusterName = testName + "-" + clusterName;
}
*/
-
- configuration.setClusterName(clusterName);
-
+
+ configuration.setClusterName(clusterName);
+
}
/**
* Updates cluster configuration to ensure mutual thread isolation.
+ *
* @param configuration Configuration to update.
*/
- public String mangleClusterConfiguration(String clusterConfig) {
- if (clusterConfig == null) {
+ public String mangleClusterConfiguration(String clusterConfig)
+ {
+ if (clusterConfig == null)
+ {
// No explicit cluster configuration found. we need to resolve the default config
// now in orded to be able to update it before the cache (and the channel) starts.
// TODO: this does not seem to be the best solution :(
clusterConfig = UnitTestCacheConfigurationFactory.getClusterConfigFromFile(
- new Configuration().getDefaultClusterConfig());
-
+ new Configuration().getDefaultClusterConfig());
+
}
-
- if (Thread.currentThread().getName().equals("main")) {
- Exception e = new Exception("Invoked from main thread.");
- e.printStackTrace();
- };
-
+
+ // - Do not print out this exception - since tests are ALSO run from IDEs on the main thread. - MANIK
+//
+// if (Thread.currentThread().getName().equals("main")) {
+// Exception e = new Exception("Invoked from main thread.");
+// e.printStackTrace();
+// };
+
// replace mcast_addr
Pattern pattern = Pattern.compile("mcast_addr=[^;]*");
Matcher m = pattern.matcher(clusterConfig);
- if (m.find()) {
+ if (m.find())
+ {
String origAddr = m.group().substring(m.group().indexOf("=") + 1);
String newAddr = threadMcastIP.get();
// System.out.println(getThreadId() + " Replacing mcast_addr " + origAddr + " with " + newAddr);
clusterConfig = m.replaceFirst("mcast_addr=" + newAddr);
- } else {
+ }
+ else
+ {
Thread.dumpStack();
System.exit(1);
}
-
+
// replace mcast_port
pattern = Pattern.compile("mcast_port=[^;]*");
m = pattern.matcher(clusterConfig);
- if (m.find()) {
+ if (m.find())
+ {
String origPort = m.group().substring(m.group().indexOf("=") + 1);
String newPort = threadMcastPort.get().toString();
- // System.out.println(getThreadId() + " Replacing mcast_port " + origPort + " with " + newPort);
+ // System.out.println(getThreadId() + " Replacing mcast_port " + origPort + " with " + newPort);
clusterConfig = m.replaceFirst("mcast_port=" + newPort);
}
-
+
return clusterConfig;
}
-
- private String getThreadId() {
+
+ private String getThreadId()
+ {
return "[" + Thread.currentThread().getName() + "]";
}
- private void checkCaches() {
+ private void checkCaches()
+ {
String lastTestName = threadTestName.get();
- String currentTestName = extractTestName();
-
- if ((lastTestName != null) && (! lastTestName.equals(currentTestName))) {
+ String currentTestName = extractTestName();
+ if ((lastTestName != null) && (!lastTestName.equals(currentTestName)))
+ {
+
String threadId = "[" + Thread.currentThread().getName() + "] ";
// we are running new test class
// check if there is a cache(s) instance left & kill it if possitive
-
- if (cleanUp()) {
+
+ if (cleanUp())
+ {
System.out.print(threadId + "WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ");
- System.out.print(threadId +" A test method in " + lastTestName + " did not clean all cache instances properly. ");
- System.out.println(threadId +" Use UnitTestCacheFactory.cleanUp() or TestngUtil.killCaches(...) ");
+ System.out.print(threadId + " A test method in " + lastTestName + " did not clean all cache instances properly. ");
+ System.out.println(threadId + " Use UnitTestCacheFactory.cleanUp() or TestngUtil.killCaches(...) ");
}
-
+
}
threadTestName.set(currentTestName);
}
-
- private String extractTestName() {
+
+ private String extractTestName()
+ {
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
if (stack.length == 0) return null;
- for (int i=stack.length-1; i>0; i--) {
+ for (int i = stack.length - 1; i > 0; i--)
+ {
StackTraceElement e = stack[i];
String className = e.getClassName();
if (className.indexOf("org.jboss.cache") != -1) return className; //+ "." + e.getMethodName();
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-10-14 09:23:28 UTC (rev 6927)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-10-14 09:38:28 UTC (rev 6928)
@@ -11,6 +11,7 @@
import org.jboss.cache.io.ByteBuffer;
import org.jboss.cache.marshall.AbstractMarshaller;
import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
+import org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.RegionalizedMethodCall;
import org.jboss.cache.util.TestingUtil;
@@ -61,7 +62,11 @@
RPCManager rpcManager = componentRegistry.getComponent(RPCManager.class);
CommandAwareRpcDispatcher realDispatcher = (CommandAwareRpcDispatcher) TestingUtil.extractField(rpcManager, "rpcDispatcher");
RpcDispatcher.Marshaller2 realMarshaller = (RpcDispatcher.Marshaller2) realDispatcher.getMarshaller();
- MarshallerDelegate delegate = new MarshallerDelegate(realMarshaller);
+ RpcDispatcher.Marshaller2 delegate = null;
+ if (realDispatcher instanceof InactiveRegionAwareRpcDispatcher)
+ delegate = new RegionMarshallerDelegate((Marshaller) realMarshaller);
+ else
+ delegate = new MarshallerDelegate(realMarshaller);
realDispatcher.setMarshaller(delegate);
realDispatcher.setRequestMarshaller(delegate);
realDispatcher.setResponseMarshaller(delegate);
@@ -204,11 +209,6 @@
return realOne.regionalizedMethodCallFromObjectStream(in);
}
- public Object objectFromByteBuffer(byte[] bytes) throws Exception
- {
- return realOne.objectFromByteBuffer(bytes);
- }
-
public ByteBuffer objectToBuffer(Object o) throws Exception
{
return realOne.objectToBuffer(o);
16 years, 2 months
JBoss Cache SVN: r6927 - in core/branches/2.2.X/src: main/java/org/jboss/cache/buddyreplication and 5 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-14 05:23:28 -0400 (Tue, 14 Oct 2008)
New Revision: 6927
Added:
core/branches/2.2.X/src/main/java/org/jboss/cache/io/
core/branches/2.2.X/src/main/java/org/jboss/cache/io/ByteBuffer.java
core/branches/2.2.X/src/main/java/org/jboss/cache/io/ExposedByteArrayOutputStream.java
Removed:
core/branches/2.2.X/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStream.java
Modified:
core/branches/2.2.X/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/Marshaller.java
core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
core/branches/2.2.X/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
core/branches/2.2.X/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
Log:
Ported JBCACHE-1382: Investigate use of ExposedBAOS instead of BAOS when marshalling objects
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-10-13 22:20:04 UTC (rev 6926)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-10-14 09:23:28 UTC (rev 6927)
@@ -31,13 +31,13 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
+import org.jboss.cache.io.ExposedByteArrayOutputStream;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.ViewChanged;
import org.jboss.cache.notifications.event.ViewChangedEvent;
import org.jboss.cache.statetransfer.StateTransferManager;
-import org.jboss.cache.util.ExposedByteArrayOutputStream;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import org.jboss.cache.util.reflect.ReflectionUtil;
import org.jboss.util.stream.MarshalledValueInputStream;
@@ -48,7 +48,18 @@
import org.jgroups.util.Util;
import java.io.ByteArrayInputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.Vector;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
Added: core/branches/2.2.X/src/main/java/org/jboss/cache/io/ByteBuffer.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/io/ByteBuffer.java (rev 0)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/io/ByteBuffer.java 2008-10-14 09:23:28 UTC (rev 6927)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.io;
+
+import org.jgroups.util.Buffer;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+/**
+ * A subclass of a JGroups Buffer
+ */
+public class ByteBuffer extends Buffer
+{
+ public ByteBuffer(byte[] bytes, int offset, int length)
+ {
+ super(bytes, offset, length);
+ }
+
+ /**
+ * @return an input stream for the bytes in the buffer
+ */
+ public InputStream getStream()
+ {
+ return new ByteArrayInputStream(getBuf(), getOffset(), getLength());
+ }
+}
Copied: core/branches/2.2.X/src/main/java/org/jboss/cache/io/ExposedByteArrayOutputStream.java (from rev 6926, core/branches/2.2.X/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStream.java)
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/io/ExposedByteArrayOutputStream.java (rev 0)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/io/ExposedByteArrayOutputStream.java 2008-10-14 09:23:28 UTC (rev 6927)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.io;
+
+import net.jcip.annotations.NotThreadSafe;
+
+import java.io.ByteArrayOutputStream;
+
+/**
+ * Extends ByteArrayOutputStream, but exposes the internal buffer.
+ * Using this, callers don't need to call toByteArray() which copies the
+ * internal buffer.
+ * <p>
+ * Also overrides the superclass' behavior of always doubling the size of the
+ * internal buffer any time more capacity is needed. This class doubles the
+ * size until the internal buffer reaches a configurable max size (default is
+ * 4MB), after which it begins growing the buffer in 25% increments. This is
+ * intended to help prevent an OutOfMemoryError during a resize of a large
+ * buffer.
+ * </p>
+ * <p>
+ * A version of this class was originally created by Bela Ban as part of the
+ * JGroups library.
+ * </p>
+ * This class is not threadsafe as it will not support concurrent readers and writers.
+ * <p/>
+ *
+ * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
+ * @version $Id$
+ */
+@NotThreadSafe
+public class ExposedByteArrayOutputStream extends ByteArrayOutputStream
+{
+ /**
+ * Default buffer size after which if more buffer capacity
+ * is needed the buffer will grow by 25% rather than 100%
+ */
+ public static final int DEFAULT_DOUBLING_SIZE = 4 * 1024 * 1024; // 4MB
+
+ private int maxDoublingSize = DEFAULT_DOUBLING_SIZE;
+
+ public ExposedByteArrayOutputStream()
+ {
+ super();
+ }
+
+ public ExposedByteArrayOutputStream(int size)
+ {
+ super(size);
+ }
+
+ /**
+ * Creates a new byte array output stream, with a buffer capacity of
+ * the specified size, in bytes.
+ *
+ * @param size the initial size.
+ * @param maxDoublingSize the buffer size, after which if more capacity
+ * is needed the buffer will grow by 25%
+ * rather than 100%
+ * @throws IllegalArgumentException if size is negative.
+ */
+ public ExposedByteArrayOutputStream(int size, int maxDoublingSize)
+ {
+ super(size);
+ this.maxDoublingSize = maxDoublingSize;
+ }
+
+ /**
+ * Gets the internal buffer array. Note that the length of this array
+ * will almost certainly be longer than the data written to it; call
+ * <code>size()</code> to get the number of bytes of actual data.
+ */
+ public final byte[] getRawBuffer()
+ {
+ return buf;
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len)
+ {
+ if ((off < 0) || (off > b.length) || (len < 0) ||
+ ((off + len) > b.length) || ((off + len) < 0))
+ {
+ throw new IndexOutOfBoundsException();
+ }
+ else if (len == 0)
+ {
+ return;
+ }
+
+ int newcount = count + len;
+ if (newcount > buf.length)
+ {
+ byte newbuf[] = new byte[getNewBufferSize(buf.length, newcount)];
+ System.arraycopy(buf, 0, newbuf, 0, count);
+ buf = newbuf;
+ }
+
+ System.arraycopy(b, off, buf, count, len);
+ count = newcount;
+ }
+
+ @Override
+ public void write(int b)
+ {
+ int newcount = count + 1;
+ if (newcount > buf.length)
+ {
+ byte newbuf[] = new byte[getNewBufferSize(buf.length, newcount)];
+ System.arraycopy(buf, 0, newbuf, 0, count);
+ buf = newbuf;
+ }
+ buf[count] = (byte) b;
+ count = newcount;
+ }
+
+ /**
+ * Gets the highest internal buffer size after which if more capacity
+ * is needed the buffer will grow in 25% increments rather than 100%.
+ */
+ public final int getMaxDoublingSize()
+ {
+ return maxDoublingSize;
+ }
+
+ /**
+ * Gets the number of bytes to which the internal buffer should be resized.
+ *
+ * @param curSize the current number of bytes
+ * @param minNewSize the minimum number of bytes required
+ * @return the size to which the internal buffer should be resized
+ */
+ public final int getNewBufferSize(int curSize, int minNewSize)
+ {
+ if (curSize <= maxDoublingSize)
+ return Math.max(curSize << 1, minNewSize);
+ else
+ return Math.max(curSize + (curSize >> 2), minNewSize);
+ }
+}
Property changes on: core/branches/2.2.X/src/main/java/org/jboss/cache/io/ExposedByteArrayOutputStream.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-10-13 22:20:04 UTC (rev 6926)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-10-14 09:23:28 UTC (rev 6927)
@@ -35,7 +35,9 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.io.ByteBuffer;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jgroups.util.Buffer;
import java.io.InputStream;
import java.io.ObjectInputStream;
@@ -87,31 +89,44 @@
}
// implement the basic contract set in RPCDispatcher.AbstractMarshaller
- public byte[] objectToByteBuffer(Object obj) throws Exception
+ public Object objectFromStream(InputStream in) throws Exception
{
throw new RuntimeException("Needs to be overridden!");
}
- public Object objectFromByteBuffer(byte[] bytes) throws Exception
+ public RegionalizedMethodCall regionalizedMethodCallFromByteBuffer(byte[] buffer) throws Exception
{
throw new RuntimeException("Needs to be overridden!");
}
- public Object objectFromStream(InputStream in) throws Exception
+ public RegionalizedMethodCall regionalizedMethodCallFromObjectStream(ObjectInputStream in) throws Exception
{
throw new RuntimeException("Needs to be overridden!");
}
- public RegionalizedMethodCall regionalizedMethodCallFromByteBuffer(byte[] buffer) throws Exception
+ public ByteBuffer objectToBuffer(Object o) throws Exception
{
throw new RuntimeException("Needs to be overridden!");
}
- public RegionalizedMethodCall regionalizedMethodCallFromObjectStream(ObjectInputStream in) throws Exception
+ public Object objectFromByteBuffer(byte[] bytes) throws Exception
{
+ return objectFromByteBuffer(bytes, 0, bytes.length);
+ }
+
+ public Object objectFromByteBuffer(byte[] bytes, int offset, int len) throws Exception
+ {
throw new RuntimeException("Needs to be overridden!");
}
+ public byte[] objectToByteBuffer(Object obj) throws Exception
+ {
+ Buffer b = objectToBuffer(obj);
+ byte[] bytes = new byte[b.getLength()];
+ System.arraycopy(b.getBuf(), b.getOffset(), bytes, 0, b.getLength());
+ return bytes;
+ }
+
protected Fqn extractFqn(ReplicableCommand cmd)
{
if (cmd == null) throw new NullPointerException("Command is null");
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/Marshaller.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-10-13 22:20:04 UTC (rev 6926)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-10-14 09:23:28 UTC (rev 6927)
@@ -31,7 +31,7 @@
* @author <a href="mailto://manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-public interface Marshaller extends RpcDispatcher.Marshaller
+public interface Marshaller extends RpcDispatcher.Marshaller2
{
/**
* Marshalls an object to a given {@link ObjectOutputStream}
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-10-13 22:20:04 UTC (rev 6926)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-10-14 09:23:28 UTC (rev 6927)
@@ -12,11 +12,12 @@
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.io.ByteBuffer;
+import org.jboss.cache.io.ExposedByteArrayOutputStream;
import org.jboss.cache.util.Util;
import org.jboss.util.stream.MarshalledValueInputStream;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -150,9 +151,9 @@
}
@Override
- public byte[] objectToByteBuffer(Object obj) throws Exception
+ public ByteBuffer objectToBuffer(Object obj) throws Exception
{
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
ObjectOutputStream out = new ObjectOutputStream(baos);
out.writeShort(versionInt);
@@ -163,15 +164,15 @@
out.close();
// and return bytes.
- return baos.toByteArray();
+ return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
}
@Override
- public Object objectFromByteBuffer(byte[] buf) throws Exception
+ public Object objectFromByteBuffer(byte[] bytes, int offset, int len) throws Exception
{
Marshaller marshaller;
int versionId;
- ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(buf));
+ ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes, offset, len));
try
{
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-10-13 22:20:04 UTC (rev 6926)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-10-14 09:23:28 UTC (rev 6927)
@@ -7,8 +7,8 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.NonVolatile;
+import org.jboss.cache.io.ExposedByteArrayOutputStream;
import org.jboss.cache.statetransfer.StateTransferManager;
-import org.jboss.cache.util.ExposedByteArrayOutputStream;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import org.jgroups.ExtendedMessageListener;
Deleted: core/branches/2.2.X/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStream.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStream.java 2008-10-13 22:20:04 UTC (rev 6926)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/util/ExposedByteArrayOutputStream.java 2008-10-14 09:23:28 UTC (rev 6927)
@@ -1,141 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.cache.util;
-
-import java.io.ByteArrayOutputStream;
-
-/**
- * Extends ByteArrayOutputStream, but exposes the internal buffer.
- * Using this, callers don't need to call toByteArray() which copies the
- * internal buffer.
- * <p>
- * Also overrides the superclass' behavior of always doubling the size of the
- * internal buffer any time more capacity is needed. This class doubles the
- * size until the internal buffer reaches a configurable max size (default is
- * 4MB), after which it begins growing the buffer in 25% increments. This is
- * intended to help prevent an OutOfMemoryError during a resize of a large
- * buffer.
- * </p>
- * <p>
- * A version of this class was originally created by Bela Ban as part of the
- * JGroups library.
- * </p>
- *
- * @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
- * @version $Id$
- */
-public class ExposedByteArrayOutputStream extends ByteArrayOutputStream
-{
- /**
- * Default buffer size after which if more buffer capacity
- * is needed the buffer will grow by 25% rather than 100%
- */
- public static final int DEFAULT_DOUBLING_SIZE = 4 * 1024 * 1024; // 4MB
-
- private int maxDoublingSize = DEFAULT_DOUBLING_SIZE;
-
- public ExposedByteArrayOutputStream()
- {
- super();
- }
-
- public ExposedByteArrayOutputStream(int size)
- {
- super(size);
- }
-
- /**
- * Creates a new byte array output stream, with a buffer capacity of
- * the specified size, in bytes.
- *
- * @param size the initial size.
- * @param maxDoublingSize the buffer size, after which if more capacity
- * is needed the buffer will grow by 25%
- * rather than 100%
- * @throws IllegalArgumentException if size is negative.
- */
- public ExposedByteArrayOutputStream(int size, int maxDoublingSize)
- {
- super(size);
- this.maxDoublingSize = maxDoublingSize;
- }
-
- /**
- * Gets the internal buffer array. Note that the length of this array
- * will almost certainly be longer than the data written to it; call
- * <code>size()</code> to get the number of bytes of actual data.
- */
- public byte[] getRawBuffer()
- {
- return buf;
- }
-
- @Override
- public synchronized void write(byte[] b, int off, int len)
- {
- if ((off < 0) || (off > b.length) || (len < 0) ||
- ((off + len) > b.length) || ((off + len) < 0))
- {
- throw new IndexOutOfBoundsException();
- }
- else if (len == 0)
- {
- return;
- }
-
- int newcount = count + len;
- if (newcount > buf.length)
- {
- byte newbuf[] = new byte[getNewBufferSize(buf.length, newcount)];
- System.arraycopy(buf, 0, newbuf, 0, count);
- buf = newbuf;
- }
-
- System.arraycopy(b, off, buf, count, len);
- count = newcount;
- }
-
- @Override
- public synchronized void write(int b)
- {
- int newcount = count + 1;
- if (newcount > buf.length)
- {
- byte newbuf[] = new byte[getNewBufferSize(buf.length, newcount)];
- System.arraycopy(buf, 0, newbuf, 0, count);
- buf = newbuf;
- }
- buf[count] = (byte) b;
- count = newcount;
- }
-
- /**
- * Gets the highest internal buffer size after which if more capacity
- * is needed the buffer will grow in 25% increments rather than 100%.
- */
- public int getMaxDoublingSize()
- {
- return maxDoublingSize;
- }
-
- /**
- * Gets the number of bytes to which the internal buffer should be resized.
- *
- * @param curSize the current number of bytes
- * @param minNewSize the minimum number of bytes required
- * @return the size to which the internal buffer should be resized
- */
- public int getNewBufferSize(int curSize, int minNewSize)
- {
- if (curSize <= maxDoublingSize)
- return Math.max(curSize << 1, minNewSize);
- else
- return Math.max(curSize + (curSize >> 2), minNewSize);
- }
-
-}
Modified: core/branches/2.2.X/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
===================================================================
--- core/branches/2.2.X/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-10-13 22:20:04 UTC (rev 6926)
+++ core/branches/2.2.X/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-10-14 09:23:28 UTC (rev 6927)
@@ -9,10 +9,13 @@
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
+import org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.RegionalizedMethodCall;
import org.jboss.cache.util.TestingUtil;
import org.jgroups.blocks.RpcDispatcher;
+import org.jgroups.blocks.RpcDispatcher.Marshaller2;
+import org.jgroups.util.Buffer;
import java.io.InputStream;
import java.io.ObjectInputStream;
@@ -57,8 +60,15 @@
ComponentRegistry componentRegistry = TestingUtil.extractComponentRegistry(cache);
RPCManager rpcManager = componentRegistry.getComponent(RPCManager.class);
CommandAwareRpcDispatcher realDispatcher = (CommandAwareRpcDispatcher) TestingUtil.extractField(rpcManager, "rpcDispatcher");
- RpcDispatcher.Marshaller realMarshaller = realDispatcher.getMarshaller();
- MarshallerDelegate delegate = new MarshallerDelegate(realMarshaller);
+ RpcDispatcher.Marshaller2 realMarshaller = (Marshaller2) realDispatcher.getMarshaller();
+
+ RpcDispatcher.Marshaller delegate = null;
+
+ if (realDispatcher instanceof InactiveRegionAwareRpcDispatcher)
+ delegate = new RegionMarshallerDelegate((Marshaller) realMarshaller);
+ else
+ delegate = new MarshallerDelegate(realMarshaller);
+
realDispatcher.setMarshaller(delegate);
realDispatcher.setRequestMarshaller(delegate);
realDispatcher.setResponseMarshaller(delegate);
@@ -194,6 +204,16 @@
{
return realOne.objectFromByteBuffer(bytes);
}
+
+ public Buffer objectToBuffer(Object obj) throws Exception
+ {
+ return realOne.objectToBuffer(obj);
+ }
+
+ public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws Exception
+ {
+ return realOne.objectFromByteBuffer(buf, offset, length);
+ }
}
/**
16 years, 2 months
JBoss Cache SVN: r6924 - /.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 18:15:21 -0400 (Mon, 13 Oct 2008)
New Revision: 6924
Added:
enterprise-docs/
Log:
16 years, 2 months
JBoss Cache SVN: r6923 - core/trunk/src/test/java/org/jboss/cache/util/internals.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 14:52:52 -0400 (Mon, 13 Oct 2008)
New Revision: 6923
Modified:
core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
Log:
bah
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-10-13 18:48:10 UTC (rev 6922)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-10-13 18:52:52 UTC (rev 6923)
@@ -60,7 +60,7 @@
ComponentRegistry componentRegistry = TestingUtil.extractComponentRegistry(cache);
RPCManager rpcManager = componentRegistry.getComponent(RPCManager.class);
CommandAwareRpcDispatcher realDispatcher = (CommandAwareRpcDispatcher) TestingUtil.extractField(rpcManager, "rpcDispatcher");
- RpcDispatcher.Marshaller realMarshaller = realDispatcher.getMarshaller();
+ RpcDispatcher.Marshaller2 realMarshaller = (RpcDispatcher.Marshaller2) realDispatcher.getMarshaller();
MarshallerDelegate delegate = new MarshallerDelegate(realMarshaller);
realDispatcher.setMarshaller(delegate);
realDispatcher.setRequestMarshaller(delegate);
16 years, 2 months
JBoss Cache SVN: r6922 - in core/trunk: src/main and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 14:48:10 -0400 (Mon, 13 Oct 2008)
New Revision: 6922
Added:
core/trunk/src/main/tutorial/
core/trunk/src/main/tutorial/README-Tutorial.txt
core/trunk/src/main/tutorial/build.xml
Modified:
core/trunk/assembly/all.xml
core/trunk/src/main/docbook/tutorial/en/master.xml
core/trunk/src/test/java/org/jboss/cache/profiling/MemConsumptionTest.java
core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
Log:
JBoss Cache tutorial stuff
Modified: core/trunk/assembly/all.xml
===================================================================
--- core/trunk/assembly/all.xml 2008-10-13 18:32:30 UTC (rev 6921)
+++ core/trunk/assembly/all.xml 2008-10-13 18:48:10 UTC (rev 6922)
@@ -82,14 +82,34 @@
<directory>target/docbook</directory>
<outputDirectory>doc/</outputDirectory>
</fileSet>
+
+ <fileSet>
+ <directory>src/main/tutorial</directory>
+ <outputDirectory>tutorial/</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory>tutorial/lib/</outputDirectory>
+ <includes>
+ <include>**/jbosscache-core-tests.jar</include>
+ </includes>
+ </fileSet>
</fileSets>
<!-- Make sure we filter out the junk that jboss-common-core pulls in -->
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
- <outputFileNameMapping>${scope}/${artifactId}.${extension}</outputFileNameMapping>
+ <outputFileNameMapping>${artifactId}.${extension}</outputFileNameMapping>
<unpack>false</unpack>
+ <scope>runtime</scope>
+ </dependencySet>
+
+ <dependencySet>
+ <outputDirectory>tutorial/lib</outputDirectory>
+ <outputFileNameMapping>${artifactId}.${extension}</outputFileNameMapping>
+ <unpack>false</unpack>
<scope>test</scope>
</dependencySet>
</dependencySets>
Modified: core/trunk/src/main/docbook/tutorial/en/master.xml
===================================================================
--- core/trunk/src/main/docbook/tutorial/en/master.xml 2008-10-13 18:32:30 UTC (rev 6921)
+++ core/trunk/src/main/docbook/tutorial/en/master.xml 2008-10-13 18:48:10 UTC (rev 6922)
@@ -29,12 +29,12 @@
<para>
JBoss Cache is an in-memory replicated, transactional, and fine-grained cache.
This tutorial focuses on the core Cache API. Please refer to the accompanying tutorial
- for the Pojo Cache API if it is the Pojo Cache API you are interested in.
+ for POJO Cache, if it is the POJO Cache API you are interested in.
</para>
<para>
For details of configuration, usage and APIs, please refer to the
<ulink
- url="http://labs.jboss.org/portal/jbosscache/docs/index.html">user manuals
+ url="http://labs.jboss.org/jbosscache/docs/index.html">user manuals
</ulink>
.
</para>
@@ -61,15 +61,14 @@
<section>
<title>Configuration</title>
- <para>First download the JBoss Cache 2.x distribution from
+ <para>First download the JBoss Cache 3.x distribution from
<ulink
- url="http://labs.jboss.org/portal/jbosscache/download/index.html">the download page
+ url="http://labs.jboss.org/jbosscache/download/index.html">the download page
</ulink>
- . You probably want the
- <literal>JBossCache-core-2.X.Y.zip</literal>
- distribution.
+ . You will need the ALL distribution (
+ <literal>jbosscache-core-3.X.Y.GA-all.zip</literal>).
Unzip it, and you will get a directory containing the distribution, such as
- <literal>JBossCache-core-2.X.Y</literal>
+ <literal>jbosscache-core-3.X.Y</literal>
.
For the sake of this tutorial, I will refer to this as
<literal>JBossCache</literal>
@@ -93,7 +92,7 @@
<listitem>
<para>
- <literal>config-samples/replSync-service.xml</literal>
+ <literal>config-samples/total-replication.xml</literal>
. Cache configuration file used for this tutorial.
</para>
</listitem>
@@ -104,7 +103,7 @@
<title>Script</title>
<para>The only script needed for this tutorial is the
- <literal>JBossCache/build.xml</literal>
+ <literal>JBossCache/tutorial/build.xml</literal>
ant script. You also need to have
<ulink url="http://ant.apache.org/">ant</ulink>
installed for running the demo.
@@ -115,15 +114,18 @@
<title>Running The Demo GUI</title>
<para>
- The demo is run by calling the ant script with the
- <literal>run.demo</literal>
- target. E.g.,
+ The demo is run by:
+ <ol>
+ <li>Changing to the
+ <literal>tutorial</literal>
+ directory (e.g.,<literal>cd tutorial</literal>)
+ </li>
+ <li>And then running the ant script (e.g.,<literal>ant run</literal>)
+ </li>
+ </ol>
</para>
<para>
- <literal>ant run.demo</literal>
- </para>
- <para>
This will cause a GUI window to appear, giving you a tree view of the cache in the top pane and a BeanShell
view
of the JVM in the lower pane.
Added: core/trunk/src/main/tutorial/README-Tutorial.txt
===================================================================
--- core/trunk/src/main/tutorial/README-Tutorial.txt (rev 0)
+++ core/trunk/src/main/tutorial/README-Tutorial.txt 2008-10-13 18:48:10 UTC (rev 6922)
@@ -0,0 +1,4 @@
+Please see the tutorial in the /doc directory.
+
+This directory contains script and code to run the tutorial.
+
Added: core/trunk/src/main/tutorial/build.xml
===================================================================
--- core/trunk/src/main/tutorial/build.xml (rev 0)
+++ core/trunk/src/main/tutorial/build.xml 2008-10-13 18:48:10 UTC (rev 6922)
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="JBoss Cache Demo" default="help" basedir=".">
+
+ <property name="className" value="org.jboss.cache.demo.JBossCacheView"/>
+ <property name="cfgFile" value="../etc/config-samples/total-replication.xml"/>
+ <property name="jvm.ipv4" value="-Djava.net.preferIPv4Stack=true"/>
+ <property name="jvm.localhost" value="-Dbind.address=127.0.0.1"/>
+ <property name="jvm.memory" value="-Xmx128M"/>
+
+
+ <path id="classpath">
+ <fileset dir="lib">
+ <include name="**/*.jar"/>
+ </fileset>
+ <fileset dir="../lib">
+ <include name="**/*.jar"/>
+ </fileset>
+ <fileset dir="..">
+ <include name="jbosscache-core.jar"/>
+ </fileset>
+ </path>
+
+ <target name="help">
+ <echo>
+ ________________ _________ ______
+ ______ /__ __ )____________________ __ ____/_____ _________ /______
+ ___ _ /__ __ | __ \_ ___/_ ___/ _ / _ __ `/ ___/_ __ \ _ \
+ / /_/ / _ /_/ // /_/ /(__ )_(__ ) / /___ / /_/ // /__ _ / / / __/
+ \____/ /_____/ \____//____/ /____/ \____/ \__,_/ \___/ /_/ /_/\___/
+
+ ________ _____ _____ ______
+ ___ __/___ ___ /________________(_)_____ ___ /
+ __ / _ / / / __/ __ \_ ___/_ /_ __ `/_ /
+ _ / / /_/ // /_ / /_/ / / _ / / /_/ /_ /
+ /_/ \__,_/ \__/ \____//_/ /_/ \__,_/ /_/
+
+
+ ----------------------------------------------------------------------------
+
+ To run the tutorial, type "ant run"
+ </echo>
+ </target>
+
+ <target name="run">
+ <echo>
+ ________________ _________ ______
+ ______ /__ __ )____________________ __ ____/_____ _________ /______
+ ___ _ /__ __ | __ \_ ___/_ ___/ _ / _ __ `/ ___/_ __ \ _ \
+ / /_/ / _ /_/ // /_/ /(__ )_(__ ) / /___ / /_/ // /__ _ / / / __/
+ \____/ /_____/ \____//____/ /____/ \____/ \__,_/ \___/ /_/ /_/\___/
+
+ ________ _____ _____ ______
+ ___ __/___ ___ /________________(_)_____ ___ /
+ __ / _ / / / __/ __ \_ ___/_ /_ __ `/_ /
+ _ / / /_/ // /_ / /_/ / / _ / / /_/ /_ /
+ /_/ \__,_/ \__/ \____//_/ /_/ \__,_/ /_/
+
+
+ ----------------------------------------------------------------------------
+
+ </echo>
+ <java classname="${className}" classpathref="classpath" fork="true">
+ <jvmarg value="${jvm.ipv4}"/>
+ <jvmarg value="${jvm.localhost}"/>
+ <jvmarg value="${jvm.memory}"/>
+ <arg value="-console"/>
+ <arg value="-config"/>
+ <arg value="${cfgFile}"/>
+ </java>
+ </target>
+</project>
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/MemConsumptionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/MemConsumptionTest.java 2008-10-13 18:32:30 UTC (rev 6921)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/MemConsumptionTest.java 2008-10-13 18:48:10 UTC (rev 6922)
@@ -29,6 +29,7 @@
import java.io.IOException;
import java.text.NumberFormat;
+import java.util.Arrays;
import java.util.Random;
@Test(groups = "profiling")
@@ -43,13 +44,16 @@
public void testMemConsumption() throws IOException
{
- int kBytesCached = (numNodes * (payloadSize + keySize)) / 1024;
+ int kBytesCached = (2 * numNodes * (payloadSize + keySize)) / 1024;
System.out.println("Bytes to be cached: " + NumberFormat.getIntegerInstance().format(kBytesCached) + " kb");
- Cache<String, String> c = new DefaultCacheFactory<String, String>().createCache(); // default LOCAL cache
+ Cache<String, String> c = new DefaultCacheFactory<String, String>().createCache(false); // default LOCAL cache
+// c.getConfiguration().setConcurrencyLevel(numNodes);
+ c.start();
for (int i = 0; i < numNodes; i++)
{
c.put(Fqn.fromString("/node" + i), generateRandomString(keySize), generateRandomString(payloadSize));
+ if (i % 1000 == 0) System.out.println("Added " + i + " entries");
}
System.out.println("Calling System.gc()");
@@ -72,4 +76,24 @@
assert sb.length() == stringSize;
return sb.toString();
}
+
+ private byte[] generateUniqueKey(int runNumber, int keySize)
+ {
+ byte[] b = new byte[keySize];
+ b[0] = (byte) (runNumber >>> 0);
+ b[1] = (byte) (runNumber >>> 8);
+ b[2] = (byte) (runNumber >>> 16);
+ b[3] = (byte) (runNumber >>> 24);
+
+ for (int i = 4; i < keySize; i++) b[i] = 0;
+ return b;
+ }
+
+ private byte[] generateBytePayload(int payloadSize)
+ {
+ byte[] b = new byte[payloadSize];
+ Arrays.fill(b, (byte) 0);
+ return b;
+ }
+
}
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2008-10-13 18:32:30 UTC (rev 6921)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/ProfileTest.java 2008-10-13 18:48:10 UTC (rev 6922)
@@ -38,7 +38,7 @@
/*
Test configuration options
*/
- protected static final long NUM_OPERATIONS = 1000000; // DURATION is replaced with a fixed number of operations instead.
+ protected static final long NUM_OPERATIONS = 5000000; // DURATION is replaced with a fixed number of operations instead.
protected static final int NUM_THREADS = 25;
protected static final int MAX_RANDOM_SLEEP_MILLIS = 1;
protected static final int MAX_DEPTH = 3;
@@ -81,6 +81,7 @@
{
cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.MVCC);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_ASYNC);
+ cache.getConfiguration().setSerializationExecutorPoolSize(0);
cache.getConfiguration().setConcurrencyLevel(5000);
cache.getConfiguration().setClusterConfig(getJGroupsConfig());
runCompleteTest();
16 years, 2 months
JBoss Cache SVN: r6921 - core/trunk/src/test/java/org/jboss/cache/util/internals.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-13 14:32:30 -0400 (Mon, 13 Oct 2008)
New Revision: 6921
Modified:
core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
Log:
replaced test helper brittleness
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-10-13 18:31:25 UTC (rev 6920)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-10-13 18:32:30 UTC (rev 6921)
@@ -11,7 +11,6 @@
import org.jboss.cache.io.ByteBuffer;
import org.jboss.cache.marshall.AbstractMarshaller;
import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
-import org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.RegionalizedMethodCall;
import org.jboss.cache.util.TestingUtil;
@@ -61,18 +60,11 @@
ComponentRegistry componentRegistry = TestingUtil.extractComponentRegistry(cache);
RPCManager rpcManager = componentRegistry.getComponent(RPCManager.class);
CommandAwareRpcDispatcher realDispatcher = (CommandAwareRpcDispatcher) TestingUtil.extractField(rpcManager, "rpcDispatcher");
- if (realDispatcher instanceof InactiveRegionAwareRpcDispatcher)
- {
- Marshaller realMarshaller = (Marshaller) TestingUtil.extractField(InactiveRegionAwareRpcDispatcher.class, realDispatcher, "requestMarshaller");
- RegionMarshallerDelegate delegate = new RegionMarshallerDelegate(realMarshaller);
- TestingUtil.replaceField(delegate, "requestMarshaller", realDispatcher, InactiveRegionAwareRpcDispatcher.class);
- }
- else
- {
- RpcDispatcher.Marshaller2 realMarshaller = (RpcDispatcher.Marshaller2) TestingUtil.extractField(RpcDispatcher.class, realDispatcher, "req_marshaller");
- MarshallerDelegate delegate = new MarshallerDelegate(realMarshaller);
- TestingUtil.replaceField(delegate, "req_marshaller", realDispatcher, RpcDispatcher.class);
- }
+ RpcDispatcher.Marshaller realMarshaller = realDispatcher.getMarshaller();
+ MarshallerDelegate delegate = new MarshallerDelegate(realMarshaller);
+ realDispatcher.setMarshaller(delegate);
+ realDispatcher.setRequestMarshaller(delegate);
+ realDispatcher.setResponseMarshaller(delegate);
}
private class MarshallerDelegate implements RpcDispatcher.Marshaller2
16 years, 2 months