ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [08/27] incubator-ignite git commit: IGNITE-105 (Need to add IgniteCacheConfiguration.isReadFromBackup() method)
Date Wed, 21 Jan 2015 17:47:48 GMT
IGNITE-105 (Need to add IgniteCacheConfiguration.isReadFromBackup() method)


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

Branch: refs/heads/ignite-86
Commit: 04f77769f17b2722956dd9f518637997809a244b
Parents: 2860388
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Tue Jan 20 14:15:09 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Tue Jan 20 14:15:09 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/cache/CacheFlag.java |  3 --
 .../grid/cache/GridCacheConfiguration.java      | 30 ++++++++++++++++++++
 .../org/gridgain/grid/cache/GridCacheFlag.java  |  3 --
 .../processors/cache/GridCacheAdapter.java      |  8 +++---
 4 files changed, 34 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/04f77769/modules/core/src/main/java/org/apache/ignite/cache/CacheFlag.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheFlag.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheFlag.java
index 1e5076f..d441096 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheFlag.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheFlag.java
@@ -33,9 +33,6 @@ public enum CacheFlag {
     /** Skip swap space for reads and writes. */
     SKIP_SWAP,
 
-    /** Always get data from primary node (never from backup). */
-    GET_PRIMARY,
-
     /** Synchronous commit. */
     SYNC_COMMIT,
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/04f77769/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
index 071324b..8cd961d 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
@@ -172,6 +172,9 @@ public class GridCacheConfiguration extends MutableConfiguration {
     @Deprecated
     public static final int DFLT_CONT_QUERY_MAX_BUF_SIZE = 1024;
 
+    /** Default value for 'readFromBackup' flag. */
+    public static final boolean DFLT_READ_FROM_BACKUP = true;
+
     /** Cache name. */
     private String name;
 
@@ -331,6 +334,12 @@ public class GridCacheConfiguration extends MutableConfiguration {
     /** Query configuration. */
     private GridCacheQueryConfiguration qryCfg;
 
+    /**
+     * Flag indicating whether data can be read from backup.
+     * If {@code false} always get data from primary node (never from backup).
+     */
+    private boolean readFromBackup = DFLT_READ_FROM_BACKUP;
+
     /** Empty constructor (all values are initialized to their defaults). */
     public GridCacheConfiguration() {
         /* No-op. */
@@ -408,6 +417,7 @@ public class GridCacheConfiguration extends MutableConfiguration {
         writeBehindFlushSize = cc.getWriteBehindFlushSize();
         writeBehindFlushThreadCnt = cc.getWriteBehindFlushThreadCount();
         writeSync = cc.getWriteSynchronizationMode();
+        readFromBackup = cc.isReadFromBackup();
     }
 
     /**
@@ -1711,6 +1721,26 @@ public class GridCacheConfiguration extends MutableConfiguration {
         this.qryCfg = qryCfg;
     }
 
+    /**
+     * Gets flag indicating whether data can be read from backup.
+     * If {@code false} always get data from primary node (never from backup).
+     * Default value is defined by {@link #DFLT_READ_FROM_BACKUP}.
+     *
+     * @return {@code true} if data can be read from backup node. {@code false} if data always
get from primary node
+     * (never from backup).
+     */
+    public boolean isReadFromBackup() {
+        return readFromBackup;
+    }
+
+    /**
+     * Sets read from backup flag.
+     * @param readFromBackup Value of read from backup flag.
+     */
+    public void setReadFromBackup(boolean readFromBackup) {
+        this.readFromBackup = readFromBackup;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridCacheConfiguration.class, this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/04f77769/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheFlag.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheFlag.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheFlag.java
index 953c2c3..8b4bb63 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheFlag.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheFlag.java
@@ -70,9 +70,6 @@ public enum GridCacheFlag {
     /** Skip swap space for reads and writes. */
     SKIP_SWAP,
 
-    /** Always get data from primary node (never from backup). */
-    GET_PRIMARY,
-
     /** Synchronous commit. */
     SYNC_COMMIT,
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/04f77769/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
index 69e10fc..af8899f 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheAdapter.java
@@ -1356,7 +1356,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter
im
         @Nullable IgnitePredicate<GridCacheEntry<K, V>>... filter) throws IgniteCheckedException
{
         String taskName = ctx.kernalContext().job().currentTaskName();
 
-        return getAllAsync(F.asList(key), ctx.hasFlag(GET_PRIMARY), /*skip tx*/false, entry,
null, taskName,
+        return getAllAsync(F.asList(key), !ctx.config().isReadFromBackup(), /*skip tx*/false,
entry, null, taskName,
             deserializePortable, filter).get().get(key);
     }
 
@@ -1389,14 +1389,14 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter
im
     @Nullable @Override public Map<K, V> getAllOutTx(List<K> keys) throws IgniteCheckedException
{
         String taskName = ctx.kernalContext().job().currentTaskName();
 
-        return getAllAsync(keys, ctx.hasFlag(GET_PRIMARY), /*skip tx*/true, null, null, taskName,
true).get();
+        return getAllAsync(keys, !ctx.config().isReadFromBackup(), /*skip tx*/true, null,
null, taskName, true).get();
     }
 
     /** {@inheritDoc} */
     @Override public IgniteFuture<Map<K, V>> getAllOutTxAsync(List<K> keys)
{
         String taskName = ctx.kernalContext().job().currentTaskName();
 
-        return getAllAsync(keys, ctx.hasFlag(GET_PRIMARY), /*skip tx*/true, null, null, taskName,
true);
+        return getAllAsync(keys, !ctx.config().isReadFromBackup(), /*skip tx*/true, null,
null, taskName, true);
     }
 
     /** {@inheritDoc} */
@@ -4579,7 +4579,7 @@ public abstract class GridCacheAdapter<K, V> extends GridMetadataAwareAdapter
im
             });
         }
 
-        return getAllAsync(keys, ctx.hasFlag(GET_PRIMARY), /*skip tx*/false, null, null,
taskName,
+        return getAllAsync(keys, !ctx.config().isReadFromBackup(), /*skip tx*/false, null,
null, taskName,
             deserializePortable, filter);
     }
 


Mime
View raw message