Skip to content

Commit

Permalink
to CHECK
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Oct 25, 2022
1 parent 7531182 commit 2c9ec47
Show file tree
Hide file tree
Showing 51 changed files with 142 additions and 142 deletions.
4 changes: 2 additions & 2 deletions src/base/pegasus_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,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. */
dassert_f('0' == 0x30 && 'A' == 0x41 && 'a' == 0x61, "");
dassert_f(isxdigit(c), "");
CHECK('0' == 0x30 && 'A' == 0x41 && 'a' == 0x61, "");
CHECK(isxdigit(c), "");
unsigned int x = static_cast<unsigned char>(c);
if (x > '9') {
x += 9;
Expand Down
2 changes: 1 addition & 1 deletion src/base/value_schema_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ value_schema *value_schema_manager::get_value_schema(uint32_t meta_cf_data_versi
} else {
auto schema = get_value_schema(meta_cf_data_version);
if (nullptr == schema) {
dassert_f(false, "data version({}) in meta cf is not supported", meta_cf_data_version);
CHECK(false, "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 @@ -32,7 +32,7 @@ std::unique_ptr<value_field> value_schema_v0::extract_field(dsn::string_view val
field = extract_timestamp(value);
break;
default:
dassert_f(false, "Unsupported field type: {}", type);
CHECK(false, "Unsupported field type: {}", type);
}
return field;
}
Expand All @@ -51,7 +51,7 @@ void value_schema_v0::update_field(std::string &value, std::unique_ptr<value_fie
update_expire_ts(value, std::move(field));
break;
default:
dassert_f(false, "Unsupported update field type: {}", type);
CHECK(false, "Unsupported update field type: {}", type);
}
}

Expand All @@ -62,7 +62,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)) {
dassert_f(false, "USER_DATA or EXPIRE_TIMESTAMP is not provided");
CHECK(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 @@ -37,7 +37,7 @@ std::unique_ptr<value_field> value_schema_v1::extract_field(dsn::string_view val
field = extract_time_tag(value);
break;
default:
dassert_f(false, "Unsupported field type: {}", type);
CHECK(false, "Unsupported field type: {}", type);
}
return field;
}
Expand All @@ -56,7 +56,7 @@ void value_schema_v1::update_field(std::string &value, std::unique_ptr<value_fie
update_expire_ts(value, std::move(field));
break;
default:
dassert_f(false, "Unsupported update field type: {}", type);
CHECK(false, "Unsupported update field type: {}", type);
}
}

Expand All @@ -70,7 +70,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)) {
dassert_f(false, "USER_DATA or EXPIRE_TIMESTAMP or TIME_TAG is not provided");
CHECK(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 @@ -38,7 +38,7 @@ std::unique_ptr<value_field> value_schema_v2::extract_field(dsn::string_view val
field = extract_time_tag(value);
break;
default:
dassert_f(false, "Unsupported field type: {}", type);
CHECK(false, "Unsupported field type: {}", type);
}
return field;
}
Expand All @@ -58,7 +58,7 @@ void value_schema_v2::update_field(std::string &value, std::unique_ptr<value_fie
update_expire_ts(value, std::move(field));
break;
default:
dassert_f(false, "Unsupported update field type: {}", type);
CHECK(false, "Unsupported update field type: {}", type);
}
}

Expand All @@ -72,7 +72,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)) {
dassert_f(false, "USER_DATA or EXPIRE_TIMESTAMP or TIME_TAG is not provided");
CHECK(false, "USER_DATA or EXPIRE_TIMESTAMP or TIME_TAG is not provided");
return {nullptr, 0};
}

Expand Down
24 changes: 12 additions & 12 deletions src/block_service/fds/fds_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,19 @@ dsn::task_ptr fds_service::list_dir(const ls_request &req,
// fds listing's objects are with full-path, we must extract the postfix to emulate
// the filesystem structure
for (const galaxy::fds::FDSObjectSummary &obj : objs) {
dassert(fds_path.empty() || boost::starts_with(obj.objectName(), fds_path),
"invalid path(%s) in parent(%s)",
obj.objectName().c_str(),
fds_path.c_str());
CHECK((fds_path.empty() || boost::starts_with(obj.objectName(), fds_path),
"invalid path({}) in parent({})",
obj.objectName(),
fds_path);
resp.entries->push_back(
{utils::path_from_fds(obj.objectName().substr(fds_path.size()), false),
false});
}
for (const std::string &s : common_prefix) {
dassert(fds_path.empty() || boost::starts_with(s, fds_path),
"invalid path(%s) in parent(%s)",
s.c_str(),
fds_path.c_str());
CHECK((fds_path.empty() || boost::starts_with(s, fds_path),
"invalid path({}) in parent({})",
s,
fds_path);
resp.entries->push_back(
{utils::path_from_fds(s.substr(fds_path.size()), true), true});
}
Expand Down Expand Up @@ -412,14 +412,14 @@ error_code fds_file_object::get_file_meta()
fds_service::FILE_LENGTH_CUSTOM_KEY.c_str(),
_fds_path.c_str());
bool valid = dsn::buf2uint64(iter->second, _size);
dassert_f(valid, "error to get file size");
CHECK(valid, "error to get file size");

// get md5 key
iter = meta.find(fds_service::FILE_MD5_KEY);
dassert_f(iter != meta.end(),
CHECK(iter != meta.end(),
"can't find {} in object({})'s metadata",
fds_service::FILE_MD5_KEY.c_str(),
_fds_path.c_str());
fds_service::FILE_MD5_KEY,
_fds_path);
_md5sum = iter->second;

_has_meta_synced = true;
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 @@ -30,7 +30,7 @@ bool pegasus_client_factory_impl::initialize(const char *config_file)
{
bool is_initialized = ::dsn::tools::is_engine_ready();
if (config_file == nullptr) {
dassert(is_initialized, "rdsn engine not started, please specify a valid config file");
CHECK((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 '%s'", config_file);
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 @@ -142,7 +142,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
dassert(!_queue.empty(), "queue should not be empty when _async_next_internal start");
CHECK((!_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 @@ -232,7 +232,7 @@ void pegasus_client_impl::pegasus_scanner_impl::_next_batch()
::dsn::apps::scan_request req;
req.context_id = _context;

dassert(!_rpc_started, "");
CHECK((!_rpc_started, "");
_rpc_started = true;
_client->scan(req,
[this](::dsn::error_code err,
Expand Down Expand Up @@ -267,7 +267,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);

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

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

if (_client) {
if (_context >= SCAN_CONTEXT_ID_VALID_MIN)
Expand Down
12 changes: 6 additions & 6 deletions src/common/replication_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void replication_options::initialize()
std::string error_msg = "";
bool flag = get_data_dir_and_tag(
dirs_str, app_dir, app_name, config_data_dirs, config_data_dir_tags, error_msg);
dassert_f(flag, error_msg);
CHECK(flag, error_msg);

// check if data_dir in black list, data_dirs doesn't contain dir in black list
std::string black_list_file =
Expand All @@ -160,7 +160,7 @@ void replication_options::initialize()
}

if (data_dirs.empty()) {
dassert_f(false, "no replica data dir found, maybe not set or excluded by black list");
CHECK(false, "no replica data dir found, maybe not set or excluded by black list");
}

deny_client_on_start = dsn_config_get_value_bool("replication",
Expand Down Expand Up @@ -409,7 +409,7 @@ void replication_options::initialize()

max_concurrent_bulk_load_downloading_count = FLAGS_max_concurrent_bulk_load_downloading_count;

dassert_f(replica_helper::load_meta_servers(meta_servers), "invalid meta server config");
CHECK(replica_helper::load_meta_servers(meta_servers), "invalid meta server config");

sanity_check();
}
Expand Down Expand Up @@ -486,9 +486,9 @@ bool replica_helper::load_meta_servers(/*out*/ std::vector<dsn::rpc_address> &se
section,
key);
uint32_t port_num = 0;
dassert_f(dsn::internal::buf2unsigned(hostname_port[1], port_num) && port_num < UINT16_MAX,
CHECK(dsn::internal::buf2unsigned(hostname_port[1], port_num) && port_num < UINT16_MAX,
"invalid address '{}' specified in config [{}].{}",
s.c_str(),
s,
section,
key);
if (0 != (ip = ::dsn::rpc_address::ipv4_from_host(hostname_port[0].c_str()))) {
Expand Down Expand Up @@ -581,7 +581,7 @@ replication_options::get_data_dirs_in_black_list(const std::string &fname,
LOG_INFO_F("data_dirs_black_list_file[{}] found, apply it", fname);
std::ifstream file(fname);
if (!file) {
dassert_f(false, "open data_dirs_black_list_file failed: {}", fname);
CHECK(false, "open data_dirs_black_list_file failed: {}", fname);
}

std::string str;
Expand Down
2 changes: 1 addition & 1 deletion src/geo/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int main(int argc, char **argv)
std::string value;
S2LatLng latlng(S2Testing::SamplePoint(rect));
bool ok = codec.encode_to_value(latlng.lat().degrees(), latlng.lng().degrees(), value);
dassert_f(ok, "");
CHECK(ok, "");
int ret = my_geo.set(std::to_string(i), "", value, 1000);
if (ret != pegasus::PERR_OK) {
std::cerr << "set data failed. error=" << ret << std::endl;
Expand Down
10 changes: 5 additions & 5 deletions src/geo/lib/geo_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ geo_client::geo_client(const char *config_file,
const char *geo_app_name)
{
bool ok = pegasus_client_factory::initialize(config_file);
dassert(ok, "init pegasus client factory failed");
CHECK((ok, "init pegasus client factory failed");

_common_data_client = pegasus_client_factory::get_client(cluster_name, common_app_name);
dassert(_common_data_client != nullptr, "init pegasus _common_data_client failed");
CHECK((_common_data_client, "init pegasus _common_data_client failed");

_geo_data_client = pegasus_client_factory::get_client(cluster_name, geo_app_name);
dassert(_geo_data_client != nullptr, "init pegasus _geo_data_client failed");
CHECK((_geo_data_client, "init pegasus _geo_data_client failed");

_min_level = (int32_t)dsn_config_get_value_uint64(
"geo_client.lib", "min_level", 12, "min cell level for scan");
Expand All @@ -93,7 +93,7 @@ geo_client::geo_client(const char *config_file,
"geo_client.lib", "longitude_index", 4, "longitude index in value");

dsn::error_s s = _codec.set_latlng_indices(latitude_index, longitude_index);
dassert_f(s.is_ok(), "set_latlng_indices({}, {}) failed", latitude_index, longitude_index);
CHECK(s.is_ok(), "set_latlng_indices({}, {}) failed", latitude_index, longitude_index);
}

dsn::error_s geo_client::set_max_level(int level)
Expand Down Expand Up @@ -649,7 +649,7 @@ void geo_client::async_get_result_from_cells(const S2CellUnion &cids,
}
}

dassert(!start_stop_sort_keys.first.empty(), "");
CHECK((!start_stop_sort_keys.first.empty(), "");
// the last sub slice of current `cid` on `_max_level` in Hilbert curve covered by `cap`
if (start_stop_sort_keys.second.empty()) {
start_stop_sort_keys.second = gen_stop_sort_key(pre, hash_key);
Expand Down
2 changes: 1 addition & 1 deletion src/geo/test/geo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class geo_client_test : public ::testing::Test
std::vector<dsn::rpc_address> meta_list;
bool ok = dsn::replication::replica_helper::load_meta_servers(
meta_list, PEGASUS_CLUSTER_SECTION_NAME.c_str(), "onebox");
dassert_f(ok, "load_meta_servers failed");
CHECK(ok, "load_meta_servers failed");
auto ddl_client = new dsn::replication::replication_ddl_client(meta_list);
dsn::error_code error = ddl_client->create_app("temp_geo", "pegasus", 4, 3, {}, false);
dcheck_eq(dsn::ERR_OK, error);
Expand Down
2 changes: 1 addition & 1 deletion src/meta/backup_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ error_code backup_engine::write_backup_file(const std::string &file_name,
LOG_INFO_F("create file {} failed", file_name);
return err;
}
dassert_f(remote_file != nullptr,
CHECK(remote_file,
"create file {} succeed, but can't get handle",
create_file_req.file_name);
remote_file
Expand Down
4 changes: 2 additions & 2 deletions src/meta/meta_server_failure_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ bool meta_server_failure_detector::get_leader(rpc_address *leader)
// get leader addr
auto addr_part = str.substr(pos + 1, str.length() - pos - 1);
if (!leader->from_string_ipv4(addr_part.data())) {
dassert_f(false, "parse {} to rpc_address failed", addr_part);
CHECK(false, "parse {} to rpc_address failed", addr_part);
}

// get the return value which implies whether the current node is primary or not
bool is_leader = true;
auto is_leader_part = str.substr(0, pos);
if (!dsn::buf2bool(is_leader_part, is_leader)) {
dassert_f(false, "parse {} to bool failed", is_leader_part);
CHECK(false, "parse {} to bool failed", is_leader_part);
}
return is_leader;
});
Expand Down
8 changes: 4 additions & 4 deletions src/meta/meta_split_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ void meta_split_service::register_child_on_meta(register_child_rpc rpc)

zauto_write_lock l(app_lock());
std::shared_ptr<app_state> app = _state->get_app(app_name);
dassert_f(app != nullptr, "app({}) is not existed", app_name);
dassert_f(app->is_stateful, "app({}) is stateless currently", app_name);
CHECK(app, "app({}) is not existed", app_name);
CHECK(app->is_stateful, "app({}) is stateless currently", app_name);

const gpid &parent_gpid = request.parent_config.pid;
const gpid &child_gpid = request.child_config.pid;
Expand Down Expand Up @@ -245,8 +245,8 @@ void meta_split_service::on_add_child_on_remote_storage_reply(error_code ec,

zauto_write_lock l(app_lock());
std::shared_ptr<app_state> app = _state->get_app(app_name);
dassert_f(app != nullptr, "app({}) is not existed", app_name);
dassert_f(app->is_stateful, "app({}) is stateless currently", app_name);
CHECK(app, "app({}) is not existed", app_name);
CHECK(app->is_stateful, "app({}) is stateless currently", app_name);

const gpid &parent_gpid = request.parent_config.pid;
const gpid &child_gpid = request.child_config.pid;
Expand Down
4 changes: 2 additions & 2 deletions src/meta/meta_state_service_utils_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct op_type
"OP_GET_CHILDREN",
};

dassert_f(v != OP_NONE && v <= (sizeof(op_type_to_string_map) / sizeof(char *)),
CHECK(v != OP_NONE && v <= (sizeof(op_type_to_string_map) / sizeof(char *)),
"invalid type: {}",
v);
return op_type_to_string_map[v - 1];
Expand Down Expand Up @@ -81,7 +81,7 @@ struct operation : pipeline::environment
pipeline::repeat(std::move(*this_instance), 1_s);
return;
}
dassert_f(false,
CHECK(false,
"request({}) on path({}) encountered an unexpected error({})",
op_type::to_string(type),
path,
Expand Down
6 changes: 3 additions & 3 deletions src/meta/test/meta_app_operation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class meta_app_operation_test : public meta_test_base
int32_t max_replica_count)
{
auto app = find_app(app_name);
dassert_f(app != nullptr, "app({}) does not exist", app_name);
CHECK(app, "app({}) does not exist", app_name);

auto &partition_config = app->partitions[partition_index];
partition_config.max_replica_count = max_replica_count;
Expand All @@ -137,7 +137,7 @@ class meta_app_operation_test : public meta_test_base
void set_max_replica_count_env(const std::string &app_name, const std::string &env)
{
auto app = find_app(app_name);
dassert_f(app != nullptr, "app({}) does not exist", app_name);
CHECK(app, "app({}) does not exist", app_name);

if (env.empty()) {
app->envs.erase(replica_envs::UPDATE_MAX_REPLICA_COUNT);
Expand Down Expand Up @@ -176,7 +176,7 @@ class meta_app_operation_test : public meta_test_base
int32_t max_replica_count)
{
auto app = find_app(app_name);
dassert_f(app != nullptr, "app({}) does not exist", app_name);
CHECK(app, "app({}) does not exist", app_name);

auto partition_size = static_cast<int>(app->partitions.size());
for (int i = 0; i < partition_size; ++i) {
Expand Down
Loading

0 comments on commit 2c9ec47

Please sign in to comment.