ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [3/5] incubator-ignite git commit: IGNITE-443 Moved CacheConflictResolver interfaces to Ignite.
Date Wed, 11 Mar 2015 15:23:38 GMT
IGNITE-443 Moved CacheConflictResolver interfaces to Ignite.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2f17a25b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2f17a25b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2f17a25b

Branch: refs/heads/ignite-443
Commit: 2f17a25bdb10d8392fd0de122d94667fcfd87b19
Parents: 9426a74
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Wed Mar 11 17:28:04 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Wed Mar 11 17:28:04 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/GridKernalContextImpl.java  |  3 +
 .../cache/CacheConflictResolverManager.java     | 28 +++++++
 .../processors/cache/CacheResolveEntryImpl.java | 79 ++++++++++++++++++++
 .../DrReceiverCacheConflictContextImpl.java     | 64 ++++++++++++++++
 .../processors/cache/GridCacheContext.java      | 18 ++---
 .../GridCacheEntryAbstractConflictResolver.java | 57 ++++++++++++++
 .../processors/cache/GridCacheProcessor.java    |  7 +-
 .../IgniteCacheConflictResolverManager.java     | 33 ++++++++
 .../processors/cache/dr/GridCacheDrManager.java |  5 --
 .../cache/dr/os/GridOsCacheDrManager.java       |  5 --
 ...ridCacheVersionAbstractConflictResolver.java | 56 --------------
 .../GridCacheVersionConflictResolver.java       | 76 +++++++++++++------
 .../loadtests/hashmap/GridCacheTestContext.java |  4 +-
 13 files changed, 334 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index 2bc44a3..455819c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.managers.checkpoint.*;
 import org.apache.ignite.internal.managers.collision.*;
@@ -789,6 +790,8 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
             return (T)new GridOsPortableProcessor(this);
         else if (cls.equals(IgniteCacheSerializationManager.class))
             return (T)new IgniteCacheOsSerializationManager();
+        else if (cls.equals(CacheConflictResolver.class))
+            return (T)new IgniteCacheConflictResolverManager();
 
         throw new IgniteException("Unsupported component type: " + cls);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConflictResolverManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConflictResolverManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConflictResolverManager.java
new file mode 100644
index 0000000..ea1e1b0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConflictResolverManager.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+/**
+ *
+ */
+public abstract class CacheConflictResolverManager<K, V> extends GridCacheManagerAdapter<K,
V> {
+    /**
+     * @return Cache conflict resolver.
+     */
+    public abstract GridCacheEntryAbstractConflictResolver conflictResolver();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheResolveEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheResolveEntryImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheResolveEntryImpl.java
new file mode 100644
index 0000000..c966f13
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheResolveEntryImpl.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.processors.cache.version.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * DR cache entry implementation.
+ */
+public class CacheResolveEntryImpl<K, V> implements CacheResolveEntry<K, V> {
+    /** Underlying cache versioned entry. */
+    private final GridCacheVersionedEntry<K, V> entry;
+
+    /**
+     * Constructor.
+     *
+     * @param entry Underlying cache versioned entry.
+     */
+    public CacheResolveEntryImpl(GridCacheVersionedEntry<K, V> entry) {
+        this.entry = entry;
+    }
+
+    /** {@inheritDoc} */
+    @Override public K key() {
+        return entry.key();
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public V value() {
+        return entry.value();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long ttl() {
+        return entry.ttl();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long expireTime() {
+        return entry.expireTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte dataCenterId() {
+        return entry.dataCenterId();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int topologyVersion() {
+        return entry.topologyVersion();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long order() {
+        return entry.order();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long globalTime() {
+        return entry.globalTime();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DrReceiverCacheConflictContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DrReceiverCacheConflictContextImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DrReceiverCacheConflictContextImpl.java
new file mode 100644
index 0000000..99c19f4
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DrReceiverCacheConflictContextImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.processors.cache.version.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * DR conflict context implementation.
+ */
+public class DrReceiverCacheConflictContextImpl<K, V> implements CacheConflictContext<K,
V> {
+    /** Underlying cache conflict context. */
+    private final GridCacheVersionConflictContext<K, V> ctx;
+
+    /**
+     * Constructor.
+     *
+     * @param ctx Underlying cache conflict context.
+     */
+    public DrReceiverCacheConflictContextImpl(GridCacheVersionConflictContext<K, V>
ctx) {
+        this.ctx = ctx;
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheResolveEntry<K, V> oldEntry() {
+        return new CacheResolveEntryImpl<>(ctx.oldEntry());
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheResolveEntry<K, V> newEntry() {
+        return new CacheResolveEntryImpl<>(ctx.newEntry());
+    }
+
+    /** {@inheritDoc} */
+    @Override public void useOld() {
+        ctx.useOld();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void useNew() {
+        ctx.useNew();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void merge(@Nullable V mergeVal, long ttl) {
+        ctx.merge(mergeVal, ttl);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 44f8e69..0493085 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -138,6 +138,9 @@ public class GridCacheContext<K, V> implements Externalizable {
     /** JTA manager. */
     private CacheJtaManagerAdapter<K, V> jtaMgr;
 
+    /** Conflict resolver manager. */
+    private CacheConflictResolverManager rslvrMgr;
+
     /** Managers. */
     private List<GridCacheManager<K, V>> mgrs = new LinkedList<>();
 
@@ -202,7 +205,7 @@ public class GridCacheContext<K, V> implements Externalizable {
     private CacheWeakQueryIteratorsHolder<Map.Entry<K, V>> itHolder;
 
     /** Conflict resolver. */
-    private GridCacheVersionAbstractConflictResolver conflictRslvr;
+    private GridCacheEntryAbstractConflictResolver conflictRslvr;
 
     /**
      * Empty constructor required for {@link Externalizable}.
@@ -249,7 +252,8 @@ public class GridCacheContext<K, V> implements Externalizable {
         CacheDataStructuresManager<K, V> dataStructuresMgr,
         GridCacheTtlManager<K, V> ttlMgr,
         GridCacheDrManager<K, V> drMgr,
-        CacheJtaManagerAdapter<K, V> jtaMgr) {
+        CacheJtaManagerAdapter<K, V> jtaMgr,
+        CacheConflictResolverManager<K, V> rslvrMgr) {
         assert ctx != null;
         assert sharedCtx != null;
         assert cacheCfg != null;
@@ -263,6 +267,7 @@ public class GridCacheContext<K, V> implements Externalizable {
         assert affMgr != null;
         assert dataStructuresMgr != null;
         assert ttlMgr != null;
+        assert rslvrMgr != null;
 
         this.ctx = ctx;
         this.sharedCtx = sharedCtx;
@@ -284,6 +289,7 @@ public class GridCacheContext<K, V> implements Externalizable {
         this.ttlMgr = add(ttlMgr);
         this.drMgr = add(drMgr);
         this.jtaMgr = add(jtaMgr);
+        this.rslvrMgr = add(rslvrMgr);
 
         log = ctx.log(getClass());
 
@@ -330,13 +336,7 @@ public class GridCacheContext<K, V> implements Externalizable {
      * Initialize conflict resolver after all managers are started.
      */
     void initConflictResolver() {
-        // Conflict resolver is determined in two stages:
-        // 1. If DR receiver hub is enabled, then pick it from DR manager.
-        // 2. Otherwise instantiate default resolver in case local store is configured.
-        conflictRslvr = drMgr.conflictResolver();
-
-        if (conflictRslvr == null && storeMgr.isLocalStore())
-            conflictRslvr = new GridCacheVersionConflictResolver();
+        conflictRslvr = rslvrMgr.conflictResolver();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryAbstractConflictResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryAbstractConflictResolver.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryAbstractConflictResolver.java
new file mode 100644
index 0000000..ad6a60d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryAbstractConflictResolver.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.processors.cache.version.*;
+
+/**
+ * Cache version conflict resolver.
+ */
+public abstract class GridCacheEntryAbstractConflictResolver {
+    /**
+     * Resolve the conflict.
+     *
+     * @param oldEntry Old entry.
+     * @param newEntry New entry.
+     * @param atomicVerComparator Whether to use atomic version comparator.
+     * @return Conflict resolution context.
+     * @throws IgniteCheckedException If failed.
+     */
+    public <K, V> GridCacheVersionConflictContext<K, V> resolve(GridCacheVersionedEntryEx<K,
V> oldEntry,
+        GridCacheVersionedEntryEx<K, V> newEntry, boolean atomicVerComparator) throws
IgniteCheckedException {
+        GridCacheVersionConflictContext<K, V> ctx = new GridCacheVersionConflictContext<>(oldEntry,
newEntry);
+
+        resolve0(ctx, oldEntry, newEntry, atomicVerComparator);
+
+        return ctx;
+    }
+
+    /**
+     * Internal conflict resolution routine.
+     *
+     * @param ctx Context.
+     * @param oldEntry Old entry.
+     * @param newEntry New entry.
+     * @param atomicVerComparator Whether to use atomic version comparator.
+     * @throws IgniteCheckedException If failed.
+     */
+    protected abstract <K, V> void resolve0(GridCacheVersionConflictContext<K, V>
ctx,
+        GridCacheVersionedEntryEx<K, V> oldEntry, GridCacheVersionedEntryEx<K, V>
newEntry,
+        boolean atomicVerComparator) throws IgniteCheckedException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 7f945da..70e6328 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -640,6 +640,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             GridCacheTtlManager ttlMgr = new GridCacheTtlManager();
             GridCacheDrManager drMgr = ctx.createComponent(GridCacheDrManager.class);
             IgniteCacheSerializationManager serMgr = ctx.createComponent(IgniteCacheSerializationManager.class);
+            CacheConflictResolverManager rslvrMgr = ctx.createComponent(CacheConflictResolverManager.class);
 
             GridCacheStoreManager storeMgr = new GridCacheStoreManager(ctx, sesHolders, cfgStore,
cfg);
 
@@ -663,7 +664,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 dataStructuresMgr,
                 ttlMgr,
                 drMgr,
-                jta);
+                jta,
+                rslvrMgr);
 
             cacheCtx.defaultAffMapper(dfltAffMapper);
 
@@ -803,7 +805,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                     dataStructuresMgr,
                     ttlMgr,
                     drMgr,
-                    jta);
+                    jta,
+                    rslvrMgr);
 
                 cacheCtx.defaultAffMapper(dfltAffMapper);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheConflictResolverManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheConflictResolverManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheConflictResolverManager.java
new file mode 100644
index 0000000..50cc508
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheConflictResolverManager.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.internal.processors.cache.version.*;
+
+/**
+ *
+ */
+public class IgniteCacheConflictResolverManager<K ,V> extends CacheConflictResolverManager<K
,V> {
+    /**
+     * @return Cache conflict resolver.
+     */
+    @Override public GridCacheEntryAbstractConflictResolver conflictResolver() {
+        return new GridCacheVersionConflictResolver(cctx.config().getConflictResolverMode(),
+            cctx.config().getConflictResolver());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridCacheDrManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridCacheDrManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridCacheDrManager.java
index 85831a8..4162af4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridCacheDrManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/GridCacheDrManager.java
@@ -33,11 +33,6 @@ public interface GridCacheDrManager<K, V> extends GridCacheManager<K,
V> {
     public byte dataCenterId();
 
     /**
-     * @return Cache version conflict resolver.
-     */
-    public GridCacheVersionAbstractConflictResolver conflictResolver();
-
-    /**
      * Performs replication.
      *
      * @param key Key.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/os/GridOsCacheDrManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/os/GridOsCacheDrManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/os/GridOsCacheDrManager.java
index 49f617b..e3744fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/os/GridOsCacheDrManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/dr/os/GridOsCacheDrManager.java
@@ -64,11 +64,6 @@ public class GridOsCacheDrManager<K, V> implements GridCacheDrManager<K,
V> {
     }
 
     /** {@inheritDoc} */
-    @Override public GridCacheVersionAbstractConflictResolver conflictResolver() {
-        return null;
-    }
-
-    /** {@inheritDoc} */
     @Override public void replicate(K key,
         @Nullable byte[] keyBytes,
         @Nullable V val,

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAbstractConflictResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAbstractConflictResolver.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAbstractConflictResolver.java
deleted file mode 100644
index 8bc6425..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAbstractConflictResolver.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.version;
-
-import org.apache.ignite.*;
-
-/**
- * Cache version conflict resolver.
- */
-public abstract class GridCacheVersionAbstractConflictResolver {
-    /**
-     * Resolve the conflict.
-     *
-     * @param oldEntry Old entry.
-     * @param newEntry New entry.
-     * @param atomicVerComparator Whether to use atomic version comparator.
-     * @return Conflict resolution context.
-     * @throws IgniteCheckedException If failed.
-     */
-    public <K, V> GridCacheVersionConflictContext<K, V> resolve(GridCacheVersionedEntryEx<K,
V> oldEntry,
-        GridCacheVersionedEntryEx<K, V> newEntry, boolean atomicVerComparator) throws
IgniteCheckedException {
-        GridCacheVersionConflictContext<K, V> ctx = new GridCacheVersionConflictContext<>(oldEntry,
newEntry);
-
-        resolve0(ctx, oldEntry, newEntry, atomicVerComparator);
-
-        return ctx;
-    }
-
-    /**
-     * Internal conflict resolution routine.
-     *
-     * @param ctx Context.
-     * @param oldEntry Old entry.
-     * @param newEntry New entry.
-     * @param atomicVerComparator Whether to use atomic version comparator.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected abstract <K, V> void resolve0(GridCacheVersionConflictContext<K, V>
ctx,
-        GridCacheVersionedEntryEx<K, V> oldEntry, GridCacheVersionedEntryEx<K, V>
newEntry,
-        boolean atomicVerComparator) throws IgniteCheckedException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictResolver.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictResolver.java
index 869993c..896d151 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictResolver.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictResolver.java
@@ -18,41 +18,71 @@
 package org.apache.ignite.internal.processors.cache.version;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.internal.processors.cache.*;
 
+import static org.apache.ignite.cache.CacheConflictResolverMode.*;
+
 /**
  * Default conflict resolver.
  */
-public class GridCacheVersionConflictResolver extends GridCacheVersionAbstractConflictResolver
{
+public class GridCacheVersionConflictResolver extends GridCacheEntryAbstractConflictResolver
{
+    /** Mode. */
+    protected final CacheConflictResolverMode mode;
+
+    /** Resolver. */
+    protected final CacheConflictResolver rslvr;
+
+    /**
+     * Constructor.
+     *
+     * @param mode Mode.
+     * @param rslvr Resolver.
+     */
+    public GridCacheVersionConflictResolver(CacheConflictResolverMode mode, CacheConflictResolver
rslvr) {
+        this.mode = mode;
+        this.rslvr = rslvr;
+    }
+
     /** {@inheritDoc} */
     @Override protected <K, V> void resolve0(GridCacheVersionConflictContext<K,
V> ctx,
         GridCacheVersionedEntryEx<K, V> oldEntry, GridCacheVersionedEntryEx<K, V>
newEntry,
         boolean atomicVerComparator) throws IgniteCheckedException {
-        if (newEntry.dataCenterId() != oldEntry.dataCenterId())
+        if (mode == ALWAYS) {
+            if (rslvr != null) {
+                // Try falling back to user resolver.
+                rslvr.resolve(new DrReceiverCacheConflictContextImpl(ctx));
+
+                ctx.manualResolve();
+            }
+            else
+                // No other option, but to use new entry.
+                ctx.useNew();
+
+            return;
+        }
+
+        if (oldEntry.isStartVersion())
             ctx.useNew();
         else {
-            if (oldEntry.isStartVersion())
-                ctx.useNew();
+            if (atomicVerComparator) {
+                // Handle special case when version check using ATOMIC cache comparator is
required.
+                if (GridCacheMapEntry.ATOMIC_VER_COMPARATOR.compare(oldEntry.version(), newEntry.version())
>= 0)
+                    ctx.useOld();
+                else
+                    ctx.useNew();
+            }
             else {
-                if (atomicVerComparator) {
-                    // Handle special case when version check using ATOMIC cache comparator
is required.
-                    if (GridCacheMapEntry.ATOMIC_VER_COMPARATOR.compare(oldEntry.version(),
newEntry.version()) >= 0)
-                        ctx.useOld();
-                    else
-                        ctx.useNew();
-                }
-                else {
-                    long topVerDiff = newEntry.topologyVersion() - oldEntry.topologyVersion();
-
-                    if (topVerDiff > 0)
-                        ctx.useNew();
-                    else if (topVerDiff < 0)
-                        ctx.useOld();
-                    else if (newEntry.order() > oldEntry.order())
-                        ctx.useNew();
-                    else
-                        ctx.useOld();
-                }
+                long topVerDiff = newEntry.topologyVersion() - oldEntry.topologyVersion();
+
+                if (topVerDiff > 0)
+                    ctx.useNew();
+                else if (topVerDiff < 0)
+                    ctx.useOld();
+                else if (newEntry.order() > oldEntry.order())
+                    ctx.useNew();
+                else
+                    ctx.useOld();
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f17a25b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
index 8ba8966..44ac6a1 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
@@ -69,6 +69,8 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K,
V> {
             new CacheDataStructuresManager<K, V>(),
             new GridCacheTtlManager<K, V>(),
             new GridOsCacheDrManager<K, V>(),
-            new CacheNoopJtaManager<K, V>());
+            new CacheNoopJtaManager<K, V>(),
+            new IgniteCacheConflictResolverManager<K, V>()
+        );
     }
 }


Mime
View raw message