This is an automated email from the ASF dual-hosted git repository.

amashenkov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b4d29c  IGNITE-11979 Add ability to set default parallelism of 
rebuild indexes in ignite system properties. This closes #6687.
5b4d29c is described below

commit 5b4d29c194bdec1cd7bcd6b0a69ed0287eb75e6d
Author: denis-chudov <[email protected]>
AuthorDate: Fri Jul 26 12:27:38 2019 +0300

    IGNITE-11979 Add ability to set default parallelism of rebuild indexes in 
ignite system properties. This closes #6687.
---
 .../org/apache/ignite/IgniteSystemProperties.java    |  9 +++++++++
 .../query/schema/SchemaIndexCacheVisitorImpl.java    | 20 ++++++++++++++++----
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java 
b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 9d785d1..65457de 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -1238,6 +1238,15 @@ public final class IgniteSystemProperties {
     public static final String IGNITE_LOG_CLASSPATH_CONTENT_ON_STARTUP = 
"IGNITE_LOG_CLASSPATH_CONTENT_ON_STARTUP";
 
     /**
+     * Index rebuilding parallelism level. It sets a number of threads will be 
used for index rebuilding.
+     * Zero value means default should be used.
+     * Default value is calculated as <code>CPU count / 4</code> with upper 
limit of <code>4</code>.
+     * <p>
+     * Note: Number of threads is bounded within the range from <code>1</code> 
up to <code>CPU count</code>.
+     */
+    public static final String INDEX_REBUILDING_PARALLELISM = 
"INDEX_REBUILDING_PARALLELISM";
+
+    /**
      * Enforces singleton.
      */
     private IgniteSystemProperties() {
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java
index 1c42843..d45f1a1 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.query.schema;
 
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -37,6 +38,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.util.worker.GridWorker;
 import org.apache.ignite.thread.IgniteThread;
 
+import static 
org.apache.ignite.IgniteSystemProperties.INDEX_REBUILDING_PARALLELISM;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.EVICTED;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.MOVING;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING;
@@ -46,9 +48,8 @@ import static 
org.apache.ignite.internal.processors.cache.distributed.dht.topolo
  * Traversor operating all primary and backup partitions of given cache.
  */
 public class SchemaIndexCacheVisitorImpl implements SchemaIndexCacheVisitor {
-    /** Default degree of parallelism. */
-    private static final int DFLT_PARALLELISM =
-        Math.min(4, Math.max(1, Runtime.getRuntime().availableProcessors() / 
4));
+    /** Default degree of parallelism for rebuilding indexes. */
+    private static final int DFLT_INDEX_REBUILDING_PARALLELISM;
 
     /** Count of rows, being processed within a single checkpoint lock. */
     private static final int BATCH_SIZE = 1000;
@@ -68,6 +69,16 @@ public class SchemaIndexCacheVisitorImpl implements 
SchemaIndexCacheVisitor {
     /** Whether to stop the process. */
     private volatile boolean stop;
 
+    static {
+        int parallelism = 
IgniteSystemProperties.getInteger(INDEX_REBUILDING_PARALLELISM, 0);
+
+        // Parallelism lvl is bounded to range of [1, CPUs count]
+        if (parallelism > 0)
+            DFLT_INDEX_REBUILDING_PARALLELISM = Math.min(parallelism, 
Runtime.getRuntime().availableProcessors());
+        else
+            DFLT_INDEX_REBUILDING_PARALLELISM = Math.min(4, Math.max(1, 
Runtime.getRuntime().availableProcessors() / 4));
+    }
+
     /**
      * Constructor.
      *  @param cctx Cache context.
@@ -89,10 +100,11 @@ public class SchemaIndexCacheVisitorImpl implements 
SchemaIndexCacheVisitor {
         this.rowFilter = rowFilter;
         this.cancel = cancel;
 
+        // Parallelism lvl is bounded to range of [1, CPUs count]
         if (parallelism > 0)
             this.parallelism = 
Math.min(Runtime.getRuntime().availableProcessors(), parallelism);
         else
-            this.parallelism =  DFLT_PARALLELISM;
+            this.parallelism = DFLT_INDEX_REBUILDING_PARALLELISM;
 
         if (cctx.isNear())
             cctx = ((GridNearCacheAdapter)cctx.cache()).dht().context();

Reply via email to