[jbosscache-commits] JBoss Cache SVN: r7885 - in core/trunk/src/main/java/org/jboss/cache: transaction and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Sun Mar 8 19:58:09 EDT 2009
Author: manik.surtani at jboss.com
Date: 2009-03-08 19:58:09 -0400 (Sun, 08 Mar 2009)
New Revision: 7885
Modified:
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java
Log:
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2009-03-08 21:03:03 UTC (rev 7884)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2009-03-08 23:58:09 UTC (rev 7885)
@@ -21,24 +21,6 @@
*/
package org.jboss.cache.marshall;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.IdentityHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.commons.httpclient.cookie.IgnoreCookiesSpec;
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
@@ -56,6 +38,13 @@
import org.jgroups.Address;
import org.jgroups.stack.IpAddress;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.*;
+
/**
* An enhanced marshaller for RPC calls between CacheImpl instances.
*
@@ -485,7 +474,13 @@
private void marshallLogEntry(LogEntry log, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception
{
marshallObject(log.getTransaction(), out, refMap);
- marshallObject(log.getModifications(), out, refMap);
+ List<WriteCommand> mods = log.getModifications();
+ boolean isList = mods.size() > 1;
+ out.writeBoolean(isList);
+ if (isList)
+ marshallObject(log.getModifications(), out, refMap);
+ else
+ marshallObject(mods.get(0), out, refMap);
}
private void marshallGravitateResult(GravitateResult gravitateResult, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception
@@ -718,8 +713,12 @@
private LogEntry unmarshallLogEntry(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception
{
GlobalTransaction gtx = (GlobalTransaction)unmarshallObject(in, refMap);
- List<WriteCommand> mods = (List<WriteCommand>)unmarshallObject(in, refMap);
-
+ boolean isList = in.readBoolean();
+ List mods;
+ if (isList)
+ mods = (List)unmarshallObject(in, refMap);
+ else
+ mods = Collections.singletonList(unmarshallObject(in, refMap));
return new LogEntry(gtx, mods);
}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java 2009-03-08 21:03:03 UTC (rev 7884)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionLog.java 2009-03-08 23:58:09 UTC (rev 7885)
@@ -29,6 +29,7 @@
import java.io.ObjectOutputStream;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
@@ -82,13 +83,17 @@
// it is perfectly normal for a prepare not to be logged for this gtx, for example if a transaction did not
// modify anything, then beforeCompletion() is not invoked and logPrepare() will not be called to register the
// prepare.
- if (command != null) addEntry(new LogEntry(gtx, command.getModifications()));
+ if (command != null && isActive()) addEntry(gtx, command.getModifications());
}
- private void addEntry(LogEntry entry)
+ private void addEntry(GlobalTransaction gtx, WriteCommand command)
+ {
+ addEntry(gtx, Collections.singletonList(command));
+ }
+
+ private void addEntry(GlobalTransaction gtx, List<WriteCommand> commands)
{
- if (! isActive())
- return;
+ LogEntry entry = new LogEntry(gtx, commands);
for (;;)
{
@@ -111,17 +116,12 @@
{
// Just in case...
if (gtx != null) pendingPrepares.remove(gtx);
- if (!modifications.isEmpty()) addEntry(new LogEntry(gtx, modifications));
+ if (isActive() && !modifications.isEmpty()) addEntry(gtx, modifications);
}
public void logNoTxWrite(WriteCommand write)
{
- if (! isActive())
- return;
-
- ArrayList<WriteCommand> list = new ArrayList<WriteCommand>();
- list.add(write);
- addEntry(new LogEntry(null, list));
+ if (isActive()) addEntry(null, write);
}
public void rollback(GlobalTransaction gtx)
@@ -129,7 +129,7 @@
pendingPrepares.remove(gtx);
}
- public boolean isActive()
+ public final boolean isActive()
{
return active.get();
}
@@ -171,7 +171,7 @@
marshaller.objectToObjectStream(entry, out);
}
- public boolean hasPendingPrepare(PrepareCommand command)
+ public final boolean hasPendingPrepare(PrepareCommand command)
{
return pendingPrepares.containsKey(command.getGlobalTransaction());
}
More information about the jbosscache-commits
mailing list