[jboss-cvs] JBossCache/src/org/jboss/cache/loader ...
Galder Zamarreno
galder.zamarreno at jboss.com
Fri Jan 12 12:02:02 EST 2007
User: gzamarreno
Date: 07/01/12 12:02:02
Modified: src/org/jboss/cache/loader AbstractCacheLoader.java
JDBCCacheLoader.java
Log:
[JBCACHE-879] Functionality for JDBCacheLoader to use version aware marshalling mechanism instead of standard serialization has been introduced. Previous method has been commented out in case there's a need to revert back to it as profiling/performance study has not finished yet.
Revision Changes Path
1.16 +6 -0 JBossCache/src/org/jboss/cache/loader/AbstractCacheLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractCacheLoader.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/AbstractCacheLoader.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- AbstractCacheLoader.java 1 Jan 2007 22:12:20 -0000 1.15
+++ AbstractCacheLoader.java 12 Jan 2007 17:02:02 -0000 1.16
@@ -11,6 +11,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.RegionManager;
+import org.jboss.cache.marshall.VersionAwareMarshaller;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.util.MapCopy;
@@ -24,6 +25,7 @@
* A convenience abstract implementation of a {@link CacheLoader}
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
* @since 2.0.0
*/
public abstract class AbstractCacheLoader implements CacheLoader
@@ -239,4 +241,8 @@
}
}
+ protected VersionAwareMarshaller getMarshaller()
+ {
+ return cache.getMarshaller();
+ }
}
1.27 +24 -40 JBossCache/src/org/jboss/cache/loader/JDBCCacheLoader.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JDBCCacheLoader.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/JDBCCacheLoader.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- JDBCCacheLoader.java 30 Dec 2006 19:48:44 -0000 1.26
+++ JDBCCacheLoader.java 12 Jan 2007 17:02:02 -0000 1.27
@@ -79,7 +79,8 @@
*
* @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
* @author <a href="mailto:hmesha at novell.com">Hany Mesha </a>
- * @version <tt>$Revision: 1.26 $</tt>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ * @version <tt>$Revision: 1.27 $</tt>
*/
public class JDBCCacheLoader extends AbstractCacheLoader
{
@@ -676,15 +677,13 @@
if (node != null)
{
-// Object marshalledNode = new MarshalledValue(node);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
-// oos.writeObject(marshalledNode);
-//
- oos.writeObject(node);
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ps.setBinaryStream(2, bais, baos.size());
+// ByteArrayOutputStream baos = new ByteArrayOutputStream();
+// ObjectOutputStream oos = new ObjectOutputStream(baos);
+// oos.writeObject(node);
+
+ byte[] byteStream = getMarshaller().objectToByteBuffer(node);
+ ByteArrayInputStream bais = new ByteArrayInputStream(byteStream);
+ ps.setBinaryStream(2, bais, byteStream.length);
}
else
{
@@ -759,17 +758,14 @@
// don't set it to null - simply use an empty hash map.
node = new HashMap(0);
}
- // else
- // {
-// Object marshalledNode = new MarshalledValue(node);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
-// oos.writeObject(marshalledNode);
- oos.writeObject(node);
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ps.setBinaryStream(1, bais, baos.size());
- // }
+// ByteArrayOutputStream baos = new ByteArrayOutputStream();
+// ObjectOutputStream oos = new ObjectOutputStream(baos);
+// oos.writeObject(node);
+
+ byte[] byteStream = getMarshaller().objectToByteBuffer(node);
+ ByteArrayInputStream bais = new ByteArrayInputStream(byteStream);
+ ps.setBinaryStream(1, bais, byteStream.length);
ps.setString(2, name.toString());
@@ -825,35 +821,23 @@
InputStream is = rs.getBinaryStream(1);
if (is != null && !rs.wasNull())
{
- ObjectInputStream ois = null;
try
{
- // deserialize result
- ois = new ObjectInputStream(is);
- Object marshalledNode = ois.readObject();
+// ObjectInputStream ois = null;
+// ois = new ObjectInputStream(is);
+// Object marshalledNode = ois.readObject();
- // de-marshall value if possible
-// if (marshalledNode instanceof MarshalledValue)
-// {
-// oldNode = (Map) ((MarshalledValue) marshalledNode).get();
-// }
-// else if (marshalledNode instanceof MarshalledObject)
-// {
-// oldNode = (Map) ((MarshalledObject) marshalledNode).get();
-// }
+ // deserialize result
+ Object marshalledNode = getMarshaller().objectFromInputStream(is);
oldNode = (Map) marshalledNode;
}
- catch (IOException e)
- {
- throw new SQLException("Unable to load to deserialize result: " + e);
- }
- catch (ClassNotFoundException e)
+ catch (Exception e)
{
throw new SQLException("Unable to load to deserialize result: " + e);
}
finally
{
- safeClose(ois);
+ safeClose(is);
}
}
}
More information about the jboss-cvs-commits
mailing list