Skip to content

Commit

Permalink
IGNITE-22917 Remove GridDhtLockRequest#nearKeys (#11474)
Browse files Browse the repository at this point in the history
  • Loading branch information
shishkovilja authored Aug 15, 2024
1 parent edb32fa commit 6fb58f2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 329 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,6 @@ private void map(Iterable<GridDhtCacheEntry> entries) {
isInvalidate(),
timeout,
cnt,
0,
inTx() ? tx.size() : cnt,
inTx() ? tx.taskNameHash() : 0,
read ? accessTtl : -1L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@

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;
Expand All @@ -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;

Expand Down Expand Up @@ -113,7 +104,6 @@ public GridDhtLockRequest() {
* @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.
Expand All @@ -138,7 +128,6 @@ public GridDhtLockRequest(
boolean isInvalidate,
long timeout,
int dhtCnt,
int nearCnt,
int txSize,
int taskNameHash,
long accessTtl,
Expand All @@ -159,7 +148,7 @@ public GridDhtLockRequest(
isolation,
isInvalidate,
timeout,
dhtCnt == 0 ? nearCnt : dhtCnt,
dhtCnt,
txSize,
skipStore,
keepBinary,
Expand All @@ -169,8 +158,7 @@ public GridDhtLockRequest(

storeUsed(storeUsed);

nearKeys = nearCnt == 0 ? Collections.emptyList() : new ArrayList<>(nearCnt);
invalidateEntries = new BitSet(dhtCnt == 0 ? nearCnt : dhtCnt);
invalidateEntries = new BitSet(dhtCnt);

assert miniId != null;

Expand Down Expand Up @@ -202,22 +190,6 @@ public int taskNameHash() {
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.
*
Expand Down Expand Up @@ -304,8 +276,6 @@ public long accessTtl() {
@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];
Expand All @@ -324,8 +294,6 @@ public long accessTtl() {
@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);

Expand Down Expand Up @@ -373,42 +341,36 @@ public long accessTtl() {
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;

Expand Down Expand Up @@ -455,54 +417,46 @@ public long accessTtl() {
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())
return false;

reader.incrementState();

case 26:
case 25:
ownedValues = reader.readObjectArray("ownedValues", MessageCollectionItemType.MSG, GridCacheVersion.class);

if (!reader.isLastRead())
return false;

reader.incrementState();

case 27:
case 26:
preloadKeys = reader.readBitSet("preloadKeys");

if (!reader.isLastRead())
return false;

reader.incrementState();

case 28:
case 27:
taskNameHash = reader.readInt("taskNameHash");

if (!reader.isLastRead())
return false;

reader.incrementState();

case 29:
case 28:
topVer = reader.readAffinityTopologyVersion("topVer");

if (!reader.isLastRead())
return false;

reader.incrementState();

case 30:
case 29:
txLbl = reader.readString("txLbl");

if (!reader.isLastRead())
Expand All @@ -522,7 +476,7 @@ public long accessTtl() {

/** {@inheritDoc} */
@Override public byte fieldsCount() {
return 31;
return 30;
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
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;
Expand All @@ -73,7 +72,6 @@
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;
Expand Down Expand Up @@ -461,7 +459,6 @@ private void processDhtLockRequest0(UUID nodeId, GridDhtLockRequest req) {
GridDhtLockResponse res;

GridDhtTxRemote dhtTx = null;
GridNearTxRemote nearTx = null;

boolean fail = false;
boolean cancelled = false;
Expand All @@ -471,23 +468,6 @@ private void processDhtLockRequest0(UUID nodeId, GridDhtLockRequest req) {
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;
Expand Down Expand Up @@ -562,9 +542,6 @@ private void processDhtLockRequest0(UUID nodeId, GridDhtLockRequest req) {
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) {
Expand Down
Loading

0 comments on commit 6fb58f2

Please sign in to comment.