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
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,24 @@ FileStorageWriter::FileStorageWriter(

FileStorageWriter::~FileStorageWriter()
{
if (info_file_.good()) {
/* Obtain current time */
int64_t current_time = (int64_t) time(NULL);
if (current_time == -1) {
// can't throw in a destructor
std::cerr << "Failed to obtain the current time";
}
/* Time was returned in seconds. Transform to nanoseconds */
current_time *= NANOSECS_PER_SEC;
info_file_ << "End timestamp: " << current_time << std::endl;
if (info_file_.fail()) {
std::cerr << "Failed to use file to store metadata";
return;
}

/* Obtain current time */
int64_t current_time = (int64_t) time(NULL);
if (current_time == -1) {
// can't throw in a destructor
std::cerr << "Failed to obtain the current time";
return;
}
/* Time was returned in seconds. Transform to nanoseconds */
current_time *= NANOSECS_PER_SEC;
info_file_ << "End timestamp: " << current_time << std::endl;

if (info_file_.fail()) {
std::cerr << "Failed to write end timestamp";
}
}

Expand Down
10 changes: 6 additions & 4 deletions examples/recording_service/pluggable_storage/c++11/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ RTI Recording Service (Recorder) 7.0.0 starting...
RTI Recording Service started
```

*Recorder* will create two files, `Cpp_PluggableStorage.dat` and
`Cpp_PluggableStorage.dat.info`. The `HelloMsg` recorded samples are in the *.dat*
file. The *.dat.info* file contains information about when the service started
and finished.
*Recorder* will create three files:
* `Cpp_PluggableStorage.dat`: contains the `HelloMsg` recorded samples.
* `Cpp_PluggableStorage.dat.info`: contains information about when the service
started and finished.
* `Cpp_PluggableStorage.dat.pub`: contains discovery information required to
replay the recorded database.

## Running the C++ example (Replay storage reader)

Expand Down
35 changes: 24 additions & 11 deletions examples/recording_service/service_admin/c++11/Requester.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,26 @@ CommandActionKind ArgumentsParser::parse_command_kind(char *arg)
return command_kind;
}

uint64_t ArgumentsParser::parse_number(char *arg)
uint32_t ArgumentsParser::parse_domain_id(char *arg)
{
std::stringstream stream(arg);
uint32_t value;
if (!(stream >> value)) {
std::stringstream error_stream;
error_stream << "Error: could not parse domain id value provided, '" << arg
<< "'";
throw std::runtime_error(error_stream.str());
}
return value;
}

uint64_t ArgumentsParser::parse_timestamp(char *arg)
{
std::stringstream stream(arg);
uint64_t value;
if (!(stream >> value)) {
std::stringstream error_stream;
error_stream << "Error: could not parse uint64 value provided, '" << arg
error_stream << "Error: could not parse timestamp value provided, '" << arg
<< "'";
throw std::runtime_error(error_stream.str());
}
Expand Down Expand Up @@ -237,7 +250,7 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
<< DOMAIN_ID_ARG_NAME << " parameter";
throw std::runtime_error(error_stream.str());
}
admin_domain_id_ = parse_number(argv[current_arg + 1]);
admin_domain_id_ = parse_domain_id(argv[current_arg + 1]);
current_arg += 2;
} else if (TIME_TAG_ARG_NAME.compare(argv[current_arg]) == 0) {
// This parameter may use one or two arguments
Expand All @@ -264,7 +277,7 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
octet_kind_ = OctetKind::BREAKPOINT;
// This parameter may use one or two arguments
br_params_.value().timestamp_nanos(
parse_number(argv[current_arg + 1]));
parse_timestamp(argv[current_arg + 1]));
// Check if a label has been provided
if (current_arg + 2 < argc) {
br_params_.label(std::string(argv[current_arg + 2]));
Expand All @@ -285,14 +298,14 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
// This parameter may use one or two arguments
if (is_number(argv[current_arg + 1])) {
br_params_.value().timestamp_nanos(
parse_number(argv[current_arg + 1]));
parse_timestamp(argv[current_arg + 1]));
} else {
br_params_.label(std::string(argv[current_arg + 1]));
}
current_arg += 2;
} else if (current_arg + 2 < argc) {
br_params_.value().timestamp_nanos(
parse_number(argv[current_arg + 1]));
parse_timestamp(argv[current_arg + 1]));
br_params_.label(std::string(argv[current_arg + 2]));
current_arg += 3;
} else {
Expand All @@ -308,14 +321,14 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
// This parameter may use one or two arguments
if (is_number(argv[current_arg + 1])) {
br_params_.value().timestamp_nanos(
parse_number(argv[current_arg + 1]));
parse_timestamp(argv[current_arg + 1]));
} else {
br_params_.label(std::string(argv[current_arg + 1]));
}
current_arg += 2;
} else if (current_arg + 2 < argc) {
br_params_.value().timestamp_nanos(
parse_number(argv[current_arg + 1]));
parse_timestamp(argv[current_arg + 1]));
br_params_.label(std::string(argv[current_arg + 2]));
current_arg += 3;
} else {
Expand All @@ -330,7 +343,7 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
if (current_arg + 1 < argc) {
octet_kind_ = OctetKind::CONTINUE;
continue_params_.value().offset(
parse_number(argv[current_arg + 1]));
parse_timestamp(argv[current_arg + 1]));
current_arg += 2;
} else {
// No number of seconds for the continue param
Expand All @@ -344,7 +357,7 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
if (current_arg + 1 < argc) {
octet_kind_ = OctetKind::CONTINUE;
continue_params_.value().slices(
parse_number(argv[current_arg + 1]));
parse_timestamp(argv[current_arg + 1]));
current_arg += 2;
} else {
// No number of slices for the continue param
Expand All @@ -357,7 +370,7 @@ ArgumentsParser::ArgumentsParser(int argc, char *argv[])
if (current_arg + 1 < argc) {
octet_kind_ = OctetKind::TIMESTAMPHOLDER;
timestamp_holder_.timestamp_nanos(
parse_number(argv[current_arg + 1]));
parse_timestamp(argv[current_arg + 1]));
current_arg += 2;
} else {
// No timestamp for the jump in time
Expand Down
4 changes: 3 additions & 1 deletion examples/recording_service/service_admin/c++11/Requester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class ArgumentsParser {

static RTI::Service::Admin::CommandActionKind parse_command_kind(char *arg);

static uint64_t parse_number(char *arg);
static uint32_t parse_domain_id(char *arg);

static uint64_t parse_timestamp(char *arg);

static bool is_number(char *arg);
};
Expand Down
Loading