Skip to content

Commit

Permalink
return value
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteYue committed Apr 19, 2024
1 parent 0012eb9 commit 81f3365
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 6 additions & 6 deletions be/src/cloud/injection_point_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ void register_suites() {
should_ret = true;
});
sp->set_call_back("HdfsFileWriter::hdfsFlush", [](auto&& args) {
auto& [ret_value, should_ret] = *try_any_cast<std::pair<int, bool>*>(args.back());
ret_value = -1;
auto& [ret_value, should_ret] = *try_any_cast<std::pair<Status, bool>*>(args.back());
ret_value = Status::InternalError("failed to flush hdfs file");
should_ret = true;
});
sp->set_call_back("HdfsFileWriter::hdfsCloseFile", [](auto&& args) {
auto& [ret_value, should_ret] = *try_any_cast<std::pair<int, bool>*>(args.back());
ret_value = -1;
auto& [ret_value, should_ret] = *try_any_cast<std::pair<Status, bool>*>(args.back());
ret_value = Status::InternalError("failed to flush hdfs file");
should_ret = true;
});
sp->set_call_back("HdfsFileWriter::hdfeSync", [](auto&& args) {
auto& [ret_value, should_ret] = *try_any_cast<std::pair<int, bool>*>(args.back());
ret_value = -1;
auto& [ret_value, should_ret] = *try_any_cast<std::pair<Status, bool>*>(args.back());
ret_value = Status::InternalError("failed to flush hdfs file");
should_ret = true;
});
sp->set_call_back("HdfsFileReader:read_error", [](auto&& args) {
Expand Down
2 changes: 1 addition & 1 deletion be/src/io/fs/hdfs_file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Status HdfsFileReader::read_at_impl(size_t offset, Slice result, size_t* bytes_r
to + has_read, bytes_req - has_read);
{
[[maybe_unused]] Status error_ret;
TEST_INJECTION_POINT_RETURN_WITH_VALUE("HdfsFileReader:read_error", &error_ret);
TEST_INJECTION_POINT_RETURN_WITH_VALUE("HdfsFileReader:read_error", error_ret);
}
if (loop_read < 0) {
// invoker maybe just skip Status.NotFound and continue
Expand Down
11 changes: 7 additions & 4 deletions be/src/io/fs/hdfs_file_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ Status HdfsFileWriter::close() {
ret = hdfsHSync(_hdfs_handler->hdfs_fs, _hdfs_file);
#endif
}
TEST_INJECTION_POINT_RETURN_WITH_VALUE("HdfsFileWriter::hdfeSync", &ret);
TEST_INJECTION_POINT_RETURN_WITH_VALUE("HdfsFileWriter::hdfeSync",
Status::InternalError("failed to sync hdfs file"));

if (ret != 0) {
return Status::InternalError("failed to sync hdfs file. fs_name={} path={} : {}",
Expand All @@ -112,7 +113,8 @@ Status HdfsFileWriter::close() {
ret = hdfsCloseFile(_hdfs_handler->hdfs_fs, _hdfs_file);
}
_hdfs_file = nullptr;
TEST_INJECTION_POINT_RETURN_WITH_VALUE("HdfsFileWriter::hdfsCloseFile", &ret);
TEST_INJECTION_POINT_RETURN_WITH_VALUE("HdfsFileWriter::hdfsCloseFile",
Status::InternalError("failed to close hdfs file"));
if (ret != 0) {
std::string err_msg = hdfs_error();
return Status::InternalError(
Expand Down Expand Up @@ -193,7 +195,7 @@ Status HdfsFileWriter::append_hdfs_file(std::string_view content) {
"write hdfs failed. fs_name: {}, path: {}, error: size exceeds", _fs_name,
_path.native());
TEST_INJECTION_POINT_RETURN_WITH_VALUE("HdfsFileWriter::append_hdfs_file_error",
&error_ret);
error_ret);
}
}
if (written_bytes < 0) {
Expand Down Expand Up @@ -265,7 +267,8 @@ Status HdfsFileWriter::finalize() {

// Flush buffered data to HDFS without waiting for HDFS response
int ret = hdfsFlush(_hdfs_handler->hdfs_fs, _hdfs_file);
TEST_INJECTION_POINT_CALLBACK("hdfsFlush", &ret)
TEST_INJECTION_POINT_RETURN_WITH_VALUE("HdfsFileWriter::hdfsFlush",
Status::InternalError("failed to flush hdfs file"));
if (ret != 0) {
return Status::InternalError("failed to flush hdfs file. fs_name={} path={} : {}", _fs_name,
_path.native(), hdfs_error());
Expand Down

0 comments on commit 81f3365

Please sign in to comment.