luozenglin commented on code in PR #24229:
URL: https://github.com/apache/doris/pull/24229#discussion_r1328619641
##########
be/src/olap/storage_engine.cpp:
##########
@@ -357,6 +358,15 @@ Status
StorageEngine::get_all_data_dir_info(std::vector<DataDirInfo>* data_dir_i
return res;
}
+Status StorageEngine::get_log_dir_info(LogDirInfo* log_dir_infos) {
+ Status res = Status::OK();
+ _log_dir->health_check();
+ _log_dir->update_capacity();
+ LogDirInfo dir_info = _log_dir->get_dir_info();
Review Comment:
Why not just pass the log_dir_infos pointer as an argument to get_dir_info()?
##########
be/src/olap/log_dir.cpp:
##########
@@ -0,0 +1,66 @@
+// 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.
+
+#include "olap/log_dir.h"
+
+#include <string>
+
+#include "io/fs/file_reader_writer_fwd.h"
+#include "io/fs/file_writer.h"
+#include "io/fs/local_file_system.h"
+#include "io/fs/path.h"
+#include "olap/utils.h" // for check_dir_existed
+
+namespace doris {
+using namespace ErrorCode;
+
+static const char* const kTestFilePath = ".testfile";
+
+LogDir::LogDir(const std::string& path)
+ : _path(path),
+ _fs(io::LocalFileSystem::create(path)),
+ _available_bytes(0),
+ _capacity_bytes(0),
+ _is_used(true) {}
+
+LogDir::~LogDir() {}
+
+Status LogDir::update_capacity() {
+ RETURN_IF_ERROR(io::global_local_filesystem()->get_space_info(_path,
&_capacity_bytes,
+
&_available_bytes));
+ LOG(INFO) << "path: " << _path << " total capacity: " << _capacity_bytes
+ << ", available capacity: " << _available_bytes;
+
+ return Status::OK();
+}
+
+void LogDir::health_check() {
+ // check disk
+ Status res = _read_and_write_test_file();
+ if (!res) {
+ LOG(WARNING) << "log read/write test file occur IO Error. path=" <<
_path
+ << ", err: " << res;
+ _is_used = !res.is<IO_ERROR>();
+ }
Review Comment:
Do we need to set `_is_used` to true here when the test failed before, but
succeeded at some point?
##########
be/src/agent/task_worker_pool.cpp:
##########
@@ -678,6 +679,19 @@ void
TaskWorkerPool::_report_disk_state_worker_thread_callback() {
disk.__set_used(root_path_info.is_used);
request.disks[root_path_info.path] = disk;
}
+
+ LogDirInfo log_dir_info;
+ StorageEngine::instance()->get_log_dir_info(&log_dir_info);
+ LOG(INFO) << "path: " << log_dir_info.path << " total capacity: " <<
log_dir_info.capacity
Review Comment:
Using the info level here will result in frequent log printing, I recommend
using VLOG to print this line. The same is true below.
##########
gensrc/thrift/MasterService.thrift:
##########
@@ -76,7 +76,7 @@ struct TDisk {
1: required string root_path
2: required Types.TSize disk_total_capacity
// local used capacity
- 3: required Types.TSize data_used_capacity
+ 3: optional Types.TSize data_used_capacity
Review Comment:
Consider that when upgrading, be applies the new code, but fe is still
REQUIRED, which will cause an exception.
--
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]