You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2019/12/02 10:13:46 UTC

[GitHub] [ignite] NSAmelchev commented on a change in pull request #6937: IGNITE-12186 TDE - Phase-2. Master key rotation.

NSAmelchev commented on a change in pull request #6937: IGNITE-12186 TDE - Phase-2. Master key rotation.
URL: https://github.com/apache/ignite/pull/6937#discussion_r352513581
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/util/distributed/DistributedProcess.java
 ##########
 @@ -0,0 +1,388 @@
+/*
+ * 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.util.distributed;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.failure.FailureContext;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.GridTopic;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.managers.encryption.GridEncryptionManager;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.util.GridConcurrentHashSet;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.CI3;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
+import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
+import static org.apache.ignite.failure.FailureType.CRITICAL_ERROR;
+import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL;
+
+/**
+ * Distributed process is a cluster-wide process that accumulates single nodes results to finish itself.
+ * <p>
+ * The process consists of the following phases:
+ * <ol>
+ *  <li>Initial request starts process. (Sent via discovery)</li>
+ *  <li>Each server node process an initial request and send the single node result to the coordinator. (Sent via
+ *  communication)</li>
+ *  <li>The coordinator accumulate all single nodes results and finish process. (Sent via discovery)</li>
+ * </ol>
+ * <p>
+ * Several processes of one type can be started at the same time.
+ *
+ * @param <I> Request type.
+ * @param <R> Result type.
+ */
+public class DistributedProcess<I extends Serializable, R extends Serializable> {
+    /** Process type. */
+    private final DistributedProcessType type;
+
+    /** Active processes. */
+    private final ConcurrentHashMap<UUID, Process> processes = new ConcurrentHashMap<>(1);
+
+    /** Synchronization mutex for coordinator initializing and the remaining collection operations. */
+    private final Object mux = new Object();
+
+    /** Kernal context. */
+    private final GridKernalContext ctx;
+
+    /** Logger. */
+    private final IgniteLogger log;
+
+    /**
+     * @param ctx Kernal context.
+     * @param type Process type.
+     * @param exec Execute action and returns future with the single node result to send to the coordinator.
+     * @param finish Finish process closure. Called on each node when all single nodes results received.
+     */
+    public DistributedProcess(GridKernalContext ctx, DistributedProcessType type,
+        Function<I, IgniteInternalFuture<R>> exec,
+        CI3<UUID, Map<UUID, R>, Map<UUID, Exception>> finish) {
+        this.ctx = ctx;
+        this.type = type;
+
+        log = ctx.log(getClass());
+
+        ctx.discovery().setCustomEventListener(InitMessage.class, (topVer, snd, msg) -> {
 
 Review comment:
   Could you tell API for removal, please?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services