IGNITE-28773 CacheOperationContext refactoring#13242
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors CacheOperationContext construction and usage across internal cache projections to reduce constructor/“setter” sprawl and align flag-setting APIs around withX() methods.
Changes:
- Replaces direct
new CacheOperationContext(...)/ mutator-style methods with aCacheOperationContext.builder()+withX()API. - Renames skip-store projection from
setSkipStore(boolean)towithSkipStore()and updates REST handler code paths accordingly. - Adds a new
withHandleBinaryInInterceptor()projection API and propagates it through cache proxies.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlUtils.java | Switches keep-binary context creation to the new builder/with-style API. |
| modules/core/src/test/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandlerSelfTest.java | Simplifies the local cache proxy used in REST handler tests after projection API changes. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java | Updates REST cache-flag application to use withSkipStore() (conditional) and keep-binary projection. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java | Refactors keep-binary context setup to builder/with-style methods. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java | Updates projection API surface (withSkipStore) and introduces withHandleBinaryInInterceptor(). |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java | Reuses a shared default CacheOperationContext instance instead of allocating new defaults. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java | Reworks projection methods to build new immutable contexts via builder/with-style calls; adds interceptor-binary projection plumbing. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java | Updates adapter-level projection creation to use builder/with-style contexts and adds new projection API. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GatewayProtectedCacheProxy.java | Migrates to new CacheOperationContext “with” methods and extends keep-binary to also set the interceptor-binary flag. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java | Replaces hasDataCenterId() checks with dataCenterId() != null. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java | Uses builder-based context creation for application attributes. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java | Uses builder-based context creation for application attributes and updates data center ID checks. |
| modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java | Introduces immutable builder-based CacheOperationContext, shared default instance, and new interceptor-binary flag. |
Comments suppressed due to low confidence (1)
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java:24
- Unused imports
java.util.Collectionsandjava.util.HashMapwill fail the repository's CheckstyleUnusedImportsrule; they are no longer referenced after the refactor and should be removed.
import java.io.Serial;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @GridToStringInclude | ||
| private boolean skipStore; | ||
|
|
||
| /** Skip read through. */ | ||
| @GridToStringInclude | ||
| private boolean skipReadThrough; | ||
|
|
||
| /** No retries flag. */ | ||
| @GridToStringInclude |
There was a problem hiding this comment.
Why only these three fields marked as GridToStringInclude? AFAIK like this annotation is redundant for booleans and we can remove it (and from CacheOperationContext too). Let's check it.
There was a problem hiding this comment.
you are right, remove it
| appAttrs); | ||
| /** Context with keepBinary flag. */ | ||
| public CacheOperationContext withKeepBinary() { | ||
| return builder(this).keepBinary(true).build(); |
There was a problem hiding this comment.
Check for each method:
if (keepBinary)
return this;
There was a problem hiding this comment.
done except expiration for same behavior as in GridCacheAdapter#withExpiryPolicy, really don`t know why equality is not checked there.
| if (opCtx == null) | ||
| opCtx = CacheOperationContext.builder().skipReadThrough(true).build(); | ||
| else { | ||
| if (!opCtx.skipReadThrough()) | ||
| opCtx = opCtx.withSkipReadThrough(); | ||
| } |
There was a problem hiding this comment.
Maybe replace this boilerplate code in cache adapters/cache proxies with something like:
opCtx = CacheOperationContext.of(opCtx).withSkipReadThrough();
?
And implement CacheOperationContext.of like:
return opCtx == null ? INSTANCE : opCtx;
Count of allocated objects will be the same (one builder and one context object). Perhaps builder can be marked as private after such a change.
No description provided.