You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@celeborn.apache.org by GitBox <gi...@apache.org> on 2022/12/14 09:56:27 UTC

[GitHub] [incubator-celeborn] waitinfuture commented on a diff in pull request #1060: [CELEBORN-117] refactor CommitManager, implements M/R Partition Commi…

waitinfuture commented on code in PR #1060:
URL: https://github.com/apache/incubator-celeborn/pull/1060#discussion_r1048212994


##########
client/src/main/scala/org/apache/celeborn/client/CommitManager.scala:
##########
@@ -145,7 +133,8 @@ class CommitManager(appId: String, val conf: CelebornConf, lifecycleManager: Lif
                     if (partitionType == PartitionType.MAP) {

Review Comment:
   We should avoid check for PartitionType in CommitManager, maybe move such methods into commitHandler, same for incrementInflightNum and decrementInflightNum



##########
client/src/main/scala/org/apache/celeborn/client/commit/ReducePartitionCommitHandler.scala:
##########
@@ -0,0 +1,176 @@
+/*
+ * 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.celeborn.client.commit
+
+import java.util
+import java.util.concurrent.ConcurrentHashMap
+
+import scala.collection.JavaConverters._
+
+import org.apache.celeborn.client.CommitManager.CommittedPartitionInfo
+import org.apache.celeborn.client.LifecycleManager.{ShuffleAllocatedWorkers, ShuffleFailedWorkers, ShuffleFileGroups, ShuffleMapperAttempts}
+import org.apache.celeborn.client.ShuffleCommittedInfo
+import org.apache.celeborn.common.CelebornConf
+import org.apache.celeborn.common.internal.Logging
+import org.apache.celeborn.common.meta.{PartitionLocationInfo, WorkerInfo}
+import org.apache.celeborn.common.protocol.PartitionType
+
+/**
+ * This commit handler is for ReducePartition ShuffleType, which means that a Reduce Partition contains all data
+ * produced by all upstream MapTasks, and data in a Reduce Partition would only be consumed by one ReduceTask. If the
+ * ReduceTask has multiple inputs, each will be a ReducePartition
+ *
+ * @see [[org.apache.celeborn.common.protocol.PartitionType.REDUCE]]
+ */
+class ReducePartitionCommitHandler(
+    appId: String,
+    conf: CelebornConf,
+    allocatedWorkers: ShuffleAllocatedWorkers,
+    reducerFileGroupsMap: ShuffleFileGroups,
+    committedPartitionInfo: CommittedPartitionInfo,
+    shuffleMapperAttempts: ShuffleMapperAttempts)
+  extends CommitHandler(appId, conf, allocatedWorkers, reducerFileGroupsMap, committedPartitionInfo)
+  with Logging {
+
+  private val dataLostShuffleSet = ConcurrentHashMap.newKeySet[Int]()
+  private val stageEndShuffleSet = ConcurrentHashMap.newKeySet[Int]()
+  private val inProcessStageEndShuffleSet = ConcurrentHashMap.newKeySet[Int]()
+
+  override def getPartitionType(): PartitionType = {
+    PartitionType.REDUCE
+  }
+
+  override def isStageEnd(shuffleId: Int): Boolean = {
+    stageEndShuffleSet.contains(shuffleId)
+  }
+
+  override def isStageEndOrInProcess(shuffleId: Int): Boolean = {
+    if (inProcessStageEndShuffleSet.contains(shuffleId) ||

Review Comment:
   just 
   ```  
   override def isStageEndOrInProcess(shuffleId: Int): Boolean = {
       inProcessStageEndShuffleSet.contains(shuffleId) || stageEndShuffleSet.contains(shuffleId)
   }
   ```



##########
client/src/main/scala/org/apache/celeborn/client/commit/ReducePartitionCommitHandler.scala:
##########
@@ -0,0 +1,176 @@
+/*
+ * 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.celeborn.client.commit
+
+import java.util
+import java.util.concurrent.ConcurrentHashMap
+
+import scala.collection.JavaConverters._
+
+import org.apache.celeborn.client.CommitManager.CommittedPartitionInfo
+import org.apache.celeborn.client.LifecycleManager.{ShuffleAllocatedWorkers, ShuffleFailedWorkers, ShuffleFileGroups, ShuffleMapperAttempts}
+import org.apache.celeborn.client.ShuffleCommittedInfo
+import org.apache.celeborn.common.CelebornConf
+import org.apache.celeborn.common.internal.Logging
+import org.apache.celeborn.common.meta.{PartitionLocationInfo, WorkerInfo}
+import org.apache.celeborn.common.protocol.PartitionType
+
+/**
+ * This commit handler is for ReducePartition ShuffleType, which means that a Reduce Partition contains all data
+ * produced by all upstream MapTasks, and data in a Reduce Partition would only be consumed by one ReduceTask. If the
+ * ReduceTask has multiple inputs, each will be a ReducePartition
+ *
+ * @see [[org.apache.celeborn.common.protocol.PartitionType.REDUCE]]
+ */
+class ReducePartitionCommitHandler(
+    appId: String,
+    conf: CelebornConf,
+    allocatedWorkers: ShuffleAllocatedWorkers,
+    reducerFileGroupsMap: ShuffleFileGroups,
+    committedPartitionInfo: CommittedPartitionInfo,
+    shuffleMapperAttempts: ShuffleMapperAttempts)
+  extends CommitHandler(appId, conf, allocatedWorkers, reducerFileGroupsMap, committedPartitionInfo)
+  with Logging {
+
+  private val dataLostShuffleSet = ConcurrentHashMap.newKeySet[Int]()
+  private val stageEndShuffleSet = ConcurrentHashMap.newKeySet[Int]()
+  private val inProcessStageEndShuffleSet = ConcurrentHashMap.newKeySet[Int]()
+
+  override def getPartitionType(): PartitionType = {
+    PartitionType.REDUCE
+  }
+
+  override def isStageEnd(shuffleId: Int): Boolean = {
+    stageEndShuffleSet.contains(shuffleId)
+  }
+
+  override def isStageEndOrInProcess(shuffleId: Int): Boolean = {
+    if (inProcessStageEndShuffleSet.contains(shuffleId) ||
+      stageEndShuffleSet.contains(shuffleId)) {
+      true
+    } else {
+      false
+    }
+  }
+
+  override def isStageDataLost(shuffleId: Int): Boolean = {
+    dataLostShuffleSet.contains(shuffleId)
+  }
+
+  override def isPartitionInProcess(shuffleId: Int, partitionId: Int): Boolean = {
+    isStageEndOrInProcess(shuffleId)
+  }
+
+  override def setStageEnd(shuffleId: Int): Unit = {
+    stageEndShuffleSet.add(shuffleId)
+  }
+
+  def removeExpiredShuffle(shuffleId: Int): Unit = {
+    dataLostShuffleSet.remove(shuffleId)
+    stageEndShuffleSet.remove(shuffleId)
+    inProcessStageEndShuffleSet.remove(shuffleId)
+  }
+
+  override def finalCommit(
+      shuffleId: Int,
+      recordWorkerFailure: ShuffleFailedWorkers => Unit): Unit = {
+    if (stageEndShuffleSet.contains(shuffleId)) {
+      logInfo(s"[handleStageEnd] Shuffle $shuffleId already ended!")
+      return
+    }
+    inProcessStageEndShuffleSet.synchronized {
+      if (inProcessStageEndShuffleSet.contains(shuffleId)) {

Review Comment:
   It's dangerous to just return here because handleStageEnd will release resources and clear info after finalCommit return, but there are other inprocess finalCommit.



##########
client/src/main/scala/org/apache/celeborn/client/CommitManager.scala:
##########
@@ -19,22 +19,24 @@ package org.apache.celeborn.client
 
 import java.util
 import java.util.concurrent.{ConcurrentHashMap, ScheduledExecutorService, ScheduledFuture, TimeUnit}
-import java.util.concurrent.atomic.{AtomicInteger, AtomicLong, LongAdder}
+import java.util.concurrent.atomic.{AtomicInteger, LongAdder}
 
 import scala.collection.JavaConverters._
 import scala.concurrent.duration.DurationInt
 
 import org.roaringbitmap.RoaringBitmap
 
+import org.apache.celeborn.client.CommitManager.CommittedPartitionInfo
+import org.apache.celeborn.client.LifecycleManager.ShuffleFailedWorkers
+import org.apache.celeborn.client.commit.{CommitHandler, MapPartitionCommitHandler, ReducePartitionCommitHandler}
 import org.apache.celeborn.common.CelebornConf
 import org.apache.celeborn.common.internal.Logging
-import org.apache.celeborn.common.meta.{PartitionLocationInfo, WorkerInfo}
+import org.apache.celeborn.common.meta.WorkerInfo
 import org.apache.celeborn.common.protocol.{PartitionLocation, PartitionType, StorageInfo}
-import org.apache.celeborn.common.protocol.message.ControlMessages.{CommitFiles, CommitFilesResponse}
 import org.apache.celeborn.common.protocol.message.StatusCode
-import org.apache.celeborn.common.rpc.RpcEndpointRef
-import org.apache.celeborn.common.util.{ThreadUtils, Utils}
+// Can Remove this if celeborn don't support scala211 in future
 import org.apache.celeborn.common.util.FunctionConverter._

Review Comment:
   unused import



##########
client/src/main/scala/org/apache/celeborn/client/LifecycleManager.scala:
##########
@@ -41,8 +42,18 @@ import org.apache.celeborn.common.protocol.message.StatusCode
 import org.apache.celeborn.common.rpc._
 import org.apache.celeborn.common.rpc.netty.{LocalNettyRpcCallContext, RemoteNettyRpcCallContext}
 import org.apache.celeborn.common.util.{PbSerDeUtils, ThreadUtils, Utils}
+// Can Remove this if celeborn don't support scala211 in future
 import org.apache.celeborn.common.util.FunctionConverter._

Review Comment:
   unused import



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@celeborn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org