Skip to content

Commit

Permalink
fix the case of dir which does not end with '/'
Browse files Browse the repository at this point in the history
  • Loading branch information
naive-zhang committed Dec 20, 2024
1 parent 2efb0df commit 15ea677
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

package org.apache.kyuubi.spark.connector.yarn

import java.io.{BufferedReader, InputStreamReader}

import scala.collection.mutable.ArrayBuffer
import scala.util.matching.Regex

import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.{FileSystem, Path}
import org.apache.hadoop.io.IOUtils
Expand All @@ -25,10 +30,6 @@ import org.apache.spark.sql.catalyst.expressions.GenericInternalRow
import org.apache.spark.sql.connector.read.PartitionReader
import org.apache.spark.unsafe.types.UTF8String

import java.io.{BufferedReader, InputStreamReader}
import scala.collection.mutable.ArrayBuffer
import scala.util.matching.Regex

class YarnLogPartitionReader(yarnLogPartition: YarnLogPartition)
extends PartitionReader[InternalRow] {

Expand Down Expand Up @@ -74,7 +75,9 @@ class YarnLogPartitionReader(yarnLogPartition: YarnLogPartition)
private def fetchLog(): Seq[LogEntry] = {
val logDirInReg = yarnLogPartition.remoteAppLogDir match {
// in case of /tmp/logs/, /tmp/logs//
case dir if dir.endsWith("/") => dir.replaceAll("/+", "/").replace("/", "\\/")
case dir if dir.endsWith("/") =>
val tmpDir = dir.replaceAll("/+", "/")
tmpDir.substring(0, tmpDir.length - 1).replace("/", "\\/")
// in case of /tmp/logs
case dir => dir.replace("/", "\\/")
}
Expand All @@ -93,7 +96,6 @@ class YarnLogPartitionReader(yarnLogPartition: YarnLogPartition)
line = reader.readLine();
line != null
}) {
// println(s"Line $lineNumber: $line")
lineNumber += 1
logEntries += LogEntry(
applicationId,
Expand Down

0 comments on commit 15ea677

Please sign in to comment.