Skip to content

Commit

Permalink
IGNITE-22919 Remove redundant CacheEntryPredicate filters (#11519)
Browse files Browse the repository at this point in the history
  • Loading branch information
shishkovilja authored Sep 23, 2024
1 parent e4b38b2 commit ca19795
Show file tree
Hide file tree
Showing 14 changed files with 11 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ public EntryGetResult innerGetAndReserveForLoad(boolean updateMetrics,
* @param oldValPresent {@code True} if oldValue present.
* @param oldVal Old value.
* @param topVer Topology version.
* @param filter Filter.
* @param drType DR type.
* @param drExpireTime DR expire time (if any).
* @param explicitVer Explicit version (if any).
Expand All @@ -359,7 +358,6 @@ public GridCacheUpdateTxResult innerSet(
boolean oldValPresent,
@Nullable CacheObject oldVal,
AffinityTopologyVersion topVer,
CacheEntryPredicate[] filter,
GridDrType drType,
long drExpireTime,
@Nullable GridCacheVersion explicitVer,
Expand All @@ -379,7 +377,6 @@ public GridCacheUpdateTxResult innerSet(
* @param oldValPresent {@code True} if oldValue present.
* @param oldVal Old value.
* @param topVer Topology version.
* @param filter Filter.
* @param drType DR type.
* @param explicitVer Explicit version (if any).
* @param taskName Task name.
Expand All @@ -400,7 +397,6 @@ public GridCacheUpdateTxResult innerRemove(
boolean oldValPresent,
@Nullable CacheObject oldVal,
AffinityTopologyVersion topVer,
CacheEntryPredicate[] filter,
GridDrType drType,
@Nullable GridCacheVersion explicitVer,
String taskName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,6 @@ protected void recordNodeId(UUID nodeId, AffinityTopologyVersion topVer) {
boolean oldValPresent,
@Nullable CacheObject oldVal,
AffinityTopologyVersion topVer,
CacheEntryPredicate[] filter,
GridDrType drType,
long drExpireTime,
@Nullable GridCacheVersion explicitVer,
Expand All @@ -998,10 +997,6 @@ protected void recordNodeId(UUID nodeId, AffinityTopologyVersion topVer) {

final boolean valid = valid(tx != null ? tx.topologyVersion() : topVer);

// Lock should be held by now.
if (!cctx.isAll(this, filter))
return new GridCacheUpdateTxResult(false);

final GridCacheVersion newVer;

boolean intercept = cctx.config().getInterceptor() != null;
Expand Down Expand Up @@ -1206,7 +1201,6 @@ protected Object keyValue(boolean cpy) {
boolean oldValPresent,
@Nullable CacheObject oldVal,
AffinityTopologyVersion topVer,
CacheEntryPredicate[] filter,
GridDrType drType,
@Nullable GridCacheVersion explicitVer,
String taskName,
Expand All @@ -1221,10 +1215,6 @@ protected Object keyValue(boolean cpy) {

final boolean valid = valid(tx != null ? tx.topologyVersion() : topVer);

// Lock should be held by now.
if (!cctx.isAll(this, filter))
return new GridCacheUpdateTxResult(false);

GridCacheVersion obsoleteVer = null;

boolean intercept = cctx.config().getInterceptor() != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ else if (conflictCtx.isMerge()) {
txEntry.hasOldValue(),
txEntry.oldValue(),
topVer,
null,
replicate ? DR_BACKUP : DR_NONE,
near() ? null : explicitVer,
resolveTaskName(),
Expand All @@ -650,7 +649,6 @@ else if (conflictCtx.isMerge()) {
txEntry.hasOldValue(),
txEntry.oldValue(),
topVer,
null,
replicate ? DR_BACKUP : DR_NONE,
txEntry.conflictExpireTime(),
near() ? null : explicitVer,
Expand Down Expand Up @@ -688,7 +686,6 @@ else if (op == DELETE) {
txEntry.hasOldValue(),
txEntry.oldValue(),
topVer,
null,
replicate ? DR_BACKUP : DR_NONE,
near() ? null : explicitVer,
resolveTaskName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.ignite.internal.NodeStoppingException;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheInvalidStateException;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheOperationContext;
Expand Down Expand Up @@ -737,7 +736,6 @@ else if (txLockMsgLog.isDebugEnabled()) {
isolation,
createTtl,
accessTtl,
CU.empty0(),
opCtx != null && opCtx.skipStore(),
opCtx != null && opCtx.isKeepBinary());
}
Expand All @@ -754,7 +752,6 @@ else if (txLockMsgLog.isDebugEnabled()) {
* @param isolation Transaction isolation.
* @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter Optional filter.
* @param skipStore Skip store flag.
* @return Lock future.
*/
Expand All @@ -767,7 +764,6 @@ public GridDhtFuture<Boolean> lockAllAsyncInternal(@Nullable Collection<KeyCache
TransactionIsolation isolation,
long createTtl,
long accessTtl,
CacheEntryPredicate[] filter,
boolean skipStore,
boolean keepBinary) {
if (keys == null || keys.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,6 @@ private IgniteInternalFuture<GridCacheReturn> obtainLockAsync(
isolation,
createTtl,
accessTtl,
CU.empty0(),
skipStore,
keepBinary);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheOperationContext;
import org.apache.ignite.internal.processors.cache.EntryGetResult;
Expand Down Expand Up @@ -659,7 +658,6 @@ else if (!skipVals && ctx.statisticsEnabled())
timeout,
createTtl,
accessTtl,
CU.empty0(),
opCtx != null && opCtx.skipStore(),
opCtx != null && opCtx.isKeepBinary(),
opCtx != null && opCtx.recovery());
Expand Down Expand Up @@ -903,7 +901,6 @@ public void removeLocks(long threadId, GridCacheVersion ver, Collection<KeyCache
* @param timeout Lock timeout.
* @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter filter Optional filter.
* @param skipStore Skip store flag.
* @return Lock future.
*/
Expand All @@ -919,7 +916,6 @@ IgniteInternalFuture<Exception> lockAllAsync(
final long timeout,
final long createTtl,
final long accessTtl,
@Nullable final CacheEntryPredicate[] filter,
final boolean skipStore,
final boolean keepBinary
) {
Expand All @@ -944,7 +940,6 @@ IgniteInternalFuture<Exception> lockAllAsync(
timeout,
createTtl,
accessTtl,
filter,
skipStore,
keepBinary);
}
Expand All @@ -966,7 +961,6 @@ IgniteInternalFuture<Exception> lockAllAsync(
timeout,
createTtl,
accessTtl,
filter,
skipStore,
keepBinary);
}
Expand All @@ -987,7 +981,6 @@ IgniteInternalFuture<Exception> lockAllAsync(
* @param timeout Lock timeout.
* @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter filter Optional filter.
* @param skipStore Skip store flag.
* @return Lock future.
*/
Expand All @@ -1003,7 +996,6 @@ private IgniteInternalFuture<Exception> lockAllAsync0(
final long timeout,
final long createTtl,
final long accessTtl,
@Nullable final CacheEntryPredicate[] filter,
boolean skipStore,
boolean keepBinary) {
int cnt = keys.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheInvalidStateException;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheOperationContext;
Expand Down Expand Up @@ -146,9 +145,6 @@ public final class GridDhtColocatedLockFuture extends GridCacheCompoundIdentityF
/** Lock timeout. */
private final long timeout;

/** Filter. */
private final CacheEntryPredicate[] filter;

/** Transaction. */
@GridToStringExclude
private final GridNearTxLocal tx;
Expand Down Expand Up @@ -198,7 +194,6 @@ public final class GridDhtColocatedLockFuture extends GridCacheCompoundIdentityF
* @param timeout Lock acquisition timeout.
* @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter Filter.
* @param skipStore Skip store flag.
*/
public GridDhtColocatedLockFuture(
Expand All @@ -210,7 +205,6 @@ public GridDhtColocatedLockFuture(
long timeout,
long createTtl,
long accessTtl,
CacheEntryPredicate[] filter,
boolean skipStore,
boolean keepBinary,
boolean recovery
Expand All @@ -227,7 +221,6 @@ public GridDhtColocatedLockFuture(
this.timeout = timeout;
this.createTtl = createTtl;
this.accessTtl = accessTtl;
this.filter = filter;
this.skipStore = skipStore;
this.keepBinary = keepBinary;
this.recovery = recovery;
Expand Down Expand Up @@ -1037,15 +1030,6 @@ private synchronized void map0(
if (entry == null)
entry = cctx.colocated().entryExx(key, topVer, true);

if (!cctx.isAll(entry, filter)) {
if (log.isDebugEnabled())
log.debug("Entry being locked did not pass filter (will not lock): " + entry);

onComplete(false, false);

return;
}

assert loc ^ entry.detached() : "Invalid entry [loc=" + loc + ", entry=" + entry + ']';

GridCacheMvccCandidate cand = addEntry(entry);
Expand Down Expand Up @@ -1219,9 +1203,6 @@ private void proceedMapping0()
final Collection<KeyCacheObject> mappedKeys = map.distributedKeys();
final ClusterNode node = map.node();

if (filter != null && filter.length != 0)
req.filter(filter);

if (node.isLocal())
lockLocally(mappedKeys, req.topologyVersion());
else {
Expand Down Expand Up @@ -1271,7 +1252,6 @@ private void lockLocally(
timeout,
createTtl,
accessTtl,
filter,
skipStore,
keepBinary);

Expand Down Expand Up @@ -1400,15 +1380,6 @@ private boolean addLocalKey(

assert !entry.detached();

if (!cctx.isAll(entry, filter)) {
if (log.isDebugEnabled())
log.debug("Entry being locked did not pass filter (will not lock): " + entry);

onComplete(false, false);

return false;
}

GridCacheMvccCandidate cand = addEntry(entry);

if (cand != null && !cand.reentry())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheStoppedException;
import org.apache.ignite.internal.processors.cache.GridCacheCompoundIdentityFuture;
Expand Down Expand Up @@ -132,9 +131,6 @@ public final class GridNearLockFuture extends GridCacheCompoundIdentityFuture<Bo
/** Lock timeout. */
private final long timeout;

/** Filter. */
private final CacheEntryPredicate[] filter;

/** Transaction. */
@GridToStringExclude
private final GridNearTxLocal tx;
Expand Down Expand Up @@ -183,7 +179,6 @@ public final class GridNearLockFuture extends GridCacheCompoundIdentityFuture<Bo
* @param timeout Lock acquisition timeout.
* @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter Filter.
* @param skipStore skipStore
* @param keepBinary Keep binary flag.
* @param recovery Recovery flag.
Expand All @@ -197,7 +192,6 @@ public GridNearLockFuture(
long timeout,
long createTtl,
long accessTtl,
CacheEntryPredicate[] filter,
boolean skipStore,
boolean keepBinary,
boolean recovery
Expand All @@ -215,7 +209,6 @@ public GridNearLockFuture(
this.timeout = timeout;
this.createTtl = createTtl;
this.accessTtl = accessTtl;
this.filter = filter;
this.skipStore = skipStore;
this.keepBinary = keepBinary;
this.recovery = recovery;
Expand Down Expand Up @@ -313,7 +306,7 @@ private boolean implicitTx() {
*/
private boolean locked(GridCacheEntryEx cached) throws GridCacheEntryRemovedException {
// Reentry-aware check (If filter failed, lock is failed).
return cached.lockedLocallyByIdOrThread(lockVer, threadId) && filter(cached);
return cached.lockedLocallyByIdOrThread(lockVer, threadId);
}

/**
Expand Down Expand Up @@ -613,30 +606,6 @@ private void onError(Throwable t) {
}
}

/**
* @param cached Entry to check.
* @return {@code True} if filter passed.
*/
private boolean filter(GridCacheEntryEx cached) {
try {
if (!cctx.isAll(cached, filter)) {
if (log.isDebugEnabled())
log.debug("Filter didn't pass for entry (will fail lock): " + cached);

onFailed(true);

return false;
}

return true;
}
catch (IgniteCheckedException e) {
onError(e);

return false;
}
}

/**
* Callback for whenever entry lock ownership changes.
*
Expand Down Expand Up @@ -1017,15 +986,6 @@ private void map(Iterable<KeyCacheObject> keys, boolean remap, boolean topLocked
try {
entry = cctx.near().entryExx(key, topVer);

if (!cctx.isAll(entry, filter)) {
if (log.isDebugEnabled())
log.debug("Entry being locked did not pass filter (will not lock): " + entry);

onComplete(false, false);

return;
}

// Removed exception may be thrown here.
GridCacheMvccCandidate cand = addEntry(
topVer,
Expand Down Expand Up @@ -1213,9 +1173,6 @@ private void proceedMapping0()
final Collection<KeyCacheObject> mappedKeys = map.distributedKeys();
final ClusterNode node = map.node();

if (filter != null && filter.length != 0)
req.filter(filter);

if (node.isLocal()) {
req.miniId(-1);

Expand Down
Loading

0 comments on commit ca19795

Please sign in to comment.