BESBasicInterface.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <iostream>
00034 #include <sstream>
00035
00036 using std::endl ;
00037 using std::stringstream ;
00038
00039 #include "BESBasicInterface.h"
00040 #include "BESInterface.h"
00041 #include "BESLog.h"
00042 #include "BESDebug.h"
00043 #include "BESBasicHttpTransmitter.h"
00044 #include "BESReturnManager.h"
00045 #include "BESSyntaxUserError.h"
00046 #include "BESInternalError.h"
00047 #include "BESAggFactory.h"
00048 #include "BESAggregationServer.h"
00049 #include "BESTransmitterNames.h"
00050 #include "BESDataNames.h"
00051
00058 BESBasicInterface::BESBasicInterface( ostream *strm )
00059 : BESInterface( strm )
00060 {
00061 }
00062
00063 BESBasicInterface::~BESBasicInterface()
00064 {
00065 }
00066
00075 int
00076 BESBasicInterface::execute_request( const string &from )
00077 {
00078 return BESInterface::execute_request( from ) ;
00079 }
00080
00090 void
00091 BESBasicInterface::initialize()
00092 {
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 string protocol = _dhi->transmit_protocol ;
00104 if( protocol != "HTTP" )
00105 {
00106 BESDEBUG( "bes", "Finding " << BASIC_TRANSMITTER << " transmitter ... " << endl )
00107 _transmitter = BESReturnManager::TheManager()->find_transmitter( BASIC_TRANSMITTER ) ;
00108 if( !_transmitter )
00109 {
00110 string s = (string)"Unable to find transmitter "
00111 + BASIC_TRANSMITTER ;
00112 throw BESInternalError( s, __FILE__, __LINE__ ) ;
00113 }
00114 BESDEBUG( "bes", "OK" << endl )
00115 }
00116 else
00117 {
00118 BESDEBUG( "bes", "Finding " << HTTP_TRANSMITTER << " transmitter ... " << endl )
00119 _transmitter = BESReturnManager::TheManager()->find_transmitter( HTTP_TRANSMITTER ) ;
00120 if( !_transmitter )
00121 {
00122 string s = (string)"Unable to find transmitter "
00123 + HTTP_TRANSMITTER ;
00124 throw BESInternalError( s, __FILE__, __LINE__ ) ;
00125 }
00126 BESDEBUG( "bes", "OK" << endl )
00127 }
00128
00129 BESInterface::initialize() ;
00130 }
00131
00134 void
00135 BESBasicInterface::validate_data_request()
00136 {
00137 BESInterface::validate_data_request() ;
00138 }
00139
00144 void
00145 BESBasicInterface::build_data_request_plan()
00146 {
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 if( _dhi->data[RETURN_CMD] != "" )
00157 {
00158 BESDEBUG( "bes", "Finding transmitter: " << _dhi->data[RETURN_CMD] << " ... " << endl )
00159 _transmitter = BESReturnManager::TheManager()->find_transmitter( _dhi->data[RETURN_CMD] ) ;
00160 if( !_transmitter )
00161 {
00162 string s = (string)"Unable to find transmitter "
00163 + _dhi->data[RETURN_CMD] ;
00164 throw BESSyntaxUserError( s, __FILE__, __LINE__ ) ;
00165 }
00166 BESDEBUG( "bes", "OK" << endl )
00167 }
00168
00169 if( BESDebug::IsSet( "bes" ) ) _dhi->dump( *(BESDebug::GetStrm()) ) ;
00170 }
00171
00179 void
00180 BESBasicInterface::execute_data_request_plan()
00181 {
00182 if( BESLog::TheLog()->is_verbose() )
00183 {
00184 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00185 << " from " << _dhi->data[REQUEST_FROM]
00186 << " [" << _dhi->data[DATA_REQUEST] << "] executing"
00187 << endl ;
00188 }
00189 BESInterface::execute_data_request_plan() ;
00190 }
00191
00199 void
00200 BESBasicInterface::invoke_aggregation()
00201 {
00202 if( _dhi->data[AGG_CMD] == "" )
00203 {
00204 if( BESLog::TheLog()->is_verbose() )
00205 {
00206 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00207 << " from " << _dhi->data[REQUEST_FROM]
00208 << " [" << _dhi->data[DATA_REQUEST] << "]"
00209 << " not aggregating, command empty"
00210 << endl ;
00211 }
00212 }
00213 else
00214 {
00215 BESAggregationServer *agg = BESAggFactory::TheFactory()->find_handler( _dhi->data[AGG_HANDLER] ) ;
00216 if( !agg )
00217 {
00218 if( BESLog::TheLog()->is_verbose() )
00219 {
00220 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00221 << " from " << _dhi->data[REQUEST_FROM]
00222 << " [" << _dhi->data[DATA_REQUEST] << "]"
00223 << " not aggregating, no handler"
00224 << endl ;
00225 }
00226 }
00227 else
00228 {
00229 if( BESLog::TheLog()->is_verbose() )
00230 {
00231 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00232 << " from " << _dhi->data[REQUEST_FROM]
00233 << " [" << _dhi->data[DATA_REQUEST]
00234 << "] aggregating" << endl ;
00235 }
00236 }
00237 }
00238 BESInterface::invoke_aggregation() ;
00239 }
00240
00248 void
00249 BESBasicInterface::transmit_data()
00250 {
00251 if( BESLog::TheLog()->is_verbose() )
00252 {
00253 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00254 << " from " << _dhi->data[REQUEST_FROM]
00255 << " [" << _dhi->data[DATA_REQUEST]
00256 << "] transmitting" << endl ;
00257 }
00258 BESInterface::transmit_data() ;
00259 }
00260
00265 void
00266 BESBasicInterface::log_status()
00267 {
00268 string result = "completed" ;
00269 if( _dhi->error_info )
00270 result = "failed" ;
00271 if( BESLog::TheLog()->is_verbose() )
00272 {
00273 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00274 << " from " << _dhi->data[REQUEST_FROM]
00275 << " [" << _dhi->data[DATA_REQUEST] << "] "
00276 << result << endl ;
00277 }
00278 }
00279
00288 void
00289 BESBasicInterface::clean()
00290 {
00291 BESInterface::clean() ;
00292 if( BESLog::TheLog()->is_verbose() )
00293 {
00294 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00295 << " from " << _dhi->data[REQUEST_FROM]
00296 << " [" << _dhi->data[DATA_REQUEST] << "] cleaning"
00297 << endl ;
00298 }
00299 }
00300
00307 void
00308 BESBasicInterface::dump( ostream &strm ) const
00309 {
00310 strm << BESIndent::LMarg << "BESBasicInterface::dump - ("
00311 << (void *)this << ")" << endl ;
00312 BESIndent::Indent() ;
00313 BESInterface::dump( strm ) ;
00314 BESIndent::UnIndent() ;
00315
00316
00317 }
00318