ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgovoruk...@apache.org
Subject [02/12] ignite git commit: IGNITE-1678 add percentage as parameter for atomic seq
Date Wed, 29 Aug 2018 12:17:44 GMT
IGNITE-1678 add percentage as parameter for atomic seq


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

Branch: refs/heads/ignite-1678
Commit: cbfe5932a4b1230bb1aac8075004eea73479e7b2
Parents: ed9c2d2
Author: Dmitriy Govorukhin <dmitriy.govorukhin@gmail.com>
Authored: Sun Aug 26 10:53:47 2018 +0300
Committer: Dmitriy Govorukhin <dmitriy.govorukhin@gmail.com>
Committed: Sun Aug 26 10:53:47 2018 +0300

----------------------------------------------------------------------
 .../datastructures/DataStructuresProcessor.java    | 13 ++++++++++---
 .../GridCacheAtomicSequenceImpl.java               | 17 ++++++++++++-----
 2 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cbfe5932/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index 571e072..38c3bff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -403,6 +403,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter
implemen
                 long upBound;
                 long locCntr;
 
+                // If not present, first initialization.
                 if (seqVal == null) {
                     locCntr = initVal;
 
@@ -411,6 +412,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter
implemen
                     // Global counter must be more than reserved region.
                     seqVal = new GridCacheAtomicSequenceValue(upBound + 1);
                 }
+                // If present, start from exist seq value.
                 else {
                     locCntr = seqVal.get();
 
@@ -420,13 +422,18 @@ public final class DataStructuresProcessor extends GridProcessorAdapter
implemen
                     seqVal.set(upBound + 1);
                 }
 
+                int reservePercentage = cfg0.getAtomicSequenceReservePercentage();
+
                 // Only one thread can be in the transaction scope and create sequence.
-                seq = new GridCacheAtomicSequenceImpl(name,
+                seq = new GridCacheAtomicSequenceImpl(
+                    name,
                     key,
                     cache,
                     cfg0.getAtomicSequenceReserveSize(),
+                    reservePercentage,
                     locCntr,
-                    upBound);
+                    upBound
+                );
 
                 return new T2<GridCacheAtomicSequenceEx, AtomicDataStructureValue>(seq,
seqVal);
             }
@@ -1646,7 +1653,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter
implemen
             );
         }
 
-        if (atomicCfg.getAtomicSequenceReservePercentage() <= 0 || atomicCfg.getAtomicSequenceReservePercentage()
> 100) {
+        if (atomicCfg.getAtomicSequenceReservePercentage() < 0 || atomicCfg.getAtomicSequenceReservePercentage()
> 100) {
             throw new IgniteException(
                 "Atomic sequence can not be created, reserve percentage must have value "
+
                     "between 0 and 100, but atomicSequenceReservePercentage: " + atomicCfg.getAtomicSequenceReservePercentage()

http://git-wip-us.apache.org/repos/asf/ignite/blob/cbfe5932/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
index 33a68e1..61e9262 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
@@ -66,12 +66,15 @@ public final class GridCacheAtomicSequenceImpl extends AtomicDataStructureProxy<
     @GridToStringInclude(sensitive = true)
     private volatile long locVal;
 
-    /**  Upper bound of local counter. */
+    /** Upper bound of local counter. */
     private long upBound;
 
-    /**  Sequence batch size */
+    /** Sequence batch size */
     private volatile int batchSize;
 
+    /** Reservation percentage. */
+    private int reservePercentage;
+
     /** Synchronization lock for local value updates. */
     private final Lock localUpdate = new ReentrantLock();
 
@@ -101,21 +104,25 @@ public final class GridCacheAtomicSequenceImpl extends AtomicDataStructureProxy<
      * @param key Sequence key.
      * @param seqView Sequence projection.
      * @param batchSize Sequence batch size.
+     * @param reservePercentage Reservation percentage.
      * @param locVal Local counter.
      * @param upBound Upper bound.
      */
-    public GridCacheAtomicSequenceImpl(String name,
+    public GridCacheAtomicSequenceImpl(
+        String name,
         GridCacheInternalKey key,
         IgniteInternalCache<GridCacheInternalKey, GridCacheAtomicSequenceValue> seqView,
         int batchSize,
+        int reservePercentage,
         long locVal,
-        long upBound)
-    {
+        long upBound
+    ) {
         super(name, key, seqView);
 
         assert locVal <= upBound;
 
         this.batchSize = batchSize;
+        this.reservePercentage = reservePercentage;
         this.upBound = upBound;
         this.locVal = locVal;
     }


Mime
View raw message