Author: manik.surtani(a)jboss.com
Date: 2008-04-12 19:12:51 -0400 (Sat, 12 Apr 2008)
New Revision: 5545
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
Log:
Added pFER support
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-12
23:01:09 UTC (rev 5544)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-04-12
23:12:51 UTC (rev 5545)
@@ -1,11 +1,9 @@
package org.jboss.cache.commands;
import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.RPCManager;
import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.channel.BlockChannelCommand;
import org.jboss.cache.commands.channel.UnblockChannelCommand;
@@ -19,18 +17,11 @@
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.invocation.CacheTransactionHelper;
-import org.jboss.cache.invocation.InterceptorChain;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionTable;
import org.jgroups.Address;
-import javax.transaction.TransactionManager;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -49,40 +40,19 @@
*/
public class CommandsFactory
{
- private Notifier notifier;
- private TransactionTable transactionTable;
- private CacheData cacheData;
- private CacheSPI spi;
- private Configuration configuration;
- private TransactionManager tm;
private RPCManager rpcManager;
- private CacheTransactionHelper transactionHelper;
- private BuddyManager buddyManager;
- private InterceptorChain interceptorChain;
private ComponentRegistry registry;
@Inject
- public void initialize(Notifier notifier, TransactionTable transactionTable, CacheData
cacheData, CacheSPI spi,
- Configuration configuration, TransactionManager txm, RPCManager
rpc, CacheTransactionHelper txHelper,
- BuddyManager buddyManager, InterceptorChain interceptorChain,
ComponentRegistry registry)
+ public void initialize(RPCManager rpc, ComponentRegistry registry)
{
- this.notifier = notifier;
- this.transactionTable = transactionTable;
- this.cacheData = cacheData;
- this.spi = spi;
- this.configuration = configuration;
- this.tm = txm;
this.rpcManager = rpc;
- this.transactionHelper = txHelper;
- this.buddyManager = buddyManager;
- this.interceptorChain = interceptorChain;
this.registry = registry;
}
public PutDataMapCommand buildPutDataMapCommand(GlobalTransaction gtx, Fqn fqn, Map
data, boolean createUndoOps, boolean eraseContents)
{
PutDataMapCommand cmd = new PutDataMapCommand(gtx, fqn, data, createUndoOps,
eraseContents);
- //putDataMapCommand.initialize(cacheData, notifier, transactionTable);
registry.wireDependencies(cmd);
return cmd;
}
@@ -90,7 +60,6 @@
public PutKeyValueCommand buildPutKeyValueCommand(GlobalTransaction gtx, Fqn fqn,
Object key, Object value, boolean createUndoOps, boolean putForExternalRead)
{
PutKeyValueCommand command = new PutKeyValueCommand(gtx, fqn, key, value,
createUndoOps, putForExternalRead);
- //command.initialize(cacheData, notifier, transactionTable);
registry.wireDependencies(command);
return command;
}
@@ -131,7 +100,6 @@
public DataGravitationCleanupCommand buildDataGravitationCleanupCommand(Fqn
primaryFqn, Fqn backupFqn)
{
DataGravitationCleanupCommand command = new
DataGravitationCleanupCommand(primaryFqn, backupFqn);
- //command.initialize(buddyManager, interceptorChain, transactionHelper, this,
cacheData);
registry.wireDependencies(command);
return command;
}
@@ -139,7 +107,6 @@
public GravitateDataCommand buildGravitateDataCommand(Fqn fqn, Boolean
searchSubtrees)
{
GravitateDataCommand command = new GravitateDataCommand(fqn, searchSubtrees);
- //command.initialize(spi, rpcManager, cacheData);
registry.wireDependencies(command);
return command;
}
@@ -147,7 +114,6 @@
public RemoveNodeCommand buildRemoveNodeCommand(GlobalTransaction gtx, Fqn fqn,
boolean eviction, boolean skipSendingNodeEvents, boolean createUndoOps)
{
RemoveNodeCommand command = new RemoveNodeCommand(gtx, fqn, createUndoOps,
skipSendingNodeEvents, eviction);
-// command.initialize(cacheData, transactionTable, notifier,
configuration.isNodeLockingOptimistic());
registry.wireDependencies(command);
return command;
}
@@ -155,7 +121,6 @@
public RemoveDataCommand buildRemoveDataCommand(GlobalTransaction gtx, Fqn fqn,
boolean createUndoops, boolean sendNodeEvent, boolean eviction)
{
RemoveDataCommand command = new RemoveDataCommand(gtx, fqn, createUndoops,
sendNodeEvent, eviction);
-// command.initialize(cacheData, transactionTable, notifier);
registry.wireDependencies(command);
return command;
}
@@ -163,7 +128,6 @@
public EvictFqnCommand buildEvictFqnCommand(Fqn fqn)
{
EvictFqnCommand command = new EvictFqnCommand(fqn);
-// command.initialize(cacheData);
registry.wireDependencies(command);
return command;
}
@@ -171,7 +135,6 @@
public InvalidateCommand buildInvalidateCommand(Fqn fqn)
{
InvalidateCommand command = new InvalidateCommand(fqn);
-// command.initialize(cacheData, notifier, spi, tm,
configuration.isNodeLockingOptimistic());
registry.wireDependencies(command);
return command;
}
@@ -179,7 +142,6 @@
public RemoveKeyCommand buildRemoveKeyCommand(GlobalTransaction tx, Fqn<?> fqn,
Object key, boolean b)
{
RemoveKeyCommand command = new RemoveKeyCommand(tx, fqn, key, b);
-// command.initialize(cacheData, notifier, transactionTable);
registry.wireDependencies(command);
return command;
}
@@ -187,7 +149,6 @@
public GetDataMapCommand buildGetDataMapCommand(Fqn fqn)
{
GetDataMapCommand command = new GetDataMapCommand(fqn);
- //command.initialize(cacheData);
registry.wireDependencies(command);
return command;
}
@@ -195,7 +156,6 @@
public ExistsNodeCommand buildExistsNodeCommand(Fqn fqn)
{
ExistsNodeCommand command = new ExistsNodeCommand(fqn);
-// command.initialize(cacheData);
registry.wireDependencies(command);
return command;
}
@@ -203,7 +163,6 @@
public GetKeyValueCommand buildGetKeyValueCommand(Fqn<?> fqn, Object key,
boolean sendNodeEvent)
{
GetKeyValueCommand command = new GetKeyValueCommand(fqn, key, sendNodeEvent);
-// command.initialize(cacheData, notifier);
registry.wireDependencies(command);
return command;
}
@@ -211,7 +170,6 @@
public GetNodeCommand buildGetNodeCommand(Fqn fqn)
{
GetNodeCommand command = new GetNodeCommand(fqn);
-// command.initialize(cacheData);
registry.wireDependencies(command);
return command;
}
@@ -219,7 +177,6 @@
public GetKeysCommand buildGetKeysCommand(Fqn fqn)
{
GetKeysCommand command = new GetKeysCommand(fqn);
-// command.initialize(cacheData);
registry.wireDependencies(command);
return command;
}
@@ -227,7 +184,6 @@
public GetChildrenNamesCommand buildGetChildrenNamesCommand(Fqn fqn)
{
GetChildrenNamesCommand command = new GetChildrenNamesCommand(fqn);
-// command.initialize(cacheData);
registry.wireDependencies(command);
return command;
}
@@ -235,7 +191,6 @@
public MoveCommand buildMoveCommand(Fqn from, Fqn to)
{
MoveCommand command = new MoveCommand(from, to);
-// command.initialize(cacheData, notifier, transactionTable);
registry.wireDependencies(command);
return command;
}
@@ -243,7 +198,6 @@
public GravitateDataCommand buildGravitateDataCacheCommand(Fqn fqn, boolean
searchSubtrees)
{
GravitateDataCommand command = new GravitateDataCommand(fqn, searchSubtrees);
-// command.initialize(spi, rpcManager, cacheData);
registry.wireDependencies(command);
return command;
}
@@ -271,7 +225,6 @@
public AnnounceBuddyPoolNameCommand buildAnnounceBuddyPoolNameCommand(Address address,
String buddyPoolName)
{
AnnounceBuddyPoolNameCommand command = new AnnounceBuddyPoolNameCommand(address,
buddyPoolName);
-// command.initialize(buddyManager);
registry.wireDependencies(command);
return command;
}
@@ -279,7 +232,6 @@
public RemoveFromBuddyGroupCommand buildRemoveFromBuddyGroupCommand(String groupName)
{
RemoveFromBuddyGroupCommand command = new RemoveFromBuddyGroupCommand(groupName);
-// command.initialize(buddyManager);
registry.wireDependencies(command);
return command;
}
@@ -287,7 +239,6 @@
public AssignToBuddyGroupCommand buildAssignToBuddyGroupCommand(BuddyGroup group,
Map<Fqn, byte[]> state)
{
AssignToBuddyGroupCommand command = new AssignToBuddyGroupCommand(group, state);
-// command.initialize(buddyManager);
registry.wireDependencies(command);
return command;
}
@@ -360,6 +311,9 @@
break;
case PutKeyValueCommand.METHOD_ID:
+ case PutKeyValueCommand.VERSIONED_METHOD_ID:
+ case PutKeyValueCommand.PUT_FOR_EXT_READ_METHOD_ID:
+ case PutKeyValueCommand.PUT_FOR_EXT_READ_VERSIONED_METHOD_ID:
returnValue = new PutKeyValueCommand();
break;
@@ -407,12 +361,4 @@
registry.wireDependencies(returnValue);
return returnValue;
}
-
-// private List<CacheCommand> toCacheCommandList(List<MethodCall> calls)
-// {
-// if (calls == null) return null;
-// List<CacheCommand> ccList = new
ArrayList<CacheCommand>(calls.size());
-// for (MethodCall mc : calls) ccList.add(fromStream(mc.getMethodId(),
mc.getArgs()));
-// return ccList;
-// }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java 2008-04-12
23:01:09 UTC (rev 5544)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java 2008-04-12
23:12:51 UTC (rev 5545)
@@ -30,6 +30,9 @@
public class PutKeyValueCommand extends BaseCacheCommand implements TxCacheCommand,
CacheDataCommand, DataVersionCommand, GlobalTransactionCommand
{
public static final int METHOD_ID = 3;
+ public static final int VERSIONED_METHOD_ID = 39;
+ public static final int PUT_FOR_EXT_READ_METHOD_ID = 45;
+ public static final int PUT_FOR_EXT_READ_VERSIONED_METHOD_ID = 46;
private static final Log log = LogFactory.getLog(PutKeyValueCommand.class);
@@ -181,12 +184,22 @@
public int getCommandId()
{
- return METHOD_ID;
+ if (isVersioned())
+ {
+ return isPutForExternalRead ? PUT_FOR_EXT_READ_VERSIONED_METHOD_ID :
VERSIONED_METHOD_ID;
+ }
+ else
+ {
+ return isPutForExternalRead ? PUT_FOR_EXT_READ_METHOD_ID : METHOD_ID;
+ }
}
public Object[] getParameters()
{
- return new Object[]{globalTransaction, fqn, key, value, createUndoOps};
+ if (isVersioned())
+ return new Object[]{globalTransaction, fqn, key, value, createUndoOps,
dataVersion};
+ else
+ return new Object[]{globalTransaction, fqn, key, value, createUndoOps};
}
public void setState(int commandId, Object[] args)
@@ -196,5 +209,8 @@
key = args[2];
value = args[3];
createUndoOps = (Boolean) args[4];
+ isPutForExternalRead = (commandId == PUT_FOR_EXT_READ_METHOD_ID || commandId ==
PUT_FOR_EXT_READ_VERSIONED_METHOD_ID);
+ if (commandId == PUT_FOR_EXT_READ_VERSIONED_METHOD_ID || commandId ==
VERSIONED_METHOD_ID)
+ dataVersion = (DataVersion) args[5];
}
}
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-12
23:01:09 UTC (rev 5544)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-12
23:12:51 UTC (rev 5545)
@@ -452,7 +452,7 @@
{
getInvocationContext().getOptionOverrides().setFailSilently(true);
getInvocationContext().getOptionOverrides().setForceAsynchronous(true);
- PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, fqn,
key, value, false, false);
+ PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, fqn,
key, value, false, true);
invoke(command);
}
else