31#include <libdap/InternalErr.h>
33#include <BESResponseHandler.h>
34#include <BESResponseNames.h>
35#include <BESVersionInfo.h>
36#include <BESConstraintFuncs.h>
37#include <BESServiceRegistry.h>
38#include <TheBESKeys.h>
42#include "NgapRequestHandler.h"
50unsigned int NgapRequestHandler::d_cmr_cache_size_items = 100;
51unsigned int NgapRequestHandler::d_cmr_cache_purge_items = 20;
53bool NgapRequestHandler::d_use_cmr_cache =
false;
57unsigned int NgapRequestHandler::d_dmrpp_mem_cache_size_items = 100;
58unsigned int NgapRequestHandler::d_dmrpp_mem_cache_purge_items = 20;
60bool NgapRequestHandler::d_use_dmrpp_cache =
false;
63long long NgapRequestHandler::d_dmrpp_file_cache_size_mb = 10'000;
64long long NgapRequestHandler::d_dmrpp_file_cache_purge_size_mb = 2'000;
65string NgapRequestHandler::d_dmrpp_file_cache_dir =
"/tmp/hyrax_dmrpp_cache";
67FileCache NgapRequestHandler::d_dmrpp_file_cache;
69NgapRequestHandler::NgapRequestHandler(
const string &name) :
72 add_method(VERS_RESPONSE, NgapRequestHandler::ngap_build_vers);
73 add_method(HELP_RESPONSE, NgapRequestHandler::ngap_build_help);
76 NgapRequestHandler::d_use_cmr_cache
78 if (NgapRequestHandler::d_use_cmr_cache) {
79 NgapRequestHandler::d_cmr_cache_size_items
81 NgapRequestHandler::d_cmr_cache_purge_items
83 if (!d_cmr_mem_cache.initialize(d_cmr_cache_size_items, d_cmr_cache_purge_items)) {
84 ERROR_LOG(
"NgapRequestHandler::NgapRequestHandler() - failed to initialize CMR cache");
88 NgapRequestHandler::d_use_dmrpp_cache
90 if (NgapRequestHandler::d_use_dmrpp_cache) {
91 NgapRequestHandler::d_dmrpp_mem_cache_size_items
93 NgapRequestHandler::d_dmrpp_mem_cache_purge_items
95 if (!d_dmrpp_mem_cache.initialize(d_dmrpp_mem_cache_size_items, d_dmrpp_mem_cache_purge_items)) {
96 ERROR_LOG(
"NgapRequestHandler::NgapRequestHandler() - failed to initialize DMR++ cache");
101 NgapRequestHandler::d_dmrpp_file_cache_size_mb
103 NgapRequestHandler::d_dmrpp_file_cache_size_mb);
104 NgapRequestHandler::d_dmrpp_file_cache_purge_size_mb
106 NgapRequestHandler::d_dmrpp_file_cache_purge_size_mb);
107 NgapRequestHandler::d_dmrpp_file_cache_dir
109 NgapRequestHandler::d_dmrpp_file_cache_dir);
110 if (
BESUtil::mkdir_p(NgapRequestHandler::d_dmrpp_file_cache_dir, 0775) != 0) {
111 ERROR_LOG(
"DMR++ file cache directory '" + NgapRequestHandler::d_dmrpp_file_cache_dir +
"' error: "
114 if (!NgapRequestHandler::d_dmrpp_file_cache.initialize(NgapRequestHandler::d_dmrpp_file_cache_dir,
115 NgapRequestHandler::d_dmrpp_file_cache_size_mb,
116 NgapRequestHandler::d_dmrpp_file_cache_purge_size_mb)) {
117 ERROR_LOG(
"NgapRequestHandler::NgapRequestHandler() - failed to initialize DMR++ file cache");
125 if (!info)
throw InternalErr(__FILE__, __LINE__,
"Expected a BESVersionInfo instance");
127 info->add_module(MODULE_NAME, MODULE_VERSION);
131bool NgapRequestHandler::ngap_build_help(BESDataHandlerInterface &dhi)
134 if (!info)
throw InternalErr(__FILE__, __LINE__,
"Expected a BESInfo instance");
138 map<string, string, std::less<>> attrs;
139 attrs[
"name"] = MODULE_NAME;
140 attrs[
"version"] = MODULE_VERSION;
142 list<string> services;
144 if (!services.empty()) {
146 attrs[
"handles"] = handles;
148 info->begin_tag(
"module", &attrs);
149 info->end_tag(
"module");
156 strm << BESIndent::LMarg <<
"NgapRequestHandler::dump - (" << (
void *)
this <<
")" << endl;
159 BESIndent::UnIndent();
Structure storing information used by the BES to handle the request.
Represents a specific data type request handler.
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual BESResponseObject * get_response_object()
return the current response object
virtual void services_handled(const std::string &handler, std::list< std::string > &services)
returns the list of servies provided by the handler in question
static int mkdir_p(const std::string &path, mode_t mode)
static std::string implode(const std::list< std::string > &values, char delim)
Implementation of a caching mechanism for files.
static int read_int_key(const std::string &key, int default_value)
Read an integer-valued key from the bes.conf file.
static bool read_bool_key(const std::string &key, bool default_value)
Read a boolean-valued key from the bes.conf file.
static std::string read_string_key(const std::string &key, const std::string &default_value)
Read a string-valued key from the bes.conf file.
static unsigned long read_ulong_key(const std::string &key, unsigned long default_value)
Read an integer-valued key from the bes.conf file.
void dump(std::ostream &strm) const override
dumps information about this object