mridulm commented on code in PR #2346:
URL: 
https://github.com/apache/incubator-celeborn/pull/2346#discussion_r1508859046


##########
common/src/main/scala/org/apache/celeborn/common/util/PbSerDeUtils.scala:
##########
@@ -446,9 +448,24 @@ object PbSerDeUtils {
       builder.setCurrentAppDiskUsageMetricsSnapshot(
         toPbAppDiskUsageSnapshot(currentAppDiskUsageMetricsSnapshot))
     }
+    if (localCollectionUtils.isNotEmpty(applicationMetas)) {
+      builder.putAllApplicationMetas(applicationMetas.asScala.map {
+        case (appId, applicationMeta) => (appId, 
toPbApplicationMeta(applicationMeta))
+      }.asJava)
+    }

Review Comment:
   Can `applicationMetas` be concurrently modified ? If yes:
   ```suggestion
       val pbApplicationMetas = applicationMetas.asScala.map {
           case (appId, applicationMeta) => (appId, 
toPbApplicationMeta(applicationMeta))
         }.asJava
       if (localCollectionUtils.isNotEmpty(pbApplicationMetas)) {
         builder.putAllApplicationMetas(pbApplicationMetas)
       }
   ```



##########
common/src/main/scala/org/apache/celeborn/common/util/ApplicationMeta.scala:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.common.util;
+
+/**
+ * Application meta
+ */
+class ApplicationMeta(private val appId: String, private val secret: String) {
+  def getAppId: String = appId
+
+  def getSecret: String = secret
+
+  override def equals(other: Any): Boolean = other match {
+    case that: ApplicationMeta =>
+      appId == that.getAppId &&
+        secret == that.getSecret
+    case _ => false
+  }
+
+  override def hashCode(): Int = {
+    var result = appId.hashCode()
+    result = 31 * result + secret.hashCode()
+    result
+  }
+}

Review Comment:
   Can this not be simply a `case class` ?
   
   `case class ApplicationMeta(appId: String, secret: String)`



##########
master/src/main/scala/org/apache/celeborn/service/deploy/master/Master.scala:
##########
@@ -850,6 +852,27 @@ private[celeborn] class Master(
       logInfo(s"Offered extra $offerSlotsExtraSize slots for $shuffleKey")
     }
 
+    if (authEnabled) {
+      // Pass application registration information to the workers
+      val pbApplicationMeta = PbApplicationMeta.newBuilder()
+        .setAppId(requestSlots.applicationId)
+        .setSecret(secretRegistry.getSecretKey(requestSlots.applicationId))
+        .build()
+      val transportMessage =
+        new TransportMessage(MessageType.APPLICATION_META, 
pbApplicationMeta.toByteArray)
+
+      slots.keySet().asScala.foreach { worker =>
+        try {
+          logInfo(s"Sending app registration info to 
${worker.host}:${worker.internalPort}")
+          internalRpcEnvInUse.setupEndpointRef(
+            RpcAddress.apply(worker.host, worker.internalPort),
+            RpcNameConstants.WORKER_INTERNAL_EP).send(transportMessage)
+        } catch {
+          case t: Throwable =>
+            logError(s"Send application meta info to workers failed!", t)

Review Comment:
   Workers will reach out to master in case the appId is unknown, right ?
   Given this, make it `logInfo` ?



##########
master/src/main/scala/org/apache/celeborn/service/deploy/master/Master.scala:
##########
@@ -850,6 +852,27 @@ private[celeborn] class Master(
       logInfo(s"Offered extra $offerSlotsExtraSize slots for $shuffleKey")
     }
 
+    if (authEnabled) {
+      // Pass application registration information to the workers
+      val pbApplicationMeta = PbApplicationMeta.newBuilder()
+        .setAppId(requestSlots.applicationId)
+        .setSecret(secretRegistry.getSecretKey(requestSlots.applicationId))
+        .build()
+      val transportMessage =
+        new TransportMessage(MessageType.APPLICATION_META, 
pbApplicationMeta.toByteArray)
+
+      slots.keySet().asScala.foreach { worker =>
+        try {
+          logInfo(s"Sending app registration info to 
${worker.host}:${worker.internalPort}")
+          internalRpcEnvInUse.setupEndpointRef(
+            RpcAddress.apply(worker.host, worker.internalPort),
+            RpcNameConstants.WORKER_INTERNAL_EP).send(transportMessage)
+        } catch {
+          case t: Throwable =>

Review Comment:
   Why `Throwable` ?



##########
master/src/main/java/org/apache/celeborn/service/deploy/master/clustermeta/ha/HAMasterMetaManager.java:
##########
@@ -375,4 +376,23 @@ public void handleUpdatePartitionSize() {
       throw e;
     }
   }
+
+  @Override
+  public void handleApplicationMeta(ApplicationMeta applicationMeta) {
+    try {
+      ratisServer.submitRequest(
+          ResourceRequest.newBuilder()
+              .setCmdType(Type.ApplicationMeta)
+              .setRequestId(MasterClient.genRequestId())
+              .setApplicationMetaRequest(
+                  ResourceProtos.ApplicationMetaRequest.newBuilder()
+                      .setAppId(applicationMeta.getAppId())
+                      .setSecret(applicationMeta.getSecret())
+                      .build())
+              .build());
+    } catch (CelebornRuntimeException e) {
+      LOG.error("Handle app meta failed!", e);

Review Comment:
   Do we want to include the app id to help with debugging ?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to