ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/5] incubator-ignite git commit: IGNITE-443 Moved CacheConflictResolver interfaces to Ignite.
Date Wed, 11 Mar 2015 15:23:37 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/9426a745
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9426a745
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9426a745

Branch: refs/heads/ignite-443
Commit: 9426a745e70ecde9acfaefaec2e1eb215421f2f5
Parents: 540304d
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Wed Mar 11 12:43:03 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Wed Mar 11 13:09:02 2015 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       | 62 ++++++++++++++++++++
 .../processors/cache/GridCacheProcessor.java    |  8 +++
 2 files changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9426a745/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 224176f..89496e2 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -30,6 +30,8 @@ import org.jetbrains.annotations.*;
 import javax.cache.configuration.*;
 import java.util.*;
 
+import static org.apache.ignite.cache.CacheConflictResolverMode.*;
+
 /**
  * This class defines grid cache configuration. This configuration is passed to
  * grid via {@link IgniteConfiguration#getCacheConfiguration()} method. It defines all configuration
@@ -160,6 +162,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K,
V> {
     /** Default value for 'readFromBackup' flag. */
     public static final boolean DFLT_READ_FROM_BACKUP = true;
 
+    /** Default data center replication receiver cache conflict resolver mode. */
+    public static final CacheConflictResolverMode DFLT_CONFLICT_RSLVR_MODE = AUTO;
+
     /** Cache name. */
     private String name;
 
@@ -319,6 +324,12 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K,
V> {
     /** Collection of type metadata. */
     private Collection<CacheTypeMetadata> typeMeta;
 
+    /** Receiver cache conflict resolver mode. */
+    private CacheConflictResolverMode conflictRslvrMode = DFLT_CONFLICT_RSLVR_MODE;
+
+    /** Receiver cache conflict resolver. */
+    private CacheConflictResolver conflictRslvr;
+
     /** Empty constructor (all values are initialized to their defaults). */
     public CacheConfiguration() {
         /* No-op. */
@@ -349,6 +360,8 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K,
V> {
         cacheLoaderFactory = cc.getCacheLoaderFactory();
         cacheMode = cc.getCacheMode();
         cacheWriterFactory = cc.getCacheWriterFactory();
+        conflictRslvr = cc.getConflictResolver();
+        conflictRslvrMode = cc.getConflictResolverMode();
         dfltLockTimeout = cc.getDefaultLockTimeout();
         dfltQryTimeout = cc.getDefaultQueryTimeout();
         distro = cc.getDistributionMode();
@@ -1620,6 +1633,55 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K,
V> {
         this.readFromBackup = readFromBackup;
     }
 
+    /**
+     * Gets conflict resolver mode. See {@link CacheConflictResolverMode} for more information.
+     * <p>
+     * Defaults to {@link #DFLT_CONFLICT_RSLVR_MODE}.
+     *
+     * @return Conflict resolution mode.
+     */
+    public CacheConflictResolverMode getConflictResolverMode() {
+        return conflictRslvrMode;
+    }
+
+    /**
+     * Sets conflict resolver mode. See {@link #getConflictResolverMode()} for
+     * more information.
+     *
+     * @param conflictRslvrMode Conflict resolver mode.
+     */
+    public void setConflictResolverMode(CacheConflictResolverMode conflictRslvrMode) {
+        this.conflictRslvrMode = conflictRslvrMode;
+    }
+
+    /**
+     * Gets conflict resolver.
+     * <p>
+     * For {@link CacheConflictResolverMode#AUTO} mode this parameter can be {@code null}
and in
+     * this case new entry will always overwrite the old one.
+     * <p>
+     * For {@link CacheConflictResolverMode#ALWAYS} mode this parameter is mandatory.
+     * <p>
+     * Default value is {@code null}.
+     *
+     * @return Conflict resolver.
+     */
+    @Nullable public CacheConflictResolver getConflictResolver() {
+        return conflictRslvr;
+    }
+
+    /**
+     * Sets conflict resolver. See {@link #getConflictResolver()} for more
+     * information.
+     * <p>
+     * Defaults to {@code null}.
+     *
+     * @param conflictRslvr Conflict resolver.
+     */
+    public void setConflictResolver(CacheConflictResolver conflictRslvr) {
+        this.conflictRslvr = conflictRslvr;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(CacheConfiguration.class, this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9426a745/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 13fc5cf..7f945da 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
@@ -56,6 +56,7 @@ import java.util.*;
 
 import static org.apache.ignite.IgniteSystemProperties.*;
 import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheConflictResolverMode.*;
 import static org.apache.ignite.configuration.CacheConfiguration.*;
 import static org.apache.ignite.cache.CacheDistributionMode.*;
 import static org.apache.ignite.cache.CacheMode.*;
@@ -442,6 +443,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (cc.getAtomicityMode() == ATOMIC)
             assertParameter(cc.getTransactionManagerLookupClassName() == null,
                 "transaction manager can not be used with ATOMIC cache");
+
+        assertParameter(cc.getConflictResolverMode() != null, "cc.getConflictResolverMode()
!= null");
+
+        if (cc.getConflictResolverMode() != AUTO && cc.getConflictResolver() == null)
+            throw new IgniteException("Conflict resolver must be not null with " + cc.getConflictResolverMode()
+
+                " resolving policy");
     }
 
     /**
@@ -477,6 +484,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         prepare(cfg, cfg.getAffinityMapper(), false);
         prepare(cfg, cfg.getEvictionFilter(), false);
         prepare(cfg, cfg.getInterceptor(), false);
+        prepare(cfg, cfg.getConflictResolver(), false);
 
         for (Object obj : objs)
             prepare(cfg, obj, false);


Mime
View raw message