From 47cc31a2560d3337cc786a8e28d767018a9fe91c Mon Sep 17 00:00:00 2001 From: Jia Ke Date: Mon, 15 Apr 2024 17:05:03 +0800 Subject: [PATCH] Add failed log info --- .../hive/storage_adapters/hdfs/HdfsFileSystem.cpp | 3 +++ .../hive/storage_adapters/hdfs/HdfsReadFile.cpp | 5 +++++ .../hive/storage_adapters/hdfs/HdfsReadFile.h | 4 ++++ .../hive/storage_adapters/hdfs/HdfsWriteFile.cpp | 11 +++++++++++ 4 files changed, 23 insertions(+) diff --git a/velox/connectors/hive/storage_adapters/hdfs/HdfsFileSystem.cpp b/velox/connectors/hive/storage_adapters/hdfs/HdfsFileSystem.cpp index d57affff2f8d8..49099d4e3cda0 100644 --- a/velox/connectors/hive/storage_adapters/hdfs/HdfsFileSystem.cpp +++ b/velox/connectors/hive/storage_adapters/hdfs/HdfsFileSystem.cpp @@ -42,6 +42,9 @@ class HdfsFileSystem::Impl { "Unable to connect to HDFS: {}, got error: {}.", endpoint.identity(), hdfsGetLastError()) +#elif VELOX_ENABLE_HDFS + VELOX_CHECK_NOT_NULL( + hdfsClient_, "Unable to connect to HDFS: {}.", endpoint.identity()) #endif } diff --git a/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.cpp b/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.cpp index 67b1e574369e1..6a4e6889397f5 100644 --- a/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.cpp +++ b/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.cpp @@ -38,6 +38,11 @@ HdfsReadFile::HdfsReadFile(hdfsFS hdfs, const std::string_view path) VELOX_FILE_NOT_FOUND_ERROR(errMsg); } VELOX_FAIL(errMsg); +#elif VELOX_ENABLE_HDFS + + auto errMsg = + fmt::format("Unable to get file path info for file: {}", filePath_); + VELOX_FAIL(errMsg); #endif } } diff --git a/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.h b/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.h index ee867f47f4baa..00124e2b1e0e9 100644 --- a/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.h +++ b/velox/connectors/hive/storage_adapters/hdfs/HdfsReadFile.h @@ -43,6 +43,8 @@ struct HdfsFile { "Unable to open file {}. got error: {}", path, hdfsGetLastError()); +#elif VELOX_ENABLE_HDFS + VELOX_CHECK_NOT_NULL(handle_, "Unable to open file {}", path); #endif } @@ -54,6 +56,8 @@ struct HdfsFile { 0, "Cannot seek through HDFS file, error is : {}", std::string(hdfsGetLastError())); +#elif VELOX_ENABLE_HDFS + VELOX_CHECK_EQ(result, 0, "Cannot seek through HDFS file"); #endif } diff --git a/velox/connectors/hive/storage_adapters/hdfs/HdfsWriteFile.cpp b/velox/connectors/hive/storage_adapters/hdfs/HdfsWriteFile.cpp index 8b62e2f217f04..f67c1aa6d8fa5 100644 --- a/velox/connectors/hive/storage_adapters/hdfs/HdfsWriteFile.cpp +++ b/velox/connectors/hive/storage_adapters/hdfs/HdfsWriteFile.cpp @@ -48,6 +48,8 @@ HdfsWriteFile::HdfsWriteFile( "Failed to open hdfs file: {}, with error: {}", filePath_, std::string(hdfsGetLastError())); +#elif VELOX_ENABLE_HDFS + VELOX_CHECK_NOT_NULL(hdfsFile_, "Failed to open hdfs file: {}", filePath_); #endif } @@ -65,6 +67,8 @@ void HdfsWriteFile::close() { 0, "Failed to close hdfs file: {}", std::string(hdfsGetLastError())); +#elif VELOX_ENABLE_HDFS + VELOX_CHECK_EQ(success, 0, "Failed to close hdfs file."); #endif hdfsFile_ = nullptr; } @@ -78,6 +82,8 @@ void HdfsWriteFile::flush() { #ifdef VELOX_ENABLE_HDFS3 VELOX_CHECK_EQ( success, 0, "Hdfs flush error: {}", std::string(hdfsGetLastError())); +#elif VELOX_ENABLE_HDFS + VELOX_CHECK_EQ(success, 0, "Hdfs flush error."); #endif } @@ -97,6 +103,11 @@ void HdfsWriteFile::append(std::string_view data) { data.size(), "Write failure in HDFSWriteFile::append {}", std::string(hdfsGetLastError())); +#elif VELOX_ENABLE_HDFS + VELOX_CHECK_EQ( + totalWrittenBytes, + data.size(), + "Write failure in HDFSWriteFile::append."); #endif }