[jbosscache-commits] JBoss Cache SVN: r5580 - in core/trunk/src/main/java/org/jboss/cache: buddyreplication and 7 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Apr 16 12:39:46 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-04-16 12:39:46 -0400 (Wed, 16 Apr 2008)
New Revision: 5580

Modified:
   core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
   core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
   core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
   core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
   core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java
   core/trunk/src/main/java/org/jboss/cache/commands/cachedata/CreateNodeCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/visitors/AbstractCommandsVisitor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
Log:
More fixes

Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -222,7 +222,8 @@
    public Map getDataDirect()
    {
       if (data == null) return Collections.emptyMap();
-      return Collections.unmodifiableMap(data);
+//      return Collections.unmodifiableMap(data);
+      return data;
    }
 
    public Object put(Object key, Object value)

Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -7,7 +7,14 @@
 import org.jboss.cache.commands.CommandsFactory;
 import org.jboss.cache.commands.cachedata.*;
 import org.jboss.cache.commands.functional.MarshallableCommand;
-import org.jboss.cache.commands.remote.*;
+import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
+import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ClusteredGetCommand;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.remote.GravitateDataCommand;
+import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
+import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ReplicateCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
@@ -161,7 +168,7 @@
    {
       List<? extends CacheCommand> toTransform = command.getModifications();
       List<? extends CacheCommand> transformedCommands = transformBatch(toTransform);
-      return factory.buildPrepareCommand(null, transformedCommands, command.getLocalAddress(), command.isOnePhaseCommit());
+      return factory.buildPrepareCommand(command.getGlobalTransaction(), transformedCommands, command.getLocalAddress(), command.isOnePhaseCommit());
    }
 
    public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
@@ -202,6 +209,12 @@
       return factory.buildClusteredGetCommand(command.getSearchBackupSubtrees(), transformed);
    }
 
+   public Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
+   {
+      return factory.buildCreateNodeCommand(getBackupFqn(command.getFqn()));
+   }
+
+
    /**
     * Assumes the backup Fqn if the current instance is the data owner.
     */

Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -58,7 +58,8 @@
  */
 public class BuddyManager
 {
-   private static Log log = LogFactory.getLog(BuddyManager.class);
+   private Log log = LogFactory.getLog(BuddyManager.class);
+   private boolean trace;
 
    BuddyReplicationConfig config;
 
@@ -151,7 +152,7 @@
    private void setupInternals(BuddyReplicationConfig config)
    {
       this.config = config;
-
+      trace = log.isTraceEnabled();
       BuddyLocatorConfig blc = config.getBuddyLocatorConfig();
       try
       {
@@ -345,7 +346,7 @@
          {
             //first empty the queue.  All queued up view changes that have not been processed yet are now obsolete.
             queue.clear();
-            if (log.isTraceEnabled()) log.trace("Enqueueing " + mc + " for async processing");
+            if (trace) log.trace("Enqueueing " + mc + " for async processing");
             queue.put(mc);
          }
       }
@@ -656,7 +657,10 @@
    {
       try
       {
-         return (MarshallableCommand) call.accept(null, fqnTransformer);
+
+         MarshallableCommand transformed = (MarshallableCommand) call.accept(null, fqnTransformer);
+         if (trace) log.trace("Transformed " + call + " to " + transformed);
+         return transformed;
       }
       catch (Throwable throwable)
       {
@@ -874,8 +878,6 @@
       long[] timeouts = {400, 800, 1600};
       TimeoutException timeoutException = null;
 
-      boolean trace = log.isTraceEnabled();
-
       for (int i = 0; i < timeouts.length; i++)
       {
          timeoutException = null;
@@ -1214,7 +1216,7 @@
             }
          }
 
-         if (log.isTraceEnabled())
+         if (trace)
          {
             log.trace(buddyGroup.getDataOwner() + " received buddy pool info for new members " + newMembers + "?  " + infoReceived);
          }
@@ -1237,7 +1239,7 @@
       public void handleViewChange(ViewChangedEvent event)
       {
          View newView = event.getNewView();
-         if (log.isTraceEnabled())
+         if (trace)
             log.trace("BuddyManager CacheListener - got view change with new view " + newView);
          Vector<Address> newMembers = newView.getMembers();
 

Modified: core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -8,7 +8,14 @@
 import org.jboss.cache.commands.channel.BlockChannelCommand;
 import org.jboss.cache.commands.channel.UnblockChannelCommand;
 import org.jboss.cache.commands.functional.MarshallableCommand;
-import org.jboss.cache.commands.remote.*;
+import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
+import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ClusteredGetCommand;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.remote.GravitateDataCommand;
+import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
+import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ReplicateCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
@@ -345,6 +352,10 @@
             returnValue = new RemoveNodeCommand();
             break;
 
+         case CreateNodeCommand.METHOD_ID:
+            returnValue = new CreateNodeCommand();
+            break;
+
             // --- transactional method calls
 
          case PrepareCommand.METHOD_ID:
@@ -394,6 +405,7 @@
             returnValue = new GravitateDataCommand();
             break;
 
+
          default:
             throw new CacheException("Unknown command id " + id + "!");
       }

Modified: core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -4,7 +4,14 @@
 import org.jboss.cache.commands.cachedata.*;
 import org.jboss.cache.commands.channel.BlockChannelCommand;
 import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.remote.*;
+import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
+import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ClusteredGetCommand;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.remote.GravitateDataCommand;
+import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
+import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ReplicateCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
@@ -26,7 +33,7 @@
 //         putMethodIds.add(putKeyValVersionedMethodLocal_id);
 //         putMethodIds.add(putForExternalReadMethodLocal_id);
 //         putMethodIds.add(putForExternalReadVersionedMethodLocal_id);
-//   crudMethods 
+//   crudMethods
 //   crudMethodIds.addAll(putMethodIds);
 //         crudMethodIds.add(removeNodeMethodLocal_id);
 //         crudMethodIds.add(removeKeyMethodLocal_id);
@@ -45,7 +52,7 @@
      4 - putDataVersionedMethodLocal_id
    */
 
-   public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable;
+   Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable;
 
    /*
      equiv of old:
@@ -54,151 +61,153 @@
        3 - putForExternalReadMethodLocal_id
        4 - putForExternalReadVersionedMethodLocal_id
     */
-   public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand putKeyValueCommand) throws Throwable;
+   Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand putKeyValueCommand) throws Throwable;
 
    /*
     equiv of old:
        1 - removeNodeMethodLocal_id
        2 - removeNodeVersionedMethodLocal_id
     */
-   public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand removeNodeCommand) throws Throwable;
+   Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand removeNodeCommand) throws Throwable;
 
    /*
      equiv of old:
        1 - removeDataMethodLocal_id
        2 - removeDataVersionedMethodLocal_id
     */
-   public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand removeDataCommand) throws Throwable;
+   Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand removeDataCommand) throws Throwable;
 
    /*
      equiv of old:
        1 - evictNodeMethodLocal_id
        2 - evictVersionedNodeMethodLocal_id
     */
-   public Object handleEvictFqnCommand(InvocationContext ctx, EvictNodeCommand evictFqnCommand) throws Throwable;
+   Object handleEvictFqnCommand(InvocationContext ctx, EvictNodeCommand evictFqnCommand) throws Throwable;
 
    /*
      equiv of old:
         1 - invalidateMethodLocal_id
     */
-   public Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand invalidateCommand) throws Throwable;
+   Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand invalidateCommand) throws Throwable;
 
    /*
      equiv of old:
         1 - removeKeyMethodLocal_id
         1 - removeKeyVersionedMethodLocal_id
     */
-   public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand removeKeyCommand) throws Throwable;
+   Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand removeKeyCommand) throws Throwable;
 
    /*
      equiv of old:
         1 - getDataMapMethodLocal_id
     */
-   public Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand getDataMapCommand) throws Throwable;
+   Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand getDataMapCommand) throws Throwable;
 
    /*
      equiv of old:
         1 - existsMethod_id
     */
-   public Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand existsNodeCommand) throws Throwable;
+   Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand existsNodeCommand) throws Throwable;
 
    /*
      equiv of old:
         1 - getKeyValueMethodLocal_id
     */
-   public Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand getKeyValueCommand) throws Throwable;
+   Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand getKeyValueCommand) throws Throwable;
 
    /*
      equiv of old:
         1 - getNodeMethodLocal_id
     */
-   public Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand getNodeCommand) throws Throwable;
+   Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand getNodeCommand) throws Throwable;
 
    /*
         equiv of old:
         1 - getKeysMethodLocal_id
     */
-   public Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand getKeysCommand) throws Throwable;
+   Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand getKeysCommand) throws Throwable;
 
    /*
         equiv of old:
         1 - getChildrenNamesMethodLocal_id
     */
-   public Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand getChildrenNamesCacheCommand) throws Throwable;
+   Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand getChildrenNamesCacheCommand) throws Throwable;
 
    /*
         equiv of old:
         1 - moveMethodLocal_id
     */
-   public Object handleMoveCommand(InvocationContext ctx, MoveCommand moveCommand) throws Throwable;
+   Object handleMoveCommand(InvocationContext ctx, MoveCommand moveCommand) throws Throwable;
 
    /*
         equiv of old:
         1 - dataGravitationMethod_id
     */
-   public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand gravitateDataCommand) throws Throwable;
+   Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand gravitateDataCommand) throws Throwable;
 
    /*
       prepareMethod_id
     */
-   public Object handlePrepareCommand(InvocationContext ctx, PrepareCommand prepareCommand) throws Throwable;
+   Object handlePrepareCommand(InvocationContext ctx, PrepareCommand prepareCommand) throws Throwable;
 
    /*
       rollbackMethod_id
     */
-   public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand rollbackCommand) throws Throwable;
+   Object handleRollbackCommand(InvocationContext ctx, RollbackCommand rollbackCommand) throws Throwable;
 
    /*
       commitMethod_id
     */
-   public Object handleCommitCommand(InvocationContext ctx, CommitCommand commitCommand) throws Throwable;
+   Object handleCommitCommand(InvocationContext ctx, CommitCommand commitCommand) throws Throwable;
 
    /*
       optimisticPrepareMethod_id
     */
-   public Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand optimisticPrepareCommand) throws Throwable;
+   Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand optimisticPrepareCommand) throws Throwable;
 
    /*
         equiv of old:
         1 - replicateMethod_id
         2 - replicateAllMethod_id
     */
-   public Object handleReplicateCommand(InvocationContext ctx, ReplicateCommand replicateSingleCommand) throws Throwable;
+   Object handleReplicateCommand(InvocationContext ctx, ReplicateCommand replicateSingleCommand) throws Throwable;
 
    /*
         equiv of old:
         1 - remoteAnnounceBuddyPoolNameMethod_id
     */
-   public Object handleAnnounceBuddyPoolName(InvocationContext ctx, AnnounceBuddyPoolNameCommand announceBuddyPoolNameCommand) throws Throwable;
+   Object handleAnnounceBuddyPoolName(InvocationContext ctx, AnnounceBuddyPoolNameCommand announceBuddyPoolNameCommand) throws Throwable;
 
    /*
         equiv of old:
         1 - remoteRemoveFromBuddyGroupMethod_id
     */
-   public Object handleRemoveFromBuddyGroupCommand(InvocationContext ctx, RemoveFromBuddyGroupCommand removeFromBuddyGroupCommand) throws Throwable;
+   Object handleRemoveFromBuddyGroupCommand(InvocationContext ctx, RemoveFromBuddyGroupCommand removeFromBuddyGroupCommand) throws Throwable;
 
    /*
         1 - remoteAssignToBuddyGroupMethod_id
     */
-   public Object handleAssignToBuddyGroupCommand(InvocationContext ctx, AssignToBuddyGroupCommand assignToBuddyGroupCommand) throws Throwable;
+   Object handleAssignToBuddyGroupCommand(InvocationContext ctx, AssignToBuddyGroupCommand assignToBuddyGroupCommand) throws Throwable;
 
    /*
         1 - dataGravitationCleanupMethod_id
     */
-   public Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand dataGravitationCleanupCommand) throws Throwable;
+   Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand dataGravitationCleanupCommand) throws Throwable;
 
    /*
         1 - clusteredGetMethod_id
     */
-   public Object handleClusteredGetCommand(InvocationContext ctx, ClusteredGetCommand clusteredGetCommand) throws Throwable;
+   Object handleClusteredGetCommand(InvocationContext ctx, ClusteredGetCommand clusteredGetCommand) throws Throwable;
 
    /*
     blockChannelMethodLocal_id
     */
-   public Object handleBlockChannelCommand(InvocationContext ctx, BlockChannelCommand blockChannelCommand) throws Throwable;
+   Object handleBlockChannelCommand(InvocationContext ctx, BlockChannelCommand blockChannelCommand) throws Throwable;
 
    /*
    unblockChannelMethodLocal_id
    */
-   public Object handleUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand unblockChannelCommand) throws Throwable;
+   Object handleUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand unblockChannelCommand) throws Throwable;
+
+   Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable;
 }

Modified: core/trunk/src/main/java/org/jboss/cache/commands/cachedata/CreateNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/cachedata/CreateNodeCommand.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/CreateNodeCommand.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -57,7 +57,7 @@
 
    public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
    {
-      throw new RuntimeException("Not designed to be called via any handlers!!");
+      return handler.handleCreateNodeCommand(ctx, this);
    }
 
    public void rollback()

Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -27,7 +27,7 @@
  *        todo this calls other commands through the invocation chain, check wheter direct call is not okay
  *        todo it is not natural for this command to extend TxCC, revisit
  */
-public class DataGravitationCleanupCommand extends BaseCacheDataCommand implements TxCacheCommand, GlobalTransactionCommand, DirectCommand
+public class DataGravitationCleanupCommand extends BaseCacheDataCommand implements TxCacheCommand, GlobalTransactionCommand
 {
    public static final int METHOD_ID = 34;
 
@@ -62,13 +62,8 @@
       this.commandsFactory = commandsFactory;
    }
 
-   public Object perform(InvocationContext invocationContext) throws Throwable
+   public Object perform(InvocationContext ctx) throws Throwable
    {
-      throw new UnsupportedOperationException("Direct commands are not meant to be passed up the interceptor chain!");
-   }
-
-   public Object performDirectly() throws Throwable
-   {
       if (buddyManager.isDataGravitationRemoveOnFind())
       {
          if (trace)
@@ -121,7 +116,6 @@
       RemoveNodeCommand removeBackupCommand = commandsFactory.buildRemoveNodeCommand(gtx, toRemove, true, true, false);
 
       InvocationContext ctx = invoker.getInvocationContext();
-      ctx.getOptionOverrides().setCacheModeLocal(true);
       result = invoker.invoke(ctx, removeBackupCommand);
       return result != null && (Boolean) result;
    }

Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -112,11 +112,11 @@
    }
 
 
-   @Override
    public String toString()
    {
       return "PrepareCommand{" +
-            "modifications=" + modifications +
+            "globalTransaction=" + globalTransaction +
+            ", modifications=" + modifications +
             ", localAddress=" + localAddress +
             ", onePhaseCommit=" + onePhaseCommit +
             '}';

Modified: core/trunk/src/main/java/org/jboss/cache/commands/visitors/AbstractCommandsVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/visitors/AbstractCommandsVisitor.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/commands/visitors/AbstractCommandsVisitor.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -6,7 +6,14 @@
 import org.jboss.cache.commands.cachedata.*;
 import org.jboss.cache.commands.channel.BlockChannelCommand;
 import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.remote.*;
+import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
+import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ClusteredGetCommand;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.remote.GravitateDataCommand;
+import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
+import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ReplicateCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
 import org.jboss.cache.commands.tx.PrepareCommand;
@@ -155,6 +162,11 @@
       return handleDefault(ctx, command);
    }
 
+   public Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
+   {
+      return handleDefault(ctx, command);
+   }
+
    public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
    {
       return null;

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -15,9 +15,15 @@
 import org.jboss.cache.buddyreplication.GravitateResult;
 import org.jboss.cache.commands.CacheCommand;
 import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.cachedata.CacheDataCommand;
+import org.jboss.cache.commands.cachedata.ExistsNodeCommand;
+import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
+import org.jboss.cache.commands.cachedata.GetDataMapCommand;
+import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
+import org.jboss.cache.commands.cachedata.GetKeysCommand;
+import org.jboss.cache.commands.cachedata.GetNodeCommand;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
 import org.jboss.cache.commands.remote.GravitateDataCommand;
-import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
 import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
 import org.jboss.cache.commands.tx.CommitCommand;
 import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -25,6 +31,7 @@
 import org.jboss.cache.commands.tx.RollbackCommand;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.factories.annotations.Start;
 import org.jboss.cache.invocation.CacheData;
 import org.jboss.cache.marshall.NodeData;
 import org.jboss.cache.transaction.GlobalTransaction;
@@ -62,17 +69,25 @@
    private Configuration config;
    private CommandsFactory commandsFactory;
    private CacheSPI cacheSPI;
+   private boolean usingOptimisticLocking;
 
    @Inject
    public void injectComponents(BuddyManager buddyManager, Configuration config, CacheData cacheData, CommandsFactory commandsFactory, CacheSPI cacheSPI)
    {
       this.buddyManager = buddyManager;
-      syncCommunications = config.getCacheMode() == Configuration.CacheMode.REPL_SYNC || config.getCacheMode() == Configuration.CacheMode.INVALIDATION_SYNC;
       this.cacheData = cacheData;
       this.commandsFactory = commandsFactory;
       this.cacheSPI = cacheSPI;
+      this.config = config;
    }
 
+   @Start
+   public void startInterceptor()
+   {
+      syncCommunications = config.getCacheMode() == Configuration.CacheMode.REPL_SYNC || config.getCacheMode() == Configuration.CacheMode.INVALIDATION_SYNC;
+      usingOptimisticLocking = config.isNodeLockingOptimistic();
+   }
+
    @Override
    public Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
    {
@@ -149,7 +164,7 @@
       try
       {
          transactionMods.remove(ctx.getGlobalTransaction());
-         return  invokeNextInterceptor(ctx, command);
+         return invokeNextInterceptor(ctx, command);
       }
       catch (Throwable throwable)
       {
@@ -229,7 +244,7 @@
             log.trace("Suppressing data gravitation for this call.");
          }
       }
-      return invokeNextInterceptor(ctx,command);
+      return invokeNextInterceptor(ctx, command);
    }
 
    private boolean isGravitationEnabled(InvocationContext ctx)
@@ -252,13 +267,13 @@
       if (cleanup != null)
       {
          CacheCommand prepare;
-         if (config.isNodeLockingOptimistic())
+         if (usingOptimisticLocking)
          {
             prepare = commandsFactory.buildOptimisticPrepareCommand(gtx, cleanup);
          }
          else
          {
-            prepare = commandsFactory.buildPrepareCommand(gtx, cleanup, syncCommunications);
+            prepare = commandsFactory.buildPrepareCommand(gtx, cleanup, !syncCommunications);
          }
 
          replicateCall(ctx, buddyManager.getMembersOutsideBuddyGroup(), prepare, syncCommunications, ctx.getOptionOverrides());
@@ -327,20 +342,17 @@
 
    private GravitateResult gravitateData(Fqn fqn) throws Exception
    {
-      if (trace)
-      {
-         log.trace("cache=" + rpcManager + "; requesting data gravitation for Fqn " + fqn);
-      }
+      if (trace) log.trace("Requesting data gravitation for Fqn " + fqn);
+
       List<Address> mbrs = rpcManager.getMembers();
       Boolean searchSubtrees = buddyManager.isDataGravitationSearchBackupTrees() ? Boolean.TRUE : Boolean.FALSE;
       GravitateDataCommand command = commandsFactory.buildGravitateDataCommand(fqn, searchSubtrees);
       // doing a GET_ALL is crappy but necessary since JGroups' GET_FIRST could return null results from nodes that do
       // not have either the primary OR backup, and stop polling other valid nodes.
       List resps = rpcManager.callRemoteMethods(mbrs, command, GroupRequest.GET_ALL, true, buddyManager.getBuddyCommunicationTimeout(), new ResponseValidityFilter(mbrs, rpcManager.getLocalAddress()), false);
-      if (trace)
-      {
-         log.trace("got responses " + resps);
-      }
+
+      if (trace) log.trace("got responses " + resps);
+
       if (resps == null)
       {
          if (mbrs.size() > 1) log.error("No replies to call " + command);

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -112,7 +112,9 @@
       try
       {
          Transaction tx = getTransaction();
-         setTransactionalContext(tx, getGlobalTransaction(tx, gtx), ctx);
+         GlobalTransaction realGtx = getGlobalTransaction(tx, gtx);
+         if (tx == null && realGtx != null && realGtx.isRemote()) tx = txTable.getLocalTransaction(gtx);
+         setTransactionalContext(tx, gtx, ctx);
 
          if (optionOverride != null)
          {

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -113,10 +113,11 @@
       {
          if (ctx.getGlobalTransaction().isRemote())
          {
-            result = handleRemotePrepare(ctx, command, command.isOnePhaseCommit());
+            result = handleRemotePrepare(ctx, command);
             scrubTxsOnExit = true;
-            incresePrepares();
-         } else
+            increasePrepares();
+         }
+         else
          {
             if (trace) log.trace("received my own message (discarding it)");
             result = null;
@@ -124,7 +125,6 @@
       }
       catch (Throwable e)
       {
-         boolean result1;
          ctx.throwIfNeeded(e);
       }
       finally
@@ -134,7 +134,7 @@
       return result;
    }
 
-   private void incresePrepares()
+   private void increasePrepares()
    {
       if (configuration.getExposeManagementStatistics() && getStatisticsEnabled())
       {
@@ -142,7 +142,7 @@
       }
    }
 
-   @SuppressWarnings("Unchecked")
+   @SuppressWarnings("unchecked")
    public Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
    {
       if (!ctx.getGlobalTransaction().isRemote())
@@ -188,7 +188,6 @@
       }
       catch (Throwable throwable)
       {
-         boolean result;
          ctx.throwIfNeeded(throwable);
       }
       finally
@@ -305,7 +304,7 @@
 
    // --------------------------------------------------------------
 
-   private Object handleRemotePrepare(InvocationContext ctx, PrepareCommand command, boolean onePhase) throws Throwable
+   private Object handleRemotePrepare(InvocationContext ctx, PrepareCommand command) throws Throwable
    {
       GlobalTransaction gtx = ctx.getGlobalTransaction();
       // Is there a local transaction associated with GTX ?
@@ -321,9 +320,10 @@
             ltx = createLocalTxForGlobalTx(gtx, ctx);// creates new LTX and associates it with a GTX
             if (log.isDebugEnabled())
             {
-               log.debug("Started new local TX as result of remote PREPARE: local TX=" + ltx + " (Status=" + ltx.getStatus() + "), global TX=" + gtx);
+               log.debug("Started new local tx as result of remote prepare: local tx=" + ltx + " (status=" + ltx.getStatus() + "), gtx=" + gtx);
             }
-         } else
+         }
+         else
          {
             //this should be valid
             if (!ctx.isValidTransaction())
@@ -355,7 +355,8 @@
             log.debug("creating new tx entry");
             txTable.put(gtx, entry);
             if (trace) log.trace("TxTable contents: " + txTable);
-         } else
+         }
+         else
          {
             entry = txTable.get(gtx);
          }
@@ -367,7 +368,8 @@
          if (configuration.isNodeLockingOptimistic())
          {
             retval = handleOptimisticPrepare(ctx, gtx, ltx, (OptimisticPrepareCommand) command);
-         } else
+         }
+         else
          {
             retval = handlePessimisticPrepare(ctx, ltx, command);
          }
@@ -443,7 +445,8 @@
                   log.warn("Roll back failed encountered", th);
                }
                throw t;
-            } else
+            }
+            else
             {
                throw t;
             }
@@ -504,7 +507,8 @@
       if (gtx != null)
       {
          command = replaceGtx(command, gtx);
-      } else
+      }
+      else
       {
          // get the current globalTransaction from the txTable.
          gtx = txTable.get(tx);
@@ -555,7 +559,8 @@
             {
                if (trace)
                   log.trace("Using one-phase prepare.  Not propagating the prepare call up the stack until called to do so by the sync handler.");
-            } else
+            }
+            else
             {
                invokeNextInterceptor(ctx, command);
             }
@@ -598,7 +603,8 @@
                if (success)
                {
                   ltx.commit();
-               } else
+               }
+               else
                {
                   ltx.rollback();
                }
@@ -750,11 +756,13 @@
             if (configuration.isNodeLockingOptimistic())
             {
                commitCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, null);
-            } else
+            }
+            else
             {
                commitCommand = commandsFactory.buildPrepareCommand(gtx, modifications, rpcManager.getLocalAddress(), true);
             }
-         } else
+         }
+         else
          {
             commitCommand = commandsFactory.buildCommitCommand(gtx);
          }
@@ -854,7 +862,8 @@
       if (configuration.isNodeLockingOptimistic())
       {
          prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, modifications, null, rpcManager.getLocalAddress(), false);
-      } else if (configuration.getCacheMode() != Configuration.CacheMode.REPL_ASYNC)
+      }
+      else if (configuration.getCacheMode() != Configuration.CacheMode.REPL_ASYNC)
       {
          prepareCommand = commandsFactory.buildPrepareCommand(gtx, modifications, rpcManager.getLocalAddress(),
                false);// don't commit or rollback - wait for call
@@ -880,7 +889,8 @@
       {
          ctx.setExecutingCommand(prepareCommand);
          result = invokeNextInterceptor(ctx, prepareCommand);
-      } else
+      }
+      else
       {
          log.warn("Local transaction does not exist or does not match expected transaction " + gtx);
          throw new CacheException(" local transaction " + ltx + " does not exist or does not match expected transaction " + gtx);
@@ -913,7 +923,8 @@
             {
                log.trace("is a remotely initiated gtx so no need to register a tx for it");
             }
-         } else
+         }
+         else
          {
             if (trace)
             {
@@ -923,10 +934,12 @@
             LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx, tx, !ctx.isOriginLocal());
             registerHandler(tx, myHandler, ctx, txTable.get(gtx));
          }
-      } else if ((gtx = (GlobalTransaction) rollbackTransactions.get(tx)) != null)
+      }
+      else if ((gtx = (GlobalTransaction) rollbackTransactions.get(tx)) != null)
       {
          if (log.isDebugEnabled()) log.debug("Transaction " + tx + " is already registered and is rolling back.");
-      } else
+      }
+      else
       {
          if (log.isDebugEnabled()) log.debug("Transaction " + tx + " is already registered.");
 

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java	2008-04-16 15:32:16 UTC (rev 5579)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java	2008-04-16 16:39:46 UTC (rev 5580)
@@ -104,7 +104,6 @@
       else
       {
          // not region based!
-         if (trace) log.trace("Marshalling object " + o);
          objectToObjectStream(o, out, null);
       }
    }




More information about the jbosscache-commits mailing list