JBoss Cache SVN: r5485 - core/branches/2.1.X/src/main/java/org/jboss/cache/config.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-01 09:21:16 -0400 (Tue, 01 Apr 2008)
New Revision: 5485
Modified:
core/branches/2.1.X/src/main/java/org/jboss/cache/config/Configuration.java
Log:
re-deprecated use of region based marshalling
Modified: core/branches/2.1.X/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/branches/2.1.X/src/main/java/org/jboss/cache/config/Configuration.java 2008-04-01 13:19:55 UTC (rev 5484)
+++ core/branches/2.1.X/src/main/java/org/jboss/cache/config/Configuration.java 2008-04-01 13:21:16 UTC (rev 5485)
@@ -314,6 +314,7 @@
* See the user guide for details on how this is handled.
* <p/>
*/
+ @Deprecated
public void setUseRegionBasedMarshalling(boolean useRegionBasedMarshalling)
{
testImmutability("useRegionBasedMarshalling");
@@ -621,6 +622,7 @@
* See the user guide for details on how this is handled.
* <p/>
*/
+ @Deprecated
public boolean isUseRegionBasedMarshalling()
{
return useRegionBasedMarshalling;
16 years, 9 months
JBoss Cache SVN: r5484 - core/branches/2.1.X/src/main/java/org/jboss/cache/config.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-01 09:19:55 -0400 (Tue, 01 Apr 2008)
New Revision: 5484
Modified:
core/branches/2.1.X/src/main/java/org/jboss/cache/config/Configuration.java
Log:
un-deprecated use of region based marshalling
Modified: core/branches/2.1.X/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/branches/2.1.X/src/main/java/org/jboss/cache/config/Configuration.java 2008-04-01 13:19:34 UTC (rev 5483)
+++ core/branches/2.1.X/src/main/java/org/jboss/cache/config/Configuration.java 2008-04-01 13:19:55 UTC (rev 5484)
@@ -314,7 +314,6 @@
* See the user guide for details on how this is handled.
* <p/>
*/
- @Deprecated
public void setUseRegionBasedMarshalling(boolean useRegionBasedMarshalling)
{
testImmutability("useRegionBasedMarshalling");
@@ -622,7 +621,6 @@
* See the user guide for details on how this is handled.
* <p/>
*/
- @Deprecated
public boolean isUseRegionBasedMarshalling()
{
return useRegionBasedMarshalling;
16 years, 9 months
JBoss Cache SVN: r5483 - in core/branches/2.1.X: src/main/docbook/faq/en and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-01 09:19:34 -0400 (Tue, 01 Apr 2008)
New Revision: 5483
Modified:
core/branches/2.1.X/pom.xml
core/branches/2.1.X/src/main/docbook/faq/en/master.xml
core/branches/2.1.X/src/main/docbook/tutorial/en/master.xml
core/branches/2.1.X/src/main/docbook/userguide/en/master.xml
core/branches/2.1.X/src/main/java/org/jboss/cache/Version.java
Log:
Updated version to 2.1.1
Modified: core/branches/2.1.X/pom.xml
===================================================================
--- core/branches/2.1.X/pom.xml 2008-04-01 13:19:04 UTC (rev 5482)
+++ core/branches/2.1.X/pom.xml 2008-04-01 13:19:34 UTC (rev 5483)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>2.2.0-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>2.1.1-SNAPSHOT</jbosscache-core-version>
</properties>
<parent>
<groupId>org.jboss.cache</groupId>
@@ -79,18 +79,6 @@
<version>1.0</version>
<optional>true</optional>
</dependency>
- <dependency>
- <groupId>net.noderunner</groupId>
- <artifactId>amazon-s3</artifactId>
- <version>1.0.0.0</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>net.noderunner</groupId>
- <artifactId>http</artifactId>
- <version>1.0</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
@@ -345,11 +333,6 @@
<id>snapshots.jboss.org</id>
<url>http://snapshots.jboss.org/maven2</url>
</repository>
- <!-- For Amazon S3 artifacts -->
- <repository>
- <id>e-xml.sourceforge.net</id>
- <url>http://e-xml.sourceforge.net/maven2/repository</url>
- </repository>
</repositories>
<profiles>
Modified: core/branches/2.1.X/src/main/docbook/faq/en/master.xml
===================================================================
--- core/branches/2.1.X/src/main/docbook/faq/en/master.xml 2008-04-01 13:19:04 UTC (rev 5482)
+++ core/branches/2.1.X/src/main/docbook/faq/en/master.xml 2008-04-01 13:19:34 UTC (rev 5483)
@@ -6,8 +6,8 @@
<bookinfo>
<title>Frequently Asked Questions about JBoss Cache</title>
<!-- Release version and date -->
- <releaseinfo>Release 2.1.0 Alegrias</releaseinfo>
- <pubdate>March 2008</pubdate>
+ <releaseinfo>Release 2.1.1 Alegrias</releaseinfo>
+ <pubdate>April 2008</pubdate>
<author>
<firstname>Manik</firstname>
Modified: core/branches/2.1.X/src/main/docbook/tutorial/en/master.xml
===================================================================
--- core/branches/2.1.X/src/main/docbook/tutorial/en/master.xml 2008-04-01 13:19:04 UTC (rev 5482)
+++ core/branches/2.1.X/src/main/docbook/tutorial/en/master.xml 2008-04-01 13:19:34 UTC (rev 5483)
@@ -3,8 +3,8 @@
<articleinfo>
<title>JBoss Cache Core Edition Tutorial</title>
<!-- Release version and date -->
- <releaseinfo>Release 2.1.0 Alegrias</releaseinfo>
- <pubdate>March 2008</pubdate>
+ <releaseinfo>Release 2.1.1 Alegrias</releaseinfo>
+ <pubdate>April 2008</pubdate>
<author>
<firstname>Manik</firstname>
Modified: core/branches/2.1.X/src/main/docbook/userguide/en/master.xml
===================================================================
--- core/branches/2.1.X/src/main/docbook/userguide/en/master.xml 2008-04-01 13:19:04 UTC (rev 5482)
+++ core/branches/2.1.X/src/main/docbook/userguide/en/master.xml 2008-04-01 13:19:34 UTC (rev 5483)
@@ -21,8 +21,8 @@
<subtitle>A clustered, transactional cache</subtitle>
<!-- Release version and date -->
- <releaseinfo>Release 2.1.0 Alegrias</releaseinfo>
- <pubdate>March 2008</pubdate>
+ <releaseinfo>Release 2.1.1 Alegrias</releaseinfo>
+ <pubdate>April 2008</pubdate>
<!-- Authors/contributors -->
<author>
Modified: core/branches/2.1.X/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/branches/2.1.X/src/main/java/org/jboss/cache/Version.java 2008-04-01 13:19:04 UTC (rev 5482)
+++ core/branches/2.1.X/src/main/java/org/jboss/cache/Version.java 2008-04-01 13:19:34 UTC (rev 5483)
@@ -11,10 +11,10 @@
@Immutable
public class Version
{
- public static final String version = "2.1.0-SNAPSHOT";
+ public static final String version = "2.1.1-SNAPSHOT";
public static final String codename = "Alegrias";
//public static final String cvs = "$Id: Version.java 4592 2007-10-10 16:44:36Z manik.surtani(a)jboss.com $";
- static final byte[] version_id = {'0', '2', '1', '0', 'S'};
+ static final byte[] version_id = {'0', '2', '1', '1', 'S'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
16 years, 9 months
JBoss Cache SVN: r5482 - in core/branches/2.1.X/src: main/java/org/jboss/cache/loader and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-01 09:19:04 -0400 (Tue, 01 Apr 2008)
New Revision: 5482
Removed:
core/branches/2.1.X/src/main/java/org/jboss/cache/loader/s3/
core/branches/2.1.X/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java
Modified:
core/branches/2.1.X/src/main/docbook/userguide/en/modules/cache_loaders.xml
Log:
Removed S3 cache loader stuff from 2.1.1
Modified: core/branches/2.1.X/src/main/docbook/userguide/en/modules/cache_loaders.xml
===================================================================
--- core/branches/2.1.X/src/main/docbook/userguide/en/modules/cache_loaders.xml 2008-04-01 12:56:55 UTC (rev 5481)
+++ core/branches/2.1.X/src/main/docbook/userguide/en/modules/cache_loaders.xml 2008-04-01 13:19:04 UTC (rev 5482)
@@ -898,163 +898,6 @@
</section>
</section>
</section>
-
- <section id="cl.s3">
- <title>S3CacheLoader</title>
-
- <para>The <literal>S3CacheLoader</literal> uses the
- <ulink url="http://aws.amazon.com/">Amazon S3</ulink> (Simple Storage Solution)
- for storing cache data.
- Since Amazon S3 is remote network storage and has fairly high latency,
- it is really best for caches that store large pieces of data, such as media
- or files.
- But consider this cache loader over the JDBC or
- file system based cache loaders if you want remotely managed, highly reliable
- storage. Or, use it for applications running on Amazon's Elastic Compute Cloud.
- </para>
-
- <para>
- If you're planning to use Amazon S3 for storage, consider using it with JBoss Cache.
- JBoss Cache itself provides in-memory caching for your data to minimize the amount of
- remote access calls, thus reducing the latency and cost of fetching your Amazon S3 data.
- With cache replication, you are also able to load data from your local cluster
- without having to remotely access it every time.
- </para>
-
- <para>
- Note that Amazon S3 does not support transactions. If transactions
- are used in your application then there is some possibility of state
- inconsistency when using this cache loader. However, writes are atomic, in
- that if a write fails nothing is considered written and data is never
- corrupted.
- </para>
-
- <para>
- Data is stored in keys based on the FQN of the Node and Node data is
- serialized as a java.util.Map using the <literal>CacheSPI.getMarshaller()</literal>
- instance.
- Read the JavaDoc on how data is structured and stored.
- Be aware this means data is not readily accessible over HTTP to
- non-JBossCache clients. Your feedback and help would be appreciated
- to extend this cache loader for that purpose.
- </para>
-
- <para>
- With this cache loader, single-key operations such as
- <literal>Node.remove(Object)</literal> and <literal>Node.put(Object,
- Object)</literal> are the slowest as data is stored in a single Map instance.
- Use bulk operations such as <literal>Node.replaceAll(Map)</literal>
- and <literal>Node.clearData()</literal> for more efficiency.
- Try the <literal>cache.s3.optimize</literal> option as well.
- </para>
-
- <section>
- <title>Amazon S3 Library</title>
- <para>The S3 cache loader is provided with the default
- distribution but requires a library to access the service
- at runtime. This runtime library may be obtained through the JBoss Maven
- Repository. Include the following sections in your pom.xml file:
- </para>
- <programlisting><![CDATA[
- <repository>
- <id>e-xml.sourceforge.net</id>
- <url>http://e-xml.sourceforge.net/maven2/repository</url>
- </repository>
- ...
- <dependency>
- <groupId>net.noderunner</groupId>
- <artifactId>amazon-s3</artifactId>
- <version>1.0.0.0</version>
- </dependency>
- ]]>
- </programlisting>
- If you do not use Maven, you can still download the
- amazon-s3 library through the repository URL.
- </section>
-
- <section>
- <title>Configuration</title>
- <para>At a minimum, you must configure your Amazon S3 access key and
- secret access key. The other configuration keys are listed in general
- order of utility.
- </para>
-
- <para>
- <itemizedlist>
- <listitem>
- <literal>cache.s3.accessKeyId</literal> -
- Amazon S3 Access Key, available from your account profile.
- </listitem>
-
- <listitem>
- <literal>cache.s3.secretAccessKey</literal> -
- Amazon S3 Secret Access Key, available from your account profile.
- As this is a password, be careful not to distribute it or include
- this secret key in built software.
- </listitem>
-
- <listitem>
- <literal>cache.s3.secure</literal> -
- The default is <literal>false</literal>:
- Traffic is sent unencrypted over the public Internet.
- Set to <literal>true</literal> to use HTTPS.
- Note that unencrypted is obviously faster.
- </listitem>
-
- <listitem>
- <literal>cache.s3.bucket</literal> -
- Name of the bucket to store data.
- For different caches using the same access key, use a different bucket name.
- Read the S3 documentation on the definition of a bucket.
- The default is <literal>jboss-cache</literal>.
- </listitem>
-
- <listitem>
- <literal>cache.s3.callingFormat</literal> -
- One of <literal>PATH</literal>, <literal>SUBDOMAIN</literal>, or
- <literal>VANITY</literal>.
- Read the S3 documentation on the use of calling domains.
- The default is <literal>SUBDOMAIN</literal>.
- </listitem>
-
- <listitem>
- <literal>cache.s3.optimize</literal> -
- The default is <literal>false</literal>.
- If true, <literal>put(Map)</literal> operations
- replace the data stored at an FQN rather than attempt
- to fetch and merge. (This option is fairly experimental
- at the moment.)
- </listitem>
-
- <listitem>
- <literal>cache.s3.parentCache</literal> -
- The default is <literal>true</literal>.
- Set this value to <literal>false</literal> if you are using multiple caches
- sharing the same S3 bucket, that remove parent nodes of nodes being created
- in other caches. (This is not a common use case.)
- <para>
- JBoss Cache stores nodes in a tree format and automatically
- creates intermediate parent nodes as necessary.
- The S3 cache loader must also create these parent nodes as well
- to allow for operations such as <literal>getChildrenNames</literal> to work
- properly. Checking if all parent nodes exists for every <literal>put</literal>
- operation is fairly expensive, so by default the cache loader caches
- the existance of these parent nodes.
- </para>
- </listitem>
-
- <listitem>
- <literal>cache.s3.location</literal> -
- This choses a primary storage location for your data
- to reduce loading and storage latency closest to you.
- Set to <literal>EU</literal> to store data locale to Europe.
- The default is <literal>null</literal>, or to store in the United States.
- </listitem>
- </itemizedlist>
- </para>
- </section>
-
- </section>
<section id="cl.tcp">
<title>TcpDelegatingCacheLoader</title>
Deleted: core/branches/2.1.X/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java 2008-04-01 12:56:55 UTC (rev 5481)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/loader/S3CacheLoaderTest.java 2008-04-01 13:19:04 UTC (rev 5482)
@@ -1,108 +0,0 @@
-package org.jboss.cache.loader;
-
-import static org.testng.AssertJUnit.assertNotNull;
-
-import java.io.IOException;
-import java.util.Properties;
-
-import net.noderunner.amazon.s3.emulator.Server;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.testng.annotations.Test;
-
-
-/**
- * Tests {@link org.jboss.cache.loader.s3.S3CacheLoader}.
- *
- * This requires a S3 account to truly test; uses an emulator otherwise.
- *
- * @author Elias Ross
- * @version $Id: JdbmCacheLoaderTest.java 4561 2007-10-08 14:02:02Z manik.surtani(a)jboss.com $
- */
-@Test(groups =
-{"functional"}, enabled = true)
-public class S3CacheLoaderTest extends CacheLoaderTestsBase
-{
-
- private static final Log log = LogFactory.getLog(S3CacheLoaderTest.class);
-
- private Server server;
-
- @Override
- protected void configureCache() throws Exception
- {
- String accessKey = System.getProperty("accessKey");
- String properties;
- if (accessKey == null)
- {
- log.info("Testing using S3CacheLoader using emulator");
- server = new Server();
- server.start();
- properties =
- "cache.s3.accessKeyId=dummy\n" +
- "cache.s3.secretAccessKey=dummy\n" +
- "cache.s3.server=localhost\n" +
- "cache.s3.port=" + server.getPort() + "\n" +
- "cache.s3.callingFormat=VANITY" + "\n" +
- "cache.s3.bucket=localhost" + "\n";
- }
- else
- {
- properties =
- "cache.s3.accessKeyId=" + accessKey + "\n" +
- "cache.s3.secretAccessKey=" + System.getProperty("secretKey") + "\n" ;
- }
- CacheLoaderConfig config = getSingleCacheLoaderConfig("", "org.jboss.cache.loader.s3.S3CacheLoader", properties, false, true, false);
- // System.out.println(config);
- Properties p = config.getFirstCacheLoaderConfig().getProperties();
- // System.out.println(p);
- assertNotNull(p.get("cache.s3.accessKeyId"));
- assertNotNull(p.get("cache.s3.secretAccessKey"));
- cache.getConfiguration().setCacheLoaderConfig(config);
- }
-
- @Override
- public void cleanup() {
- if (server != null)
- {
- try
- {
- server.close();
- }
- catch (IOException e) {
- }
- }
- }
-
- protected void postConfigure()
- {
- cache.removeNode(Fqn.root());
- }
-
- //@Override
- public void testCacheLoaderThreadSafety()
- {
-
- }
-
- //@Override
- public void testPartialLoadAndStore()
- {
- // do nothing
- }
-
- //@Override
- public void testBuddyBackupStore()
- {
- // do nothing
- }
-
- //@Override
- protected void threadSafetyTest(final boolean singleFqn) throws Exception
- {
- }
-
-}
16 years, 9 months
JBoss Cache SVN: r5481 - core/branches.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-01 08:56:55 -0400 (Tue, 01 Apr 2008)
New Revision: 5481
Added:
core/branches/2.1.X/
Log:
Branching 2.1.X
Copied: core/branches/2.1.X (from rev 5480, core/trunk)
16 years, 9 months
JBoss Cache SVN: r5480 - in core/trunk/src: main/java/org/jboss/cache/marshall and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-01 06:29:30 -0400 (Tue, 01 Apr 2008)
New Revision: 5480
Added:
core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java
core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedReturnValue.java
Modified:
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java
core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java
core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
Log:
JBCACHE-1170: Leakage of thread locals in CacheMarshaller when using async replication
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-03-31 17:53:52 UTC (rev 5479)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-01 10:29:30 UTC (rev 5480)
@@ -274,8 +274,17 @@
// always use the InactiveRegionAwareRpcDispatcher - exceptions due to regions not being active should not propagate to remote
// nodes as errors. - Manik
- disp = new InactiveRegionAwareRpcDispatcher(channel, messageListener, new MembershipListenerAdaptor(), remoteDelegate);
+ // but only if we are using region based marshalling?!??
+ if (configuration.isUseRegionBasedMarshalling())
+ {
+ disp = new InactiveRegionAwareRpcDispatcher(channel, messageListener, new MembershipListenerAdaptor(), remoteDelegate);
+ }
+ else
+ {
+ disp = new RpcDispatcher(channel, messageListener, new MembershipListenerAdaptor(), remoteDelegate);
+ }
+
disp.setRequestMarshaller(marshaller);
disp.setResponseMarshaller(marshaller);
}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-03-31 17:53:52 UTC (rev 5479)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-04-01 10:29:30 UTC (rev 5480)
@@ -19,6 +19,7 @@
import org.jboss.cache.transaction.GlobalTransaction;
import java.io.InputStream;
+import java.io.ObjectInputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -86,6 +87,16 @@
throw new RuntimeException("Needs to be overridden!");
}
+ public RegionalizedMethodCall regionalizedMethodCallFromByteBuffer(byte[] buffer) throws Exception
+ {
+ throw new RuntimeException("Needs to be overridden!");
+ }
+
+ public RegionalizedMethodCall regionalizedMethodCallFromObjectStream(ObjectInputStream in) throws Exception
+ {
+ throw new RuntimeException("Needs to be overridden!");
+ }
+
/**
* This is "replicate" call with a single MethodCall argument.
*
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-03-31 17:53:52 UTC (rev 5479)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-04-01 10:29:30 UTC (rev 5480)
@@ -6,7 +6,6 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import static org.jboss.cache.Region.Status;
@@ -60,9 +59,6 @@
protected static final InactiveRegionException IRE = new InactiveRegionException("Cannot unmarshall to an inactive region");
- // this is pretty nasty, and may need more thought.
- protected final ThreadLocal<Fqn> regionForCall = new ThreadLocal<Fqn>();
-
public CacheMarshaller200()
{
initLogger();
@@ -70,50 +66,26 @@
useRefs = true;
}
- /**
- * Tests if the type of object being marshalled is a method call or a return value
- *
- * @param o object to marshall
- * @return true if the object is a return value to a method call; false otherwise
- */
- protected boolean isReturnValue(Object o)
- {
- return !(o instanceof MethodCall);
- }
-
// -------- AbstractMarshaller interface
public void objectToObjectStream(Object o, ObjectOutputStream out) throws Exception
{
if (useRegionBasedMarshalling)
{
- Fqn region;
- if (o == null)
+ Fqn region = null;
+
+ if (o instanceof RegionalizedReturnValue)
{
- // if the return value we're trying to marshall is null we're easy ...
- region = null;
- // we still need to clear the thread local though.
- regionForCall.remove();
+ RegionalizedReturnValue rrv = (RegionalizedReturnValue) o;
+ region = rrv.region;
+ o = rrv.returnValue;
}
- else if (isReturnValue(o))
+ else if (o instanceof MethodCall)
{
- // we are marshalling a return value from a method call.
- // let's see if an incoming unmarshalling call for this exists, in the same thread stack and had registered
- // a Fqn region.
- region = regionForCall.get();
- regionForCall.remove();
- if (trace)
- log.trace("Suspect this is a return value. Extract region from ThreadLocal as " + region);
-
- // otherwise, we need to marshall the retval.
- }
- else
- {
- // this is an outgoing method call.
- // we first marshall the Fqn as a String
MethodCall call = (MethodCall) o;
region = extractFqnRegion(call);
}
+
if (trace) log.trace("Region based call. Using region " + region);
objectToObjectStream(o, out, region);
}
@@ -125,11 +97,22 @@
}
}
+ @Override
+ public RegionalizedMethodCall regionalizedMethodCallFromObjectStream(ObjectInputStream in) throws Exception
+ {
+ // parse the stream as per normal.
+ Object[] retVal = objectFromObjectStreamRegionBased(in);
+ RegionalizedMethodCall rmc = new RegionalizedMethodCall();
+ rmc.call = (MethodCall) retVal[0];
+ rmc.region = (Fqn) retVal[1];
+ return rmc;
+ }
+
public Object objectFromObjectStream(ObjectInputStream in) throws Exception
{
if (useRegionBasedMarshalling)
{
- return objectFromObjectStreamRegionBased(in);
+ return objectFromObjectStreamRegionBased(in)[0];
}
else
{
@@ -172,7 +155,12 @@
}
}
- protected Object objectFromObjectStreamRegionBased(ObjectInputStream in) throws Exception
+ /**
+ * @param in
+ * @return a 2-object array. The first one is the unmarshalled object and the 2nd is an Fqn that relates to the region used. If region-based marshalling is not used, the 2nd value is null.
+ * @throws Exception
+ */
+ protected Object[] objectFromObjectStreamRegionBased(ObjectInputStream in) throws Exception
{
UnmarshalledReferences refMap = useRefs ? new UnmarshalledReferences() : null;
Object o = unmarshallObject(in, refMap);
@@ -190,7 +178,7 @@
if (trace) log.trace("Unmarshalled regionFqn " + regionFqn + " from stream");
Region region = null;
- Object retValue;
+ Object[] retValue = {null, null};
if (regionFqn != null)
{
@@ -200,16 +188,14 @@
{
if (log.isDebugEnabled())
log.debug("Region does not exist for Fqn " + regionFqn + " - not using a context classloader.");
- retValue = unmarshallObject(in, defaultClassLoader, refMap, false);
+ retValue[0] = unmarshallObject(in, defaultClassLoader, refMap, false);
}
else
{
- retValue = unmarshallObject(in, region.getClassLoader(), refMap, true);
-
- // only set this if this is an incoming method call and not a return value.
- if (!isReturnValue(retValue)) regionForCall.set(regionFqn);
+ retValue[0] = unmarshallObject(in, region.getClassLoader(), refMap, true);
+ retValue[1] = regionFqn;
}
- if (trace) log.trace("Unmarshalled object " + retValue);
+ if (trace) log.trace("Unmarshalled object " + retValue[0] + " with region " + retValue[1]);
return retValue;
}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java 2008-03-31 17:53:52 UTC (rev 5479)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java 2008-04-01 10:29:30 UTC (rev 5480)
@@ -4,7 +4,6 @@
import org.jgroups.MembershipListener;
import org.jgroups.Message;
import org.jgroups.MessageListener;
-import org.jgroups.blocks.MethodCall;
import org.jgroups.blocks.RpcDispatcher;
/**
@@ -15,6 +14,8 @@
*/
public class InactiveRegionAwareRpcDispatcher extends RpcDispatcher
{
+ org.jboss.cache.marshall.Marshaller requestMarshaller;
+
/**
* Only provide the flavour of the {@link RpcDispatcher} constructor that we care about.
*/
@@ -23,6 +24,14 @@
super(channel, l, l2, server_obj);
}
+ @Override
+ public void setRequestMarshaller(Marshaller m)
+ {
+ super.setRequestMarshaller(m);
+ requestMarshaller = (org.jboss.cache.marshall.Marshaller) m;
+ }
+
+
/**
* Message contains MethodCall. Execute it against *this* object and return result.
* Use MethodCall.invoke() to do this. Return result.
@@ -30,7 +39,6 @@
@Override
public Object handle(Message req)
{
- Object body = null;
org.jgroups.blocks.MethodCall method_call;
if (server_obj == null)
@@ -45,9 +53,13 @@
return null;
}
+ RegionalizedMethodCall rmc;
+
try
{
- body = req_marshaller != null ? req_marshaller.objectFromByteBuffer(req.getBuffer()) : req.getObject();
+ // we will ALWAYS be using the marshaller to unmarshall requests.
+ rmc = requestMarshaller.regionalizedMethodCallFromByteBuffer(req.getBuffer());
+ method_call = rmc.call;
}
catch (Throwable e)
{
@@ -61,20 +73,13 @@
return e;
}
- if (body == null || !(body instanceof MethodCall))
- {
- if (log.isErrorEnabled()) log.error("message does not contain a MethodCall object");
- return null;
- }
-
- method_call = (MethodCall) body;
-
try
{
if (log.isTraceEnabled())
log.trace("[sender=" + req.getSrc() + "], method_call: " + method_call);
- return method_call.invoke(server_obj);
+ Object retVal = method_call.invoke(server_obj);
+ return new RegionalizedReturnValue(retVal, rmc);
}
catch (Throwable x)
{
@@ -82,6 +87,7 @@
}
}
+ @Override
public String toString()
{
return getClass().getSimpleName() + "[Outgoing marshaller: " + req_marshaller + "; incoming marshaller: " + rsp_marshaller + "]";
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-03-31 17:53:52 UTC (rev 5479)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/Marshaller.java 2008-04-01 10:29:30 UTC (rev 5480)
@@ -78,4 +78,26 @@
* @return
*/
byte[] objectToByteBuffer(Object o, boolean writeStreamHeaders) throws Exception;
+
+ /**
+ * Returns a RegionalizedMethodCall from a byte buffer. Only use if you <i>know</i> that the byte buffer contains a
+ * MethodCall and that you are using region-based marshalling, otherwise use {@link #objectFromByteBuffer(byte[])}
+ *
+ * @param buffer byte buffer
+ * @return a RegionalizedMethodCall
+ * @throws Exception if there are issues
+ * @since 2.1.1
+ */
+ RegionalizedMethodCall regionalizedMethodCallFromByteBuffer(byte[] buffer) throws Exception;
+
+ /**
+ * Returns a RegionalizedMethodCall from an object input stream. Only use if you <i>know</i> that the byte buffer contains a
+ * MethodCall and that you are using region-based marshalling, otherwise use {@link #objectFromObjectStream(java.io.ObjectInputStream)}
+ *
+ * @param in object inout stream
+ * @return a RegionalizedMethodCall
+ * @throws Exception if there are issues
+ * @since 2.1.1
+ */
+ RegionalizedMethodCall regionalizedMethodCallFromObjectStream(ObjectInputStream in) throws Exception;
}
Added: core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedMethodCall.java 2008-04-01 10:29:30 UTC (rev 5480)
@@ -0,0 +1,20 @@
+package org.jboss.cache.marshall;
+
+import org.jboss.cache.Fqn;
+
+/**
+ * A regionalized MethodCall object, created when {@link Marshaller#regionalizedMethodCallFromByteBuffer(byte[])} or
+ * {@link org.jboss.cache.marshall.Marshaller#regionalizedMethodCallFromObjectStream(java.io.ObjectInputStream)} is called.
+ * <p/>
+ * Specifically used by the {@link org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher} so that the region used to unmarshall
+ * the method call is known, and can be used to marshall a result to return to the remote caller.
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.1
+ */
+class RegionalizedMethodCall
+{
+ MethodCall call;
+ Fqn region;
+}
Added: core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedReturnValue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedReturnValue.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/RegionalizedReturnValue.java 2008-04-01 10:29:30 UTC (rev 5480)
@@ -0,0 +1,28 @@
+package org.jboss.cache.marshall;
+
+import org.jboss.cache.Fqn;
+
+/**
+ * A return value that holds region information, so that the marshaller knows which region to use (and hence which
+ * class loader to use) when marshalling this return value.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.1
+ */
+class RegionalizedReturnValue
+{
+ Object returnValue;
+ Fqn region;
+
+ /**
+ * Creates this value object.
+ *
+ * @param returnValue return value to marshall
+ * @param regionalizedMethodCall method call that requested this return value.
+ */
+ RegionalizedReturnValue(Object returnValue, RegionalizedMethodCall regionalizedMethodCall)
+ {
+ this.returnValue = returnValue;
+ this.region = regionalizedMethodCall.region;
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-03-31 17:53:52 UTC (rev 5479)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-04-01 10:29:30 UTC (rev 5480)
@@ -222,6 +222,37 @@
}
}
+ @Override
+ public RegionalizedMethodCall regionalizedMethodCallFromByteBuffer(byte[] buf) throws Exception
+ {
+ Marshaller marshaller;
+ int versionId;
+ ObjectInputStream in = pool.getInputStream(buf);
+
+ try
+ {
+ try
+ {
+ versionId = in.readShort();
+ if (trace) log.trace("Read version " + versionId);
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to read version id from first two bytes of stream, barfing.");
+ throw e;
+ }
+
+ marshaller = getMarshaller(versionId);
+
+ return marshaller.regionalizedMethodCallFromObjectStream(in);
+ }
+ finally
+ {
+ pool.returnStreamToPool(in);
+ }
+ }
+
+ @Override
public Object objectFromStream(InputStream is) throws Exception
{
if (is instanceof ByteArrayInputStream)
@@ -238,15 +269,6 @@
short versionId;
Marshaller marshaller;
-// PushbackInputStream pis = new PushbackInputStream(is);
-// byte[] first4bytes = new byte[4];
-// pis.read(first4bytes);
-// boolean needToWriteHeader = !Arrays.equals(first4bytes, ReusableObjectInputStream.INIT_BYTES);
-// // first push back the bytes read
-// pis.unread(first4bytes);
-// if (needToWriteHeader) pis.unread(ReusableObjectInputStream.INIT_BYTES);
-//
-// ObjectInputStream in = new MarshalledValueInputStream(pis);
ObjectInputStream in = new MarshalledValueInputStream(is);
try
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java 2008-03-31 17:53:52 UTC (rev 5479)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java 2008-04-01 10:29:30 UTC (rev 5480)
@@ -114,10 +114,11 @@
{
try
{
- cm200.objectFromObjectStream(new ObjectInputStream(new ByteArrayInputStream(stream)));
+ RegionalizedMethodCall rmc = cm200.regionalizedMethodCallFromObjectStream(new ObjectInputStream(new ByteArrayInputStream(stream)));
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream outStream = new ObjectOutputStream(out);
- cm200.objectToObjectStream("A result", outStream);
+ RegionalizedReturnValue rrv = new RegionalizedReturnValue("A result", rmc);
+ cm200.objectToObjectStream(rrv, outStream);
outStream.close();
out.close();
// test that the output stream has got "/hello" as it's region Fqn.
16 years, 9 months