41#include "ShowBesKeyCommand.h"
42#include "ShowBesKeyResponseHandler.h"
47#include "BESInfoList.h"
48#include "BESDataNames.h"
49#include "TheBESKeys.h"
51#include "BESStopWatch.h"
55const auto MODULE =
"bes";
56#define prolog std::string("ShowBesKeyResponseHandler::").append(__func__).append("() - ")
58ShowBesKeyResponseHandler::ShowBesKeyResponseHandler(
const string &name) :
63ShowBesKeyResponseHandler::~ShowBesKeyResponseHandler()
80 BES_STOPWATCH_START_DHI(MODULE, prolog +
"Timing", &dhi);
82 BESInfo *info = BESInfoList::TheList()->build_info();
83 d_response_object = info;
85 string requested_bes_key = dhi.
data[BES_KEY];
87 BESDEBUG(SBK_DEBUG_KEY, __func__ <<
"() - requested key: " << requested_bes_key << endl);
89 vector<string> key_values;
90 getBesKeyValue(requested_bes_key, key_values);
92 map<string, string, std::less<>> attrs;
94 attrs[KEY] = requested_bes_key;
100 map<string, string, std::less<>> emptyAttrs;
101 for(
unsigned long i = 0; i < key_values.size(); ++i)
102 info->add_tag(
"value", key_values[i], &emptyAttrs);
105 info->end_response();
122 if (d_response_object) {
137 strm << BESIndent::LMarg <<
"ShowBesKeyResponseHandler::dump - (" << (
void *)
this <<
")" << std::endl;
140 BESIndent::UnIndent();
144ShowBesKeyResponseHandler::ShowBesKeyResponseBuilder(
const string &name)
149void ShowBesKeyResponseHandler::getBesKeyValue(
string key, vector<string> &values)
155 BESDEBUG(SBK_DEBUG_KEY, __func__ <<
"() Failed to located BES key '" << key <<
"'" << endl);
156 throw BESError(
"Ouch! The Key name '"+key+
"' was not found in BESKeys",BES_NOT_FOUND_ERROR, __FILE__, __LINE__);
Structure storing information used by the BES to handle the request.
std::map< std::string, std::string > data
the map of string data that will be required for the current request.
informational response object
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)=0
transmit the informational object
virtual void begin_response(const std::string &response_name, BESDataHandlerInterface &dhi)
begin the informational response
exception thrown if internal error encountered
handler object that knows how to create a specific response object
void dump(std::ostream &strm) const override
dumps information about this object
Response handler that returns the value(s) of a BES key.
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &dhi)
transmit the response object built by the execute command using the specified transmitter object
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual void execute(BESDataHandlerInterface &dhi)
executes the command 'show catalog|leaves [for <node>];' by returning nodes or leaves at the top leve...
static TheBESKeys * TheKeys()
Access to the singleton.
void get_values(const std::string &s, std::vector< std::string > &vals, bool &found)
Retrieve the values of a given key, if set.