support test object storage in unittest
This commit is contained in:
@ -172,16 +172,16 @@ int ObLogExternalStorageHandler::pread(const common::ObString &uri,
|
|||||||
time_guard.click("after hold by lock");
|
time_guard.click("after hold by lock");
|
||||||
if (IS_NOT_INIT) {
|
if (IS_NOT_INIT) {
|
||||||
ret = OB_NOT_INIT;
|
ret = OB_NOT_INIT;
|
||||||
CLOG_LOG(WARN, "ObLogExternalStorageHandler not init", K(uri), K(storage_info), K(offset), KP(buf), K(read_buf_size));
|
CLOG_LOG(WARN, "ObLogExternalStorageHandler not init", K(uri), K(offset), KP(buf), K(read_buf_size));
|
||||||
} else if (!is_running_) {
|
} else if (!is_running_) {
|
||||||
ret = OB_NOT_RUNNING;
|
ret = OB_NOT_RUNNING;
|
||||||
CLOG_LOG(WARN, "ObLogExternalStorageHandler not running", K(uri), K(storage_info), K(offset), KP(buf), K(read_buf_size));
|
CLOG_LOG(WARN, "ObLogExternalStorageHandler not running", K(uri), K(offset), KP(buf), K(read_buf_size));
|
||||||
// when uri is NFS, storage_info is empty.
|
// when uri is NFS, storage_info is empty.
|
||||||
} else if (uri.empty() || 0 > offset || NULL == buf || 0 >= read_buf_size) {
|
} else if (uri.empty() || 0 > offset || NULL == buf || 0 >= read_buf_size) {
|
||||||
ret = OB_INVALID_ARGUMENT;
|
ret = OB_INVALID_ARGUMENT;
|
||||||
CLOG_LOG(WARN, "ObLogExternalStorageHandler invalid argument", K(uri), K(storage_info), K(offset), KP(buf), K(read_buf_size));
|
CLOG_LOG(WARN, "ObLogExternalStorageHandler invalid argument", K(uri), K(offset), KP(buf), K(read_buf_size));
|
||||||
} else if (OB_FAIL(handle_adapter_->get_file_size(uri, storage_info, file_size))) {
|
} else if (OB_FAIL(handle_adapter_->get_file_size(uri, storage_info, file_size))) {
|
||||||
CLOG_LOG(WARN, "get_file_size failed", K(uri), K(storage_info), K(offset), KP(buf), K(read_buf_size));
|
CLOG_LOG(WARN, "get_file_size failed", K(uri), K(offset), KP(buf), K(read_buf_size));
|
||||||
} else if (offset > file_size) {
|
} else if (offset > file_size) {
|
||||||
ret = OB_FILE_LENGTH_INVALID;
|
ret = OB_FILE_LENGTH_INVALID;
|
||||||
CLOG_LOG(WARN, "read position lager than file size, invalid argument", K(file_size), K(offset), K(uri));
|
CLOG_LOG(WARN, "read position lager than file size, invalid argument", K(file_size), K(offset), K(uri));
|
||||||
@ -193,21 +193,21 @@ int ObLogExternalStorageHandler::pread(const common::ObString &uri,
|
|||||||
} else if (FALSE_IT(real_read_buf_size = std::min(file_size - offset, read_buf_size))) {
|
} else if (FALSE_IT(real_read_buf_size = std::min(file_size - offset, read_buf_size))) {
|
||||||
} else if (OB_FAIL(construct_async_tasks_and_push_them_into_thread_pool_(
|
} else if (OB_FAIL(construct_async_tasks_and_push_them_into_thread_pool_(
|
||||||
uri, storage_info, offset, buf, real_read_buf_size, real_read_size, async_task_ctx))) {
|
uri, storage_info, offset, buf, real_read_buf_size, real_read_size, async_task_ctx))) {
|
||||||
CLOG_LOG(WARN, "construct_async_task_and_push_them_into_thread_pool_ failed", K(uri), K(storage_info),
|
CLOG_LOG(WARN, "construct_async_task_and_push_them_into_thread_pool_ failed", K(uri),
|
||||||
K(offset), KP(buf), K(read_buf_size));
|
K(offset), KP(buf), K(read_buf_size));
|
||||||
} else if (FALSE_IT(time_guard.click("after construct async tasks"))) {
|
} else if (FALSE_IT(time_guard.click("after construct async tasks"))) {
|
||||||
} else if (OB_FAIL(wait_async_tasks_finished_(async_task_ctx))) {
|
} else if (OB_FAIL(wait_async_tasks_finished_(async_task_ctx))) {
|
||||||
CLOG_LOG(WARN, "wait_async_tasks_finished_ failed", K(uri), K(storage_info),
|
CLOG_LOG(WARN, "wait_async_tasks_finished_ failed", K(uri),
|
||||||
K(offset), KP(buf), K(read_buf_size), KPC(async_task_ctx));
|
K(offset), KP(buf), K(read_buf_size), KPC(async_task_ctx));
|
||||||
} else if (FALSE_IT(time_guard.click("after wait async tasks"))) {
|
} else if (FALSE_IT(time_guard.click("after wait async tasks"))) {
|
||||||
} else {
|
} else {
|
||||||
// if there is a failure of any async task, return the error of it, otherwise, return OB_SUCCESS.
|
// if there is a failure of any async task, return the error of it, otherwise, return OB_SUCCESS.
|
||||||
ret = async_task_ctx->get_ret_code();
|
ret = async_task_ctx->get_ret_code();
|
||||||
if (OB_FAIL(ret)) {
|
if (OB_FAIL(ret)) {
|
||||||
CLOG_LOG(WARN, "pread finished", K(time_guard), K(uri), K(storage_info), K(offset), K(read_buf_size),
|
CLOG_LOG(WARN, "pread finished", K(time_guard), K(uri), K(offset), K(read_buf_size),
|
||||||
K(real_read_size));
|
K(real_read_size));
|
||||||
} else {
|
} else {
|
||||||
CLOG_LOG(TRACE, "pread finished", K(time_guard), K(uri), K(storage_info), K(offset), K(read_buf_size),
|
CLOG_LOG(TRACE, "pread finished", K(time_guard), K(uri), K(offset), K(read_buf_size),
|
||||||
K(real_read_size));
|
K(real_read_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -211,11 +211,11 @@ int get_and_init_io_device(const ObString &uri,
|
|||||||
opt.key_ = "storage_info";
|
opt.key_ = "storage_info";
|
||||||
opt.value_.value_str = storage_info.ptr();
|
opt.value_.value_str = storage_info.ptr();
|
||||||
if (OB_FAIL(ObDeviceManager::get_instance().get_device(storage_info, uri, io_device))) {
|
if (OB_FAIL(ObDeviceManager::get_instance().get_device(storage_info, uri, io_device))) {
|
||||||
CLOG_LOG(WARN, "get_device from ObDeviceManager failed", K(storage_info), K(uri), KP(io_device));
|
CLOG_LOG(WARN, "get_device from ObDeviceManager failed", K(uri), KP(io_device));
|
||||||
} else if (OB_FAIL(io_device->start(opts))) {
|
} else if (OB_FAIL(io_device->start(opts))) {
|
||||||
CLOG_LOG(WARN, "start io device failed", K(storage_info), K(uri), KP(io_device));
|
CLOG_LOG(WARN, "start io device failed", K(uri), KP(io_device));
|
||||||
} else {
|
} else {
|
||||||
CLOG_LOG(TRACE, "get_io_device success", K(uri), K(storage_info), KP(io_device));
|
CLOG_LOG(TRACE, "get_io_device success", K(uri), KP(io_device));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -299,11 +299,11 @@ int ObLogExternalStorageIOTaskHandleAdapter::exist(const ObString &uri,
|
|||||||
exist = false;
|
exist = false;
|
||||||
ObIODevice *io_device = NULL;
|
ObIODevice *io_device = NULL;
|
||||||
if (OB_FAIL(get_and_init_io_device(uri, storage_info, io_device))) {
|
if (OB_FAIL(get_and_init_io_device(uri, storage_info, io_device))) {
|
||||||
CLOG_LOG(WARN, "get_io_device failed", K(uri), K(storage_info), KP(io_device));
|
CLOG_LOG(WARN, "get_io_device failed", K(uri), KP(io_device));
|
||||||
} else if (OB_FAIL(io_device->exist(uri.ptr(), exist))) {
|
} else if (OB_FAIL(io_device->exist(uri.ptr(), exist))) {
|
||||||
CLOG_LOG(WARN, "exist failed", K(uri), K(storage_info), KP(io_device), K(exist));
|
CLOG_LOG(WARN, "exist failed", K(uri), KP(io_device), K(exist));
|
||||||
} else {
|
} else {
|
||||||
CLOG_LOG(TRACE, "exist success", K(uri), K(storage_info), KP(io_device), K(exist));
|
CLOG_LOG(TRACE, "exist success", K(uri), KP(io_device), K(exist));
|
||||||
}
|
}
|
||||||
release_io_device(io_device);
|
release_io_device(io_device);
|
||||||
return ret;
|
return ret;
|
||||||
@ -318,12 +318,12 @@ int ObLogExternalStorageIOTaskHandleAdapter::get_file_size(const ObString &uri,
|
|||||||
ObIODFileStat file_stat;
|
ObIODFileStat file_stat;
|
||||||
ObIODevice *io_device = NULL;
|
ObIODevice *io_device = NULL;
|
||||||
if (OB_FAIL(get_and_init_io_device(uri, storage_info, io_device))) {
|
if (OB_FAIL(get_and_init_io_device(uri, storage_info, io_device))) {
|
||||||
CLOG_LOG(WARN, "get_io_device failed", K(uri), K(storage_info), KP(io_device));
|
CLOG_LOG(WARN, "get_io_device failed", K(uri), KP(io_device));
|
||||||
} else if (OB_FAIL(io_device->stat(uri.ptr(), file_stat))) {
|
} else if (OB_FAIL(io_device->stat(uri.ptr(), file_stat))) {
|
||||||
CLOG_LOG(WARN, "stat io deveice failed", K(uri));
|
CLOG_LOG(WARN, "stat io deveice failed", K(uri));
|
||||||
} else {
|
} else {
|
||||||
file_size = file_stat.size_;
|
file_size = file_stat.size_;
|
||||||
CLOG_LOG(TRACE, "get_file_size success", K(uri), K(storage_info), KP(io_device), K(file_size));
|
CLOG_LOG(TRACE, "get_file_size success", K(uri), KP(io_device), K(file_size));
|
||||||
}
|
}
|
||||||
release_io_device(io_device);
|
release_io_device(io_device);
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user