pan3793 commented on code in PR #7455:
URL: https://github.com/apache/kyuubi/pull/7455#discussion_r3293462101


##########
extensions/spark/kyuubi-spark-connector-yarn/src/main/scala/org/apache/kyuubi/spark/connector/yarn/YarnLogBatchScan.scala:
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.kyuubi.spark.connector.yarn
+
+import org.apache.hadoop.conf.Configuration
+import org.apache.hadoop.fs.{FileStatus, Path}
+import org.apache.hadoop.yarn.conf.YarnConfiguration
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.connector.read._
+import org.apache.spark.sql.sources.{EqualTo, Filter}
+import org.apache.spark.sql.types.StructType
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+import org.apache.spark.util.SerializableConfiguration
+
+case class YarnLogBatchScan(
+    options: CaseInsensitiveStringMap,
+    schema: StructType,
+    pushedFilters: Array[Filter])
+  extends Scan with Batch with Logging {
+
+  override def readSchema(): StructType = schema
+
+  protected val hadoopConf: Configuration =
+    SparkSession.active.sessionState.newHadoopConf()
+
+  private val _formats = 
hadoopConf.get(YarnConfiguration.LOG_AGGREGATION_FILE_FORMATS, "TFile")
+  if (!_formats.equalsIgnoreCase("TFile")) {
+    throw new UnsupportedOperationException(
+      "Currently, only TFile format is supported. While " +
+        s"${YarnConfiguration.LOG_AGGREGATION_FILE_FORMATS} was set to 
${_formats}.")
+  }
+
+  private val remoteAppLogDir = hadoopConf.get(
+    YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
+    YarnConfiguration.DEFAULT_NM_REMOTE_APP_LOG_DIR)
+
+  private val remoteAppLogDirSuffix = hadoopConf.get(
+    YarnConfiguration.NM_REMOTE_APP_LOG_DIR_SUFFIX,
+    YarnConfiguration.DEFAULT_NM_REMOTE_APP_LOG_DIR_SUFFIX)
+
+  // given a path in hdfs, then get all files under it, supports *
+  private def listFiles(pathStr: String): Array[FileStatus] = {
+    val path = new Path(pathStr)
+    val fs = path.getFileSystem(hadoopConf)
+
+    val start = System.currentTimeMillis()
+    val files = fs.globStatus(path)

Review Comment:
   I feel this is not much necessary as we don't require strict consistency for 
log analysis cases, instead, log files may expire after listing, then executors 
may hit `FileNotFoundException`, I make it to respect 
`spark.sql.files.ignoreMissingFiles`. I leave a TODO here to mention the 
`fs.msync()` suggestion for now, we can add it if we see real problems. WDYT? 
@aajisaka 



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