Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/capio/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ constexpr char CAPIO_FILE_MODE_NO_UPDATE[] = "no_update";
constexpr char CAPIO_FILE_MODE_UPDATE[] = "update";
constexpr char CAPIO_FILE_COMMITTED_ON_CLOSE[] = "on_close";
constexpr char CAPIO_FILE_COMMITTED_ON_FILE[] = "on_file";
constexpr char CAPIO_FILE_COMMITTED_N_FILES[] = "n_files";
constexpr char CAPIO_FILE_COMMITTED_ON_TERMINATION[] = "on_termination";

// CAPIO POSIX return codes
Expand Down
26 changes: 17 additions & 9 deletions src/server/capio-cl-engine/json_parser.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#ifndef JSON_PARSER_HPP
#define JSON_PARSER_HPP
#include "capio/constants.hpp"

#include <singleheader/simdjson.h>

/**
Expand Down Expand Up @@ -216,22 +218,28 @@ class JsonParser {
auto pos = committed.find(':');
if (pos != std::string::npos) {
commit_rule = committed.substr(0, pos);
if (commit_rule != CAPIO_FILE_COMMITTED_ON_CLOSE) {
std::string count_str(committed.substr(pos + 1, committed.length()));
if (!is_int(count_str)) {
std::cout << CAPIO_LOG_SERVER_CLI_LEVEL_ERROR << " [ " << node_name
<< " ] "
<< "commit rule " << commit_rule << std::endl;
ERR_EXIT("error commit rule: %s", std::string(commit_rule).c_str());
<< "commit rule on_close/n_files invalid number"
<< std::endl;
ERR_EXIT("error commit rule on_close invalid number: !is_int()");
}

std::string n_close_str(committed.substr(pos + 1, committed.length()));

if (!is_int(n_close_str)) {
if (commit_rule == CAPIO_FILE_COMMITTED_ON_CLOSE) {
n_close = std::stol(count_str);
} else if (commit_rule == CAPIO_FILE_COMMITTED_N_FILES) {
n_files = std::stol(count_str);
// TODO: use internally n_files. for now, we use on_close as default
commit_rule = CAPIO_FILE_COMMITTED_ON_CLOSE;
} else {
std::cout << CAPIO_LOG_SERVER_CLI_LEVEL_ERROR << " [ " << node_name
<< " ] "
<< "commit rule on_close invalid number" << std::endl;
ERR_EXIT("error commit rule on_close invalid number: !is_int()");
<< "commit rule " << commit_rule << std::endl;
ERR_EXIT("error commit rule: %s", std::string(commit_rule).c_str());
}
n_close = std::stol(n_close_str);

} else {
commit_rule = committed;
}
Expand Down