haiyangsun-db commented on code in PR #55683:
URL: https://github.com/apache/spark/pull/55683#discussion_r3376148114


##########
udf/worker/core/src/main/scala/org/apache/spark/udf/worker/core/grpc/DirectGrpcDispatcher.scala:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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.spark.udf.worker.core.grpc
+
+import java.io.{File, IOException}
+import java.nio.file.{FileVisitResult, Files, Path, SimpleFileVisitor}
+import java.nio.file.attribute.{BasicFileAttributes, PosixFilePermissions}
+
+import org.apache.spark.annotation.Experimental
+import org.apache.spark.udf.worker.{UDFProtoCommunicationPattern, 
UDFWorkerSpecification,
+  WorkerConnectionSpec}
+import org.apache.spark.udf.worker.core.{WorkerConnection, WorkerHandle, 
WorkerLogger,
+  WorkerSession}
+import org.apache.spark.udf.worker.core.direct.{DirectWorkerDispatcher, 
DirectWorkerException,
+  DirectWorkerTimeoutException}
+import 
org.apache.spark.udf.worker.core.direct.DirectWorkerDispatcher.SOCKET_POLL_INTERVAL_MS
+
+/**
+ * :: Experimental ::
+ * A concrete [[DirectWorkerDispatcher]] that spawns workers and talks to
+ * them over the UDF gRPC protocol on a Unix domain socket. Allocates a
+ * private 0700 socket directory at construction; each worker is given a
+ * UDS path inside it.
+ *
+ * gRPC over UDS is the only protocol/transport combination shipped today.

Review Comment:
   rephrased.



##########
udf/worker/core/src/main/scala/org/apache/spark/udf/worker/core/grpc/DirectGrpcDispatcher.scala:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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.spark.udf.worker.core.grpc
+
+import java.io.{File, IOException}
+import java.nio.file.{FileVisitResult, Files, Path, SimpleFileVisitor}
+import java.nio.file.attribute.{BasicFileAttributes, PosixFilePermissions}
+
+import org.apache.spark.annotation.Experimental
+import org.apache.spark.udf.worker.{UDFProtoCommunicationPattern, 
UDFWorkerSpecification,
+  WorkerConnectionSpec}
+import org.apache.spark.udf.worker.core.{WorkerConnection, WorkerHandle, 
WorkerLogger,
+  WorkerSession}
+import org.apache.spark.udf.worker.core.direct.{DirectWorkerDispatcher, 
DirectWorkerException,
+  DirectWorkerTimeoutException}
+import 
org.apache.spark.udf.worker.core.direct.DirectWorkerDispatcher.SOCKET_POLL_INTERVAL_MS
+
+/**
+ * :: Experimental ::
+ * A concrete [[DirectWorkerDispatcher]] that spawns workers and talks to
+ * them over the UDF gRPC protocol on a Unix domain socket. Allocates a
+ * private 0700 socket directory at construction; each worker is given a
+ * UDS path inside it.
+ *
+ * gRPC over UDS is the only protocol/transport combination shipped today.
+ * Lives in the `core.grpc` package alongside [[GrpcWorkerSession]] and
+ * [[GrpcWorkerChannel]] -- the two collaborators it composes.
+ */
+@Experimental
+class DirectGrpcDispatcher(
+    workerSpec: UDFWorkerSpecification,
+    logger: WorkerLogger = WorkerLogger.NoOp)
+  extends DirectWorkerDispatcher(workerSpec, logger) {
+
+  // Upper bound on the rename-on-collision retry loop in newEndpointAddress.
+  // 16 is well above any realistic concurrent-worker count and keeps the
+  // failure mode bounded if something pathological occupies the directory.
+  private val MAX_SOCKET_LEAF_RETRIES = 16
+
+  // Removed explicitly in closeTransport(). deleteOnExit is avoided because
+  // the JDK retains the path for the JVM lifetime, which leaks in
+  // long-lived drivers.
+  //
+  // Initialisation order: the parent constructor runs validateTransportSupport
+  // (against the spec passed as a parameter, not subclass state) BEFORE this
+  // val is evaluated. If validation throws, this field is never assigned and

Review Comment:
   fixed



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to