OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
Entry point into BES, building responses to given requests. More...
#include <BESInterface.h>
Public Member Functions | |
virtual void | dump (ostream &strm) const |
dumps information about this object | |
virtual int | execute_request (const string &from) |
Executes the given request to generate a specified response object. | |
virtual int | finish_with_error (int status) |
Static Public Member Functions | |
static void | add_end_callback (p_bes_end end) |
static void | add_init_callback (p_bes_init init) |
Protected Member Functions | |
BESInterface (ostream *strm) | |
virtual void | build_data_request_plan ()=0 |
Build the data request plan. | |
virtual void | clean () |
Clean up after the request. | |
virtual void | end_request () |
End the BES request. | |
virtual int | exception_manager (BESError &e) |
Manage any exceptions thrown during the whole process. | |
virtual void | execute_data_request_plan () |
Execute the data request plan. | |
virtual int | finish (int status) |
virtual void | initialize () |
Initialize the BES object. | |
virtual void | invoke_aggregation () |
Aggregate the resulting response object. | |
virtual void | log_status () |
Log the status of the request. | |
virtual void | report_request () |
Report the request and status of the request to BESReporterList::TheList() | |
virtual void | transmit_data () |
Transmit the resulting response object. | |
virtual void | validate_data_request () |
Validate the incoming request information. | |
virtual | ~BESInterface () |
Protected Attributes | |
BESDataHandlerInterface * | _dhi |
BESTransmitter * | _transmitter |
Entry point into BES, building responses to given requests.
BESInterface is an abstract class providing the entry point into the retrieval of information using the BES framework. There are eight steps to retrieving a response to a given request:
The way in which the response is generated is as follows. A BESResponseHandler is found that knows how to build the requested response object. The built-in response handlers are for the response objects das, dds, ddx, data, help, version. These response handlers are added to a response handler list during initialization. Additional response handlers can be added to this list. For example, in Cedar, response handlers are registered to build flat, tab, info, and stream responses.
To build the response objects a user can make many requests. For example, a das object can be built using as many different files as is requested, say for file1,file2,file3,file4. And each of these files could be of a different data type. For example, file1 and file3 could be cedar files, file2 could be cdf file and file4 could be a netcdf file.
The structure that holds all of the requested information is the BESDataHandlerInterface. It holds on to a list of containers, each of which has the data type (cedar, cdf, nph, etc...) and the file to be read. The BESDataHandlerInterface is built in the build request method.
The response handlers know how to build the specified response object, such as DAS, DDS, help, status, version, etc...
For each container in the BESDataHandlerInterface find the request handler (BESRequestHandler) for the containers data type. Each request handler registers functions that know how to fill in a certain type of response (DAS, DDS, etc...). Find that function and invoke it. So, for example, there is a CedarRequestHandler class that registers functions that knows how to fill in the different response objects from cedar files.
Once the response object is filled it is transmitted using a specified BESTransmitter.
The status is then logged (default is to not log any status. It is up to derived classes of BESInterface to implement the log_status method.)
The request and status are then reported. The default action is to pass off the reporting to BESReporterList::TheList(), which has a list of registered reporters and passes off the information to each of those reporters. For example, if the Cedar project wants to report on any cedar access then it can register a reporter with BESReporterList::TheList().
Definition at line 123 of file BESInterface.h.
BESInterface::BESInterface | ( | ostream * | strm | ) | [protected] |
Definition at line 69 of file BESInterface.cc.
BESInterface::~BESInterface | ( | ) | [protected, virtual] |
Definition at line 80 of file BESInterface.cc.
void BESInterface::add_end_callback | ( | p_bes_end | end | ) | [static] |
Definition at line 467 of file BESInterface.cc.
void BESInterface::add_init_callback | ( | p_bes_init | init | ) | [static] |
Definition at line 281 of file BESInterface.cc.
virtual void BESInterface::build_data_request_plan | ( | ) | [protected, pure virtual] |
Build the data request plan.
It is the responsibility of the derived class to build the request plan. In other words, the container list must be filled in and the action set in the BESDataHandlerInterface structure.
Implemented in BESBasicInterface, and BESXMLInterface.
Referenced by execute_request().
void BESInterface::clean | ( | ) | [protected, virtual] |
Clean up after the request.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 503 of file BESInterface.cc.
References _dhi, and BESDataHandlerInterface::clean().
void BESInterface::dump | ( | ostream & | strm | ) | const [virtual] |
dumps information about this object
Displays the pointer value of this instance along with information about BESDataHandlerInterface, the BESTransmitter being used, and the number of initialization and termimation callbacks.
strm | C++ i/o stream to dump the information to |
Implements BESObj.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 536 of file BESInterface.cc.
References _dhi, _transmitter, BESTransmitter::dump(), BESDataHandlerInterface::dump(), BESIndent::Indent(), BESIndent::LMarg(), and BESIndent::UnIndent().
void BESInterface::end_request | ( | ) | [protected, virtual] |
End the BES request.
This method allows developers to add callbacks at the end of a request, to do any cleanup or do any extra work at the end of a request
Definition at line 478 of file BESInterface.cc.
References _dhi, BESDEBUG, BESDataHandlerInterface::container, BESDataHandlerInterface::data, DATA_REQUEST, BESDataHandlerInterface::first_container(), BESDataHandlerInterface::next_container(), and BESContainer::release().
Referenced by finish().
int BESInterface::exception_manager | ( | BESError & | e | ) | [protected, virtual] |
Manage any exceptions thrown during the whole process.
Specific responses are generated given a specific Exception caught. If additional exceptions are thrown within derived systems then implement those in the derived exception_manager methods. This is a catch-all manager and should be called once derived methods have caught their exceptions.
e | BESError to be managed |
Definition at line 522 of file BESInterface.cc.
References _dhi, BESExceptionManager::handle_exception(), and BESExceptionManager::TheEHM().
Referenced by execute_request(), finish(), and finish_with_error().
void BESInterface::execute_data_request_plan | ( | ) | [protected, virtual] |
Execute the data request plan.
Given the information in the BESDataHandlerInterface, execute the request. To do this we simply find the response handler given the action in the BESDataHandlerInterface and tell it to execute.
If no BESResponseHandler can be found given the action then an exception is thrown.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 337 of file BESInterface.cc.
References _dhi, BESDataHandlerInterface::action, BESDEBUG, BESDataHandlerInterface::data, DATA_REQUEST, BESResponseHandler::execute(), invoke_aggregation(), BESDataHandlerInterface::response_handler, and transmit_data().
Referenced by execute_request().
int BESInterface::execute_request | ( | const string & | from | ) | [virtual] |
Executes the given request to generate a specified response object.
Execute the request by:
If an exception is thrown in any of these steps the exception is handed over to the exception manager in order to generate the proper response. Control is returned back to the calling method if an exception is thrown and it is the responsibility of the calling method to call finish_with_error in order to transmit the error message back to the client.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 117 of file BESInterface.cc.
References _dhi, build_data_request_plan(), BESDataHandlerInterface::data, exception_manager(), execute_data_request_plan(), BESDataHandlerInterface::executed, finish(), initialize(), REQUEST_FROM, SERVER_PID, BESDataHandlerInterface::set_output_stream(), BESLog::TheLog(), and validate_data_request().
int BESInterface::finish | ( | int | status | ) | [protected, virtual] |
Definition at line 176 of file BESInterface.cc.
References _dhi, end_request(), BESDataHandlerInterface::error_info, exception_manager(), BESError::get_message(), log_status(), BESInfo::print(), report_request(), BESLog::TheLog(), and transmit_data().
Referenced by execute_request(), and finish_with_error().
int BESInterface::finish_with_error | ( | int | status | ) | [virtual] |
Definition at line 267 of file BESInterface.cc.
References _dhi, BESDataHandlerInterface::error_info, exception_manager(), and finish().
void BESInterface::initialize | ( | ) | [protected, virtual] |
Initialize the BES object.
This method must be called by all derived classes as it will initialize the environment
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 292 of file BESInterface.cc.
References _dhi, BESDEBUG, BESDataHandlerInterface::data, and DATA_REQUEST.
Referenced by execute_request().
void BESInterface::invoke_aggregation | ( | ) | [protected, virtual] |
Aggregate the resulting response object.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 364 of file BESInterface.cc.
References _dhi, AGG_CMD, AGG_HANDLER, BESAggregationServer::aggregate(), BESDEBUG, BESDataHandlerInterface::data, BESAggFactory::find_handler(), and BESAggFactory::TheFactory().
Referenced by execute_data_request_plan().
void BESInterface::log_status | ( | ) | [protected, virtual] |
Log the status of the request.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 440 of file BESInterface.cc.
Referenced by finish().
void BESInterface::report_request | ( | ) | [protected, virtual] |
Report the request and status of the request to BESReporterList::TheList()
If interested in reporting the request and status of the request then one must register a BESReporter with BESReporterList::TheList().
If no BESReporter objects are registered then nothing happens.
Reimplemented in BESXMLInterface.
Definition at line 456 of file BESInterface.cc.
References _dhi, BESDEBUG, BESDataHandlerInterface::data, DATA_REQUEST, BESReporterList::report(), and BESReporterList::TheList().
Referenced by finish().
void BESInterface::transmit_data | ( | ) | [protected, virtual] |
Transmit the resulting response object.
The derived classes are responsible for specifying a transmitter object for use in transmitting the response object. Again, the BESResponseHandler knows how to transmit itself.
If no response handler or no response object or no transmitter is specified then do nothing here.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 400 of file BESInterface.cc.
References _dhi, _transmitter, BESDEBUG, BESDataHandlerInterface::data, DATA_REQUEST, BESDataHandlerInterface::error_info, BESInfo::print(), BESDataHandlerInterface::response_handler, BESLog::TheLog(), BESInfo::transmit(), and BESResponseHandler::transmit().
Referenced by execute_data_request_plan(), and finish().
void BESInterface::validate_data_request | ( | ) | [protected, virtual] |
Validate the incoming request information.
Reimplemented in BESBasicInterface, and BESXMLInterface.
Definition at line 319 of file BESInterface.cc.
Referenced by execute_request().
BESDataHandlerInterface* BESInterface::_dhi [protected] |
Definition at line 136 of file BESInterface.h.
Referenced by BESXMLInterface::BESXMLInterface(), BESXMLInterface::build_data_request_plan(), BESBasicInterface::build_data_request_plan(), BESXMLInterface::clean(), BESBasicInterface::clean(), clean(), dump(), end_request(), exception_manager(), BESXMLInterface::execute_data_request_plan(), BESBasicInterface::execute_data_request_plan(), execute_data_request_plan(), execute_request(), finish(), finish_with_error(), initialize(), BESBasicInterface::invoke_aggregation(), invoke_aggregation(), BESXMLInterface::log_status(), BESBasicInterface::log_status(), BESXMLInterface::report_request(), report_request(), BESXMLInterface::transmit_data(), BESBasicInterface::transmit_data(), and transmit_data().
BESTransmitter* BESInterface::_transmitter [protected] |
Definition at line 137 of file BESInterface.h.
Referenced by BESBasicInterface::build_data_request_plan(), dump(), BESBasicInterface::initialize(), BESXMLInterface::transmit_data(), and transmit_data().