Skip to content

Commit

Permalink
#142: removed some logs and added additional try catch
Browse files Browse the repository at this point in the history
removed some unnecessary log messages and added additional try catch
statements around stol statements.
  • Loading branch information
jrse committed May 23, 2018
1 parent ac76882 commit 7608f2b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
17 changes: 14 additions & 3 deletions src/librmb/tools/rmb/ls_cmd_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ class Predicate {
time_t query_date = 0;
convert_str_to_time_t(this->value, &query_date);

uint64_t val2 = std::stol(_p_value);
uint64_t val2 = -1;
try {
val2 = std::stol(_p_value);
} catch (std::exception &e) {
std::cerr << "eval: search criteria: RBOX_METADATA_RECEIVED_TIME or RBOX_METADATA_OLDV1_SAVE_TIME '" << _p_value << "' is not a number " << std::endl;
}
time_t obj_date = static_cast<time_t>(val2);

double diff = difftime(obj_date, query_date);
Expand All @@ -57,8 +62,14 @@ class Predicate {
return true;
} else if (rbox_key == RBOX_METADATA_VIRTUAL_SIZE || rbox_key == RBOX_METADATA_PHYSICAL_SIZE ||
rbox_key == RBOX_METADATA_MAIL_UID) {
uint64_t val = std::stol(_p_value);
uint64_t val2 = std::stol(this->value);
uint64_t val = -1;
uint64_t val2 = -1;
try {
val = std::stol(_p_value);
val2 = std::stol(this->value);
} catch (std::exception &e) {
std::cerr << "eval: search criteria: RBOX_METADATA_VIRTUAL_SIZE or RBOX_METADATA_PHYSICAL_SIZE or RBOX_METADATA_MAIL_UID: _p_value " << _p_value << " or " << this->value << " is not a number" << std::endl;
}

if (this->op.compare("=") == 0) {
// numeric
Expand Down
4 changes: 1 addition & 3 deletions src/librmb/tools/rmb/rmb-commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ RmbCommands::RmbCommands(librmb::RadosStorage *storage_, librmb::RadosCluster *c
}

RmbCommands::~RmbCommands() {
// TODO Auto-generated destructor stub
}

// TODO:: currently untestable with mocks.
// TODO:: currently untestable with mocks.
int RmbCommands::lspools() {
librmb::RadosClusterImpl cluster;

Expand Down Expand Up @@ -348,7 +347,6 @@ RadosStorageMetadataModule *RmbCommands::init_metadata_storage_module(librmb::Ra
}

*uid = (*opts)["namespace"] + cfg.get_user_suffix();
std::cout << "uidl: " << *uid << std::endl;
std::string ns;
if (mgr.lookup_key(*uid, &ns)) {
storage->set_namespace(ns);
Expand Down
6 changes: 3 additions & 3 deletions src/tests/librmb/it_test_librmb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ TEST(librmb, rmb_load_objects_valid_metadata) {
list.push_back(&obj2);

EXPECT_EQ(true, !storage.wait_for_rados_operations(list));
std::cout << " wait ok " << std::endl;

std::vector<librmb::RadosMailObject *> mail_objects;
std::string sort_string = "uid";

Expand Down Expand Up @@ -1146,12 +1146,12 @@ TEST(librmb, rmb_load_objects_invalid_metadata) {
list.push_back(&obj2);

EXPECT_EQ(true, !storage.wait_for_rados_operations(list));
std::cout << " wait ok " << std::endl;

std::vector<librmb::RadosMailObject *> mail_objects;
std::string sort_string = "uid";

EXPECT_EQ(0, rmb_commands.load_objects(ms, mail_objects, sort_string));
// there needs to be one mail
// no mail
EXPECT_EQ(0, mail_objects.size());

storage.delete_mail(&obj2);
Expand Down

0 comments on commit 7608f2b

Please sign in to comment.