alex-plekhanov commented on code in PR #13242:
URL: https://github.com/apache/ignite/pull/13242#discussion_r3442465282


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java:
##########
@@ -32,68 +31,52 @@
  */
 public class CacheOperationContext implements Serializable {
     /** */
-    private static final long serialVersionUID = 0L;
+    @Serial private static final long serialVersionUID = 0L;
 
-    /** Skip store. */
-    @GridToStringInclude
+    /** */
+    private static final CacheOperationContext INSTANCE = new 
Builder().build();
+
+    /** Skip store flag. */
     private final boolean skipStore;
 
-    /** Skip store. */
-    @GridToStringInclude
+    /** Skip read through flag. */
     private final boolean skipReadThrough;
 
     /** No retries flag. */
-    @GridToStringInclude
     private final boolean noRetries;
 
-    /** */
+    /** Recovery flag. */
     private final boolean recovery;
 
-    /** Read-repair strategy. */
-    private final ReadRepairStrategy readRepairStrategy;
+    /** Read-repair strategy.*/

Review Comment:
   Space before end of the comment



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheOperationContext.java:
##########
@@ -183,223 +136,311 @@ public CacheOperationContext 
withKeepBinaryInInterceptor() {
         return dataCenterId;
     }
 
-    /**
-     * @return Skip store.
-     */
-    public boolean skipStore() {
-        return skipStore;
+    /** Context with dataCenterId. */
+    public CacheOperationContext withDataCenterId(Byte dataCenterId) {
+        if (Objects.equals(this.dataCenterId, dataCenterId))
+            return this;
+
+        return builder(this).dataCenterId(dataCenterId).build();
     }
 
     /**
-     * See {@link IgniteInternalCache#setSkipStore(boolean)}.
-     *
-     * @param skipStore Skip store flag.
-     * @return New instance of CacheOperationContext with skip store flag.
+     * @return Partition recover flag.
      */
-    public CacheOperationContext setSkipStore(boolean skipStore) {
-        return new CacheOperationContext(
-            skipStore,
-            skipReadThrough,
-            keepBinary,
-            expiryPlc,
-            noRetries,
-            dataCenterId,
-            recovery,
-            readRepairStrategy,
-            appAttrs,
-            keepBinaryInInterceptor);
+    public boolean recovery() {
+        return recovery;
     }
 
-    /** @return Skip read-through cache store. */
-    public boolean skipReadThrough() {
-        return skipReadThrough;
+    /** Context with recovery flag. */
+    public CacheOperationContext withRecovery() {
+        if (recovery())
+            return this;
+
+        return builder(this).recovery(true).build();
     }
 
     /**
-     * See {@link IgniteInternalCache#withApplicationAttributes(Map)}.
-     *
-     * @return New instance of CacheOperationContext with new application 
attributes.
+     * @return Read Repair strategy.
      */
-    public CacheOperationContext withApplicationAttributes(Map<String, String> 
attrs) {
-        return new CacheOperationContext(
-            skipStore,
-            skipReadThrough,
-            keepBinary,
-            expiryPlc,
-            noRetries,
-            dataCenterId,
-            recovery,
-            readRepairStrategy,
-            Collections.unmodifiableMap(attrs),
-            keepBinaryInInterceptor);
+    @Nullable public ReadRepairStrategy readRepairStrategy() {
+        return readRepairStrategy;
     }
 
-    /**
-     * See {@link IgniteInternalCache#withSkipReadThrough()}.
-     *
-     * @return New instance of CacheOperationContext with skip store flag.
-     */
-    public CacheOperationContext withSkipReadThrough() {
-        return new CacheOperationContext(
-            skipStore,
-            true,
-            keepBinary,
-            expiryPlc,
-            noRetries,
-            dataCenterId,
-            recovery,
-            readRepairStrategy,
-            appAttrs,
-            keepBinaryInInterceptor);
+    /** Context with read repair strategy. */
+    public CacheOperationContext withReadRepairStrategy(ReadRepairStrategy 
strategy) {
+        if (readRepairStrategy() != null && readRepairStrategy() == strategy)

Review Comment:
   Condition `readRepairStrategy() != null` is redundant



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java:
##########
@@ -252,26 +251,22 @@ public IgniteInternalCache<K, V> delegate() {
     }
 
     /** {@inheritDoc} */
-    @Override public GridCacheProxyImpl<K, V> setSkipStore(boolean skipStore) {
+    @Override public GridCacheProxyImpl<K, V> withSkipStore() {
         CacheOperationContext prev = gate.enter(opCtx);
 
+        CacheOperationContext newOpCtx;
+
         try {
-            if (opCtx != null && opCtx.skipStore() == skipStore)
-                return this;
+            if (opCtx != null) {
+                if (opCtx.skipStore())
+                    return this;
+                else
+                    newOpCtx = opCtx.withSkipStore();
+            }
+            else
+                newOpCtx = 
CacheOperationContext.builder().skipStore(true).build();

Review Comment:
   ```
   newOpCtx = CacheOperationContext.of(opCtx).withSkipStore();
   
   return newOpCtx == opCtx ? this : new GridCacheProxyImpl<>(ctx, delegate, 
newOpCtx);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to