bes  Updated for version 3.17.0
BESDapResponseBuilder Class Reference

#include <BESDapResponseBuilder.h>

Public Member Functions

 BESDapResponseBuilder ()
 
void conditional_timeout_cancel ()
 
virtual void establish_timeout (std::ostream &stream) const
 
virtual std::string get_async_accepted () const
 
virtual std::string get_btp_func_ce () const
 
virtual std::string get_ce () const
 Get the constraint expression. More...
 
virtual std::string get_dap4ce () const
 Get the DAP4 constraint expression. More...
 
virtual std::string get_dap4function () const
 Get the DAP4 server side function expression. More...
 
virtual std::string get_dataset_name () const
 Get the dataset name. More...
 
virtual std::string get_store_result () const
 
virtual void remove_timeout () const
 
virtual void send_dap2_data (std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
 Transmit data. More...
 
virtual void send_dap4_data (std::ostream &out, libdap::DMR &dmr, bool with_mime_headers=true)
 
virtual void send_das (std::ostream &out, libdap::DAS &das, bool with_mime_headers=true) const
 
virtual void send_das (std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true)
 
virtual void send_dds (std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true)
 Transmit a DDS. More...
 
virtual void send_ddx (std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
 
virtual void send_dmr (std::ostream &out, libdap::DMR &dmr, bool with_mime_headers=true)
 
virtual void serialize_dap2_data_dds (std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool ce_eval=true)
 
virtual void serialize_dap2_data_ddx (std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, const std::string &boundary, const std::string &start, bool ce_eval=true)
 
virtual void serialize_dap4_data (std::ostream &out, libdap::DMR &dmr, bool with_mime_headers=true)
 
virtual void set_async_accepted (std::string _aa)
 
virtual void set_btp_func_ce (std::string _ce)
 
virtual void set_ce (std::string _ce)
 
virtual void set_dap4ce (std::string _ce)
 
virtual void set_dap4function (std::string _func)
 
virtual void set_dataset_name (const std::string _dataset)
 Set the dataset pathname. More...
 
virtual void set_store_result (std::string _sr)
 
virtual void split_ce (libdap::ConstraintEvaluator &eval, const std::string &expr="")
 
virtual bool store_dap4_result (ostream &out, libdap::DMR &dmr)
 
DDS_timeout

Old deprecated BESDapResponseBuilder timeout code. Do not use.

Deprecated:
void register_timeout () const
 
void set_timeout (int timeout=0)
 
int get_timeout () const
 
void timeout_on () const
 
void timeout_off ()
 

Protected Member Functions

void initialize ()
 
void send_dap4_data_using_ce (std::ostream &out, libdap::DMR &dmr, bool with_mime_headersr)
 
bool store_dap2_result (ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval)
 

Protected Attributes

std::string d_async_accepted
 Should a timeout be cancelled once transmission starts? More...
 
std::string d_btp_func_ce
 DAP4 Server Side Function expression.
 
bool d_cancel_timeout_on_send
 Version string for the library's default protocol version.
 
std::string d_dap2ce
 Name of the dataset/database.
 
std::string d_dap4ce
 DAP2 Constraint expression.
 
std::string d_dap4function
 DAP4 Constraint expression.
 
std::string d_dataset
 
std::string d_default_protocol
 Response timeout after N seconds.
 
std::string d_store_result
 
int d_timeout
 The BTP functions, extracted from the CE.
 

Friends

class ResponseBuilderTest
 

Detailed Description

This class is used to build responses for/by the BES. This class replaces DODSFilter (although DODSFilter is still included in the library, its use is deprecated). and it does not have a provision for command line arguments.

Author
jhrg 1/28/2011

Definition at line 47 of file BESDapResponseBuilder.h.

Constructor & Destructor Documentation

BESDapResponseBuilder::BESDapResponseBuilder ( )
inline

Make an empty instance. Use the set_*() methods to load with needed values. You must call at least set_dataset_name() or be requesting version information.

Definition at line 87 of file BESDapResponseBuilder.h.

Member Function Documentation

void BESDapResponseBuilder::conditional_timeout_cancel ( )

If the value of the BES Key BES.CancelTimeoutOnSend is true, cancel the timeout. The intent of this is to stop the timeout counter once the BES starts sending data back since, the network link used by a remote client may be low-bandwidth and data providers might want to ensure those users get their data (and don't submit second, third, ..., requests when/if the first one fails). The timeout is initiated in the BES framework when it first processes the request.

Note
The BES timeout is set/controlled in bes/dispatch/BESInterface in the 'int BESInterface::execute_request(const string &from)' method.
See also
BESInterface::execute_request(const string &from)

Definition at line 320 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::establish_timeout ( std::ostream &  stream) const
virtual

Use values of this instance to establish a timeout alarm for the server. If the timeout value is zero, do nothing.

Deprecated:

Definition at line 351 of file BESDapResponseBuilder.cc.

string BESDapResponseBuilder::get_ce ( ) const
virtual

Return the entire DAP2 constraint expression in a string. This includes both the projection and selection clauses, but not the question mark.

Returns
A string object that contains the constraint expression.

Definition at line 142 of file BESDapResponseBuilder.cc.

string BESDapResponseBuilder::get_dap4ce ( ) const
virtual

Return the entire DAP4 constraint expression in a string.

Returns
A string object that contains the constraint expression.

Definition at line 165 of file BESDapResponseBuilder.cc.

string BESDapResponseBuilder::get_dap4function ( ) const
virtual

Return the entire DAP4 server side function expression in a string.

Returns
A string object that contains the constraint expression.

Definition at line 188 of file BESDapResponseBuilder.cc.

string BESDapResponseBuilder::get_dataset_name ( ) const
virtual

The ``dataset name'' is the filename or other string that the filter program will use to access the data. In some cases this will indicate a disk file containing the data. In others, it may represent a database query or some other exotic data access method.

Returns
A string object that contains the name of the dataset.

Definition at line 239 of file BESDapResponseBuilder.cc.

int BESDapResponseBuilder::get_timeout ( ) const

Get the server's timeout value.

Definition at line 270 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::initialize ( )
protected

Look up the BES Keys (parameters in the bes.conf file) that this class uses.

Definition at line 113 of file BESDapResponseBuilder.cc.

References BESKeys::get_value(), and TheBESKeys::TheKeys().

void BESDapResponseBuilder::register_timeout ( ) const

Configure a signal handler for the SIGALRM. The signal handler will throw a DAP Error object if the alarm signal is triggered.

Deprecated:
Returns
void

Definition at line 334 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::remove_timeout ( ) const
virtual
Deprecated:
Use timeout_off() instead.

Definition at line 368 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::send_dap2_data ( std::ostream &  data_stream,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
bool  with_mime_headers = true 
)
virtual

Send the data in the DDS object back to the client program. The data is encoded using a Marshaller, and enclosed in a MIME document which is all sent to data_stream.

Note
This is the DAP2 data response.
Parameters
ddsA DDS object containing the data to be sent.
evalA reference to the ConstraintEvaluator to use.
data_streamWrite the response to this stream.
anc_locationA directory to search for ancillary files (in addition to the CWD). This is used in a call to get_data_last_modified_time().
with_mime_headersIf true, include the MIME headers in the response. Defaults to true.
Returns
void

Definition at line 942 of file BESDapResponseBuilder.cc.

References BESDapResponseCache::get_instance(), and BESFileLockingCache::unlock_and_close().

void BESDapResponseBuilder::send_dds ( std::ostream &  out,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
bool  constrained = false,
bool  with_mime_headers = true 
)
virtual

This function formats and prints an ASCII representation of a DDS on stdout. Either an entire DDS or a constrained DDS may be sent. This function looks in the local cache and uses a DDS object there if it's valid. Otherwise, if the request CE contains server functions that build data for the response, the resulting DDS will be cached.

Parameters
outThe output stream to which the DAS is to be sent.
ddsThe DDS to send back to a client.
evalA reference to the ConstraintEvaluator to use.
constrainedIf this argument is true, evaluate the current constraint expression and send the `constrained DDS' back to the client.
constrainedIf true, apply the constraint bound to this instance of ResponseBuilder
with_mime_headersIf true (default) send MIME headers.
Returns
void
See also
DDS

Definition at line 665 of file BESDapResponseBuilder.cc.

References BESDapResponseCache::get_instance(), and BESFileLockingCache::unlock_and_close().

void BESDapResponseBuilder::send_ddx ( std::ostream &  out,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
bool  with_mime_headers = true 
)
virtual

Send the DDX response. The DDX never contains data, instead it holds a reference to a Blob response which is used to get the data values. The DDS and DAS objects are built using code that already exists in the servers.

Note
This is the DAP3.x metadata response; it is supported by most DAP2 servers as well. The DAP4 DDX will contain types not present in DAP2 or 3.x
Parameters
ddsThe dataset's DDS with attributes in the variables.
evalA reference to the ConstraintEvaluator to use.
outDestination
with_mime_headersIf true, include the MIME headers in the response. Defaults to true.

Definition at line 1066 of file BESDapResponseBuilder.cc.

References BESDapResponseCache::get_instance(), and BESFileLockingCache::unlock_and_close().

void BESDapResponseBuilder::serialize_dap2_data_dds ( std::ostream &  out,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
bool  ce_eval = true 
)
virtual

Build/return the BLOB part of the DAP2 data response.

Definition at line 844 of file BESDapResponseBuilder.cc.

References BESStopWatch::start().

void BESDapResponseBuilder::serialize_dap2_data_ddx ( std::ostream &  out,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
const std::string &  boundary,
const std::string &  start,
bool  ce_eval = true 
)
virtual

Serialize a DAP3.2 DataDDX to the stream "out". This was originally intended to be used for DAP4, now it is used to store responses for the async response feature as well as response caching for function results.

FIXME Comment is probably wrong jhrg 10/20/15

Definition at line 883 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::serialize_dap4_data ( std::ostream &  out,
libdap::DMR &  dmr,
bool  with_mime_headers = true 
)
virtual

Serialize the DAP4 data response to the passed stream

Definition at line 1239 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::set_ce ( std::string  _ce)
virtual

Set the DAP2 constraint expression. This will filter the CE text removing any 'WWW' escape characters except space. Spaces are left in the CE because the CE parser uses whitespace to delimit tokens while some datasets have identifiers that contain spaces. It's possible to use double quotes around identifiers too, but most client software doesn't know about that.

@brief Set the CE

Parameters
_ceThe constraint expression

Definition at line 157 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::set_dap4ce ( std::string  _ce)
virtual

Set the DAP4 constraint expression. This will filter the DAP4 CE text removing any 'WWW' escape characters except space. Spaces are left in the CE because the CE parser uses whitespace to delimit tokens while some datasets have identifiers that contain spaces. It's possible to use double quotes around identifiers too, but most client software doesn't know about that.

@brief Set the CE

Parameters
_ceThe constraint expression

Definition at line 180 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::set_dap4function ( std::string  _func)
virtual

Set the DAP4 Server Side Function expression. This will filter the function expression text removing any 'WWW' escape characters except space. Spaces are left in the CE because the CE parser uses whitespace to delimit tokens while some datasets have identifiers that contain spaces. It's possible to use double quotes around identifiers too, but most client software doesn't know about that.

@brief Set the CE

Parameters
_ceThe constraint expression

Definition at line 204 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::set_dataset_name ( const std::string  _dataset)
virtual

Set the dataset name, which is a string used to access the dataset on the machine running the server. That is, this is typically a pathname to a data file, although it doesn't have to be. This is not echoed in error messages (because that would reveal server storage patterns that data providers might want to hide). All WWW-style escapes are replaced except for spaces.

Parameters
dsThe pathname (or equivalent) to the dataset.

Definition at line 254 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::set_timeout ( int  t = 0)

Set the server's timeout value. A value of zero (the default) means no timeout.

See also
To establish a timeout, call establish_timeout(ostream &)
Parameters
tServer timeout in seconds. Default is zero (no timeout).

Definition at line 264 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::split_ce ( libdap::ConstraintEvaluator &  eval,
const std::string &  expr = "" 
)
virtual

Split the CE so that the server functions that compute new values are separated into their own string and can be evaluated separately from the rest of the CE (which can contain simple and slicing projection as well as other types of function calls).

Definition at line 402 of file BESDapResponseBuilder.cc.

References BESDapResponseCache::get_instance(), and BESFileLockingCache::unlock_and_close().

bool BESDapResponseBuilder::store_dap2_result ( ostream &  out,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval 
)
protected

Should this result be returned using the asynchronous response mechanism? Look at the 'store_result' property and see if the code should return this using the asynchronous mechanism. If yes, it will try and return the correct response or an error if the server is not configured or the client has not included the correct information in the request.

Parameters
outWrite information to the client using this stream
ddsThe DDS that hold information used to build the response. The response won't be built until some time in the future
evalUse this to evaluate the CE associated with the response.
Returns
True if the response should/will be returned asynchronously, false otherwise.

OOPS. Looks like the BES is not configured to use a Stored Result Cache. Looks like need to reject the request and move on.

Client accepts async responses so, woot! lets store this thing and tell them where to find it.

Client didn't indicate a willingness to accept an async response So - we tell them that async is required.

Definition at line 760 of file BESDapResponseBuilder.cc.

References BESUtil::assemblePath(), BESStoredDapResultCache::get_instance(), BESKeys::get_value(), BESStoredDapResultCache::store_dap2_result(), and TheBESKeys::TheKeys().

bool BESDapResponseBuilder::store_dap4_result ( ostream &  out,
libdap::DMR &  dmr 
)
virtual

Should this DAP4 result be stored and the client sent an Asynchronous response? This code looks at the 'store_result' property to determine if the response should be asynchronous and then, if so, churns through the options, sorting out if the client sent the correct information indicating it knows how to process them. If the 'store_result' property is not set, then this method simply returns false, indicating that the response should be returned using the normal synchronous response pattern.

Parameters
outWrite information about the response here
dmrThis DMR will be serialized to build the response, at some point in time
Returns
True if the response will be Asynchronous, false if the DMR should be sent right away.

OOPS. Looks like the BES is not configured to use a Stored Result Cache. Looks like need to reject the request and move on.

Client accepts async responses so, woot! lets store this thing and tell them where to find it.

Client didn't indicate a willingness to accept an async response So - we tell them that async is required.

Definition at line 1284 of file BESDapResponseBuilder.cc.

References BESUtil::assemblePath(), BESStoredDapResultCache::get_instance(), BESKeys::get_value(), BESStoredDapResultCache::store_dap4_result(), and TheBESKeys::TheKeys().

void BESDapResponseBuilder::timeout_off ( )

Turn off the timeout.

Deprecated:

Definition at line 297 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::timeout_on ( ) const

Turn on the alarm. The code will timeout after d_timeout seconds unless timeout_off() is called first.

Deprecated:

Definition at line 282 of file BESDapResponseBuilder.cc.

Member Data Documentation

std::string BESDapResponseBuilder::d_async_accepted
protected

Time, if any, that the client will wait for an async response. An empty string (length=0) means the client didn't supply an async parameter

Definition at line 66 of file BESDapResponseBuilder.h.

std::string BESDapResponseBuilder::d_store_result
protected

If set (i.e. non-null) then the client has asked for the result to be stored for later retrieval. The value is the service URL used to construct the stored result access URL to be returned to the client. An empty string (length=0) means the client didn't supply a store_result async parameter

Definition at line 74 of file BESDapResponseBuilder.h.


The documentation for this class was generated from the following files: