From 4938f735e976edad9e785f3c81421a4be302b90f Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Sun, 13 Feb 2011 22:39:25 +0000 Subject: [PATCH] ISPN-922 Fix proposal with backwards compatibility --- .../java/org/infinispan/CacheDelegate.java | 58 ++++--- .../infinispan/commands/CommandsFactory.java | 18 +- .../commands/CommandsFactoryImpl.java | 34 ++-- .../commands/FlagAffectedCommand.java | 48 ++++++ .../commands/control/LockControlCommand.java | 63 +++++-- .../commands/read/AbstractDataCommand.java | 73 +++++--- .../commands/read/GetKeyValueCommand.java | 19 +- .../remote/BaseRpcInvokingCommand.java | 9 +- .../commands/remote/ClusteredGetCommand.java | 41 +++-- .../write/AbstractDataWriteCommand.java | 5 +- .../commands/write/ClearCommand.java | 28 ++- .../commands/write/EvictCommand.java | 11 ++ .../commands/write/InvalidateCommand.java | 5 +- .../commands/write/PutKeyValueCommand.java | 16 +- .../commands/write/PutMapCommand.java | 32 +++- .../commands/write/RemoveCommand.java | 31 +++- .../commands/write/ReplaceCommand.java | 12 +- .../commands/write/WriteCommand.java | 3 +- .../container/EntryFactoryImpl.java | 1 + .../java/org/infinispan/context/Flag.java | 34 +++- .../org/infinispan/context/FlagContainer.java | 1 - .../context/InvocationContextContainer.java | 11 +- .../InvocationContextContainerImpl.java | 18 ++ .../InvocationContextFlagsOverride.java | 162 ++++++++++++++++++ ...ctionalInvocationContextFlagsOverride.java | 84 +++++++++ .../distribution/DistributionManager.java | 4 +- .../distribution/DistributionManagerImpl.java | 6 +- .../interceptors/DistTxInterceptor.java | 4 +- .../interceptors/DistributionInterceptor.java | 4 +- .../ImplicitEagerLockingInterceptor.java | 2 +- .../interceptors/ReplicationInterceptor.java | 8 + .../interceptors/base/BaseRpcInterceptor.java | 1 + .../loaders/cluster/ClusterCacheLoader.java | 3 +- .../transport/jgroups/JGroupsDistSync.java | 2 +- .../marshall/VersionAwareMarshallerTest.java | 18 +- .../SyncReplImplicitLockingTest.java | 4 +- 36 files changed, 713 insertions(+), 160 deletions(-) create mode 100644 core/src/main/java/org/infinispan/commands/FlagAffectedCommand.java create mode 100644 core/src/main/java/org/infinispan/context/InvocationContextFlagsOverride.java create mode 100644 core/src/main/java/org/infinispan/context/TransactionalInvocationContextFlagsOverride.java diff --git a/core/src/main/java/org/infinispan/CacheDelegate.java b/core/src/main/java/org/infinispan/CacheDelegate.java index 5425d9c7e186..ef174a6fad2b 100644 --- a/core/src/main/java/org/infinispan/CacheDelegate.java +++ b/core/src/main/java/org/infinispan/CacheDelegate.java @@ -89,6 +89,7 @@ /** * @author Mircea.Markus@jboss.com * @author Galder ZamarreƱo + * @author Sanne Grinovero * @author Trustin Lee * @since 4.0 */ @@ -174,7 +175,7 @@ private void assertKeysNotNull(Map data) { public final boolean remove(Object key, Object value) { assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); - RemoveCommand command = commandsFactory.buildRemoveCommand(key, value); + RemoveCommand command = commandsFactory.buildRemoveCommand(key, value, ctx.getFlags()); return (Boolean) invoker.invoke(ctx, command); } @@ -190,7 +191,7 @@ public final boolean isEmpty() { public final boolean containsKey(Object key) { assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); - GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key); + GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, ctx.getFlags()); Object response = invoker.invoke(ctx, command); return response != null; } @@ -203,7 +204,7 @@ public final boolean containsValue(Object value) { public final V get(Object key) { assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); - GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key); + GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, ctx.getFlags()); return (V) invoker.invoke(ctx, command); } @@ -211,32 +212,35 @@ public final V get(Object key) { public final V remove(Object key) { assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); - RemoveCommand command = commandsFactory.buildRemoveCommand(key, null); + RemoveCommand command = commandsFactory.buildRemoveCommand(key, null, ctx.getFlags()); return (V) invoker.invoke(ctx, command); } public final void clear() { InvocationContext ctx = getInvocationContext(false); - ClearCommand command = commandsFactory.buildClearCommand(); + ClearCommand command = commandsFactory.buildClearCommand(ctx.getFlags()); invoker.invoke(ctx, command); } @SuppressWarnings("unchecked") public Set keySet() { + InvocationContext ctx = getInvocationContext(false); KeySetCommand command = commandsFactory.buildKeySetCommand(); - return (Set) invoker.invoke(getInvocationContext(false), command); + return (Set) invoker.invoke(ctx, command); } @SuppressWarnings("unchecked") public Collection values() { + InvocationContext ctx = getInvocationContext(false); ValuesCommand command = commandsFactory.buildValuesCommand(); - return (Collection) invoker.invoke(getInvocationContext(false), command); + return (Collection) invoker.invoke(ctx, command); } @SuppressWarnings("unchecked") public Set> entrySet() { + InvocationContext ctx = getInvocationContext(false); EntrySetCommand command = commandsFactory.buildEntrySetCommand(); - return (Set>) invoker.invoke(getInvocationContext(false), command); + return (Set>) invoker.invoke(ctx, command); } public final void putForExternalRead(K key, V value) { @@ -307,8 +311,9 @@ public boolean lock(Collection keys) { if (keys == null || keys.isEmpty()) { throw new IllegalArgumentException("Cannot lock empty list of keys"); } - LockControlCommand command = commandsFactory.buildLockControlCommand(keys, false); - return (Boolean) invoker.invoke(getInvocationContext(false), command); + InvocationContext ctx = getInvocationContext(false); + LockControlCommand command = commandsFactory.buildLockControlCommand(keys, false, ctx.getFlags()); + return (Boolean) invoker.invoke(ctx, command); } @ManagedOperation(description = "Starts the cache.") @@ -440,30 +445,31 @@ public Stats getStats() { public final V put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit idleTimeUnit) { assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); - PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value, lifespanUnit.toMillis(lifespan), idleTimeUnit.toMillis(maxIdleTime)); + PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value, lifespanUnit.toMillis(lifespan), idleTimeUnit.toMillis(maxIdleTime), ctx.getFlags()); return (V) invoker.invoke(ctx, command); } @SuppressWarnings("unchecked") public final V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit idleTimeUnit) { assertKeyNotNull(key); - InvocationContext context = getInvocationContext(false); - PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value, lifespanUnit.toMillis(lifespan), idleTimeUnit.toMillis(maxIdleTime)); + InvocationContext ctx = getInvocationContext(false); + PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value, lifespanUnit.toMillis(lifespan), idleTimeUnit.toMillis(maxIdleTime), ctx.getFlags()); command.setPutIfAbsent(true); - return (V) invoker.invoke(context, command); + return (V) invoker.invoke(ctx, command); } public final void putAll(Map map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit idleTimeUnit) { assertKeysNotNull(map); - PutMapCommand command = commandsFactory.buildPutMapCommand(map, lifespanUnit.toMillis(lifespan), idleTimeUnit.toMillis(maxIdleTime)); - invoker.invoke(getInvocationContext(false), command); + InvocationContext ctx = getInvocationContext(false); + PutMapCommand command = commandsFactory.buildPutMapCommand(map, lifespanUnit.toMillis(lifespan), idleTimeUnit.toMillis(maxIdleTime), ctx.getFlags()); + invoker.invoke(ctx, command); } @SuppressWarnings("unchecked") public final V replace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit idleTimeUnit) { assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); - ReplaceCommand command = commandsFactory.buildReplaceCommand(key, null, value, lifespanUnit.toMillis(lifespan), idleTimeUnit.toMillis(maxIdleTime)); + ReplaceCommand command = commandsFactory.buildReplaceCommand(key, null, value, lifespanUnit.toMillis(lifespan), idleTimeUnit.toMillis(maxIdleTime), ctx.getFlags()); return (V) invoker.invoke(ctx, command); } @@ -471,7 +477,7 @@ public final V replace(K key, V value, long lifespan, TimeUnit lifespanUnit, lon public final boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit idleTimeUnit) { assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); - ReplaceCommand command = commandsFactory.buildReplaceCommand(key, oldValue, value, lifespanUnit.toMillis(lifespan), idleTimeUnit.toMillis(maxIdleTime)); + ReplaceCommand command = commandsFactory.buildReplaceCommand(key, oldValue, value, lifespanUnit.toMillis(lifespan), idleTimeUnit.toMillis(maxIdleTime), ctx.getFlags()); return (Boolean) invoker.invoke(ctx, command); } @@ -505,7 +511,7 @@ public final NotifyingFuture putAsync(K key, V value, long lifespan, TimeUnit assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); ctx.setUseFutureReturnType(true); - PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle)); + PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle), ctx.getFlags()); return wrapInFuture(invoker.invoke(ctx, command)); } @@ -513,14 +519,14 @@ public final NotifyingFuture putAllAsync(Map dat assertKeysNotNull(data); InvocationContext ctx = getInvocationContext(false); ctx.setUseFutureReturnType(true); - PutMapCommand command = commandsFactory.buildPutMapCommand(data, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle)); + PutMapCommand command = commandsFactory.buildPutMapCommand(data, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle), ctx.getFlags()); return wrapInFuture(invoker.invoke(ctx, command)); } public final NotifyingFuture clearAsync() { InvocationContext ctx = getInvocationContext(false); ctx.setUseFutureReturnType(true); - ClearCommand command = commandsFactory.buildClearCommand(); + ClearCommand command = commandsFactory.buildClearCommand(ctx.getFlags()); return wrapInFuture(invoker.invoke(ctx, command)); } @@ -528,7 +534,7 @@ public final NotifyingFuture putIfAbsentAsync(K key, V value, long lifespan, assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); ctx.setUseFutureReturnType(true); - PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle)); + PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle), ctx.getFlags()); command.setPutIfAbsent(true); return wrapInFuture(invoker.invoke(ctx, command)); } @@ -537,7 +543,7 @@ public final NotifyingFuture removeAsync(Object key) { assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); ctx.setUseFutureReturnType(true); - RemoveCommand command = commandsFactory.buildRemoveCommand(key, null); + RemoveCommand command = commandsFactory.buildRemoveCommand(key, null, ctx.getFlags()); return wrapInFuture(invoker.invoke(ctx, command)); } @@ -545,7 +551,7 @@ public final NotifyingFuture removeAsync(Object key, Object value) { assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); ctx.setUseFutureReturnType(true); - RemoveCommand command = commandsFactory.buildRemoveCommand(key, value); + RemoveCommand command = commandsFactory.buildRemoveCommand(key, value, ctx.getFlags()); return wrapInFuture(invoker.invoke(ctx, command)); } @@ -553,7 +559,7 @@ public final NotifyingFuture replaceAsync(K key, V value, long lifespan, Time assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); ctx.setUseFutureReturnType(true); - ReplaceCommand command = commandsFactory.buildReplaceCommand(key, null, value, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle)); + ReplaceCommand command = commandsFactory.buildReplaceCommand(key, null, value, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle), ctx.getFlags()); return wrapInFuture(invoker.invoke(ctx, command)); } @@ -561,7 +567,7 @@ public final NotifyingFuture replaceAsync(K key, V oldValue, V newValue assertKeyNotNull(key); InvocationContext ctx = getInvocationContext(false); ctx.setUseFutureReturnType(true); - ReplaceCommand command = commandsFactory.buildReplaceCommand(key, oldValue, newValue, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle)); + ReplaceCommand command = commandsFactory.buildReplaceCommand(key, oldValue, newValue, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle), ctx.getFlags()); return wrapInFuture(invoker.invoke(ctx, command)); } diff --git a/core/src/main/java/org/infinispan/commands/CommandsFactory.java b/core/src/main/java/org/infinispan/commands/CommandsFactory.java index c518239d7086..a71f03d4f791 100644 --- a/core/src/main/java/org/infinispan/commands/CommandsFactory.java +++ b/core/src/main/java/org/infinispan/commands/CommandsFactory.java @@ -44,6 +44,7 @@ import org.infinispan.commands.write.ReplaceCommand; import org.infinispan.commands.write.WriteCommand; import org.infinispan.container.entries.InternalCacheValue; +import org.infinispan.context.Flag; import org.infinispan.distribution.ch.ConsistentHash; import org.infinispan.factories.scopes.Scope; import org.infinispan.factories.scopes.Scopes; @@ -53,6 +54,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Set; /** * A factory to build commands, initializing and injecting dependencies accordingly. Commands built for a specific, @@ -75,7 +77,7 @@ public interface CommandsFactory { * @param maxIdleTimeMillis max idle time in milliseconds. -1 if maxIdle is not used. * @return a PutKeyValueCommand */ - PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value, long lifespanMillis, long maxIdleTimeMillis); + PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value, long lifespanMillis, long maxIdleTimeMillis, Set flags); /** * Builds a RemoveCommand @@ -83,7 +85,7 @@ public interface CommandsFactory { * @param value value to check for ina conditional remove, or null for an unconditional remove. * @return a RemoveCommand */ - RemoveCommand buildRemoveCommand(Object key, Object value); + RemoveCommand buildRemoveCommand(Object key, Object value, Set flags); /** * Builds an InvalidateCommand @@ -117,7 +119,7 @@ public interface CommandsFactory { * @param maxIdleTimeMillis max idle time in milliseconds. -1 if maxIdle is not used. * @return a ReplaceCommand */ - ReplaceCommand buildReplaceCommand(Object key, Object oldValue, Object newValue, long lifespanMillis, long maxIdleTimeMillis); + ReplaceCommand buildReplaceCommand(Object key, Object oldValue, Object newValue, long lifespanMillis, long maxIdleTimeMillis, Set flags); /** * Builds a SizeCommand @@ -130,7 +132,7 @@ public interface CommandsFactory { * @param key key to get * @return a GetKeyValueCommand */ - GetKeyValueCommand buildGetKeyValueCommand(Object key); + GetKeyValueCommand buildGetKeyValueCommand(Object key, Set flags); /** * Builds a KeySetCommand @@ -157,13 +159,13 @@ public interface CommandsFactory { * @param maxIdleTimeMillis max idle time in milliseconds. -1 if maxIdle is not used. * @return a PutMapCommand */ - PutMapCommand buildPutMapCommand(Map map, long lifespanMillis, long maxIdleTimeMillis); + PutMapCommand buildPutMapCommand(Map map, long lifespanMillis, long maxIdleTimeMillis, Set flags); /** * Builds a ClearCommand * @return a ClearCommand */ - ClearCommand buildClearCommand(); + ClearCommand buildClearCommand(Set flags); /** * Builds an EvictCommand @@ -234,7 +236,7 @@ public interface CommandsFactory { * @param key key to look up * @return a ClusteredGetCommand */ - ClusteredGetCommand buildClusteredGetCommand(Object key); + ClusteredGetCommand buildClusteredGetCommand(Object key, Set flags); /** * Builds a LockControlCommand to control explicit remote locking @@ -242,7 +244,7 @@ public interface CommandsFactory { * @param implicit whether the lock command was implicit (triggered internally) or explicit (triggered by an API call) * @return a LockControlCommand */ - LockControlCommand buildLockControlCommand(Collection keys, boolean implicit); + LockControlCommand buildLockControlCommand(Collection keys, boolean implicit, Set flags); /** * Builds a RehashControlCommand for coordinating a rehash event. This version of this factory method creates a simple diff --git a/core/src/main/java/org/infinispan/commands/CommandsFactoryImpl.java b/core/src/main/java/org/infinispan/commands/CommandsFactoryImpl.java index 133569a163b8..1758d136dd5c 100644 --- a/core/src/main/java/org/infinispan/commands/CommandsFactoryImpl.java +++ b/core/src/main/java/org/infinispan/commands/CommandsFactoryImpl.java @@ -50,6 +50,7 @@ import org.infinispan.config.Configuration; import org.infinispan.container.DataContainer; import org.infinispan.container.entries.InternalCacheValue; +import org.infinispan.context.Flag; import org.infinispan.context.InvocationContextContainer; import org.infinispan.distribution.ch.ConsistentHash; import org.infinispan.distribution.DistributionManager; @@ -73,6 +74,7 @@ /** * @author Mircea.Markus@jboss.com * @author Galder ZamarreƱo + * @author Sanne Grinovero (C) 2011 Red Hat Inc. * @since 4.0 */ public class CommandsFactoryImpl implements CommandsFactory { @@ -117,12 +119,12 @@ public void start() { cacheName = cache.getName(); } - public PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value, long lifespanMillis, long maxIdleTimeMillis) { - return new PutKeyValueCommand(key, value, false, notifier, lifespanMillis, maxIdleTimeMillis); + public PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value, long lifespanMillis, long maxIdleTimeMillis, Set flags) { + return new PutKeyValueCommand(key, value, false, notifier, lifespanMillis, maxIdleTimeMillis, flags); } - public RemoveCommand buildRemoveCommand(Object key, Object value) { - return new RemoveCommand(key, value, notifier); + public RemoveCommand buildRemoveCommand(Object key, Object value, Set flags) { + return new RemoveCommand(key, value, notifier, flags); } public InvalidateCommand buildInvalidateCommand(Object... keys) { @@ -137,8 +139,8 @@ public InvalidateCommand buildInvalidateFromL1Command(boolean forRehash, Collect return new InvalidateL1Command(forRehash, dataContainer, configuration, distributionManager, notifier, keys); } - public ReplaceCommand buildReplaceCommand(Object key, Object oldValue, Object newValue, long lifespan, long maxIdleTimeMillis) { - return new ReplaceCommand(key, oldValue, newValue, lifespan, maxIdleTimeMillis); + public ReplaceCommand buildReplaceCommand(Object key, Object oldValue, Object newValue, long lifespan, long maxIdleTimeMillis, Set flags) { + return new ReplaceCommand(key, oldValue, newValue, lifespan, maxIdleTimeMillis, flags); } public SizeCommand buildSizeCommand() { @@ -169,16 +171,16 @@ public EntrySetCommand buildEntrySetCommand() { return cachedEntrySetCommand; } - public GetKeyValueCommand buildGetKeyValueCommand(Object key) { - return new GetKeyValueCommand(key, notifier); + public GetKeyValueCommand buildGetKeyValueCommand(Object key, Set flags) { + return new GetKeyValueCommand(key, notifier, flags); } - public PutMapCommand buildPutMapCommand(Map map, long lifespan, long maxIdleTimeMillis) { - return new PutMapCommand(map, notifier, lifespan, maxIdleTimeMillis); + public PutMapCommand buildPutMapCommand(Map map, long lifespan, long maxIdleTimeMillis, Set flags) { + return new PutMapCommand(map, notifier, lifespan, maxIdleTimeMillis, flags); } - public ClearCommand buildClearCommand() { - return new ClearCommand(notifier); + public ClearCommand buildClearCommand(Set flags) { + return new ClearCommand(notifier, flags); } public EvictCommand buildEvictCommand(Object key) { @@ -215,8 +217,8 @@ public StateTransferControlCommand buildStateTransferControlCommand(boolean bloc return new StateTransferControlCommand(block); } - public ClusteredGetCommand buildClusteredGetCommand(Object key) { - return new ClusteredGetCommand(key, cacheName); + public ClusteredGetCommand buildClusteredGetCommand(Object key, Set flags) { + return new ClusteredGetCommand(key, cacheName, flags); } /** @@ -319,8 +321,8 @@ public void initializeReplicableCommand(ReplicableCommand c, boolean isRemote) { } } - public LockControlCommand buildLockControlCommand(Collection keys, boolean implicit) { - return new LockControlCommand(keys, cacheName, implicit); + public LockControlCommand buildLockControlCommand(Collection keys, boolean implicit, Set flags) { + return new LockControlCommand(keys, cacheName, flags, implicit); } public RehashControlCommand buildRehashControlCommand(RehashControlCommand.Type type, Address sender) { diff --git a/core/src/main/java/org/infinispan/commands/FlagAffectedCommand.java b/core/src/main/java/org/infinispan/commands/FlagAffectedCommand.java new file mode 100644 index 000000000000..dd67b8ecde3d --- /dev/null +++ b/core/src/main/java/org/infinispan/commands/FlagAffectedCommand.java @@ -0,0 +1,48 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * 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, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.infinispan.commands; + +import java.util.Set; + +import org.infinispan.context.Flag; + +/** + * Commands affected by Flags should carry them over to the remote nodes. + * + * By implementing this interface the remote handler will read them out and restore in context; + * flags should still be evaluated in the InvocationContext. + * + * @author Sanne Grinovero (C) 2011 Red Hat Inc. + * @since 5.0 + */ +public interface FlagAffectedCommand { + + /** + * @return the Flags which where set in the context - only valid to invoke after {@link #setFlags(Set)} + */ + public Set getFlags(); + + /** + * Use it to store the flags from the InvocationContext into the Command before remoting the Command. + * @param flags + */ + public void setFlags(Set flags); + +} diff --git a/core/src/main/java/org/infinispan/commands/control/LockControlCommand.java b/core/src/main/java/org/infinispan/commands/control/LockControlCommand.java index 140b7711e6e8..8e505d66c755 100644 --- a/core/src/main/java/org/infinispan/commands/control/LockControlCommand.java +++ b/core/src/main/java/org/infinispan/commands/control/LockControlCommand.java @@ -21,15 +21,17 @@ */ package org.infinispan.commands.control; +import org.infinispan.commands.FlagAffectedCommand; import org.infinispan.commands.Visitor; import org.infinispan.commands.tx.AbstractTransactionBoundaryCommand; +import org.infinispan.context.Flag; import org.infinispan.context.InvocationContext; +import org.infinispan.context.TransactionalInvocationContextFlagsOverride; import org.infinispan.context.impl.RemoteTxInvocationContext; import org.infinispan.context.impl.TxInvocationContext; import org.infinispan.marshall.Ids; import org.infinispan.marshall.Marshallable; import org.infinispan.marshall.exts.ReplicableCommandExternalizer; -import org.infinispan.remoting.transport.Address; import org.infinispan.transaction.xa.GlobalTransaction; import org.infinispan.transaction.xa.RemoteTransaction; import org.infinispan.util.Util; @@ -52,7 +54,7 @@ * @since 4.0 */ @Marshallable(externalizer = ReplicableCommandExternalizer.class, id = Ids.LOCK_CONTROL_COMMAND) -public class LockControlCommand extends AbstractTransactionBoundaryCommand { +public class LockControlCommand extends AbstractTransactionBoundaryCommand implements FlagAffectedCommand { private static Log log = LogFactory.getLog(LockControlCommand.class); @@ -61,15 +63,16 @@ public class LockControlCommand extends AbstractTransactionBoundaryCommand { private Object singleKey; private boolean implicit = false; private boolean unlock = false; + private Set flags; public LockControlCommand() { } - public LockControlCommand(Collection keys, String cacheName) { - this(keys, cacheName, false); + public LockControlCommand(Collection keys, String cacheName, Set flags) { + this(keys, cacheName, flags, false); } - public LockControlCommand(Collection keys, String cacheName, boolean implicit) { + public LockControlCommand(Collection keys, String cacheName, Set flags, boolean implicit) { this.cacheName = cacheName; this.keys = null; this.singleKey = null; @@ -80,8 +83,8 @@ public LockControlCommand(Collection keys, String cacheName, boolean imp // defensive copy this.keys = new HashSet(keys); } - } + this.flags = flags; this.implicit = implicit; } @@ -162,7 +165,11 @@ public Object perform(InvocationContext ignored) throws Throwable { transaction = txTable.createRemoteTransaction(globalTx); } ctxt.setRemoteTransaction(transaction); - return invoker.invoke(ctxt, this); + TxInvocationContext ctx = ctxt; + if (flags != null && !flags.isEmpty()) { + ctx = new TransactionalInvocationContextFlagsOverride(ctxt, flags); + } + return invoker.invoke(ctx, this); } public byte getCommandId() { @@ -172,11 +179,11 @@ public byte getCommandId() { public Object[] getParameters() { if (keys == null || keys.isEmpty()) { if (singleKey == null) - return new Object[]{globalTx, cacheName, unlock, (byte) 1}; + return new Object[]{globalTx, cacheName, unlock, (byte) 1, flags}; else - return new Object[]{globalTx, cacheName, unlock, (byte) 2, singleKey}; + return new Object[]{globalTx, cacheName, unlock, (byte) 2, singleKey, flags}; } - return new Object[]{globalTx, cacheName, unlock, (byte) 3, keys}; + return new Object[]{globalTx, cacheName, unlock, (byte) 3, keys, flags}; } @SuppressWarnings("unchecked") @@ -185,19 +192,25 @@ public void setParameters(int commandId, Object[] args) { throw new IllegalStateException("Unusupported command id:" + commandId); globalTx = (GlobalTransaction) args[0]; cacheName = (String) args[1]; - unlock = (Boolean)args[2]; + unlock = (Boolean) args[2]; keys = null; singleKey = null; byte mode = (Byte) args[3]; switch (mode) { case 1: - break; // do nothing + if (args.length == 5) + this.flags = (Set) args[4]; + break; case 2: singleKey = args[4]; + if (args.length == 6) + this.flags = (Set) args[5]; break; case 3: keys = (Set) args[4]; + if (args.length == 6) + this.flags = (Set) args[5]; break; } } @@ -232,12 +245,24 @@ public int hashCode() { @Override public String toString() { - return "LockControlCommand {" + - "gtx=" + globalTx + - ", cacheName='" + cacheName + - ", implicit='" + implicit + - ", keys=" + keys + - ", unlock=" + unlock + - ", singleKey=" + singleKey + '}'; + return new StringBuilder() + .append("LockControlCommand{keys=").append(keys) + .append(", cacheName='").append(cacheName) + .append(", flags=").append(flags) + .append("', implicit=").append(implicit) + .append(", unlock=").append(unlock) + .append(", singleKey='").append(singleKey) + .append("'}") + .toString(); + } + + @Override + public Set getFlags() { + return flags; + } + + @Override + public void setFlags(Set flags) { + this.flags = flags; } } diff --git a/core/src/main/java/org/infinispan/commands/read/AbstractDataCommand.java b/core/src/main/java/org/infinispan/commands/read/AbstractDataCommand.java index 956b57f1d647..255fc7127379 100644 --- a/core/src/main/java/org/infinispan/commands/read/AbstractDataCommand.java +++ b/core/src/main/java/org/infinispan/commands/read/AbstractDataCommand.java @@ -21,15 +21,21 @@ */ package org.infinispan.commands.read; +import java.util.Set; + import org.infinispan.commands.DataCommand; +import org.infinispan.commands.FlagAffectedCommand; +import org.infinispan.context.Flag; import org.infinispan.context.InvocationContext; /** * @author Mircea.Markus@jboss.com + * @author Sanne Grinovero (C) 2011 Red Hat Inc. * @since 4.0 */ -public abstract class AbstractDataCommand implements DataCommand { +public abstract class AbstractDataCommand implements DataCommand, FlagAffectedCommand { protected Object key; + protected Set flags; public Object getKey() { return key; @@ -38,45 +44,66 @@ public Object getKey() { public void setKey(Object key) { this.key = key; } + + public Set getFlags() { + return flags; + } + + public void setFlags(Set flags) { + this.flags = flags; + } - protected AbstractDataCommand(Object key) { + protected AbstractDataCommand(Object key, Set flags) { this.key = key; + this.flags = flags; } protected AbstractDataCommand() { } - public void setParameters(int commandId, Object[] parameters) { - if (commandId != getCommandId()) throw new IllegalStateException("Invalid method id"); - key = parameters[0]; - } + public abstract void setParameters(int commandId, Object[] parameters); - public Object[] getParameters() { - return new Object[]{key}; - } + public abstract Object[] getParameters(); public boolean shouldInvoke(InvocationContext ctx) { return true; } - - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AbstractDataCommand that = (AbstractDataCommand) o; - - if (key != null ? !key.equals(that.key) : that.key != null) return false; - + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AbstractDataCommand other = (AbstractDataCommand) obj; + if (key == null) { + if (other.key != null) + return false; + } else if (!key.equals(other.key)) + return false; + if (flags == null) { + if (other.flags != null) + return false; + } else if (!flags.equals(other.flags)) + return false; return true; } - + + @Override public int hashCode() { return (key != null ? key.hashCode() : 0); } - + + @Override public String toString() { - return getClass().getSimpleName() + "{" + - "key=" + key + - '}'; + return new StringBuilder() + .append("AbstractDataCommand{key=") + .append(key) + .append(", flags=").append(flags) + .append("}") + .toString(); } + } diff --git a/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java b/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java index 02bd1b739677..7cf0d9323c71 100644 --- a/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java +++ b/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java @@ -21,8 +21,12 @@ */ package org.infinispan.commands.read; +import java.util.Collections; +import java.util.Set; + import org.infinispan.commands.Visitor; import org.infinispan.container.entries.CacheEntry; +import org.infinispan.context.Flag; import org.infinispan.context.InvocationContext; import org.infinispan.marshall.Ids; import org.infinispan.marshall.Marshallable; @@ -46,9 +50,10 @@ public class GetKeyValueCommand extends AbstractDataCommand { private CacheNotifier notifier; private boolean returnCacheEntry; - public GetKeyValueCommand(Object key, CacheNotifier notifier) { + public GetKeyValueCommand(Object key, CacheNotifier notifier, Set flags) { this.key = key; this.notifier = notifier; + this.flags = flags; } public GetKeyValueCommand() { @@ -96,4 +101,16 @@ public Object perform(InvocationContext ctx) throws Throwable { public byte getCommandId() { return COMMAND_ID; } + + @Override + public void setParameters(int commandId, Object[] parameters) { + if (commandId != COMMAND_ID) throw new IllegalStateException("Invalid method id"); + key = parameters[0]; + flags = (Set) (parameters.length>1 ? parameters[1] : Collections.EMPTY_SET); //TODO remove conditional check in future - eases migration for now + } + + @Override + public Object[] getParameters() { + return new Object[]{key, flags}; + } } diff --git a/core/src/main/java/org/infinispan/commands/remote/BaseRpcInvokingCommand.java b/core/src/main/java/org/infinispan/commands/remote/BaseRpcInvokingCommand.java index 01f55a1bd197..c0c208bb5688 100644 --- a/core/src/main/java/org/infinispan/commands/remote/BaseRpcInvokingCommand.java +++ b/core/src/main/java/org/infinispan/commands/remote/BaseRpcInvokingCommand.java @@ -1,5 +1,6 @@ package org.infinispan.commands.remote; +import org.infinispan.commands.FlagAffectedCommand; import org.infinispan.commands.ReplicableCommand; import org.infinispan.commands.VisitableCommand; import org.infinispan.context.InvocationContext; @@ -35,8 +36,14 @@ public void init(InterceptorChain interceptorChain, InvocationContextContainer i protected final Object processVisitableCommand(ReplicableCommand cacheCommand) throws Throwable { if (cacheCommand instanceof VisitableCommand) { - InvocationContext ctx = icc.createRemoteInvocationContext(); VisitableCommand vc = (VisitableCommand) cacheCommand; + final InvocationContext ctx; + if (vc instanceof FlagAffectedCommand) { + ctx = icc.createRemoteInvocationContextForCommand(vc); + } + else { + ctx = icc.createRemoteInvocationContext(); + } if (vc.shouldInvoke(ctx)) { if (trace) log.trace("Invoking command " + cacheCommand + ", with originLocal flag set to " + ctx.isOriginLocal() + "."); return interceptorChain.invoke(ctx, vc); diff --git a/core/src/main/java/org/infinispan/commands/remote/ClusteredGetCommand.java b/core/src/main/java/org/infinispan/commands/remote/ClusteredGetCommand.java index 773a32c111d4..07bd9ebd5a42 100644 --- a/core/src/main/java/org/infinispan/commands/remote/ClusteredGetCommand.java +++ b/core/src/main/java/org/infinispan/commands/remote/ClusteredGetCommand.java @@ -21,7 +21,10 @@ */ package org.infinispan.commands.remote; +import java.util.Set; + import org.infinispan.commands.CommandsFactory; +import org.infinispan.commands.FlagAffectedCommand; import org.infinispan.commands.read.GetKeyValueCommand; import org.infinispan.container.DataContainer; import org.infinispan.container.entries.CacheEntry; @@ -29,9 +32,9 @@ import org.infinispan.container.entries.InternalCacheValue; import org.infinispan.container.entries.InternalEntryFactory; import org.infinispan.container.entries.MVCCEntry; +import org.infinispan.context.Flag; import org.infinispan.context.InvocationContext; import org.infinispan.context.InvocationContextContainer; -import org.infinispan.context.impl.NonTxInvocationContext; import org.infinispan.distribution.DistributionManager; import org.infinispan.interceptors.InterceptorChain; import org.infinispan.marshall.Ids; @@ -49,7 +52,7 @@ * @since 4.0 */ @Marshallable(externalizer = ReplicableCommandExternalizer.class, id = Ids.CLUSTERED_GET_COMMAND) -public class ClusteredGetCommand implements CacheRpcCommand { +public class ClusteredGetCommand implements CacheRpcCommand, FlagAffectedCommand { public static final byte COMMAND_ID = 16; private static final Log log = LogFactory.getLog(ClusteredGetCommand.class); @@ -64,13 +67,15 @@ public class ClusteredGetCommand implements CacheRpcCommand { private InterceptorChain invoker; private DistributionManager distributionManager; + private Set flags; public ClusteredGetCommand() { } - public ClusteredGetCommand(Object key, String cacheName) { + public ClusteredGetCommand(Object key, String cacheName, Set flags) { this.key = key; this.cacheName = cacheName; + this.flags = flags; } public void initialize(DataContainer dataContainer, InvocationContextContainer icc, CommandsFactory commandsFactory, InterceptorChain interceptorChain) { @@ -88,10 +93,9 @@ public void initialize(DataContainer dataContainer, InvocationContextContainer i */ public InternalCacheValue perform(InvocationContext context) throws Throwable { if (distributionManager != null && distributionManager.isAffectedByRehash(key)) return null; - - GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key); + GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, flags); command.setReturnCacheEntry(true); - NonTxInvocationContext invocationContext = icc.createRemoteInvocationContext(); + InvocationContext invocationContext = icc.createRemoteInvocationContextForCommand(command); CacheEntry cacheEntry = (CacheEntry) invoker.invoke(invocationContext, command); if (cacheEntry == null) { if (trace) log.trace("Did not find anything, returning null"); @@ -113,12 +117,15 @@ public byte getCommandId() { } public Object[] getParameters() { - return new Object[]{key, cacheName}; + return new Object[]{key, cacheName, flags}; } public void setParameters(int commandId, Object[] args) { key = args[0]; cacheName = (String) args[1]; + if (args.length>2) { + this.flags = (Set) args[2]; + } } @Override @@ -140,10 +147,12 @@ public int hashCode() { @Override public String toString() { - return "ClusteredGetCommand{" + - "key=" + key + - ", dataContainer=" + dataContainer + - '}'; + return new StringBuilder() + .append("ClusteredGetCommand{key=") + .append(key) + .append(", flags=").append(flags) + .append("}") + .toString(); } public String getCacheName() { @@ -153,4 +162,14 @@ public String getCacheName() { public Object getKey() { return key; } + + @Override + public Set getFlags() { + return flags; + } + + @Override + public void setFlags(Set flags) { + this.flags = flags; + } } diff --git a/core/src/main/java/org/infinispan/commands/write/AbstractDataWriteCommand.java b/core/src/main/java/org/infinispan/commands/write/AbstractDataWriteCommand.java index 4cfb11d16209..d1f5b4e42b0a 100644 --- a/core/src/main/java/org/infinispan/commands/write/AbstractDataWriteCommand.java +++ b/core/src/main/java/org/infinispan/commands/write/AbstractDataWriteCommand.java @@ -1,6 +1,7 @@ package org.infinispan.commands.write; import org.infinispan.commands.read.AbstractDataCommand; +import org.infinispan.context.Flag; import java.util.Collections; import java.util.Set; @@ -16,8 +17,8 @@ public abstract class AbstractDataWriteCommand extends AbstractDataCommand imple protected AbstractDataWriteCommand() { } - protected AbstractDataWriteCommand(Object key) { - super(key); + protected AbstractDataWriteCommand(Object key, Set flags) { + super(key, flags); } public Set getAffectedKeys() { diff --git a/core/src/main/java/org/infinispan/commands/write/ClearCommand.java b/core/src/main/java/org/infinispan/commands/write/ClearCommand.java index ef4996487c57..9802ca827764 100644 --- a/core/src/main/java/org/infinispan/commands/write/ClearCommand.java +++ b/core/src/main/java/org/infinispan/commands/write/ClearCommand.java @@ -24,6 +24,7 @@ import org.infinispan.commands.Visitor; import org.infinispan.container.entries.CacheEntry; import org.infinispan.container.entries.MVCCEntry; +import org.infinispan.context.Flag; import org.infinispan.context.InvocationContext; import org.infinispan.marshall.Ids; import org.infinispan.marshall.Marshallable; @@ -39,15 +40,17 @@ */ @Marshallable(externalizer = ReplicableCommandExternalizer.class, id = Ids.CLEAR_COMMAND) public class ClearCommand implements WriteCommand { - private static final Object[] params = new Object[0]; + public static final byte COMMAND_ID = 5; CacheNotifier notifier; + private Set flags; public ClearCommand() { } - public ClearCommand(CacheNotifier notifier) { + public ClearCommand(CacheNotifier notifier, Set flags) { this.notifier = notifier; + this.flags = flags; } public void init(CacheNotifier notifier) { @@ -73,7 +76,7 @@ public Object perform(InvocationContext ctx) throws Throwable { } public Object[] getParameters() { - return params; + return new Object[]{flags}; } public byte getCommandId() { @@ -82,6 +85,9 @@ public byte getCommandId() { public void setParameters(int commandId, Object[] parameters) { if (commandId != COMMAND_ID) throw new IllegalStateException("Invalid command id"); + if (parameters.length > 0) { + this.flags = (Set) parameters[0]; + } } public boolean shouldInvoke(InvocationContext ctx) { @@ -90,7 +96,11 @@ public boolean shouldInvoke(InvocationContext ctx) { @Override public String toString() { - return "ClearCommand"; + return new StringBuilder() + .append("ClearCommand{flags=") + .append(flags) + .append("}") + .toString(); } public boolean isSuccessful() { @@ -104,4 +114,14 @@ public boolean isConditional() { public Set getAffectedKeys() { return Collections.emptySet(); } + + @Override + public Set getFlags() { + return flags; + } + + @Override + public void setFlags(Set flags) { + this.flags = flags; + } } diff --git a/core/src/main/java/org/infinispan/commands/write/EvictCommand.java b/core/src/main/java/org/infinispan/commands/write/EvictCommand.java index d79d003c7ddb..491e0967891d 100644 --- a/core/src/main/java/org/infinispan/commands/write/EvictCommand.java +++ b/core/src/main/java/org/infinispan/commands/write/EvictCommand.java @@ -68,4 +68,15 @@ public void notify(InvocationContext ctx, Object value, boolean isPre) { public byte getCommandId() { return -1; // these are not meant for replication! } + + @Override + public String toString() { + return new StringBuilder() + .append("EvictCommand{key=") + .append(key) + .append(", value=").append(value) + .append(", flags=").append(flags) + .append("}") + .toString(); + } } diff --git a/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java b/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java index 46327c8af643..c3b35c8ac3fd 100644 --- a/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java +++ b/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java @@ -97,8 +97,8 @@ public byte getCommandId() { @Override public String toString() { - return getClass().getSimpleName() + "{" + - "keys=" + Arrays.toString(keys) + + return "InvalidateCommand{keys=" + + Arrays.toString(keys) + '}'; } @@ -118,6 +118,7 @@ public Object[] getParameters() { @Override public void setParameters(int commandId, Object[] args) { + if (commandId != COMMAND_ID) throw new IllegalStateException("Invalid method id"); int size = (Integer) args[0]; keys = new Object[size]; if (size == 1) { diff --git a/core/src/main/java/org/infinispan/commands/write/PutKeyValueCommand.java b/core/src/main/java/org/infinispan/commands/write/PutKeyValueCommand.java index 9f9464b1029b..95d830264507 100644 --- a/core/src/main/java/org/infinispan/commands/write/PutKeyValueCommand.java +++ b/core/src/main/java/org/infinispan/commands/write/PutKeyValueCommand.java @@ -21,10 +21,14 @@ */ package org.infinispan.commands.write; +import java.util.Collections; +import java.util.Set; + import org.infinispan.atomic.Delta; import org.infinispan.atomic.DeltaAware; import org.infinispan.commands.Visitor; import org.infinispan.container.entries.MVCCEntry; +import org.infinispan.context.Flag; import org.infinispan.context.InvocationContext; import org.infinispan.marshall.Ids; import org.infinispan.marshall.Marshallable; @@ -51,8 +55,8 @@ public class PutKeyValueCommand extends AbstractDataWriteCommand { public PutKeyValueCommand() { } - public PutKeyValueCommand(Object key, Object value, boolean putIfAbsent, CacheNotifier notifier, long lifespanMillis, long maxIdleTimeMillis) { - super(key); + public PutKeyValueCommand(Object key, Object value, boolean putIfAbsent, CacheNotifier notifier, long lifespanMillis, long maxIdleTimeMillis, Set flags) { + super(key, flags); this.value = value; this.putIfAbsent = putIfAbsent; this.notifier = notifier; @@ -115,7 +119,7 @@ public byte getCommandId() { } public Object[] getParameters() { - return new Object[]{key, value, lifespanMillis, maxIdleTimeMillis}; + return new Object[]{key, value, lifespanMillis, maxIdleTimeMillis, flags}; } public void setParameters(int commandId, Object[] parameters) { @@ -124,6 +128,7 @@ public void setParameters(int commandId, Object[] parameters) { value = parameters[1]; lifespanMillis = (Long) parameters[2]; maxIdleTimeMillis = (Long) parameters[3]; + flags = (Set) (parameters.length>4 ? parameters[4] : Collections.EMPTY_SET); //TODO remove conditional check in future - eases migration for now } public boolean isPutIfAbsent() { @@ -171,9 +176,10 @@ public int hashCode() { @Override public String toString() { return new StringBuilder() - .append("PutKeyValueCommand{") - .append("key=").append(key) + .append("PutKeyValueCommand{key=") + .append(key) .append(", value=").append(value) + .append(", flags=").append(flags) .append(", putIfAbsent=").append(putIfAbsent) .append(", lifespanMillis=").append(lifespanMillis) .append(", maxIdleTimeMillis=").append(maxIdleTimeMillis) diff --git a/core/src/main/java/org/infinispan/commands/write/PutMapCommand.java b/core/src/main/java/org/infinispan/commands/write/PutMapCommand.java index 35f9a5bea1a4..aabf2054fb83 100644 --- a/core/src/main/java/org/infinispan/commands/write/PutMapCommand.java +++ b/core/src/main/java/org/infinispan/commands/write/PutMapCommand.java @@ -23,12 +23,14 @@ import org.infinispan.commands.Visitor; import org.infinispan.container.entries.MVCCEntry; +import org.infinispan.context.Flag; import org.infinispan.context.InvocationContext; import org.infinispan.marshall.Ids; import org.infinispan.marshall.Marshallable; import org.infinispan.marshall.exts.ReplicableCommandExternalizer; import org.infinispan.notifications.cachelistener.CacheNotifier; +import java.util.Collections; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -45,15 +47,17 @@ public class PutMapCommand implements WriteCommand { CacheNotifier notifier; long lifespanMillis = -1; long maxIdleTimeMillis = -1; + Set flags; public PutMapCommand() { } - public PutMapCommand(Map map, CacheNotifier notifier, long lifespanMillis, long maxIdleTimeMillis) { + public PutMapCommand(Map map, CacheNotifier notifier, long lifespanMillis, long maxIdleTimeMillis, Set flags) { this.map = map; this.notifier = notifier; this.lifespanMillis = lifespanMillis; this.maxIdleTimeMillis = maxIdleTimeMillis; + this.flags = flags; } public void init(CacheNotifier notifier) { @@ -94,13 +98,16 @@ public byte getCommandId() { } public Object[] getParameters() { - return new Object[]{map, lifespanMillis, maxIdleTimeMillis}; + return new Object[]{map, lifespanMillis, maxIdleTimeMillis, flags}; } public void setParameters(int commandId, Object[] parameters) { map = (Map) parameters[0]; lifespanMillis = (Long) parameters[1]; maxIdleTimeMillis = (Long) parameters[2]; + if (parameters.length>3) { + this.flags = (Set) parameters[3]; + } } @Override @@ -127,9 +134,14 @@ public int hashCode() { @Override public String toString() { - return "PutMapCommand{" + - "map=" + map + - '}'; + return new StringBuilder() + .append("PutMapCommand{map=") + .append(map) + .append(", flags=").append(flags) + .append(", lifespanMillis=").append(lifespanMillis) + .append(", maxIdleTimeMillis=").append(maxIdleTimeMillis) + .append("}") + .toString(); } public boolean shouldInvoke(InvocationContext ctx) { @@ -155,4 +167,14 @@ public long getLifespanMillis() { public long getMaxIdleTimeMillis() { return maxIdleTimeMillis; } + + @Override + public Set getFlags() { + return flags; + } + + @Override + public void setFlags(Set flags) { + this.flags = flags; + } } diff --git a/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java b/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java index 44a0b4ab84f7..ade4975465d7 100644 --- a/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java +++ b/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java @@ -21,9 +21,13 @@ */ package org.infinispan.commands.write; +import java.util.Collections; +import java.util.Set; + import org.infinispan.commands.Visitor; import org.infinispan.container.entries.CacheEntry; import org.infinispan.container.entries.MVCCEntry; +import org.infinispan.context.Flag; import org.infinispan.context.InvocationContext; import org.infinispan.marshall.Ids; import org.infinispan.marshall.Marshallable; @@ -53,8 +57,8 @@ public class RemoveCommand extends AbstractDataWriteCommand { */ protected transient Object value; - public RemoveCommand(Object key, Object value, CacheNotifier notifier) { - super(key); + public RemoveCommand(Object key, Object value, CacheNotifier notifier, Set flags) { + super(key, flags); this.value = value; this.notifier = notifier; } @@ -146,10 +150,13 @@ public int hashCode() { @Override public String toString() { - return getClass().getSimpleName() + "{" + - "key=" + key + - ", value=" + value + - '}'; + return new StringBuilder() + .append("RemoveCommand{key=") + .append(key) + .append(", value=").append(value) + .append(", flags=").append(flags) + .append("}") + .toString(); } public boolean isSuccessful() { @@ -163,4 +170,16 @@ public boolean isConditional() { public boolean isNonExistent() { return nonExistent; } + + @Override + public void setParameters(int commandId, Object[] parameters) { + if (commandId != COMMAND_ID) throw new IllegalStateException("Invalid method id"); + key = parameters[0]; + flags = (Set) (parameters.length>1 ? parameters[1] : Collections.EMPTY_SET); //TODO remove conditional check in future - eases migration for now + } + + @Override + public Object[] getParameters() { + return new Object[]{key, flags}; + } } diff --git a/core/src/main/java/org/infinispan/commands/write/ReplaceCommand.java b/core/src/main/java/org/infinispan/commands/write/ReplaceCommand.java index f559664a8974..b70bd52ecdeb 100644 --- a/core/src/main/java/org/infinispan/commands/write/ReplaceCommand.java +++ b/core/src/main/java/org/infinispan/commands/write/ReplaceCommand.java @@ -21,8 +21,12 @@ */ package org.infinispan.commands.write; +import java.util.Collections; +import java.util.Set; + import org.infinispan.commands.Visitor; import org.infinispan.container.entries.MVCCEntry; +import org.infinispan.context.Flag; import org.infinispan.context.InvocationContext; import org.infinispan.marshall.Ids; import org.infinispan.marshall.Marshallable; @@ -47,8 +51,8 @@ public class ReplaceCommand extends AbstractDataWriteCommand { public ReplaceCommand() { } - public ReplaceCommand(Object key, Object oldValue, Object newValue, long lifespanMillis, long maxIdleTimeMillis) { - super(key); + public ReplaceCommand(Object key, Object oldValue, Object newValue, long lifespanMillis, long maxIdleTimeMillis, Set flags) { + super(key, flags); this.oldValue = oldValue; this.newValue = newValue; this.lifespanMillis = lifespanMillis; @@ -99,7 +103,7 @@ public byte getCommandId() { } public Object[] getParameters() { - return new Object[]{key, oldValue, newValue, lifespanMillis, maxIdleTimeMillis}; + return new Object[]{key, oldValue, newValue, lifespanMillis, maxIdleTimeMillis, flags}; } public void setParameters(int commandId, Object[] parameters) { @@ -109,6 +113,7 @@ public void setParameters(int commandId, Object[] parameters) { newValue = parameters[2]; lifespanMillis = (Long) parameters[3]; maxIdleTimeMillis = (Long) parameters[4]; + flags = (Set) (parameters.length>5 ? parameters[5] : Collections.EMPTY_SET); //TODO remove conditional check in future - eases migration for now } @Override @@ -174,6 +179,7 @@ public String toString() { return "ReplaceCommand{" + "oldValue=" + oldValue + ", newValue=" + newValue + + ", flags=" + flags + ", successful=" + successful + '}'; } diff --git a/core/src/main/java/org/infinispan/commands/write/WriteCommand.java b/core/src/main/java/org/infinispan/commands/write/WriteCommand.java index 6da46589e2d9..da39c307b75b 100644 --- a/core/src/main/java/org/infinispan/commands/write/WriteCommand.java +++ b/core/src/main/java/org/infinispan/commands/write/WriteCommand.java @@ -1,5 +1,6 @@ package org.infinispan.commands.write; +import org.infinispan.commands.FlagAffectedCommand; import org.infinispan.commands.VisitableCommand; import java.util.Set; @@ -10,7 +11,7 @@ * @author Manik Surtani * @since 4.0 */ -public interface WriteCommand extends VisitableCommand { +public interface WriteCommand extends VisitableCommand, FlagAffectedCommand { /** * Some commands may want to provide information on whether the command was successful or not. This is different * from a failure, which usually would result in an exception being thrown. An example is a putIfAbsent() not doing diff --git a/core/src/main/java/org/infinispan/container/EntryFactoryImpl.java b/core/src/main/java/org/infinispan/container/EntryFactoryImpl.java index a91ec857a674..3cd7c8b9887b 100644 --- a/core/src/main/java/org/infinispan/container/EntryFactoryImpl.java +++ b/core/src/main/java/org/infinispan/container/EntryFactoryImpl.java @@ -240,6 +240,7 @@ public final boolean acquireLock(InvocationContext ctx, Object key) throws Inter return false; } + //TODO resolve code duplication with org.infinispan.util.concurrent.locks.LockManagerImpl.getLockAcquisitionTimeout(InvocationContext) private long getLockAcquisitionTimeout(InvocationContext ctx) { return ctx.hasFlag(Flag.ZERO_LOCK_ACQUISITION_TIMEOUT) ? 0 : configuration.getLockAcquisitionTimeout(); diff --git a/core/src/main/java/org/infinispan/context/Flag.java b/core/src/main/java/org/infinispan/context/Flag.java index 494bc7150041..fd92908d8f13 100644 --- a/core/src/main/java/org/infinispan/context/Flag.java +++ b/core/src/main/java/org/infinispan/context/Flag.java @@ -1,5 +1,9 @@ package org.infinispan.context; +import java.util.Collections; +import java.util.EnumSet; +import java.util.Set; + import org.infinispan.Cache; import org.infinispan.config.Configuration; import org.infinispan.AdvancedCache; @@ -93,8 +97,9 @@ public enum Flag { */ SKIP_CACHE_LOAD, /** - * Swallows any exceptions, logging them instead at a low log level. Will prevent a failing operation from - * affecting any ongoing JTA transactions as well. + *

Swallows any exceptions, logging them instead at a low log level. Will prevent a failing operation from + * affecting any ongoing JTA transactions as well.

+ *

This Flag will not be replicated to remote nodes, but it will still protect the invoker from remote exceptions.

*/ FAIL_SILENTLY, /** @@ -113,5 +118,28 @@ public enum Flag { /** * If this flag is enabled, if a cache store is shared, then storage to the store is skipped. */ - SKIP_SHARED_CACHE_STORE + SKIP_SHARED_CACHE_STORE; + + /** + * Creates a copy of a Flag Set removing instances of FAIL_SILENTLY. + * The copy might be the same instance if no change is required, + * and should be considered immutable. + * @param flags + * @return might return the same instance + */ + protected static Set copyWithouthRemotableFlags(Set flags) { + //FAIL_SILENTLY should not be sent to remote nodes + if (flags.contains(Flag.FAIL_SILENTLY)) { + EnumSet copy = EnumSet.copyOf(flags); + copy.remove(Flag.FAIL_SILENTLY); + if (copy.isEmpty()) { + return Collections.emptySet(); + } + else { + return copy; + } + } else { + return flags; + } + } } diff --git a/core/src/main/java/org/infinispan/context/FlagContainer.java b/core/src/main/java/org/infinispan/context/FlagContainer.java index e9545794f3e2..6fb51907335c 100644 --- a/core/src/main/java/org/infinispan/context/FlagContainer.java +++ b/core/src/main/java/org/infinispan/context/FlagContainer.java @@ -21,5 +21,4 @@ public interface FlagContainer { void reset(); - boolean isFlagsUninitialized(); } diff --git a/core/src/main/java/org/infinispan/context/InvocationContextContainer.java b/core/src/main/java/org/infinispan/context/InvocationContextContainer.java index 5c01001bba2c..7b5c066685da 100644 --- a/core/src/main/java/org/infinispan/context/InvocationContextContainer.java +++ b/core/src/main/java/org/infinispan/context/InvocationContextContainer.java @@ -1,5 +1,6 @@ package org.infinispan.context; +import org.infinispan.commands.VisitableCommand; import org.infinispan.context.impl.LocalTxInvocationContext; import org.infinispan.context.impl.RemoteTxInvocationContext; import org.infinispan.context.impl.NonTxInvocationContext; @@ -56,7 +57,14 @@ public interface InvocationContextContainer { * The context is also associated with the current thread, so further calls to * {@link #getInvocationContext()} will return same instance. */ - NonTxInvocationContext createRemoteInvocationContext(); + InvocationContext createRemoteInvocationContext(); + + /** + * As {@link #createRemoteInvocationContext()}, but returning the flags to the context from + * the Command if any Flag was set. + * @param cacheCommand + */ + InvocationContext createRemoteInvocationContextForCommand(VisitableCommand cacheCommand); /** * Returns the {@link InvocationContext} that is currently associated with the calling thread. @@ -77,4 +85,5 @@ public interface InvocationContextContainer { * Associates the supplied {@link InvocationContext} with the calling thread. */ void resume(InvocationContext ic); + } diff --git a/core/src/main/java/org/infinispan/context/InvocationContextContainerImpl.java b/core/src/main/java/org/infinispan/context/InvocationContextContainerImpl.java index 057e0bd8c68f..5faae4da0f69 100644 --- a/core/src/main/java/org/infinispan/context/InvocationContextContainerImpl.java +++ b/core/src/main/java/org/infinispan/context/InvocationContextContainerImpl.java @@ -21,7 +21,11 @@ */ package org.infinispan.context; +import java.util.Set; + import org.infinispan.CacheException; +import org.infinispan.commands.FlagAffectedCommand; +import org.infinispan.commands.VisitableCommand; import org.infinispan.context.impl.LocalTxInvocationContext; import org.infinispan.context.impl.NonTxInvocationContext; import org.infinispan.context.impl.RemoteTxInvocationContext; @@ -111,6 +115,19 @@ public NonTxInvocationContext createNonTxInvocationContext() { icTl.set(remoteTxContext); return remoteTxContext; } + + @Override + public InvocationContext createRemoteInvocationContextForCommand(VisitableCommand cacheCommand) { + InvocationContext context = createRemoteInvocationContext(); + if (cacheCommand != null && cacheCommand instanceof FlagAffectedCommand) { + FlagAffectedCommand command = (FlagAffectedCommand) cacheCommand; + Set flags = command.getFlags(); + if (flags != null && !flags.isEmpty()) { + return new InvocationContextFlagsOverride(context, flags); + } + } + return context; + } public NonTxInvocationContext createRemoteInvocationContext() { InvocationContext existing = icTl.get(); @@ -149,4 +166,5 @@ private Transaction getRunningTx() { throw new CacheException(e); } } + } \ No newline at end of file diff --git a/core/src/main/java/org/infinispan/context/InvocationContextFlagsOverride.java b/core/src/main/java/org/infinispan/context/InvocationContextFlagsOverride.java new file mode 100644 index 000000000000..c5b2a625f23d --- /dev/null +++ b/core/src/main/java/org/infinispan/context/InvocationContextFlagsOverride.java @@ -0,0 +1,162 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * 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, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.infinispan.context; + +import java.util.Collection; +import java.util.EnumSet; +import java.util.Map; +import java.util.Set; + +import org.infinispan.container.entries.CacheEntry; +import org.infinispan.util.BidirectionalMap; + + +/** + * Wraps an existing {@link InvocationContext} without changing the context directly + * but making sure the specified flags are considered enabled. + * @author Sanne Grinovero (C) 2011 Red Hat Inc. + * @since 5.0 + */ +public class InvocationContextFlagsOverride implements InvocationContext { + + private final InvocationContext delegate; + private final Set flags; + + /** + * Wraps an existing {@link InvocationContext} without changing the context directly + * but making sure the specified flags are considered enabled. + * @param delegate + * @param flags + */ + public InvocationContextFlagsOverride(InvocationContext delegate, Set flags) { + if (delegate == null || flags == null) { + throw new IllegalArgumentException("parameters shall not be null"); + } + this.delegate = delegate; + this.flags = Flag.copyWithouthRemotableFlags(flags); + } + + @Override + public CacheEntry lookupEntry(Object key) { + return delegate.lookupEntry(key); + } + + @Override + public BidirectionalMap getLookedUpEntries() { + return delegate.getLookedUpEntries(); + } + + @Override + public void putLookedUpEntry(Object key, CacheEntry e) { + delegate.putLookedUpEntry(key, e); + } + + @Override + public void putLookedUpEntries(Map lookedUpEntries) { + delegate.putLookedUpEntries(lookedUpEntries); + } + + @Override + public void removeLookedUpEntry(Object key) { + delegate.removeLookedUpEntry(key); + } + + @Override + public void clearLookedUpEntries() { + delegate.clearLookedUpEntries(); + } + + @Override + public boolean hasLockedKey(Object key) { + return delegate.hasLockedKey(key); + } + + @Override + public boolean hasFlag(Flag o) { + if (flags.contains(o)) { + return true; + } + return delegate.hasFlag(o); + } + + @Override + public Set getFlags() { + Set flagsInDelegate = delegate.getFlags(); + if (flagsInDelegate == null || flagsInDelegate.isEmpty()) { + return flags; + } + else { + Set merged = EnumSet.copyOf(flagsInDelegate); + merged.addAll(flags); + return merged; + } + } + + @Override + public void setFlags(Flag... newFlags) { + throw new IllegalStateException("Flags can't be changed after creating an InvocationContextFlagsOverride wrapper"); + } + + @Override + public void setFlags(Collection newFlags) { + throw new IllegalStateException("Flags can't be changed after creating an InvocationContextFlagsOverride wrapper"); + } + + @Override + public void reset() { + delegate.reset(); + } + + @Override + public boolean isOriginLocal() { + return delegate.isOriginLocal(); + } + + @Override + public boolean isInTxScope() { + return delegate.isInTxScope(); + } + + @Override + public Object getLockOwner() { + return delegate.getLockOwner(); + } + + @Override + public boolean isUseFutureReturnType() { + return delegate.isUseFutureReturnType(); + } + + @Override + public void setUseFutureReturnType(boolean useFutureReturnType) { + delegate.setUseFutureReturnType(useFutureReturnType); + } + + @Override + public Set getLockedKeys() { + return delegate.getLockedKeys(); + } + + @Override + public InvocationContextFlagsOverride clone() { + return new InvocationContextFlagsOverride(delegate, flags); + } + +} diff --git a/core/src/main/java/org/infinispan/context/TransactionalInvocationContextFlagsOverride.java b/core/src/main/java/org/infinispan/context/TransactionalInvocationContextFlagsOverride.java new file mode 100644 index 000000000000..b075a77cd76e --- /dev/null +++ b/core/src/main/java/org/infinispan/context/TransactionalInvocationContextFlagsOverride.java @@ -0,0 +1,84 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * 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, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.infinispan.context; + +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import javax.transaction.Transaction; + +import org.infinispan.commands.write.WriteCommand; +import org.infinispan.context.impl.TxInvocationContext; +import org.infinispan.transaction.xa.GlobalTransaction; + +/** + * Extension of InvocationContextFlagsOverride to be used when a TxInvocationContext + * is required. + * @see InvocationContextFlagsOverride + * + * @author Sanne Grinovero (C) 2011 Red Hat Inc. + * @since 5.0 + */ +public class TransactionalInvocationContextFlagsOverride extends InvocationContextFlagsOverride implements TxInvocationContext { + + private TxInvocationContext delegate; + + public TransactionalInvocationContextFlagsOverride(TxInvocationContext delegate, Set flags) { + super(delegate, flags); + this.delegate = delegate; + } + + @Override + public boolean hasModifications() { + return delegate.hasModifications(); + } + + @Override + public Set getAffectedKeys() { + return delegate.getAffectedKeys(); + } + + @Override + public GlobalTransaction getGlobalTransaction() { + return delegate.getGlobalTransaction(); + } + + @Override + public List getModifications() { + return delegate.getModifications(); + } + + @Override + public Transaction getRunningTransaction() { + return delegate.getRunningTransaction(); + } + + @Override + public void addAffectedKeys(Collection keys) { + delegate.addAffectedKeys(keys); + } + + @Override + public boolean isRunningTransactionValid() { + return delegate.isRunningTransactionValid(); + } + +} diff --git a/core/src/main/java/org/infinispan/distribution/DistributionManager.java b/core/src/main/java/org/infinispan/distribution/DistributionManager.java index 7574d54d2ed8..d1f0a8dad8b3 100644 --- a/core/src/main/java/org/infinispan/distribution/DistributionManager.java +++ b/core/src/main/java/org/infinispan/distribution/DistributionManager.java @@ -2,6 +2,7 @@ import org.infinispan.container.entries.CacheEntry; import org.infinispan.container.entries.InternalCacheEntry; +import org.infinispan.context.InvocationContext; import org.infinispan.distribution.ch.ConsistentHash; import org.infinispan.distribution.ch.NodeTopologyInfo; import org.infinispan.factories.scopes.Scope; @@ -67,10 +68,11 @@ public interface DistributionManager { * rehash in progress, involving nodes that the key maps to. * * @param key key to look up + * @param ctx * @return an internal cache entry, or null if it cannot be located * @throws Exception if something bad happens */ - InternalCacheEntry retrieveFromRemoteSource(Object key) throws Exception; + InternalCacheEntry retrieveFromRemoteSource(Object key, InvocationContext ctx) throws Exception; /** * Retrieves the consistent hash instance currently in use, which may be an instance of the configured ConsistentHash diff --git a/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java b/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java index 051c60152591..3ecdcdeb1b1c 100644 --- a/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java +++ b/core/src/main/java/org/infinispan/distribution/DistributionManagerImpl.java @@ -334,8 +334,8 @@ public void transformForL1(CacheEntry entry) { entry.setLifespan(configuration.getL1Lifespan()); } - public InternalCacheEntry retrieveFromRemoteSource(Object key) throws Exception { - ClusteredGetCommand get = cf.buildClusteredGetCommand(key); + public InternalCacheEntry retrieveFromRemoteSource(Object key, InvocationContext ctx) throws Exception { + ClusteredGetCommand get = cf.buildClusteredGetCommand(key, ctx.getFlags()); ResponseFilter filter = new ClusteredGetResponseValidityFilter(locate(key)); List responses = rpcManager.invokeRemotely(locate(key), get, ResponseMode.SYNCHRONOUS, @@ -427,9 +427,9 @@ public void applyState(ConsistentHash consistentHash, Map e : state.entrySet()) { if (consistentHash.locate(e.getKey(), configuration.getNumOwners()).contains(self)) { InternalCacheValue v = e.getValue(); - PutKeyValueCommand put = cf.buildPutKeyValueCommand(e.getKey(), v.getValue(), v.getLifespan(), v.getMaxIdle()); InvocationContext ctx = icc.createInvocationContext(); ctx.setFlags(Flag.CACHE_MODE_LOCAL, Flag.SKIP_REMOTE_LOOKUP, Flag.SKIP_SHARED_CACHE_STORE); + PutKeyValueCommand put = cf.buildPutKeyValueCommand(e.getKey(), v.getValue(), v.getLifespan(), v.getMaxIdle(), ctx.getFlags()); interceptorChain.invoke(ctx, put); } } diff --git a/core/src/main/java/org/infinispan/interceptors/DistTxInterceptor.java b/core/src/main/java/org/infinispan/interceptors/DistTxInterceptor.java index a7d24504cbc7..7abe0058dde7 100644 --- a/core/src/main/java/org/infinispan/interceptors/DistTxInterceptor.java +++ b/core/src/main/java/org/infinispan/interceptors/DistTxInterceptor.java @@ -109,7 +109,7 @@ public Object visitPutMapCommand(InvocationContext ctx, PutMapCommand command) t class ReplayCommandVisitor extends AbstractVisitor { @Override - public Object visitPutMapCommand(InvocationContext ignored, PutMapCommand command) { + public Object visitPutMapCommand(InvocationContext ctx, PutMapCommand command) { Map newMap = new HashMap(); for (Map.Entry entry : command.getMap().entrySet()) { if (dm.isLocal(entry.getKey())) newMap.put(entry.getKey(), entry.getValue()); @@ -117,7 +117,7 @@ public Object visitPutMapCommand(InvocationContext ignored, PutMapCommand comman if (newMap.isEmpty()) return null; if (newMap.size() == command.getMap().size()) return command; - return commandsFactory.buildPutMapCommand(newMap, command.getLifespanMillis(), command.getMaxIdleTimeMillis()); + return commandsFactory.buildPutMapCommand(newMap, command.getLifespanMillis(), command.getMaxIdleTimeMillis(), ctx.getFlags()); } @Override diff --git a/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java b/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java index 260e055762bf..a4df1c614246 100644 --- a/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java +++ b/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java @@ -140,14 +140,14 @@ private Object remoteGetAndStoreInL1(InvocationContext ctx, Object key, boolean private Object realRemoteGet(InvocationContext ctx, Object key, boolean storeInL1, boolean isWrite) throws Throwable { if (trace) log.trace("Doing a remote get for key %s", key); // attempt a remote lookup - InternalCacheEntry ice = dm.retrieveFromRemoteSource(key); + InternalCacheEntry ice = dm.retrieveFromRemoteSource(key, ctx); if (ice != null) { if (storeInL1) { if (isL1CacheEnabled) { if (trace) log.trace("Caching remotely retrieved entry for key %s in L1", key); long lifespan = ice.getLifespan() < 0 ? configuration.getL1Lifespan() : Math.min(ice.getLifespan(), configuration.getL1Lifespan()); - PutKeyValueCommand put = cf.buildPutKeyValueCommand(ice.getKey(), ice.getValue(), lifespan, -1); + PutKeyValueCommand put = cf.buildPutKeyValueCommand(ice.getKey(), ice.getValue(), lifespan, -1, ctx.getFlags()); entryFactory.wrapEntryForWriting(ctx, key, true, false, ctx.hasLockedKey(key), false, false); invokeNextInterceptor(ctx, put); } else { diff --git a/core/src/main/java/org/infinispan/interceptors/ImplicitEagerLockingInterceptor.java b/core/src/main/java/org/infinispan/interceptors/ImplicitEagerLockingInterceptor.java index 5752e75c27f4..3368ba7872b9 100644 --- a/core/src/main/java/org/infinispan/interceptors/ImplicitEagerLockingInterceptor.java +++ b/core/src/main/java/org/infinispan/interceptors/ImplicitEagerLockingInterceptor.java @@ -87,7 +87,7 @@ public Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand co } private Object lockEagerly(InvocationContext ctx, Collection keys) throws Throwable { - LockControlCommand lcc = cf.buildLockControlCommand(keys, true); + LockControlCommand lcc = cf.buildLockControlCommand(keys, true, ctx.getFlags()); return invokeNextInterceptor(ctx, lcc); } diff --git a/core/src/main/java/org/infinispan/interceptors/ReplicationInterceptor.java b/core/src/main/java/org/infinispan/interceptors/ReplicationInterceptor.java index 92d1a4215f13..fb4e90770f8a 100755 --- a/core/src/main/java/org/infinispan/interceptors/ReplicationInterceptor.java +++ b/core/src/main/java/org/infinispan/interceptors/ReplicationInterceptor.java @@ -105,6 +105,7 @@ public Object visitReplaceCommand(InvocationContext ctx, ReplaceCommand command) private Object handleCrudMethod(final InvocationContext ctx, final WriteCommand command) throws Throwable { // FIRST pass this call up the chain. Only if it succeeds (no exceptions) locally do we attempt to replicate. final Object returnValue = invokeNextInterceptor(ctx, command); + populateCommandFlags(command, ctx); if (!isLocalModeForced(ctx) && command.isSuccessful() && ctx.isOriginLocal() && !ctx.isInTxScope()) { if (ctx.isUseFutureReturnType()) { NotifyingNotifiableFuture future = new NotifyingFutureImpl(returnValue); @@ -116,4 +117,11 @@ private Object handleCrudMethod(final InvocationContext ctx, final WriteCommand } return returnValue; } + + /** + * Makes sure the context Flags are bundled in the command, so that they are re-read remotely + */ + private void populateCommandFlags(WriteCommand command, InvocationContext ctx) { + command.setFlags(ctx.getFlags()); + } } diff --git a/core/src/main/java/org/infinispan/interceptors/base/BaseRpcInterceptor.java b/core/src/main/java/org/infinispan/interceptors/base/BaseRpcInterceptor.java index 9e04201bbebe..1538e746c926 100644 --- a/core/src/main/java/org/infinispan/interceptors/base/BaseRpcInterceptor.java +++ b/core/src/main/java/org/infinispan/interceptors/base/BaseRpcInterceptor.java @@ -58,6 +58,7 @@ public Object visitLockControlCommand(TxInvocationContext ctx, LockControlComman if (ctx.isOriginLocal()) { //unlock will happen async as it is a best effort boolean sync = !command.isUnlock(); + command.setFlags(ctx.getFlags()); rpcManager.broadcastRpcCommand(command, sync, false); } return retVal; diff --git a/core/src/main/java/org/infinispan/loaders/cluster/ClusterCacheLoader.java b/core/src/main/java/org/infinispan/loaders/cluster/ClusterCacheLoader.java index 27cf736c1dca..2f3e451e927e 100644 --- a/core/src/main/java/org/infinispan/loaders/cluster/ClusterCacheLoader.java +++ b/core/src/main/java/org/infinispan/loaders/cluster/ClusterCacheLoader.java @@ -22,6 +22,7 @@ import org.infinispan.util.logging.Log; import org.infinispan.util.logging.LogFactory; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -50,7 +51,7 @@ public void init(CacheLoaderConfig config, Cache cache, StreamingMarshaller m) { public InternalCacheEntry load(Object key) throws CacheLoaderException { if (!(isCacheReady() && isLocalCall())) return null; - ClusteredGetCommand clusteredGetCommand = new ClusteredGetCommand(key, cache.getName()); + ClusteredGetCommand clusteredGetCommand = new ClusteredGetCommand(key, cache.getName(), Collections.EMPTY_SET); List response = doRemoteCall(clusteredGetCommand); if (response.isEmpty()) return null; if (response.size() > 1) diff --git a/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsDistSync.java b/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsDistSync.java index 9129d1e750cd..779dbbea885f 100644 --- a/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsDistSync.java +++ b/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsDistSync.java @@ -74,7 +74,7 @@ public void releaseProcessingLock() { processingLock.readLock().unlock(); } } catch (IllegalMonitorStateException imse) { - if (log.isTraceEnabled()) log.trace("Did not own lock!"); + if (trace) log.trace("Did not own lock!"); } } } diff --git a/core/src/test/java/org/infinispan/marshall/VersionAwareMarshallerTest.java b/core/src/test/java/org/infinispan/marshall/VersionAwareMarshallerTest.java index f9b8eb397816..c074dba8d5d0 100644 --- a/core/src/test/java/org/infinispan/marshall/VersionAwareMarshallerTest.java +++ b/core/src/test/java/org/infinispan/marshall/VersionAwareMarshallerTest.java @@ -184,7 +184,7 @@ public void testSingletonListMarshalling() throws Exception { 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); + PutKeyValueCommand command = new PutKeyValueCommand("k", "v", false, null, 0, 0, Collections.EMPTY_SET); TransactionLog.LogEntry entry = new TransactionLog.LogEntry(gtx, command); byte[] bytes = marshaller.objectToByteBuffer(entry); TransactionLog.LogEntry readObj = (TransactionLog.LogEntry) marshaller.objectFromByteBuffer(bytes); @@ -217,21 +217,21 @@ public void testReplicableCommandsMarshalling() throws Exception { 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"; - ClusteredGetCommand c2 = new ClusteredGetCommand("key", "mycache"); + ClusteredGetCommand c2 = new ClusteredGetCommand("key", "mycache", Collections.EMPTY_SET); marshallAndAssertEquality(c2); // SizeCommand does not have an empty constructor, so doesn't look to be one that is marshallable. - GetKeyValueCommand c4 = new GetKeyValueCommand("key", null); + GetKeyValueCommand c4 = new GetKeyValueCommand("key", null, Collections.EMPTY_SET); 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"; - PutKeyValueCommand c5 = new PutKeyValueCommand("k", "v", false, null, 0, 0); + PutKeyValueCommand c5 = new PutKeyValueCommand("k", "v", false, null, 0, 0, Collections.EMPTY_SET); marshallAndAssertEquality(c5); - RemoveCommand c6 = new RemoveCommand("key", null, null); + RemoveCommand c6 = new RemoveCommand("key", null, null, Collections.EMPTY_SET); marshallAndAssertEquality(c6); // EvictCommand does not have an empty constructor, so doesn't look to be one that is marshallable. @@ -248,7 +248,7 @@ public void testReplicableCommandsMarshalling() throws Exception { 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"; - ReplaceCommand c8 = new ReplaceCommand("key", "oldvalue", "newvalue", 0, 0); + ReplaceCommand c8 = new ReplaceCommand("key", "oldvalue", "newvalue", 0, 0, Collections.EMPTY_SET); marshallAndAssertEquality(c8); ClearCommand c9 = new ClearCommand(); @@ -262,7 +262,7 @@ public void testReplicableCommandsMarshalling() throws Exception { GlobalTransaction gtx = gtf.newGlobalTransaction(new JGroupsAddress(new IpAddress(1000 * i)), false); m1.put(1000 * i, gtx); } - PutMapCommand c10 = new PutMapCommand(m1, null, 0, 0); + PutMapCommand c10 = new PutMapCommand(m1, null, 0, 0, Collections.EMPTY_SET); marshallAndAssertEquality(c10); Address local = new JGroupsAddress(new IpAddress(12345)); @@ -334,7 +334,7 @@ public void testBucketMarshalling() throws Exception { } public void testLongPutKeyValueCommand() throws Exception { - PutKeyValueCommand c = new PutKeyValueCommand("SESSION_173", "@TSXMHVROYNOFCJVEUJQGBCENNQDEWSCYSOHECJOHEICBEIGJVTIBB@TVNCWLTQCGTEJ@NBJLTMVGXCHXTSVE@BCRYGWPRVLXOJXBRJDVNBVXPRTRLBMHPOUYQKDEPDSADUAWPFSIOCINPSSFGABDUXRMTMMJMRTGBGBOAMGVMTKUDUAJGCAHCYW@LAXMDSFYOSXJXLUAJGQKPTHUKDOXRWKEFIVRTH@VIMQBGYPKWMS@HPOESTPIJE@OTOTWUWIOBLYKQQPTNGWVLRRCWHNIMWDQNOO@JHHEVYVQEODMWKFKKKSWURVDLXPTFQYIHLIM@GSBFWMDQGDQIJONNEVHGQTLDBRBML@BEWGHOQHHEBRFUQSLB@@CILXEAVQQBTXSITMBXHM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@VNFOANM@OJHFVV@IYRMDB@LHSGXIJMMFCGJKTKDXSMY@FHDNY@VSDUORGWVFMVKJXOCCDLSLMHCSXFBTW@RQTFNRDJUIKRD@PWPY", false, null, 0, 0, Collections.EMPTY_SET); marshallAndAssertEquality(c); } @@ -410,7 +410,7 @@ public void testMIMECacheEntryMarshalling() throws Exception { } public void testNestedNonSerializable() throws Exception { - PutKeyValueCommand cmd = new PutKeyValueCommand("k", new Object(), false, null, 0, 0); + PutKeyValueCommand cmd = new PutKeyValueCommand("k", new Object(), false, null, 0, 0, Collections.EMPTY_SET); try { marshaller.objectToByteBuffer(cmd); } catch (NotSerializableException e) { diff --git a/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java b/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java index 27b3a2fc3166..c8cdb09fd8a3 100644 --- a/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java +++ b/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java @@ -56,7 +56,7 @@ public SyncReplImplicitLockingTest() { protected Configuration.CacheMode getCacheMode() { return Configuration.CacheMode.REPL_SYNC; - } + } protected void createCacheManagers() throws Throwable { Configuration cfg = getDefaultClusteredConfig(getCacheMode(), true); @@ -228,7 +228,7 @@ private void testBasicOperationHelper(boolean useCommit) throws Exception { cache2.remove(k); cache2.remove(key2); cache2.remove(key3); - cache2.remove(key4); + cache2.remove(key4); } }