Skip to content

Commit

Permalink
init glog
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Sep 10, 2024
1 parent d0e9260 commit 7c89616
Show file tree
Hide file tree
Showing 228 changed files with 1,534 additions and 1,374 deletions.
3 changes: 3 additions & 0 deletions cmake_modules/BaseFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ function(dsn_setup_thirdparty_libs)
set(Boost_NO_SYSTEM_PATHS ON)
set(Boost_NO_BOOST_CMAKE ON)

add_definitions(-DGLOG_USE_GLOG_EXPORT)
add_definitions(-DS2_USE_GLOG=0)

set(CMAKE_PREFIX_PATH ${THIRDPARTY_INSTALL_DIR};${CMAKE_PREFIX_PATH})
message(STATUS "CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
find_package(Boost COMPONENTS system filesystem REQUIRED)
Expand Down
10 changes: 5 additions & 5 deletions src/aio/disk_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,22 @@ disk_file::disk_file(std::unique_ptr<rocksdb::RandomRWFile> wf) : _write_file(st

aio_task *disk_file::read(aio_task *tsk)
{
CHECK(_read_file, "");
CHECK(_read_file);
tsk->add_ref(); // release on completion, see `on_read_completed`.
return _read_queue.add_work(tsk, nullptr);
}

aio_task *disk_file::write(aio_task *tsk, void *ctx)
{
CHECK(_write_file, "");
CHECK(_write_file);
tsk->add_ref(); // release on completion
return _write_queue.add_work(tsk, ctx);
}

aio_task *disk_file::on_read_completed(aio_task *wk, error_code err, size_t size)
{
CHECK(_read_file, "");
CHECK(wk->next == nullptr, "");
CHECK(_read_file);
CHECK_EQ(wk->next, nullptr);
auto ret = _read_queue.on_work_completed(wk, nullptr);
wk->enqueue(err, size);
wk->release_ref(); // added in above read
Expand All @@ -132,7 +132,7 @@ aio_task *disk_file::on_read_completed(aio_task *wk, error_code err, size_t size

aio_task *disk_file::on_write_completed(aio_task *wk, void *ctx, error_code err, size_t size)
{
CHECK(_write_file, "");
CHECK(_write_file);
auto ret = _write_queue.on_work_completed(wk, ctx);

while (wk) {
Expand Down
2 changes: 1 addition & 1 deletion src/aio/file_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace file {
return new disk_file(std::move(wf));
}
default:
CHECK(false, "");
CHECK(false);
}
return nullptr;
}
Expand Down
4 changes: 3 additions & 1 deletion src/aio/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ set(MY_PROJ_LIBS
rocksdb
lz4
zstd
snappy)
snappy
glog
gflags)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BINPLACES
config.ini
Expand Down
8 changes: 4 additions & 4 deletions src/base/meta_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ ::dsn::error_code meta_store::get_value_from_meta_cf(rocksdb::DB *db,
if (ec != ::dsn::ERR_OK) {
return ec;
}
CHECK(dsn::buf2uint64(data, *value),
"rocksdb {} get \"{}\" from meta column family failed to parse into uint64",
db->GetName(),
data);
PGSCHECK(dsn::buf2uint64(data, *value),
"rocksdb {} get \"{}\" from meta column family failed to parse into uint64",
db->GetName(),
data);
return ::dsn::ERR_OK;
}

Expand Down
4 changes: 2 additions & 2 deletions src/base/pegasus_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ c_escape_string(const char *src, size_t src_len, char *dest, size_t dest_len, bo
inline unsigned int hex_digit_to_int(char c)
{
/* Assume ASCII. */
CHECK('0' == 0x30 && 'A' == 0x41 && 'a' == 0x61, "");
CHECK(isxdigit(c), "");
PGSCHECK('0' == 0x30 && 'A' == 0x41 && 'a' == 0x61, "");
CHECK(isxdigit(c));
unsigned int x = static_cast<unsigned char>(c);
if (x > '9') {
x += 9;
Expand Down
4 changes: 3 additions & 1 deletion src/base/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ set(MY_PROJ_LIBS
lz4
zstd
snappy
gtest)
gtest
glog
gflags)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)

Expand Down
3 changes: 2 additions & 1 deletion src/base/value_schema_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ value_schema *value_schema_manager::get_value_schema(uint32_t meta_cf_data_versi
return schema;
} else {
auto schema = get_value_schema(meta_cf_data_version);
CHECK_NOTNULL(schema, "data version({}) in meta cf is not supported", meta_cf_data_version);
PGSCHECK_NOTNULL(
schema, "data version({}) in meta cf is not supported", meta_cf_data_version);
return schema;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/base/value_schema_v0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ std::unique_ptr<value_field> value_schema_v0::extract_field(std::string_view val
field = extract_timestamp(value);
break;
default:
CHECK(false, "Unsupported field type: {}", type);
PGSCHECK(false, "Unsupported field type: {}", type);
}
return field;
}
Expand All @@ -60,7 +60,7 @@ void value_schema_v0::update_field(std::string &value, std::unique_ptr<value_fie
update_expire_ts(value, std::move(field));
break;
default:
CHECK(false, "Unsupported update field type: {}", type);
PGSCHECK(false, "Unsupported update field type: {}", type);
}
}

Expand All @@ -71,7 +71,7 @@ rocksdb::SliceParts value_schema_v0::generate_value(const value_params &params)
auto data_field =
static_cast<user_data_field *>(params.fields[value_field_type::USER_DATA].get());
if (dsn_unlikely(expire_ts_field == nullptr || data_field == nullptr)) {
CHECK(false, "USER_DATA or EXPIRE_TIMESTAMP is not provided");
PGSCHECK(false, "USER_DATA or EXPIRE_TIMESTAMP is not provided");
return {nullptr, 0};
}

Expand Down
6 changes: 3 additions & 3 deletions src/base/value_schema_v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ std::unique_ptr<value_field> value_schema_v1::extract_field(std::string_view val
field = extract_time_tag(value);
break;
default:
CHECK(false, "Unsupported field type: {}", type);
PGSCHECK(false, "Unsupported field type: {}", type);
}
return field;
}
Expand All @@ -63,7 +63,7 @@ void value_schema_v1::update_field(std::string &value, std::unique_ptr<value_fie
update_expire_ts(value, std::move(field));
break;
default:
CHECK(false, "Unsupported update field type: {}", type);
PGSCHECK(false, "Unsupported update field type: {}", type);
}
}

Expand All @@ -77,7 +77,7 @@ rocksdb::SliceParts value_schema_v1::generate_value(const value_params &params)
static_cast<user_data_field *>(params.fields[value_field_type::USER_DATA].get());
if (dsn_unlikely(expire_ts_field == nullptr || data_field == nullptr ||
timetag_field == nullptr)) {
CHECK(false, "USER_DATA or EXPIRE_TIMESTAMP or TIME_TAG is not provided");
PGSCHECK(false, "USER_DATA or EXPIRE_TIMESTAMP or TIME_TAG is not provided");
return {nullptr, 0};
}

Expand Down
6 changes: 3 additions & 3 deletions src/base/value_schema_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::unique_ptr<value_field> value_schema_v2::extract_field(std::string_view val
field = extract_time_tag(value);
break;
default:
CHECK(false, "Unsupported field type: {}", type);
PGSCHECK(false, "Unsupported field type: {}", type);
}
return field;
}
Expand All @@ -65,7 +65,7 @@ void value_schema_v2::update_field(std::string &value, std::unique_ptr<value_fie
update_expire_ts(value, std::move(field));
break;
default:
CHECK(false, "Unsupported update field type: {}", type);
PGSCHECK(false, "Unsupported update field type: {}", type);
}
}

Expand All @@ -79,7 +79,7 @@ rocksdb::SliceParts value_schema_v2::generate_value(const value_params &params)
static_cast<user_data_field *>(params.fields[value_field_type::USER_DATA].get());
if (dsn_unlikely(expire_ts_field == nullptr || data_field == nullptr ||
timetag_field == nullptr)) {
CHECK(false, "USER_DATA or EXPIRE_TIMESTAMP or TIME_TAG is not provided");
PGSCHECK(false, "USER_DATA or EXPIRE_TIMESTAMP or TIME_TAG is not provided");
return {nullptr, 0};
}

Expand Down
12 changes: 6 additions & 6 deletions src/block_service/block_service_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ namespace block_service {

block_service_registry::block_service_registry()
{
CHECK(utils::factory_store<block_filesystem>::register_factory(
"hdfs_service", block_filesystem::create<hdfs_service>, PROVIDER_TYPE_MAIN),
"register hdfs_service failed");
PGSCHECK(utils::factory_store<block_filesystem>::register_factory(
"hdfs_service", block_filesystem::create<hdfs_service>, PROVIDER_TYPE_MAIN),
"register hdfs_service failed");

CHECK(utils::factory_store<block_filesystem>::register_factory(
"local_service", block_filesystem::create<local_service>, PROVIDER_TYPE_MAIN),
"register local_service failed");
PGSCHECK(utils::factory_store<block_filesystem>::register_factory(
"local_service", block_filesystem::create<local_service>, PROVIDER_TYPE_MAIN),
"register local_service failed");
}

block_service_manager::block_service_manager()
Expand Down
6 changes: 3 additions & 3 deletions src/block_service/local/local_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ error_code local_service::initialize(const std::vector<std::string> &args)
if (::dsn::utils::filesystem::directory_exists(_root)) {
LOG_WARNING("old local block service root dir has already exist, path({})", _root);
} else {
CHECK(::dsn::utils::filesystem::create_directory(_root),
"local block service create directory({}) fail",
_root);
PGSCHECK(::dsn::utils::filesystem::create_directory(_root),
"local block service create directory({}) fail",
_root);
}
LOG_INFO("local block service initialize succeed with root({})", _root);
}
Expand Down
4 changes: 3 additions & 1 deletion src/block_service/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ set(MY_PROJ_LIBS
rocksdb
lz4
zstd
snappy)
snappy
glog
gflags)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)

Expand Down
4 changes: 2 additions & 2 deletions src/block_service/test/hdfs_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ void HDFSClientTest::write_test_files_async(const std::string &local_test_path,
if (s.ok()) {
++(*success_count);
} else {
CHECK(s.IsIOError(), "{}", s.ToString());
PGSCHECK(s.IsIOError(), "{}", s.ToString());
auto pos1 = s.ToString().find(
"IO error: No such file or directory: While open a file for appending: ");
auto pos2 = s.ToString().find("IO error: While appending to file: ");
CHECK(pos1 == 0 || pos2 == 0, "{}", s.ToString());
PGSCHECK(pos1 == 0 || pos2 == 0, "{}", s.ToString());
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/client/partition_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ void partition_resolver::call_task(const rpc_response_task_ptr &t)
dynamic_cast<rpc_response_task *>(task::get_current_task());
partition_resolver_ptr r(this);

CHECK_NOTNULL(ctask, "current task must be rpc_response_task");
PGSCHECK_NOTNULL(ctask, "current task must be rpc_response_task");
ctask->replace_callback(std::move(oc));
CHECK(ctask->set_retry(false),
"rpc_response_task set retry failed, state = {}",
enum_to_string(ctask->state()));
PGSCHECK(ctask->set_retry(false),
"rpc_response_task set retry failed, state = {}",
enum_to_string(ctask->state()));

// sleep gap milliseconds before retry
tasking::enqueue(
Expand Down
10 changes: 5 additions & 5 deletions src/client/replication_ddl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,13 +913,13 @@ dsn::error_code replication_ddl_client::do_recovery(const std::vector<host_port>
}
}
if (req->hp_recovery_nodes.empty()) {
CHECK(req->recovery_nodes.empty(),
"recovery_nodes should be set together with hp_recovery_nodes");
PGSCHECK(req->recovery_nodes.empty(),
"recovery_nodes should be set together with hp_recovery_nodes");
out << "node set for recovery it empty" << std::endl;
return ERR_INVALID_PARAMETERS;
}
CHECK(!req->recovery_nodes.empty(),
"recovery_nodes should be set together with hp_recovery_nodes");
PGSCHECK(!req->recovery_nodes.empty(),
"recovery_nodes should be set together with hp_recovery_nodes");
req->skip_bad_nodes = skip_bad_nodes;
req->skip_lost_partitions = skip_lost_partitions;

Expand Down Expand Up @@ -1534,7 +1534,7 @@ ::dsn::error_code replication_ddl_client::clear_app_envs(const std::string &app_
if (clear_all) {
req->__set_clear_prefix("");
} else {
CHECK(!prefix.empty(), "prefix can not be empty");
PGSCHECK(!prefix.empty(), "prefix can not be empty");
req->__set_clear_prefix(prefix);
}

Expand Down
4 changes: 3 additions & 1 deletion src/client/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ set(MY_PROJ_LIBS
rocksdb
lz4
zstd
snappy)
snappy
glog
gflags)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)

Expand Down
2 changes: 1 addition & 1 deletion src/client_lib/pegasus_client_factory_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool pegasus_client_factory_impl::initialize(const char *config_file)
{
bool is_initialized = ::dsn::tools::is_engine_ready();
if (config_file == nullptr) {
CHECK(is_initialized, "rdsn engine not started, please specify a valid config file");
PGSCHECK(is_initialized, "rdsn engine not started, please specify a valid config file");
} else {
if (is_initialized) {
LOG_WARNING("rdsn engine already started, ignore the config file '{}'", config_file);
Expand Down
3 changes: 2 additions & 1 deletion src/client_lib/pegasus_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,8 @@ void pegasus_client_impl::async_duplicate(dsn::apps::duplicate_rpc rpc,
const char *pegasus_client_impl::get_error_string(int error_code) const
{
auto it = _client_error_to_string.find(error_code);
CHECK(it != _client_error_to_string.end(), "client error {} have no error string", error_code);
PGSCHECK(
it != _client_error_to_string.end(), "client error {} have no error string", error_code);
return it->second.c_str();
}

Expand Down
12 changes: 6 additions & 6 deletions src/client_lib/pegasus_scanner_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pegasus_client_impl::pegasus_scanner_impl::get_smart_wrapper()
void pegasus_client_impl::pegasus_scanner_impl::_async_next_internal()
{
// _lock will be locked out of the while block
CHECK(!_queue.empty(), "queue should not be empty when _async_next_internal start");
PGSCHECK(!_queue.empty(), "queue should not be empty when _async_next_internal start");

std::list<async_scan_next_callback_t> temp;
while (true) {
Expand Down Expand Up @@ -264,7 +264,7 @@ void pegasus_client_impl::pegasus_scanner_impl::_next_batch()
::dsn::apps::scan_request req;
req.context_id = _context;

CHECK(!_rpc_started, "");
PGSCHECK(!_rpc_started, "");
_rpc_started = true;
_client->scan(
req,
Expand Down Expand Up @@ -300,7 +300,7 @@ void pegasus_client_impl::pegasus_scanner_impl::_start_scan()
req.__set_full_scan(_full_scan);
req.__set_only_return_count(_options.only_return_count);

CHECK(!_rpc_started, "");
PGSCHECK(!_rpc_started, "");
_rpc_started = true;
_client->get_scanner(
req,
Expand All @@ -315,7 +315,7 @@ void pegasus_client_impl::pegasus_scanner_impl::_on_scan_response(::dsn::error_c
dsn::message_ex *req,
dsn::message_ex *resp)
{
CHECK(_rpc_started, "");
PGSCHECK(_rpc_started, "");
_rpc_started = false;
::dsn::apps::scan_response response;
if (err == ERR_OK) {
Expand Down Expand Up @@ -380,8 +380,8 @@ pegasus_client_impl::pegasus_scanner_impl::~pegasus_scanner_impl()
{
dsn::zauto_lock l(_lock);

CHECK(!_rpc_started, "all scan-rpc should be completed here");
CHECK(_queue.empty(), "queue should be empty");
PGSCHECK(!_rpc_started, "all scan-rpc should be completed here");
PGSCHECK(_queue.empty(), "queue should be empty");

if (_client) {
if (_context >= SCAN_CONTEXT_ID_VALID_MIN)
Expand Down
2 changes: 1 addition & 1 deletion src/common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace dsn {

/*extern*/ const char *get_current_cluster_name()
{
CHECK(!utils::is_empty(FLAGS_cluster_name), "cluster_name is not set");
PGSCHECK(!utils::is_empty(FLAGS_cluster_name), "cluster_name is not set");
return FLAGS_cluster_name;
}

Expand Down
Loading

0 comments on commit 7c89616

Please sign in to comment.