Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for warning messages in status reporting for timed out h5 calls #322

Merged
merged 2 commits into from
Sep 15, 2023
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
4 changes: 4 additions & 0 deletions cpp/frameProcessor/include/FrameProcessorPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ class FrameProcessorPlugin : public IFrameCallback, public OdinData::IVersionedO
void set_name(const std::string& name);
std::string get_name();
void set_error(const std::string& msg);
void set_warning(const std::string& msg);
void clear_errors();
virtual bool reset_statistics();
std::vector<std::string> get_errors();
std::vector<std::string> get_warnings();
virtual void configure(OdinData::IpcMessage& config, OdinData::IpcMessage& reply);
virtual void requestConfiguration(OdinData::IpcMessage& reply);
virtual void status(OdinData::IpcMessage& status);
Expand Down Expand Up @@ -79,6 +81,8 @@ class FrameProcessorPlugin : public IFrameCallback, public OdinData::IVersionedO
std::map<std::string, boost::shared_ptr<IFrameCallback> > blocking_callbacks_;
/** Error message array */
std::vector<std::string> error_messages_;
/** Warning message array */
std::vector<std::string> warning_messages_;
/** Mutex to make accessing error_messages_ threadsafe */
boost::mutex mutex_;
/** process_frame performance stats */
Expand Down
2 changes: 1 addition & 1 deletion cpp/frameProcessor/src/FileWriterPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ FileWriterPlugin::FileWriterPlugin() :
hdf5_error_definition_.write_duration = 0;
hdf5_error_definition_.flush_duration = 0;
hdf5_error_definition_.close_duration = 0;
hdf5_error_definition_.callback = boost::bind(&FileWriterPlugin::set_error, this, _1);
hdf5_error_definition_.callback = boost::bind(&FileWriterPlugin::set_warning, this, _1);
}

/**
Expand Down
9 changes: 8 additions & 1 deletion cpp/frameProcessor/src/FrameProcessorController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void FrameProcessorController::callback(boost::shared_ptr<Frame> frame) {
void FrameProcessorController::provideStatus(OdinData::IpcMessage& reply)
{
// Error messages
std::vector<std::string> error_messages;
std::vector<std::string> error_messages, warning_messages;

// Request status information from the shared memory controller
if (sharedMemController_) {
Expand All @@ -292,11 +292,18 @@ void FrameProcessorController::provideStatus(OdinData::IpcMessage& reply)
// Read error level
std::vector<std::string> plugin_errors = iter->second->get_errors();
error_messages.insert(error_messages.end(), plugin_errors.begin(), plugin_errors.end());
// Read warning level
std::vector<std::string> plugin_warnings = iter->second->get_warnings();
warning_messages.insert(warning_messages.end(), plugin_warnings.begin(), plugin_warnings.end());
}
std::vector<std::string>::iterator error_iter;
for (error_iter = error_messages.begin(); error_iter != error_messages.end(); ++error_iter) {
reply.set_param("error[]", *error_iter);
}
std::vector<std::string>::iterator warning_iter;
for (warning_iter = warning_messages.begin(); warning_iter != warning_messages.end(); ++warning_iter) {
reply.set_param("warning[]", *warning_iter);
}

}

Expand Down
38 changes: 36 additions & 2 deletions cpp/frameProcessor/src/FrameProcessorPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,39 @@ void FrameProcessorPlugin::set_error(const std::string& msg)
}
}

/** Clear any error state.
/** Set the warning state.
*
* Clears any messages that have previously been set
* Sets an warning for this plugin
*
* \param[in] msg - std::string warning message.
*/
void FrameProcessorPlugin::set_warning(const std::string& msg)
{
// Take lock to access warning_messages_
boost::lock_guard<boost::mutex> lock(mutex_);

// Loop over warning messages, if this is a new message then add it
std::vector<std::string>::iterator iter;
bool found_warning = false;
for (iter = warning_messages_.begin(); iter != warning_messages_.end(); ++iter){
if (msg == *iter){
found_warning = true;
}
}
if (!found_warning){
warning_messages_.push_back(msg);
LOG4CXX_WARN(logger_, msg);
}
}

/** Clear error and warning messages.
*/
void FrameProcessorPlugin::clear_errors()
{
// Take lock to access error_messages_
boost::lock_guard<boost::mutex> lock(mutex_);
error_messages_.clear();
warning_messages_.clear();
}

/** Reset any statistics.
Expand All @@ -109,6 +133,16 @@ std::vector<std::string> FrameProcessorPlugin::get_errors()
return error_messages_;
}

/** Return the current warning message.
*
*/
std::vector<std::string> FrameProcessorPlugin::get_warnings()
{
// Take lock to access warning_messages_
boost::lock_guard<boost::mutex> lock(mutex_);
return warning_messages_;
}

/** Configure the plugin.
*
* In this abstract class the configure method does perform any
Expand Down
Loading