[infinispan-commits] Infinispan SVN: r719 - in trunk/core/src: main/java/org/infinispan/marshall and 1 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Fri Aug 21 10:57:56 EDT 2009


Author: galder.zamarreno at jboss.com
Date: 2009-08-21 10:57:56 -0400 (Fri, 21 Aug 2009)
New Revision: 719

Removed:
   trunk/core/src/main/java/org/infinispan/marshall/MarshallerImpl.java
   trunk/core/src/test/java/org/infinispan/marshall/MarshallersTest.java
Modified:
   trunk/core/src/main/java/org/infinispan/container/entries/ImmortalCacheValue.java
Log:
[ISPN-91] (Remove MarshallerImpl once JBoss Marshaller marshalling has been road tested) Done.

Modified: trunk/core/src/main/java/org/infinispan/container/entries/ImmortalCacheValue.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/container/entries/ImmortalCacheValue.java	2009-08-21 13:48:18 UTC (rev 718)
+++ trunk/core/src/main/java/org/infinispan/container/entries/ImmortalCacheValue.java	2009-08-21 14:57:56 UTC (rev 719)
@@ -12,8 +12,6 @@
 /**
  * An immortal cache value, to correspond with {@link org.infinispan.container.entries.ImmortalCacheEntry}
  * 
- * TODO: Once {@link org.infinispan.marshall.MarshallerImpl} is gone, make the class package private.
- *
  * @author Manik Surtani
  * @since 4.0
  */

Deleted: trunk/core/src/main/java/org/infinispan/marshall/MarshallerImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/marshall/MarshallerImpl.java	2009-08-21 13:48:18 UTC (rev 718)
+++ trunk/core/src/main/java/org/infinispan/marshall/MarshallerImpl.java	2009-08-21 14:57:56 UTC (rev 719)
@@ -1,997 +0,0 @@
-/*
- * 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.infinispan.marshall;
-
-import org.infinispan.CacheException;
-import org.infinispan.atomic.DeltaAware;
-import org.infinispan.commands.RemoteCommandFactory;
-import org.infinispan.commands.ReplicableCommand;
-import org.infinispan.commands.write.WriteCommand;
-import org.infinispan.container.entries.*;
-import org.infinispan.io.ByteBuffer;
-import org.infinispan.io.ExposedByteArrayOutputStream;
-import org.infinispan.io.UnsignedNumeric;
-import org.infinispan.loaders.bucket.Bucket;
-import org.infinispan.remoting.responses.ExceptionResponse;
-import org.infinispan.remoting.responses.ExtendedResponse;
-import org.infinispan.remoting.responses.RequestIgnoredResponse;
-import org.infinispan.remoting.responses.Response;
-import org.infinispan.remoting.responses.SuccessfulResponse;
-import org.infinispan.remoting.responses.UnsuccessfulResponse;
-import org.infinispan.remoting.transport.Address;
-import org.infinispan.remoting.transport.jgroups.JGroupsAddress;
-import org.infinispan.transaction.TransactionLog;
-import org.infinispan.transaction.xa.GlobalTransaction;
-import org.infinispan.transaction.xa.GlobalTransactionFactory;
-import org.infinispan.util.FastCopyHashMap;
-import org.infinispan.util.Immutables;
-import org.infinispan.util.Util;
-import org.infinispan.util.logging.Log;
-import org.infinispan.util.logging.LogFactory;
-import org.jboss.util.stream.MarshalledValueInputStream;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Array;
-import java.util.*;
-
-/**
- * Abstract marshaller
- *
- * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
- * @author Galder Zamarreño
- * @since 4.0
- * @deprecated JBoss Marshaller based Marshaller is now use rather than this legacy
- * home grown marshaller. This marshaller hasn't been removed yet so that we can 
- * can carry on comparing payload sizes between the different marshallers. This 
- * will specially help as JBoss Marshaller continues to provide more and more efficient
- * payloads.  
- */
- at Deprecated
-public class MarshallerImpl extends AbstractMarshaller {
-   // magic numbers
-   protected static final int MAGICNUMBER_GTX = 1;
-   protected static final int MAGICNUMBER_JG_ADDRESS = 2;
-   protected static final int MAGICNUMBER_ARRAY_LIST = 3;
-   protected static final int MAGICNUMBER_INTEGER = 4;
-   protected static final int MAGICNUMBER_LONG = 5;
-   protected static final int MAGICNUMBER_BOOLEAN = 6;
-   protected static final int MAGICNUMBER_STRING = 7;
-   protected static final int MAGICNUMBER_LINKED_LIST = 8;
-   protected static final int MAGICNUMBER_HASH_MAP = 9;
-   protected static final int MAGICNUMBER_TREE_MAP = 10;
-   protected static final int MAGICNUMBER_HASH_SET = 11;
-   protected static final int MAGICNUMBER_TREE_SET = 12;
-   protected static final int MAGICNUMBER_SHORT = 13;
-   protected static final int MAGICNUMBER_IMMUTABLE_MAPCOPY = 14;
-   protected static final int MAGICNUMBER_MARSHALLEDVALUE = 15;
-   protected static final int MAGICNUMBER_FASTCOPY_HASHMAP = 16;
-   protected static final int MAGICNUMBER_ARRAY = 17;
-   protected static final int MAGICNUMBER_BYTE = 18;
-   protected static final int MAGICNUMBER_CHAR = 19;
-   protected static final int MAGICNUMBER_FLOAT = 20;
-   protected static final int MAGICNUMBER_DOUBLE = 21;
-   protected static final int MAGICNUMBER_OBJECT = 22;
-   protected static final int MAGICNUMBER_SINGLETON_LIST = 23;
-   protected static final int MAGICNUMBER_COMMAND = 24;
-   protected static final int MAGICNUMBER_TRANSACTION_LOG = 25;
-
-   // --- cache entries and values ---
-   protected static final int MAGICNUMBER_ICE_IMMORTAL = 26;
-   protected static final int MAGICNUMBER_ICE_MORTAL = 27;
-   protected static final int MAGICNUMBER_ICE_TRANSIENT = 28;
-   protected static final int MAGICNUMBER_ICE_TRANSIENT_MORTAL = 29;
-   protected static final int MAGICNUMBER_ICV_IMMORTAL = 30;
-   protected static final int MAGICNUMBER_ICV_MORTAL = 31;
-   protected static final int MAGICNUMBER_ICV_TRANSIENT = 32;
-   protected static final int MAGICNUMBER_ICV_TRANSIENT_MORTAL = 33;
-
-   // ---- responses
-   protected static final int MAGICNUMBER_REQUEST_IGNORED_RESPONSE = 34;
-   protected static final int MAGICNUMBER_EXTENDED_RESPONSE = 35;
-   protected static final int MAGICNUMBER_EXCEPTION_RESPONSE = 36;
-   protected static final int MAGICNUMBER_SUCCESSFUL_RESPONSE = 37;
-   protected static final int MAGICNUMBER_UNSUCCESSFUL_RESPONSE = 38;
-
-   // -- for cache stores
-   protected static final int MAGICNUMBER_CACHESTORE_BUCKET = 39;
-
-   protected static final int MAGICNUMBER_NULL = 99;
-   protected static final int MAGICNUMBER_SERIALIZABLE = 100;
-   protected static final int MAGICNUMBER_REF = 101;
-
-   public MarshallerImpl() {
-      initLogger();
-      // enabled, since this is always enabled in JBC 2.0.0.
-      useRefs = false;
-   }
-
-   protected Log log;
-   protected boolean trace;
-   private RemoteCommandFactory remoteCommandFactory;
-   protected ClassLoader defaultClassLoader;
-   protected boolean useRefs = false;
-
-   protected GlobalTransactionFactory gtxFactory = new GlobalTransactionFactory();
-
-   public void init(ClassLoader defaultClassLoader, RemoteCommandFactory remoteCommandFactory) {
-      this.defaultClassLoader = defaultClassLoader;
-      this.remoteCommandFactory = remoteCommandFactory;
-   }
-
-   protected void initLogger() {
-      log = LogFactory.getLog(getClass());
-      trace = log.isTraceEnabled();
-   }
-
-   public byte[] objectToByteBuffer(Object obj) throws IOException {
-      ByteBuffer b = objectToBuffer(obj);
-      byte[] bytes = new byte[b.getLength()];
-      System.arraycopy(b.getBuf(), b.getOffset(), bytes, 0, b.getLength());
-      return bytes;
-   }
-
-   protected void marshallObject(Object o, ObjectOutput out, Map<Object, Integer> refMap) throws IOException {
-      if (o != null && o.getClass().isArray() && isKnownType(o.getClass().getComponentType())) {
-         marshallArray(o, out, refMap);
-      } else {
-         if (o == null) {
-            out.writeByte(MAGICNUMBER_NULL);
-         } else if (useRefs && refMap.containsKey(o))// see if this object has been marshalled before.
-         {
-            out.writeByte(MAGICNUMBER_REF);
-            writeReference(out, refMap.get(o));
-         } else if (o instanceof ReplicableCommand) {
-            ReplicableCommand command = (ReplicableCommand) o;
-
-            if (command.getCommandId() > -1) {
-               out.writeByte(MAGICNUMBER_COMMAND);
-               marshallCommand(command, out, refMap);
-            } else {
-               throw new IllegalArgumentException("Command does not have a valid method id!");
-            }
-         } else if (o instanceof MarshalledValue) {
-            out.writeByte(MAGICNUMBER_MARSHALLEDVALUE);
-            marshallMarshalledValue((MarshalledValue) o, out, refMap);
-         } else if (o instanceof DeltaAware) {
-            // reading in should be nothing special.
-            out.writeByte(MAGICNUMBER_SERIALIZABLE);
-            // only write the delta for these maps.
-            out.writeObject(((DeltaAware) o).delta());
-         } else if (o instanceof GlobalTransaction) {
-            out.writeByte(MAGICNUMBER_GTX);
-            if (useRefs) writeReference(out, createReference(o, refMap));
-            marshallGlobalTransaction((GlobalTransaction) o, out, refMap);
-         } else if (o instanceof JGroupsAddress) {
-            out.writeByte(MAGICNUMBER_JG_ADDRESS);
-            marshallJGroupsAddress((JGroupsAddress) o, out);
-         } else if (o instanceof Response) {
-            marshallResponse((Response) o, out, refMap);
-         } else if (o instanceof InternalCacheEntry) {
-            marshallInternalCacheEntry((InternalCacheEntry) o, out, refMap);
-         } else if (o instanceof InternalCacheValue) {
-            marshallInternalCacheValue((InternalCacheValue) o, out, refMap);
-         } else if (o.getClass().equals(ArrayList.class)) {
-            out.writeByte(MAGICNUMBER_ARRAY_LIST);
-            marshallCollection((Collection) o, out, refMap);
-         } else if (o instanceof LinkedList) {
-            out.writeByte(MAGICNUMBER_LINKED_LIST);
-            marshallCollection((Collection) o, out, refMap);
-         } else if (o.getClass().getName().equals("java.util.Collections$SingletonList")) {
-            out.writeByte(MAGICNUMBER_SINGLETON_LIST);
-            marshallObject(((List) o).get(0), out, refMap);
-         } else if (o.getClass().equals(HashMap.class)) {
-            out.writeByte(MAGICNUMBER_HASH_MAP);
-            marshallMap((Map) o, out, refMap);
-         } else if (o.getClass().equals(TreeMap.class)) {
-            out.writeByte(MAGICNUMBER_TREE_MAP);
-            marshallMap((Map) o, out, refMap);
-         } else if (o.getClass().equals(FastCopyHashMap.class)) {
-            out.writeByte(MAGICNUMBER_FASTCOPY_HASHMAP);
-            marshallMap((Map) o, out, refMap);
-         } else if (o instanceof Map && Immutables.isImmutable(o)) {
-            out.writeByte(MAGICNUMBER_IMMUTABLE_MAPCOPY);
-            marshallMap((Map) o, out, refMap);
-         } else if (o.getClass().equals(HashSet.class)) {
-            out.writeByte(MAGICNUMBER_HASH_SET);
-            marshallCollection((Collection) o, out, refMap);
-         } else if (o.getClass().equals(TreeSet.class)) {
-            out.writeByte(MAGICNUMBER_TREE_SET);
-            marshallCollection((Collection) o, out, refMap);
-         } else if (o instanceof Boolean) {
-            out.writeByte(MAGICNUMBER_BOOLEAN);
-            out.writeBoolean(((Boolean) o).booleanValue());
-         } else if (o instanceof Integer) {
-            out.writeByte(MAGICNUMBER_INTEGER);
-            out.writeInt(((Integer) o).intValue());
-         } else if (o instanceof Long) {
-            out.writeByte(MAGICNUMBER_LONG);
-            out.writeLong(((Long) o).longValue());
-         } else if (o instanceof Short) {
-            out.writeByte(MAGICNUMBER_SHORT);
-            out.writeShort(((Short) o).shortValue());
-         } else if (o instanceof Byte) {
-            out.writeByte(MAGICNUMBER_BYTE);
-            out.writeByte(((Byte) o).byteValue());
-         } else if (o instanceof Bucket) {
-            out.writeByte(MAGICNUMBER_CACHESTORE_BUCKET);
-            marshallBucket((Bucket) o, out, refMap);
-         } else if (o instanceof String) {
-            out.writeByte(MAGICNUMBER_STRING);
-            if (useRefs) writeReference(out, createReference(o, refMap));
-            marshallString((String) o, out);
-         } else if (o instanceof TransactionLog.LogEntry) {
-            out.writeByte(MAGICNUMBER_TRANSACTION_LOG);
-            TransactionLog.LogEntry le = (TransactionLog.LogEntry) o;
-            marshallObject(le.getTransaction(), out, refMap);
-            WriteCommand[] cmds = le.getModifications();
-            writeUnsignedInt(out, cmds.length);
-            for (WriteCommand c : cmds)
-               marshallObject(c, out, refMap);
-         } else if (o instanceof Serializable) {
-            if (trace) log.trace("WARNING: using object serialization for [{0}]", o.getClass());
-
-            out.writeByte(MAGICNUMBER_SERIALIZABLE);
-            if (useRefs) writeReference(out, createReference(o, refMap));
-            out.writeObject(o);
-         } else {
-            throw new IOException("Don't know how to marshall object of type " + o.getClass());
-         }
-      }
-   }
-
-   private void marshallMarshalledValue(MarshalledValue mv, ObjectOutput out, Map<Object, Integer> refMap) throws IOException {
-      byte[] raw = mv.getRaw();
-      writeUnsignedInt(out, raw.length);
-      out.write(raw);
-      out.writeInt(mv.hashCode());
-   }
-
-   private void marshallBucket(Bucket b, ObjectOutput o, Map<Object, Integer> refMap) throws IOException {
-      writeUnsignedInt(o, b.getNumEntries());
-      for (InternalCacheEntry se : b.getEntries().values()) marshallObject(se, o, refMap);
-   }
-
-   private void marshallInternalCacheEntry(InternalCacheEntry ice, ObjectOutput out, Map<Object, Integer> refMap) throws IOException {
-      if (ice.getClass().equals(ImmortalCacheEntry.class)) {
-         out.writeByte(MAGICNUMBER_ICE_IMMORTAL);
-         marshallObject(ice.getKey(), out, refMap);
-         marshallObject(ice.getValue(), out, refMap);
-      } else if (ice.getClass().equals(MortalCacheEntry.class)) {
-         out.writeByte(MAGICNUMBER_ICE_MORTAL);
-         marshallObject(ice.getKey(), out, refMap);
-         marshallObject(ice.getValue(), out, refMap);
-         writeUnsignedLong(out, ice.getCreated());
-         marshallObject(ice.getLifespan(), out, refMap); // could be negative so should not use unsigned longs
-      } else if (ice.getClass().equals(TransientCacheEntry.class)) {
-         out.writeByte(MAGICNUMBER_ICE_TRANSIENT);
-         marshallObject(ice.getKey(), out, refMap);
-         marshallObject(ice.getValue(), out, refMap);
-         writeUnsignedLong(out, ice.getLastUsed());
-         marshallObject(ice.getMaxIdle(), out, refMap); // could be negative so should not use unsigned longs
-      } else if (ice.getClass().equals(TransientMortalCacheEntry.class)) {
-         out.writeByte(MAGICNUMBER_ICE_TRANSIENT_MORTAL);
-         marshallObject(ice.getKey(), out, refMap);
-         marshallObject(ice.getValue(), out, refMap);
-         writeUnsignedLong(out, ice.getCreated());
-         marshallObject(ice.getLifespan(), out, refMap); // could be negative so should not use unsigned longs
-         writeUnsignedLong(out, ice.getLastUsed());
-         marshallObject(ice.getMaxIdle(), out, refMap); // could be negative so should not use unsigned longs
-      }
-   }
-
-   private void marshallInternalCacheValue(InternalCacheValue icv, ObjectOutput out, Map<Object, Integer> refMap) throws IOException {
-      if (icv.getClass().equals(ImmortalCacheValue.class)) {
-         out.writeByte(MAGICNUMBER_ICV_IMMORTAL);
-         marshallObject(icv.getValue(), out, refMap);
-      } else if (icv.getClass().equals(MortalCacheValue.class)) {
-         out.writeByte(MAGICNUMBER_ICV_MORTAL);
-         marshallObject(icv.getValue(), out, refMap);
-         writeUnsignedLong(out, icv.getCreated());
-         marshallObject(icv.getLifespan(), out, refMap); // could be negative so should not use unsigned longs
-      } else if (icv.getClass().equals(TransientCacheValue.class)) {
-         out.writeByte(MAGICNUMBER_ICV_TRANSIENT);
-         marshallObject(icv.getValue(), out, refMap);
-         writeUnsignedLong(out, icv.getLastUsed());
-         marshallObject(icv.getMaxIdle(), out, refMap); // could be negative so should not use unsigned longs
-      } else if (icv.getClass().equals(TransientMortalCacheValue.class)) {
-         out.writeByte(MAGICNUMBER_ICV_TRANSIENT_MORTAL);
-         marshallObject(icv.getValue(), out, refMap);
-         writeUnsignedLong(out, icv.getCreated());
-         marshallObject(icv.getLifespan(), out, refMap); // could be negative so should not use unsigned longs
-         writeUnsignedLong(out, icv.getLastUsed());
-         marshallObject(icv.getMaxIdle(), out, refMap); // could be negative so should not use unsigned longs
-      }
-   }
-
-
-   protected void marshallString(String s, ObjectOutput out) throws IOException {
-      //StringUtil.saveString(out, s);
-      out.writeObject(s);
-   }
-
-   private void marshallCommand(ReplicableCommand command, ObjectOutput out, Map<Object, Integer> refMap) throws IOException {
-      out.writeShort(command.getCommandId());
-      Object[] args = command.getParameters();
-      byte numArgs = (byte) (args == null ? 0 : args.length);
-      out.writeByte(numArgs);
-
-      for (int i = 0; i < numArgs; i++) {
-         marshallObject(args[i], out, refMap);
-      }
-   }
-
-   private int createReference(Object o, Map<Object, Integer> refMap) {
-      int reference = refMap.size();
-      refMap.put(o, reference);
-      return reference;
-   }
-
-   private void marshallGlobalTransaction(GlobalTransaction globalTransaction, ObjectOutput out, Map<Object, Integer> refMap) throws IOException {
-      out.writeLong(globalTransaction.getId());
-      marshallObject(globalTransaction.getAddress(), out, refMap);
-   }
-
-   private void marshallJGroupsAddress(JGroupsAddress address, ObjectOutput out) throws IOException {
-      out.writeObject(address.getJGroupsAddress());
-   }
-
-   @SuppressWarnings("unchecked")
-   private void marshallCollection(Collection c, ObjectOutput out, Map refMap) throws IOException {
-      writeUnsignedInt(out, c.size());
-      for (Object o : c) {
-         marshallObject(o, out, refMap);
-      }
-   }
-
-   @SuppressWarnings("unchecked")
-   private void marshallMap(Map map, ObjectOutput out, Map<Object, Integer> refMap) throws IOException {
-      int mapSize = map.size();
-      writeUnsignedInt(out, mapSize);
-      if (mapSize == 0) return;
-
-      for (Map.Entry me : (Set<Map.Entry>) map.entrySet()) {
-         marshallObject(me.getKey(), out, refMap);
-         marshallObject(me.getValue(), out, refMap);
-      }
-   }
-
-   private void marshallResponse(Response response, ObjectOutput out, Map<Object, Integer> refMap) throws IOException {
-      if (response instanceof RequestIgnoredResponse) {
-         out.writeByte(MAGICNUMBER_REQUEST_IGNORED_RESPONSE);
-      } else if (response instanceof ExtendedResponse) {
-         out.writeByte(MAGICNUMBER_EXTENDED_RESPONSE);
-         ExtendedResponse er = (ExtendedResponse) response;
-         out.writeBoolean(er.isReplayIgnoredRequests());
-         marshallObject(er.getResponse(), out, refMap);
-      } else if (response instanceof UnsuccessfulResponse) {
-         out.writeByte(MAGICNUMBER_UNSUCCESSFUL_RESPONSE);
-      } else if (response instanceof SuccessfulResponse) {
-         out.writeByte(MAGICNUMBER_SUCCESSFUL_RESPONSE);
-         marshallObject(((SuccessfulResponse) response).getResponseValue(), out, refMap);
-      } else if (response instanceof ExceptionResponse) {
-         out.writeByte(MAGICNUMBER_EXCEPTION_RESPONSE);
-         marshallObject(((ExceptionResponse) response).getException(), out, refMap);
-      }
-   }
-
-   // --------- Unmarshalling methods
-
-   private Response unmarshallResponse(int magic, ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-
-      switch (magic) {
-         case MAGICNUMBER_REQUEST_IGNORED_RESPONSE:
-            return RequestIgnoredResponse.INSTANCE;
-         case MAGICNUMBER_UNSUCCESSFUL_RESPONSE:
-            return UnsuccessfulResponse.INSTANCE;
-         case MAGICNUMBER_SUCCESSFUL_RESPONSE:
-            Object retval = unmarshallObject(in, refMap);
-            return new SuccessfulResponse(retval);
-         case MAGICNUMBER_EXCEPTION_RESPONSE:
-            Exception e = (Exception) unmarshallObject(in, refMap);
-            return new ExceptionResponse(e);
-         case MAGICNUMBER_EXTENDED_RESPONSE:
-            boolean replay = in.readBoolean();
-            Response response = (Response) unmarshallObject(in, refMap);
-            return new ExtendedResponse(response, replay);
-         default:
-            return null;
-      }
-   }
-
-   protected Object unmarshallObject(ObjectInput in, ClassLoader loader, UnmarshalledReferences refMap, boolean overrideContextClassloaderOnThread) throws IOException, ClassNotFoundException {
-      if (loader == null) {
-         return unmarshallObject(in, refMap);
-      } else {
-         Thread currentThread = Thread.currentThread();
-         ClassLoader old = currentThread.getContextClassLoader();
-         try {
-            // only do this if we haven't already set a context class loaderold elsewhere.
-            if (overrideContextClassloaderOnThread || old == null) currentThread.setContextClassLoader(loader);
-            return unmarshallObject(in, refMap);
-         }
-         finally {
-            if (overrideContextClassloaderOnThread || old == null) currentThread.setContextClassLoader(old);
-         }
-      }
-   }
-
-   protected Object unmarshallObject(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      byte magicNumber = in.readByte();
-      int reference = 0;
-      Object retVal;
-      switch (magicNumber) {
-         case MAGICNUMBER_NULL:
-            return null;
-         case MAGICNUMBER_REF:
-            if (useRefs) {
-               reference = readReference(in);
-               return refMap.getReferencedObject(reference);
-            } else break;
-         case MAGICNUMBER_SERIALIZABLE:
-            if (useRefs) reference = readReference(in);
-            retVal = in.readObject();
-            if (useRefs) refMap.putReferencedObject(reference, retVal);
-            return retVal;
-         case MAGICNUMBER_MARSHALLEDVALUE:
-            return unmarshallMarshalledValue(in, refMap);
-         case MAGICNUMBER_ICE_IMMORTAL:
-         case MAGICNUMBER_ICE_MORTAL:
-         case MAGICNUMBER_ICE_TRANSIENT:
-         case MAGICNUMBER_ICE_TRANSIENT_MORTAL:
-            return unmarshallInternalCacheEntry(magicNumber, in, refMap);
-         case MAGICNUMBER_ICV_IMMORTAL:
-         case MAGICNUMBER_ICV_MORTAL:
-         case MAGICNUMBER_ICV_TRANSIENT:
-         case MAGICNUMBER_ICV_TRANSIENT_MORTAL:
-            return unmarshallInternalCacheValue(magicNumber, in, refMap);
-         case MAGICNUMBER_REQUEST_IGNORED_RESPONSE:
-         case MAGICNUMBER_EXTENDED_RESPONSE:
-         case MAGICNUMBER_EXCEPTION_RESPONSE:
-         case MAGICNUMBER_UNSUCCESSFUL_RESPONSE:
-         case MAGICNUMBER_SUCCESSFUL_RESPONSE:
-            return unmarshallResponse(magicNumber, in, refMap);
-         case MAGICNUMBER_COMMAND:
-            retVal = unmarshallCommand(in, refMap);
-            return retVal;
-         case MAGICNUMBER_GTX:
-            if (useRefs) reference = readReference(in);
-            retVal = unmarshallGlobalTransaction(in, refMap);
-            if (useRefs) refMap.putReferencedObject(reference, retVal);
-            return retVal;
-         case MAGICNUMBER_JG_ADDRESS:
-            retVal = unmarshallJGroupsAddress(in);
-            return retVal;
-         case MAGICNUMBER_TRANSACTION_LOG:
-            GlobalTransaction gtx = (GlobalTransaction) unmarshallObject(in, refMap);
-            int numCommands = readUnsignedInt(in);
-            WriteCommand[] cmds = new WriteCommand[numCommands];
-            for (int i = 0; i < numCommands; i++) cmds[i] = (WriteCommand) unmarshallObject(in, refMap);
-            return new TransactionLog.LogEntry(gtx, cmds);
-         case MAGICNUMBER_CACHESTORE_BUCKET:
-            return unmarshallBucket(in, refMap);
-         case MAGICNUMBER_ARRAY:
-            return unmarshallArray(in, refMap);
-         case MAGICNUMBER_ARRAY_LIST:
-            return unmarshallArrayList(in, refMap);
-         case MAGICNUMBER_LINKED_LIST:
-            return unmarshallLinkedList(in, refMap);
-         case MAGICNUMBER_SINGLETON_LIST:
-            return unmarshallSingletonList(in, refMap);
-         case MAGICNUMBER_HASH_MAP:
-            return unmarshallHashMap(in, refMap);
-         case MAGICNUMBER_TREE_MAP:
-            return unmarshallTreeMap(in, refMap);
-         case MAGICNUMBER_HASH_SET:
-            return unmarshallHashSet(in, refMap);
-         case MAGICNUMBER_TREE_SET:
-            return unmarshallTreeSet(in, refMap);
-         case MAGICNUMBER_IMMUTABLE_MAPCOPY:
-            return unmarshallMapCopy(in, refMap);
-         case MAGICNUMBER_FASTCOPY_HASHMAP:
-            return unmarshallFastCopyHashMap(in, refMap);
-         case MAGICNUMBER_BOOLEAN:
-            return in.readBoolean() ? Boolean.TRUE : Boolean.FALSE;
-         case MAGICNUMBER_BYTE:
-            return in.readByte();
-         case MAGICNUMBER_INTEGER:
-            return in.readInt();
-         case MAGICNUMBER_LONG:
-            return in.readLong();
-         case MAGICNUMBER_SHORT:
-            return in.readShort();
-         case MAGICNUMBER_STRING:
-            if (useRefs) reference = readReference(in);
-            retVal = unmarshallString(in);
-            if (useRefs) refMap.putReferencedObject(reference, retVal);
-            return retVal;
-         default:
-            if (log.isErrorEnabled()) {
-               log.error("Unknown Magic Number " + magicNumber);
-            }
-            throw new IOException("Unknown magic number " + magicNumber);
-      }
-      throw new IOException("Unknown magic number " + magicNumber);
-   }
-
-   private MarshalledValue unmarshallMarshalledValue(ObjectInput in, UnmarshalledReferences refs) throws IOException, ClassNotFoundException {
-      int sz = readUnsignedInt(in);
-      byte[] raw = new byte[sz];
-      in.readFully(raw);
-      int hc = in.readInt();
-      return new MarshalledValue(raw, hc, this);
-   }
-
-   private Bucket unmarshallBucket(ObjectInput input, UnmarshalledReferences references) throws IOException, ClassNotFoundException {
-      Bucket b = new Bucket();
-      int numEntries = readUnsignedInt(input);
-      for (int i = 0; i < numEntries; i++) b.addEntry((InternalCacheEntry) unmarshallObject(input, references));
-      return b;
-   }
-
-   private InternalCacheEntry unmarshallInternalCacheEntry(byte magic, ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      Object k = unmarshallObject(in, refMap);
-      Object v = unmarshallObject(in, refMap);
-      switch (magic) {
-         case MAGICNUMBER_ICE_IMMORTAL:
-            return InternalEntryFactory.create(k, v);
-         case MAGICNUMBER_ICE_MORTAL:
-            return InternalEntryFactory.create(k, v,
-                                               readUnsignedLong(in), (Long) unmarshallObject(in, refMap),
-                                               -1, -1);
-         case MAGICNUMBER_ICE_TRANSIENT:
-            return InternalEntryFactory.create(k, v,
-                                               -1, -1,
-                                               readUnsignedLong(in), (Long) unmarshallObject(in, refMap));
-         case MAGICNUMBER_ICE_TRANSIENT_MORTAL:
-            return InternalEntryFactory.create(k, v,
-                                               readUnsignedLong(in), (Long) unmarshallObject(in, refMap),
-                                               readUnsignedLong(in), (Long) unmarshallObject(in, refMap));
-      }
-      throw new IllegalArgumentException("Unknown magic number " + magic);
-   }
-
-   private InternalCacheValue unmarshallInternalCacheValue(byte magic, ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      Object v = unmarshallObject(in, refMap);
-      switch (magic) {
-         case MAGICNUMBER_ICV_IMMORTAL:
-            return InternalEntryFactory.createValue(v);
-         case MAGICNUMBER_ICV_MORTAL:
-            return InternalEntryFactory.createValue(v,
-                                                    readUnsignedLong(in), (Long) unmarshallObject(in, refMap),
-                                                    -1, -1);
-         case MAGICNUMBER_ICV_TRANSIENT:
-            return InternalEntryFactory.createValue(v,
-                                                    -1, -1,
-                                                    readUnsignedLong(in), (Long) unmarshallObject(in, refMap));
-         case MAGICNUMBER_ICV_TRANSIENT_MORTAL:
-            return InternalEntryFactory.createValue(v,
-                                                    readUnsignedLong(in), (Long) unmarshallObject(in, refMap),
-                                                    readUnsignedLong(in), (Long) unmarshallObject(in, refMap));
-      }
-      throw new IllegalArgumentException("Unknown magic number " + magic);
-   }
-
-   private FastCopyHashMap unmarshallFastCopyHashMap(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      FastCopyHashMap map = new FastCopyHashMap();
-      populateFromStream(in, refMap, map);
-      return map;
-   }
-
-   protected String unmarshallString(ObjectInput in) throws IOException, ClassNotFoundException {
-      return (String) in.readObject();
-   }
-
-   private ReplicableCommand unmarshallCommand(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      short methodId = in.readShort();
-      byte numArgs = in.readByte();
-      Object[] args = null;
-
-      if (numArgs > 0) {
-         args = new Object[numArgs];
-         for (int i = 0; i < numArgs; i++) args[i] = unmarshallObject(in, refMap);
-      }
-
-      return remoteCommandFactory.fromStream((byte) methodId, args);
-   }
-
-
-   private GlobalTransaction unmarshallGlobalTransaction(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      GlobalTransaction gtx = gtxFactory.instantiateGlobalTransaction();
-      long id = in.readLong();
-      Object address = unmarshallObject(in, refMap);
-      gtx.setId(id);
-      gtx.setAddress((Address) address);
-      return gtx;
-   }
-
-   private JGroupsAddress unmarshallJGroupsAddress(ObjectInput in) throws IOException, ClassNotFoundException {
-      org.jgroups.Address jga = (org.jgroups.Address) in.readObject();
-      return new JGroupsAddress(jga);
-   }
-
-   private List unmarshallArrayList(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      int listSize = readUnsignedInt(in);
-      List list = new ArrayList(listSize);
-      populateFromStream(in, refMap, list, listSize);
-      return list;
-   }
-
-   private List unmarshallLinkedList(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      List list = new LinkedList();
-      populateFromStream(in, refMap, list, readUnsignedInt(in));
-      return list;
-   }
-
-   private List unmarshallSingletonList(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      return Collections.singletonList(unmarshallObject(in, refMap));
-   }
-
-   private Map unmarshallHashMap(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      Map map = new HashMap();
-      populateFromStream(in, refMap, map);
-      return map;
-   }
-
-   @SuppressWarnings("unchecked")
-   private Map unmarshallMapCopy(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      // read in as a HashMap first
-      Map m = unmarshallHashMap(in, refMap);
-      return Immutables.immutableMapWrap(m);
-   }
-
-   private Map unmarshallTreeMap(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      Map map = new TreeMap();
-      populateFromStream(in, refMap, map);
-      return map;
-   }
-
-   private Set unmarshallHashSet(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      Set set = new HashSet();
-      populateFromStream(in, refMap, set);
-      return set;
-   }
-
-   private Set unmarshallTreeSet(ObjectInput in, UnmarshalledReferences refMap) throws IOException, ClassNotFoundException {
-      Set set = new TreeSet();
-      populateFromStream(in, refMap, set);
-      return set;
-   }
-
-   @SuppressWarnings("unchecked")
-   private void populateFromStream(ObjectInput in, UnmarshalledReferences refMap, Map mapToPopulate) throws IOException, ClassNotFoundException {
-      int size = readUnsignedInt(in);
-      for (int i = 0; i < size; i++) mapToPopulate.put(unmarshallObject(in, refMap), unmarshallObject(in, refMap));
-   }
-
-   @SuppressWarnings("unchecked")
-   private void populateFromStream(ObjectInput in, UnmarshalledReferences refMap, Set setToPopulate) throws IOException, ClassNotFoundException {
-      int size = readUnsignedInt(in);
-      for (int i = 0; i < size; i++) setToPopulate.add(unmarshallObject(in, refMap));
-   }
-
-   @SuppressWarnings("unchecked")
-   private void populateFromStream(ObjectInput in, UnmarshalledReferences refMap, List listToPopulate, int listSize) throws IOException, ClassNotFoundException {
-      for (int i = 0; i < listSize; i++) listToPopulate.add(unmarshallObject(in, refMap));
-   }
-
-   /**
-    * This version of writeReference is written to solve JBCACHE-1211, where references are encoded as ints rather than
-    * shorts.
-    *
-    * @param out       stream to write to
-    * @param reference reference to write
-    * @throws java.io.IOException propagated from OOS
-    * @see <a href="http://jira.jboss.org/jira/browse/JBCACHE-1211">JBCACHE-1211</a>
-    */
-   protected void writeReference(ObjectOutput out, int reference) throws IOException {
-      writeUnsignedInt(out, reference);
-   }
-
-   /**
-    * This version of readReference is written to solve JBCACHE-1211, where references are encoded as ints rather than
-    * shorts.
-    *
-    * @param in stream to read from
-    * @return reference
-    * @throws java.io.IOException propagated from OUS
-    * @see <a href="http://jira.jboss.org/jira/browse/JBCACHE-1211">JBCACHE-1211</a>
-    */
-   protected int readReference(ObjectInput in) throws IOException {
-      return readUnsignedInt(in);
-   }
-
-   protected Object unmarshallArray(ObjectInput in, UnmarshalledReferences refs) throws IOException, ClassNotFoundException {
-      int sz = readUnsignedInt(in);
-      byte type = in.readByte();
-      switch (type) {
-         case MAGICNUMBER_BOOLEAN: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               boolean[] a = new boolean[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readBoolean();
-               return a;
-            } else {
-               Boolean[] a = new Boolean[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readBoolean();
-               return a;
-            }
-         }
-         case MAGICNUMBER_INTEGER: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               int[] a = new int[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readInt();
-               return a;
-            } else {
-               Integer[] a = new Integer[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readInt();
-               return a;
-            }
-         }
-         case MAGICNUMBER_LONG: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               long[] a = new long[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readLong();
-               return a;
-            } else {
-               Long[] a = new Long[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readLong();
-               return a;
-            }
-         }
-         case MAGICNUMBER_CHAR: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               char[] a = new char[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readChar();
-               return a;
-            } else {
-               Character[] a = new Character[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readChar();
-               return a;
-            }
-         }
-         case MAGICNUMBER_BYTE: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               byte[] a = new byte[sz];
-               int bsize = 10240;
-               int offset = 0;
-               int bytesLeft = sz;
-               while (bytesLeft > 0) {
-                  int read = in.read(a, offset, Math.min(bsize, bytesLeft));
-                  offset += read;
-                  bytesLeft -= read;
-               }
-               return a;
-            } else {
-               Byte[] a = new Byte[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readByte();
-               return a;
-            }
-         }
-         case MAGICNUMBER_SHORT: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               short[] a = new short[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readShort();
-               return a;
-            } else {
-               Short[] a = new Short[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readShort();
-               return a;
-            }
-         }
-         case MAGICNUMBER_FLOAT: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               float[] a = new float[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readFloat();
-               return a;
-            } else {
-               Float[] a = new Float[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readFloat();
-               return a;
-            }
-         }
-         case MAGICNUMBER_DOUBLE: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               double[] a = new double[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readDouble();
-               return a;
-            } else {
-               Double[] a = new Double[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readDouble();
-               return a;
-            }
-         }
-         case MAGICNUMBER_OBJECT: {
-            Object[] a = new Object[sz];
-            for (int i = 0; i < sz; i++) a[i] = unmarshallObject(in, refs);
-            return a;
-         }
-         default:
-            throw new CacheException("Unknown array type");
-      }
-   }
-
-   protected void marshallArray(Object o, ObjectOutput out, Map<Object, Integer> refMap) throws IOException {
-      out.writeByte(MAGICNUMBER_ARRAY);
-      Class arrayTypeClass = o.getClass().getComponentType();
-      int sz = Array.getLength(o);
-      writeUnsignedInt(out, sz);
-      boolean isPrim = arrayTypeClass.isPrimitive();
-
-      if (!isPrim && arrayTypeClass.equals(Object.class)) {
-         out.writeByte(MAGICNUMBER_OBJECT);
-         for (int i = 0; i < sz; i++) marshallObject(Array.get(o, i), out, refMap);
-      } else if (arrayTypeClass.equals(byte.class) || arrayTypeClass.equals(Byte.class)) {
-         out.writeByte(MAGICNUMBER_BYTE);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            out.write((byte[]) o);
-         else
-            for (int i = 0; i < sz; i++) out.writeByte((Byte) Array.get(o, i));
-      } else if (arrayTypeClass.equals(int.class) || arrayTypeClass.equals(Integer.class)) {
-         out.writeByte(MAGICNUMBER_INTEGER);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeInt(Array.getInt(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeInt((Integer) Array.get(o, i));
-      } else if (arrayTypeClass.equals(long.class) || arrayTypeClass.equals(Long.class)) {
-         out.writeByte(MAGICNUMBER_LONG);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeLong(Array.getLong(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeLong((Long) Array.get(o, i));
-      } else if (arrayTypeClass.equals(boolean.class) || arrayTypeClass.equals(Boolean.class)) {
-         out.writeByte(MAGICNUMBER_BOOLEAN);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeBoolean(Array.getBoolean(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeBoolean((Boolean) Array.get(o, i));
-      } else if (arrayTypeClass.equals(char.class) || arrayTypeClass.equals(Character.class)) {
-         out.writeByte(MAGICNUMBER_CHAR);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeChar(Array.getChar(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeChar((Character) Array.get(o, i));
-      } else if (arrayTypeClass.equals(short.class) || arrayTypeClass.equals(Short.class)) {
-         out.writeByte(MAGICNUMBER_SHORT);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeShort(Array.getShort(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeShort((Short) Array.get(o, i));
-      } else if (arrayTypeClass.equals(float.class) || arrayTypeClass.equals(Float.class)) {
-         out.writeByte(MAGICNUMBER_FLOAT);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeFloat(Array.getFloat(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeFloat((Float) Array.get(o, i));
-      } else if (arrayTypeClass.equals(double.class) || arrayTypeClass.equals(Double.class)) {
-         out.writeByte(MAGICNUMBER_DOUBLE);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeDouble(Array.getDouble(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeDouble((Double) Array.get(o, i));
-      } else throw new CacheException("Unknown array type!");
-   }
-
-   protected boolean isKnownType(Class c) {
-      return (c.equals(Object.class) ||
-            c.isPrimitive() || c.equals(Character.class) || c.equals(Integer.class) || c.equals(Long.class) ||
-            c.equals(Byte.class) || c.equals(Boolean.class) || c.equals(Short.class) || c.equals(Float.class) ||
-            c.equals(Double.class));
-   }
-
-   public ObjectOutput startObjectOutput(OutputStream os, boolean isReentrant) throws IOException {
-      return new ObjectOutputStream(os);
-   }
-
-   public void finishObjectOutput(ObjectOutput oo) {
-      Util.flushAndCloseOutput(oo);
-   }
-
-   public void objectToObjectStream(Object o, ObjectOutput out) throws IOException {
-      Map<Object, Integer> refMap = useRefs ? new IdentityHashMap<Object, Integer>() : null;
-      ClassLoader toUse = defaultClassLoader;
-      Thread current = Thread.currentThread();
-      ClassLoader old = current.getContextClassLoader();
-      if (old != null) toUse = old;
-
-      try {
-         current.setContextClassLoader(toUse);
-         marshallObject(o, out, refMap);
-      }
-      finally {
-         current.setContextClassLoader(old);
-      }
-   }
-
-   public ObjectInput startObjectInput(InputStream is, boolean isReentrant) throws IOException {
-      return new ObjectInputStream(is);
-   }
-
-   public void finishObjectInput(ObjectInput oi) {
-      Util.closeInput(oi);
-   }
-
-   public Object objectFromObjectStream(ObjectInput in) throws IOException, ClassNotFoundException {
-      UnmarshalledReferences refMap = useRefs ? new UnmarshalledReferences() : null;
-      Object retValue = unmarshallObject(in, defaultClassLoader, refMap, false);
-      if (trace) log.trace("Unmarshalled object " + retValue);
-      return retValue;
-   }
-
-   public ByteBuffer objectToBuffer(Object o) throws IOException {
-      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
-      ObjectOutput out = new ObjectOutputStream(baos);
-
-      //now marshall the contents of the object
-      objectToObjectStream(o, out);
-      out.close();
-      // and return bytes.
-      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
-   }
-
-   public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws IOException, ClassNotFoundException {
-      ObjectInput in = new MarshalledValueInputStream(new ByteArrayInputStream(buf, offset, length));
-      return objectFromObjectStream(in);
-   }
-
-   public Object objectFromByteBuffer(byte[] bytes) throws IOException, ClassNotFoundException {
-      return objectFromByteBuffer(bytes, 0, bytes.length);
-   }
-
-   private int readUnsignedInt(ObjectInput in) throws IOException {
-      return UnsignedNumeric.readUnsignedInt(in);
-   }
-
-   private long readUnsignedLong(ObjectInput in) throws IOException {
-      return UnsignedNumeric.readUnsignedLong(in);
-   }
-
-   private void writeUnsignedInt(ObjectOutput o, int i) throws IOException {
-      UnsignedNumeric.writeUnsignedInt(o, i);
-   }
-
-   private void writeUnsignedLong(ObjectOutput o, long i) throws IOException {
-      UnsignedNumeric.writeUnsignedLong(o, i);
-   }
-}

Deleted: trunk/core/src/test/java/org/infinispan/marshall/MarshallersTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/marshall/MarshallersTest.java	2009-08-21 13:48:18 UTC (rev 718)
+++ trunk/core/src/test/java/org/infinispan/marshall/MarshallersTest.java	2009-08-21 14:57:56 UTC (rev 719)
@@ -1,413 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.infinispan.marshall;
-
-import org.infinispan.commands.RemoteCommandFactory;
-import org.infinispan.commands.ReplicableCommand;
-import org.infinispan.commands.control.StateTransferControlCommand;
-import org.infinispan.commands.read.GetKeyValueCommand;
-import org.infinispan.commands.remote.ClusteredGetCommand;
-import org.infinispan.commands.remote.MultipleRpcCommand;
-import org.infinispan.commands.tx.CommitCommand;
-import org.infinispan.commands.tx.PrepareCommand;
-import org.infinispan.commands.tx.RollbackCommand;
-import org.infinispan.commands.write.ClearCommand;
-import org.infinispan.commands.write.InvalidateCommand;
-import org.infinispan.commands.write.InvalidateL1Command;
-import org.infinispan.commands.write.PutKeyValueCommand;
-import org.infinispan.commands.write.PutMapCommand;
-import org.infinispan.commands.write.RemoveCommand;
-import org.infinispan.commands.write.ReplaceCommand;
-import org.infinispan.container.entries.ImmortalCacheEntry;
-import org.infinispan.container.entries.ImmortalCacheValue;
-import org.infinispan.container.entries.InternalEntryFactory;
-import org.infinispan.container.entries.MortalCacheEntry;
-import org.infinispan.container.entries.MortalCacheValue;
-import org.infinispan.container.entries.TransientCacheEntry;
-import org.infinispan.container.entries.TransientCacheValue;
-import org.infinispan.container.entries.TransientMortalCacheEntry;
-import org.infinispan.container.entries.TransientMortalCacheValue;
-import org.infinispan.distribution.DefaultConsistentHash;
-import org.infinispan.loaders.bucket.Bucket;
-import org.infinispan.marshall.jboss.JBossMarshaller;
-import org.infinispan.remoting.responses.ExtendedResponse;
-import org.infinispan.remoting.responses.RequestIgnoredResponse;
-import org.infinispan.remoting.responses.SuccessfulResponse;
-import org.infinispan.remoting.responses.UnsuccessfulResponse;
-import org.infinispan.remoting.transport.Address;
-import org.infinispan.remoting.transport.jgroups.JGroupsAddress;
-import org.infinispan.transaction.TransactionLog;
-import org.infinispan.transaction.xa.GlobalTransaction;
-import org.infinispan.transaction.xa.GlobalTransactionFactory;
-import org.infinispan.util.FastCopyHashMap;
-import org.infinispan.util.Immutables;
-import org.jgroups.stack.IpAddress;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import java.util.*;
-
-/**
- * Test for home grown and JBoss Marshalling based marshallers where data written and size of payloads are compared.
- * It's disabled by default because JBoss Marshalling for the moment generates bigger payloads in most cases.
- *
- * @author Galder Zamarreño
- * @since 4.0
- */
- at Test(groups = "functional", testName = "marshall.MarshallersTest", enabled = true)
-public class MarshallersTest {
-
-   private final MarshallerImpl home = new MarshallerImpl();
-   private GlobalTransactionFactory gtf = new GlobalTransactionFactory();
-   private final JBossMarshaller jboss = new JBossMarshaller();
-   private final Marshaller[] marshallers = new Marshaller[]{home, jboss};
-
-   @BeforeTest
-   public void setUp() {
-      home.init(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
-      jboss.start(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory(), jboss);
-   }
-
-   @AfterTest
-   public void tearDown() {
-      jboss.stop();
-   }
-
-   public void testJGroupsAddressMarshalling() throws Exception {
-      JGroupsAddress address = new JGroupsAddress(new IpAddress(12345));
-      checkEqualityAndSize(address);
-   }
-
-   public void testGlobalTransactionMarshalling() throws Exception {
-      GlobalTransaction gtx = gtf.newGlobalTransaction(new JGroupsAddress(new IpAddress(12345)), false);
-      checkEqualityAndSize(gtx);
-   }
-
-   public void testListMarshalling() throws Exception {
-      List l1 = new ArrayList();
-      List l2 = new LinkedList();
-      for (int i = 0; i < 10; i++) {
-         GlobalTransaction gtx = gtf.newGlobalTransaction(new JGroupsAddress(new IpAddress(1000 * i)), false);
-         l1.add(gtx);
-         l2.add(gtx);
-      }
-      checkEqualityAndSize(l1);
-      checkEqualityAndSize(l2);
-   }
-
-   public void testMapMarshalling() throws Exception {
-      Map m1 = new HashMap();
-      Map m2 = new TreeMap();
-      Map m3 = new HashMap();
-      Map<Integer, GlobalTransaction> m4 = new FastCopyHashMap<Integer, GlobalTransaction>();
-      for (int i = 0; i < 10; i++) {
-         GlobalTransaction gtx = gtf.newGlobalTransaction(new JGroupsAddress(new IpAddress(1000 * i)), false);
-         m1.put(1000 * i, gtx);
-         m2.put(1000 * i, gtx);
-         m4.put(1000 * i, gtx);
-      }
-      Map m5 = Immutables.immutableMapWrap(m3);
-      checkEqualityAndSize(m1);
-      checkEqualityAndSize(m2);
-
-      List<Integer> sizes = new ArrayList<Integer>(2);
-      for (Marshaller marshaller : marshallers) {
-         byte[] bytes = marshaller.objectToByteBuffer(m4);
-         Map<Integer, GlobalTransaction> m4Read = (Map<Integer, GlobalTransaction>) marshaller.objectFromByteBuffer(bytes);
-         for (Map.Entry<Integer, GlobalTransaction> entry : m4.entrySet()) {
-            assert m4Read.get(entry.getKey()).equals(entry.getValue()) : "Writen[" + entry.getValue() + "] and read[" + m4Read.get(entry.getKey()) + "] objects should be the same";
-         }
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-
-      checkEqualityAndSize(m5);
-   }
-
-   public void testSetMarshalling() throws Exception {
-      Set s1 = new HashSet();
-      Set s2 = new TreeSet();
-      for (int i = 0; i < 10; i++) {
-         Integer integ = new Integer(1000 * i);
-         s1.add(integ);
-         s2.add(integ);
-      }
-      checkEqualityAndSize(s1);
-      checkEqualityAndSize(s2);
-   }
-
-   public void testMarshalledValueMarshalling() throws Exception {
-      IpAddress addr = new IpAddress(12345);
-      int bytesH = marshallAndAssertEquality(home, new MarshalledValue(addr, true, home));
-      int bytesJ = marshallAndAssertEquality(jboss, new MarshalledValue(addr, true, jboss));
-      assert bytesJ < bytesH : "JBoss Marshaller should write less bytes: bytesJBoss=" + bytesJ + ", bytesHome=" + bytesH;
-   }
-
-   public void testSingletonListMarshalling() throws Exception {
-      GlobalTransaction gtx = gtf.newGlobalTransaction(new JGroupsAddress(new IpAddress(12345)), false);
-      List l = Collections.singletonList(gtx);
-      checkEqualityAndSize(l);
-   }
-
-   public void testTransactionLogMarshalling() throws Exception {
-      GlobalTransaction gtx = gtf.newGlobalTransaction(new JGroupsAddress(new IpAddress(12345)), false);
-      PutKeyValueCommand command = new PutKeyValueCommand("k", "v", false, null, 0, 0);
-      TransactionLog.LogEntry entry = new TransactionLog.LogEntry(gtx, command);
-
-      List<Integer> sizes = new ArrayList<Integer>(2);
-      for (Marshaller marshaller : marshallers) {
-         byte[] bytes = marshaller.objectToByteBuffer(entry);
-         TransactionLog.LogEntry readObj = (TransactionLog.LogEntry) marshaller.objectFromByteBuffer(bytes);
-         assert Arrays.equals(readObj.getModifications(), entry.getModifications()) :
-               "Writen[" + entry.getModifications() + "] and read[" + readObj.getModifications() + "] objects should be the same";
-         assert readObj.getTransaction().equals(entry.getTransaction()) :
-               "Writen[" + entry.getModifications() + "] and read[" + readObj.getModifications() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-   }
-
-   public void testImmutableResponseMarshalling() throws Exception {
-      checkEqualityAndSize(RequestIgnoredResponse.INSTANCE);
-      checkEqualityAndSize(UnsuccessfulResponse.INSTANCE);
-   }
-
-   public void testExtendedResponseMarshalling() throws Exception {
-      SuccessfulResponse sr = new SuccessfulResponse("Blah");
-      ExtendedResponse extended = new ExtendedResponse(sr, false);
-
-      List<Integer> sizes = new ArrayList<Integer>(2);
-      for (Marshaller marshaller : marshallers) {
-         byte[] bytes = marshaller.objectToByteBuffer(extended);
-         ExtendedResponse readObj = (ExtendedResponse) marshaller.objectFromByteBuffer(bytes);
-         assert extended.getResponse().equals(readObj.getResponse()) :
-               "Writen[" + extended.getResponse() + "] and read[" + readObj.getResponse() + "] objects should be the same";
-         assert extended.isReplayIgnoredRequests() == readObj.isReplayIgnoredRequests() :
-               "Writen[" + extended.isReplayIgnoredRequests() + "] and read[" + readObj.isReplayIgnoredRequests() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-   }
-
-   public void testReplicableCommandsMarshalling() throws Exception {
-      StateTransferControlCommand c1 = new StateTransferControlCommand(true);
-
-      List<Integer> sizes = new ArrayList<Integer>(2);
-      for (Marshaller marshaller : marshallers) {
-         byte[] bytes = marshaller.objectToByteBuffer(c1);
-         StateTransferControlCommand rc1 = (StateTransferControlCommand) marshaller.objectFromByteBuffer(bytes);
-         assert rc1.getCommandId() == c1.getCommandId() : "Writen[" + c1.getCommandId() + "] and read[" + rc1.getCommandId() + "] objects should be the same";
-         assert Arrays.equals(rc1.getParameters(), c1.getParameters()) : "Writen[" + c1.getParameters() + "] and read[" + rc1.getParameters() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-
-      ClusteredGetCommand c2 = new ClusteredGetCommand("key", "mycache");
-      checkEqualityAndSize(c2);
-
-      // SizeCommand does not have an empty constructor, so doesn't look to be one that is marshallable.      
-
-      GetKeyValueCommand c4 = new GetKeyValueCommand("key", null);
-      sizes.clear();
-      for (Marshaller marshaller : marshallers) {
-         byte[] bytes = marshaller.objectToByteBuffer(c4);
-         GetKeyValueCommand rc4 = (GetKeyValueCommand) marshaller.objectFromByteBuffer(bytes);
-         assert rc4.getCommandId() == c4.getCommandId() : "Writen[" + c4.getCommandId() + "] and read[" + rc4.getCommandId() + "] objects should be the same";
-         assert Arrays.equals(rc4.getParameters(), c4.getParameters()) : "Writen[" + c4.getParameters() + "] and read[" + rc4.getParameters() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-
-      PutKeyValueCommand c5 = new PutKeyValueCommand("k", "v", false, null, 0, 0);
-      checkEqualityAndSize(c5);
-
-      RemoveCommand c6 = new RemoveCommand("key", null, null);
-      checkEqualityAndSize(c6);
-
-      // EvictCommand does not have an empty constructor, so doesn't look to be one that is marshallable.
-
-      InvalidateCommand c7 = new InvalidateCommand(null, null, "key1", "key2");
-      sizes.clear();
-      for (Marshaller marshaller : marshallers) {
-         byte[] bytes = marshaller.objectToByteBuffer(c7);
-         InvalidateCommand rc7 = (InvalidateCommand) marshaller.objectFromByteBuffer(bytes);
-         assert rc7.getCommandId() == c7.getCommandId() : "Writen[" + c7.getCommandId() + "] and read[" + rc7.getCommandId() + "] objects should be the same";
-         assert Arrays.equals(rc7.getParameters(), c7.getParameters()) : "Writen[" + c7.getParameters() + "] and read[" + rc7.getParameters() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-
-      InvalidateCommand c71 = new InvalidateL1Command(null, null, "key1", "key2");
-      sizes.clear();
-      for (Marshaller marshaller : marshallers) {
-         byte[] bytes = marshaller.objectToByteBuffer(c71);
-         InvalidateCommand rc71 = (InvalidateCommand) marshaller.objectFromByteBuffer(bytes);
-         assert rc71.getCommandId() == c71.getCommandId() : "Writen[" + c71.getCommandId() + "] and read[" + rc71.getCommandId() + "] objects should be the same";
-         assert Arrays.equals(rc71.getParameters(), c71.getParameters()) : "Writen[" + c71.getParameters() + "] and read[" + rc71.getParameters() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-
-      ReplaceCommand c8 = new ReplaceCommand("key", "oldvalue", "newvalue", 0, 0);
-      checkEqualityAndSize(c8);
-
-      ClearCommand c9 = new ClearCommand();
-      sizes.clear();
-      for (Marshaller marshaller : marshallers) {
-         byte[] bytes = marshaller.objectToByteBuffer(c9);
-         ClearCommand rc9 = (ClearCommand) marshaller.objectFromByteBuffer(bytes);
-         assert rc9.getCommandId() == c9.getCommandId() : "Writen[" + c9.getCommandId() + "] and read[" + rc9.getCommandId() + "] objects should be the same";
-         assert Arrays.equals(rc9.getParameters(), c9.getParameters()) : "Writen[" + c9.getParameters() + "] and read[" + rc9.getParameters() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-
-      Map m1 = new HashMap();
-      for (int i = 0; i < 10; i++) {
-         GlobalTransaction gtx = gtf.newGlobalTransaction(new JGroupsAddress(new IpAddress(1000 * i)), false);
-         m1.put(1000 * i, gtx);
-      }
-      PutMapCommand c10 = new PutMapCommand(m1, null, 0, 0);
-      checkEqualityAndSize(c10);
-
-      Address local = new JGroupsAddress(new IpAddress(12345));
-      GlobalTransaction gtx = gtf.newGlobalTransaction(local, false);
-      PrepareCommand c11 = new PrepareCommand(gtx, true, c5, c6, c8, c10);
-      checkEqualityAndSize(c11);
-
-      CommitCommand c12 = new CommitCommand(gtx);
-      checkEqualityAndSize(c12);
-
-      RollbackCommand c13 = new RollbackCommand(gtx);
-      checkEqualityAndSize(c13);
-
-      MultipleRpcCommand c99 = new MultipleRpcCommand(Arrays.asList(new ReplicableCommand[]{c2, c5, c6, c8, c10, c12, c13}), "mycache");
-      checkEqualityAndSize(c99);
-   }
-
-   public void testInternalCacheEntryMarshalling() throws Exception {
-      ImmortalCacheEntry entry1 = (ImmortalCacheEntry) InternalEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, -1, System.currentTimeMillis(), -1);
-      checkEqualityAndSize(entry1);
-
-      MortalCacheEntry entry2 = (MortalCacheEntry) InternalEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, 200000, System.currentTimeMillis(), -1);
-      checkEqualityAndSize(entry2);
-
-      TransientCacheEntry entry3 = (TransientCacheEntry) InternalEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, -1, System.currentTimeMillis(), 4000000);
-      checkEqualityAndSize(entry3);
-
-      TransientMortalCacheEntry entry4 = (TransientMortalCacheEntry) InternalEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, 200000, System.currentTimeMillis(), 4000000);
-      checkEqualityAndSize(entry4);
-   }
-
-   public void testInternalCacheValueMarshalling() throws Exception {
-      byte[] bytes = null;
-      ImmortalCacheValue value1 = (ImmortalCacheValue) InternalEntryFactory.createValue("value", System.currentTimeMillis() - 1000, -1, System.currentTimeMillis(), -1);
-      List<Integer> sizes = new ArrayList<Integer>(2);
-      for (Marshaller marshaller : marshallers) {
-         bytes = marshaller.objectToByteBuffer(value1);
-         ImmortalCacheValue rvalue1 = (ImmortalCacheValue) marshaller.objectFromByteBuffer(bytes);
-         assert rvalue1.getValue().equals(value1.getValue()) : "Writen[" + rvalue1.getValue() + "] and read[" + value1.getValue() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-
-      sizes.clear();
-      for (Marshaller marshaller : marshallers) {
-         MortalCacheValue value2 = (MortalCacheValue) InternalEntryFactory.createValue("value", System.currentTimeMillis() - 1000, 200000, System.currentTimeMillis(), -1);
-         bytes = marshaller.objectToByteBuffer(value2);
-         MortalCacheValue rvalue2 = (MortalCacheValue) marshaller.objectFromByteBuffer(bytes);
-         assert rvalue2.getValue().equals(value2.getValue()) : "Writen[" + rvalue2.getValue() + "] and read[" + value2.getValue() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-
-      sizes.clear();
-      for (Marshaller marshaller : marshallers) {
-         TransientCacheValue value3 = (TransientCacheValue) InternalEntryFactory.createValue("value", System.currentTimeMillis() - 1000, -1, System.currentTimeMillis(), 4000000);
-         bytes = marshaller.objectToByteBuffer(value3);
-         TransientCacheValue rvalue3 = (TransientCacheValue) marshaller.objectFromByteBuffer(bytes);
-         assert rvalue3.getValue().equals(value3.getValue()) : "Writen[" + rvalue3.getValue() + "] and read[" + value3.getValue() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-
-      sizes.clear();
-      for (Marshaller marshaller : marshallers) {
-         TransientMortalCacheValue value4 = (TransientMortalCacheValue) InternalEntryFactory.createValue("value", System.currentTimeMillis() - 1000, 200000, System.currentTimeMillis(), 4000000);
-         bytes = marshaller.objectToByteBuffer(value4);
-         TransientMortalCacheValue rvalue4 = (TransientMortalCacheValue) marshaller.objectFromByteBuffer(bytes);
-         assert rvalue4.getValue().equals(value4.getValue()) : "Writen[" + rvalue4.getValue() + "] and read[" + value4.getValue() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-   }
-
-   public void testBucketMarshalling() throws Exception {
-      ImmortalCacheEntry entry1 = (ImmortalCacheEntry) InternalEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, -1, System.currentTimeMillis(), -1);
-      MortalCacheEntry entry2 = (MortalCacheEntry) InternalEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, 200000, System.currentTimeMillis(), -1);
-      TransientCacheEntry entry3 = (TransientCacheEntry) InternalEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, -1, System.currentTimeMillis(), 4000000);
-      TransientMortalCacheEntry entry4 = (TransientMortalCacheEntry) InternalEntryFactory.create("key", "value", System.currentTimeMillis() - 1000, 200000, System.currentTimeMillis(), 4000000);
-      Bucket b = new Bucket();
-      b.setBucketName("mybucket");
-      b.addEntry(entry1);
-      b.addEntry(entry2);
-      b.addEntry(entry3);
-      b.addEntry(entry4);
-
-      List<Integer> sizes = new ArrayList<Integer>(2);
-      for (Marshaller marshaller : marshallers) {
-         byte[] bytes = marshaller.objectToByteBuffer(b);
-         Bucket rb = (Bucket) marshaller.objectFromByteBuffer(bytes);
-         assert rb.getEntries().equals(b.getEntries()) : "Writen[" + b.getEntries() + "] and read[" + rb.getEntries() + "] objects should be the same";
-         sizes.add(bytes.length);
-      }
-      assert sizes.get(1) < sizes.get(0) : "JBoss Marshaller should write less bytes: bytesJBoss=" + sizes.get(1) + ", bytesHome=" + sizes.get(0);
-   }
-
-   public void testConsistentHash() throws Exception {
-      DefaultConsistentHash dch = new DefaultConsistentHash();
-      List<Address> caches = new LinkedList<Address>();
-      caches.add(new JGroupsAddress(new org.jgroups.util.UUID()));
-      caches.add(new JGroupsAddress(new org.jgroups.util.UUID()));
-      caches.add(new JGroupsAddress(new org.jgroups.util.UUID()));
-      dch.setCaches(caches);
-
-      byte[] bytes = jboss.objectToByteBuffer(dch);
-      DefaultConsistentHash dch2 = (DefaultConsistentHash) jboss.objectFromByteBuffer(bytes);
-      assert dch2.equals(dch);
-   }
-
-   protected void checkEqualityAndSize(Object writeObj) throws Exception {
-      int bytesH = marshallAndAssertEquality(home, writeObj);
-      int bytesJ = marshallAndAssertEquality(jboss, writeObj);
-      assert bytesJ < bytesH : "JBoss Marshaller should write less bytes: bytesJBoss=" + bytesJ + ", bytesHome=" + bytesH;
-   }
-
-   protected int marshallAndAssertEquality(Marshaller marshaller, Object writeObj) throws Exception {
-      byte[] bytes = marshaller.objectToByteBuffer(writeObj);
-      Object readObj = marshaller.objectFromByteBuffer(bytes);
-      assert readObj.equals(writeObj) : "Writen[" + writeObj + "] and read[" + readObj + "] objects should be the same";
-      return bytes.length;
-   }
-
-}



More information about the infinispan-commits mailing list