This is an automated email from the ASF dual-hosted git repository.
av pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 6fb58f28138 IGNITE-22917 Remove GridDhtLockRequest#nearKeys (#11474)
6fb58f28138 is described below
commit 6fb58f28138ec8f3d4ea9e9859bd8bf262e5c847
Author: Ilya Shishkov <[email protected]>
AuthorDate: Thu Aug 15 17:43:53 2024 +0300
IGNITE-22917 Remove GridDhtLockRequest#nearKeys (#11474)
---
.../cache/distributed/dht/GridDhtLockFuture.java | 1 -
.../cache/distributed/dht/GridDhtLockRequest.java | 72 ++--------
.../dht/GridDhtTransactionalCacheAdapter.java | 23 ---
.../near/GridNearTransactionalCache.java | 158 ---------------------
.../cache/distributed/near/GridNearTxRemote.java | 88 ------------
5 files changed, 13 insertions(+), 329 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
index f7c87300c76..6a0b95079c8 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
@@ -911,7 +911,6 @@ public final class GridDhtLockFuture extends
GridCacheCompoundIdentityFuture<Boo
isInvalidate(),
timeout,
cnt,
- 0,
inTx() ? tx.size() : cnt,
inTx() ? tx.taskNameHash() : 0,
read ? accessTtl : -1L,
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
index 9978813406e..04d396a1390 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
@@ -19,14 +19,10 @@ package
org.apache.ignite.internal.processors.cache.distributed.dht;
import java.io.Externalizable;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
import java.util.BitSet;
-import java.util.Collections;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridDirectCollection;
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
@@ -52,11 +48,6 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
/** */
private static final long serialVersionUID = 0L;
- /** Near keys to lock. */
- @GridToStringInclude
- @GridDirectCollection(KeyCacheObject.class)
- private List<KeyCacheObject> nearKeys;
-
/** Invalidate reader flags. */
private BitSet invalidateEntries;
@@ -113,7 +104,6 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
* @param isInvalidate Invalidation flag.
* @param timeout Lock timeout.
* @param dhtCnt DHT count.
- * @param nearCnt Near count.
* @param txSize Expected transaction size.
* @param taskNameHash Task name hash code.
* @param accessTtl TTL for read operation.
@@ -138,7 +128,6 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
boolean isInvalidate,
long timeout,
int dhtCnt,
- int nearCnt,
int txSize,
int taskNameHash,
long accessTtl,
@@ -159,7 +148,7 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
isolation,
isInvalidate,
timeout,
- dhtCnt == 0 ? nearCnt : dhtCnt,
+ dhtCnt,
txSize,
skipStore,
keepBinary,
@@ -169,8 +158,7 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
storeUsed(storeUsed);
- nearKeys = nearCnt == 0 ? Collections.emptyList() : new
ArrayList<>(nearCnt);
- invalidateEntries = new BitSet(dhtCnt == 0 ? nearCnt : dhtCnt);
+ invalidateEntries = new BitSet(dhtCnt);
assert miniId != null;
@@ -202,22 +190,6 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
return topVer;
}
- /**
- * Adds a Near key.
- *
- * @param key Key.
- */
- public void addNearKey(KeyCacheObject key) {
- nearKeys.add(key);
- }
-
- /**
- * @return Near keys.
- */
- public List<KeyCacheObject> nearKeys() {
- return nearKeys == null ? Collections.emptyList() : nearKeys;
- }
-
/**
* Adds a DHT key.
*
@@ -304,8 +276,6 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
@Override public void prepareMarshal(GridCacheSharedContext<?, ?> ctx)
throws IgniteCheckedException {
super.prepareMarshal(ctx);
- prepareMarshalCacheObjects(nearKeys, ctx.cacheContext(cacheId));
-
if (owned != null && ownedKeys == null) {
ownedKeys = new KeyCacheObject[owned.size()];
ownedValues = new GridCacheVersion[ownedKeys.length];
@@ -324,8 +294,6 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
@Override public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx,
ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);
- finishUnmarshalCacheObjects(nearKeys, ctx.cacheContext(cacheId), ldr);
-
if (ownedKeys != null) {
owned = new GridLeanMap<>(ownedKeys.length);
@@ -373,42 +341,36 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
writer.incrementState();
case 24:
- if (!writer.writeCollection("nearKeys", nearKeys,
MessageCollectionItemType.MSG))
- return false;
-
- writer.incrementState();
-
- case 25:
if (!writer.writeObjectArray("ownedKeys", ownedKeys,
MessageCollectionItemType.MSG))
return false;
writer.incrementState();
- case 26:
+ case 25:
if (!writer.writeObjectArray("ownedValues", ownedValues,
MessageCollectionItemType.MSG))
return false;
writer.incrementState();
- case 27:
+ case 26:
if (!writer.writeBitSet("preloadKeys", preloadKeys))
return false;
writer.incrementState();
- case 28:
+ case 27:
if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
- case 29:
+ case 28:
if (!writer.writeAffinityTopologyVersion("topVer", topVer))
return false;
writer.incrementState();
- case 30:
+ case 29:
if (!writer.writeString("txLbl", txLbl))
return false;
@@ -455,14 +417,6 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
reader.incrementState();
case 24:
- nearKeys = reader.readCollection("nearKeys",
MessageCollectionItemType.MSG);
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 25:
ownedKeys = reader.readObjectArray("ownedKeys",
MessageCollectionItemType.MSG, KeyCacheObject.class);
if (!reader.isLastRead())
@@ -470,7 +424,7 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
reader.incrementState();
- case 26:
+ case 25:
ownedValues = reader.readObjectArray("ownedValues",
MessageCollectionItemType.MSG, GridCacheVersion.class);
if (!reader.isLastRead())
@@ -478,7 +432,7 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
reader.incrementState();
- case 27:
+ case 26:
preloadKeys = reader.readBitSet("preloadKeys");
if (!reader.isLastRead())
@@ -486,7 +440,7 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
reader.incrementState();
- case 28:
+ case 27:
taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
@@ -494,7 +448,7 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
reader.incrementState();
- case 29:
+ case 28:
topVer = reader.readAffinityTopologyVersion("topVer");
if (!reader.isLastRead())
@@ -502,7 +456,7 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
reader.incrementState();
- case 30:
+ case 29:
txLbl = reader.readString("txLbl");
if (!reader.isLastRead())
@@ -522,7 +476,7 @@ public class GridDhtLockRequest extends
GridDistributedLockRequest {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 31;
+ return 30;
}
/** {@inheritDoc} */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index cbf3c3b287c..ded81ed40f2 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -60,7 +60,6 @@ import
org.apache.ignite.internal.processors.cache.distributed.near.GridNearLock
import
org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse;
import
org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest;
import
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache;
-import
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxRemote;
import
org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
@@ -73,7 +72,6 @@ import org.apache.ignite.internal.util.GridLeanSet;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.lang.GridClosureException;
import org.apache.ignite.internal.util.lang.IgnitePair;
-import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.C2;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.CI2;
@@ -461,7 +459,6 @@ public abstract class GridDhtTransactionalCacheAdapter<K,
V> extends GridDhtCach
GridDhtLockResponse res;
GridDhtTxRemote dhtTx = null;
- GridNearTxRemote nearTx = null;
boolean fail = false;
boolean cancelled = false;
@@ -471,23 +468,6 @@ public abstract class GridDhtTransactionalCacheAdapter<K,
V> extends GridDhtCach
ctx.deploymentEnabled());
dhtTx = startRemoteTx(nodeId, req, res);
- nearTx = isNearEnabled(cacheCfg) ? near().startRemoteTx(nodeId,
req) : null;
-
- if (nearTx != null && !nearTx.empty())
- res.nearEvicted(nearTx.evicted());
- else {
- if (!F.isEmpty(req.nearKeys())) {
- Collection<IgniteTxKey> nearEvicted = new
ArrayList<>(req.nearKeys().size());
-
- nearEvicted.addAll(F.viewReadOnly(req.nearKeys(), new
C1<KeyCacheObject, IgniteTxKey>() {
- @Override public IgniteTxKey apply(KeyCacheObject k) {
- return ctx.txKey(k);
- }
- }));
-
- res.nearEvicted(nearEvicted);
- }
- }
}
catch (IgniteTxRollbackCheckedException e) {
String err = "Failed processing DHT lock request (transaction has
been completed): " + req;
@@ -562,9 +542,6 @@ public abstract class GridDhtTransactionalCacheAdapter<K,
V> extends GridDhtCach
if (dhtTx != null)
dhtTx.rollbackRemoteTx();
- if (nearTx != null) // Even though this should never happen, we
leave this check for consistency.
- nearTx.rollbackRemoteTx();
-
List<KeyCacheObject> keys = req.keys();
if (keys != null) {
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index 5191fce6146..4494fda136a 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -34,19 +34,14 @@ import
org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import
org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate;
-import org.apache.ignite.internal.processors.cache.GridCacheOperation;
import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import
org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheEntry;
-import
org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockCancelledException;
import
org.apache.ignite.internal.processors.cache.distributed.GridDistributedUnlockRequest;
import
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCache;
-import
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockRequest;
import
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtUnlockRequest;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
import
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import
org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.lang.IgnitePair;
import org.apache.ignite.internal.util.typedef.CI2;
@@ -58,9 +53,6 @@ import org.apache.ignite.plugin.security.SecurityPermission;
import org.apache.ignite.transactions.TransactionIsolation;
import org.jetbrains.annotations.Nullable;
-import static
org.apache.ignite.internal.processors.security.SecurityUtils.securitySubjectId;
-import static
org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
-
/**
* Near cache for transactional cache.
*/
@@ -273,156 +265,6 @@ public class GridNearTransactionalCache<K, V> extends
GridNearCacheAdapter<K, V>
}
}
- /**
- * @param nodeId Primary node ID.
- * @param req Request.
- * @return Remote transaction.
- * @throws IgniteCheckedException If failed.
- * @throws GridDistributedLockCancelledException If lock has been
cancelled.
- */
- @Nullable public GridNearTxRemote startRemoteTx(UUID nodeId,
GridDhtLockRequest req)
- throws IgniteCheckedException, GridDistributedLockCancelledException {
- List<KeyCacheObject> nearKeys = req.nearKeys();
-
- GridNearTxRemote tx = null;
-
- ClassLoader ldr = ctx.deploy().globalLoader();
-
- if (ldr != null) {
- Collection<IgniteTxKey> evicted = null;
-
- // Avoid iterator creation.
- for (int i = 0; i < nearKeys.size(); i++) {
- KeyCacheObject key = nearKeys.get(i);
-
- if (key == null)
- continue;
-
- IgniteTxKey txKey = ctx.txKey(key);
-
- if (log.isDebugEnabled())
- log.debug("Unmarshalled key: " + key);
-
- GridNearCacheEntry entry = null;
-
- while (true) {
- try {
- entry = peekExx(key);
-
- if (entry != null) {
- // Handle implicit locks for pessimistic
transactions.
- if (req.inTx()) {
- tx = ctx.tm().nearTx(req.version());
-
- if (tx == null) {
- tx = new GridNearTxRemote(
- ctx.shared(),
- req.topologyVersion(),
- nodeId,
- req.nearNodeId(),
- req.nearXidVersion(),
- req.version(),
- null,
- ctx.systemTx(),
- ctx.ioPolicy(),
- PESSIMISTIC,
- req.isolation(),
- req.isInvalidate(),
- req.timeout(),
- req.txSize(),
- securitySubjectId(ctx),
- req.taskNameHash(),
- req.txLabel()
- );
-
- tx = ctx.tm().onCreated(null, tx);
-
- if (tx == null || !ctx.tm().onStarted(tx))
- throw new
IgniteTxRollbackCheckedException("Failed to acquire lock " +
- "(transaction has been completed):
" + req.version());
- }
-
- tx.addEntry(ctx,
- txKey,
- GridCacheOperation.NOOP,
- null /*Value.*/,
- null /*dr version*/,
- req.skipStore(),
- req.keepBinary());
- }
-
- // Add remote candidate before reordering.
- // Owned candidates should be reordered inside
entry lock.
- entry.addRemote(
- req.nodeId(),
- nodeId,
- req.threadId(),
- req.version(),
- tx != null,
- tx != null && tx.implicitSingle(),
- req.owned(entry.key())
- );
-
- if (!req.inTx())
- entry.touch();
- }
- else {
- if (evicted == null)
- evicted = new LinkedList<>();
-
- evicted.add(txKey);
- }
-
- // Double-check in case if sender node left the grid.
- if (ctx.discovery().node(req.nodeId()) == null) {
- if (log.isDebugEnabled())
- log.debug("Node requesting lock left grid
(lock request will be ignored): " + req);
-
- if (tx != null)
- tx.rollbackRemoteTx();
-
- return null;
- }
-
- // Entry is legit.
- break;
- }
- catch (GridCacheEntryRemovedException ignored) {
- assert entry.obsoleteVersion() != null : "Obsolete
flag not set on removed entry: " +
- entry;
-
- if (log.isDebugEnabled())
- log.debug("Received entry removed exception (will
retry on renewed entry): " + entry);
-
- if (tx != null) {
- tx.clearEntry(txKey);
-
- if (log.isDebugEnabled())
- log.debug("Cleared removed entry from remote
transaction (will retry) [entry=" +
- entry + ", tx=" + tx + ']');
- }
- }
- }
- }
-
- if (tx != null && evicted != null) {
- assert !evicted.isEmpty();
-
- for (IgniteTxKey evict : evicted)
- tx.addEvicted(evict);
- }
- }
- else {
- String err = "Failed to acquire deployment class loader for
message: " + req;
-
- U.warn(log, err);
-
- throw new IgniteCheckedException(err);
- }
-
- return tx;
- }
-
/**
* @param nodeId Node ID.
* @param res Response.
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
index 9c8562cee4e..a1293ed4030 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
@@ -53,9 +53,6 @@ public class GridNearTxRemote extends
GridDistributedTxRemoteAdapter {
/** Near node ID. */
private final UUID nearNodeId;
- /** Near transaction ID. */
- private GridCacheVersion nearXidVer;
-
/** Owned versions. */
private Map<IgniteTxKey, GridCacheVersion> owned;
@@ -140,75 +137,6 @@ public class GridNearTxRemote extends
GridDistributedTxRemoteAdapter {
topologyVersion(topVer);
}
- /**
- * This constructor is meant for pessimistic transactions.
- *
- * @param topVer Transaction topology version.
- * @param nodeId Node ID.
- * @param nearNodeId Near node ID.
- * @param nearXidVer Near transaction ID.
- * @param xidVer XID version.
- * @param commitVer Commit version.
- * @param sys System flag.
- * @param plc IO policy.
- * @param concurrency Concurrency level (should be pessimistic).
- * @param isolation Transaction isolation.
- * @param invalidate Invalidate flag.
- * @param timeout Timeout.
- * @param ctx Cache registry.
- * @param txSize Expected transaction size.
- * @param subjId Subject ID.
- * @param taskNameHash Task name hash code.
- * @param txLbl Transaction label.
- */
- public GridNearTxRemote(
- GridCacheSharedContext<?, ?> ctx,
- AffinityTopologyVersion topVer,
- UUID nodeId,
- UUID nearNodeId,
- GridCacheVersion nearXidVer,
- GridCacheVersion xidVer,
- GridCacheVersion commitVer,
- boolean sys,
- byte plc,
- TransactionConcurrency concurrency,
- TransactionIsolation isolation,
- boolean invalidate,
- long timeout,
- int txSize,
- @Nullable UUID subjId,
- int taskNameHash,
- @Nullable String txLbl
- ) {
- super(
- ctx,
- nodeId,
- xidVer,
- commitVer,
- sys,
- plc,
- concurrency,
- isolation,
- invalidate,
- timeout,
- txSize,
- subjId,
- taskNameHash,
- txLbl
- );
-
- assert nearNodeId != null;
-
- this.nearXidVer = nearXidVer;
- this.nearNodeId = nearNodeId;
-
- txState = new IgniteTxRemoteStateImpl(U.newLinkedHashMap(1),
U.newLinkedHashMap(txSize));
-
- assert topVer != null && topVer.topologyVersion() > 0 : topVer;
-
- topologyVersion(topVer);
- }
-
/** {@inheritDoc} */
@Override public boolean remote() {
return true;
@@ -229,13 +157,6 @@ public class GridNearTxRemote extends
GridDistributedTxRemoteAdapter {
return owned == null ? null : owned.get(key);
}
- /**
- * @return Near transaction ID.
- */
- @Override public GridCacheVersion nearXidVersion() {
- return nearXidVer;
- }
-
/** {@inheritDoc} */
@Override public void addActiveCache(GridCacheContext<?, ?> cacheCtx,
boolean recovery) {
throw new UnsupportedOperationException("Near tx doesn't track active
caches.");
@@ -273,15 +194,6 @@ public class GridNearTxRemote extends
GridDistributedTxRemoteAdapter {
return evicted;
}
- /**
- * Adds evicted key bytes to evicted collection.
- *
- * @param key Evicted key.
- */
- void addEvicted(IgniteTxKey key) {
- evicted.add(key);
- }
-
/**
* Adds entries to started near remote tx.
*