Skip to content

Commit

Permalink
GG-20729 Add ability to set default parallelism of rebuild indexes in…
Browse files Browse the repository at this point in the history
… ignite system properties
  • Loading branch information
denis-chudov committed Jul 8, 2019
1 parent d0d9d3f commit 05cdf46
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,14 @@ public final class IgniteSystemProperties {
*/
public static final String IGNITE_ENABLE_HASH_JOIN = "IGNITE_ENABLE_HASH_JOIN";

/**
* Index rebuilding parallelism level. If specified, sets the count of threads that are used for index rebuilding
* and can only be greater than <code>0</code>, otherwise default value will be used. Maximum count of threads
* can't be greater than total available processors count.
* Default value is minimum of <code>4</code> and processors count / 4, but always greater than <code>0</code>.
*/
public static final String INDEX_REBUILDING_PARALLELISM = "INDEX_REBUILDING_PARALLELISM";

/**
* Enforces singleton.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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;
Expand All @@ -36,6 +37,7 @@
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;
Expand All @@ -46,8 +48,7 @@
*/
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));
private static final int DFLT_PARALLELISM;

/** Count of rows, being processed within a single checkpoint lock. */
private static final int BATCH_SIZE = 1000;
Expand All @@ -67,6 +68,15 @@ public class SchemaIndexCacheVisitorImpl implements SchemaIndexCacheVisitor {
/** Whether to stop the process. */
private volatile boolean stop;

static {
int parallelism = IgniteSystemProperties.getInteger(INDEX_REBUILDING_PARALLELISM, 0);

if (parallelism > 0)
DFLT_PARALLELISM = Math.min(parallelism, Runtime.getRuntime().availableProcessors());
else
DFLT_PARALLELISM = Math.min(4, Math.max(1, Runtime.getRuntime().availableProcessors() / 4));
}

/**
* Constructor.
* @param cctx Cache context.
Expand All @@ -91,7 +101,7 @@ public SchemaIndexCacheVisitorImpl(GridCacheContext cctx, SchemaIndexCacheFilter
if (parallelism > 0)
this.parallelism = Math.min(Runtime.getRuntime().availableProcessors(), parallelism);
else
this.parallelism = DFLT_PARALLELISM;
this.parallelism = DFLT_PARALLELISM;

if (cctx.isNear())
cctx = ((GridNearCacheAdapter)cctx.cache()).dht().context();
Expand Down

0 comments on commit 05cdf46

Please sign in to comment.