Mmuzaf commented on a change in pull request #6951: Ignite 11073 12069 P2P 
Rebalance collaboration work
URL: https://github.com/apache/ignite/pull/6951#discussion_r410553276
 
 

 ##########
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/IgnitePartitionPreloadManager.java
 ##########
 @@ -0,0 +1,337 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.dht.preloader;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cluster.BaselineNode;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.IgniteFeatures;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.affinity.AffinityAssignment;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheGroupContext;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import 
org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter;
+import 
org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
+import org.apache.ignite.internal.util.future.GridFinishedFuture;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+
+import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_DISABLE_WAL_DURING_REBALANCING;
+import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_FILE_REBALANCE_ENABLED;
+import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_FILE_REBALANCE_THRESHOLD;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static 
org.apache.ignite.configuration.IgniteConfiguration.DFLT_PDS_WAL_REBALANCE_THRESHOLD;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.UTILITY_CACHE_NAME;
+import static 
org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.MOVING;
+
+/**
+ * DHT cache partition files preloader.
+ */
+public class IgnitePartitionPreloadManager extends 
GridCacheSharedManagerAdapter {
+    /** */
+    private final boolean fileRebalanceEnabled =
+        IgniteSystemProperties.getBoolean(IGNITE_FILE_REBALANCE_ENABLED, true);
+
+    /** */
+    private final long fileRebalanceThreshold =
+        IgniteSystemProperties.getLong(IGNITE_FILE_REBALANCE_THRESHOLD, 
DFLT_PDS_WAL_REBALANCE_THRESHOLD);
+
+    /** Lock. */
+    private final Lock lock = new ReentrantLock();
+
+    /** Partition File rebalancing routine. */
+    private volatile PartitionPreloadingRoutine partPreloadingRoutine;
+
+    /** {@inheritDoc} */
+    @Override protected void stop0(boolean cancel) {
+        lock.lock();
+
+        try {
+            if (partPreloadingRoutine != null)
+                partPreloadingRoutine.onDone(false);
+        }
+        finally {
+            lock.unlock();
+        }
+    }
+
+    /**
+     * @param exchId Exchange ID.
+     * @param exchFut Completed exchange future. Can be {@code null} if forced 
or reassigned generation occurs.
+     * @param rebalanceId Rebalance id.
+     * @param forcePreload {@code True} if preload requested by {@link 
ForceRebalanceExchangeTask}.
+     * @return Cache group identifiers with future assignments that will be 
ready when partitions are preloaded.
+     */
+    public Map<Integer, IgniteInternalFuture<GridDhtPreloaderAssignments>> 
generateAssignments(
+        GridDhtPartitionExchangeId exchId,
+        GridDhtPartitionsExchangeFuture exchFut,
+        long rebalanceId,
+        boolean forcePreload
+    ) {
+        Map<UUID, Map<Integer, Set<Integer>>> filePreloadingAssignments = new 
HashMap<>();
+        Map<Integer, IgniteInternalFuture<GridDhtPreloaderAssignments>> 
futAssigns = new HashMap<>();
+
+        for (final CacheGroupContext grp : cctx.cache().cacheGroups()) {
 
 Review comment:
   CacheGroupContext can be `null` here.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to