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 "BESReturnManager.h"
00044 #include "BESSyntaxUserError.h"
00045 #include "BESInternalError.h"
00046 #include "BESAggFactory.h"
00047 #include "BESAggregationServer.h"
00048 #include "BESTransmitterNames.h"
00049 #include "BESDataNames.h"
00050
00057 BESBasicInterface::BESBasicInterface( ostream *strm )
00058 : BESInterface( strm )
00059 {
00060 }
00061
00062 BESBasicInterface::~BESBasicInterface()
00063 {
00064 }
00065
00074 int
00075 BESBasicInterface::execute_request( const string &from )
00076 {
00077 return BESInterface::execute_request( from ) ;
00078 }
00079
00089 void
00090 BESBasicInterface::initialize()
00091 {
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 BESDEBUG( "bes", "Finding " << BASIC_TRANSMITTER << " transmitter ... " << endl ) ;
00103 _transmitter = BESReturnManager::TheManager()->find_transmitter( BASIC_TRANSMITTER ) ;
00104 if( !_transmitter )
00105 {
00106 string s = (string)"Unable to find transmitter "
00107 + BASIC_TRANSMITTER ;
00108 throw BESInternalError( s, __FILE__, __LINE__ ) ;
00109 }
00110 BESDEBUG( "bes", "OK" << endl ) ;
00111
00112 BESInterface::initialize() ;
00113 }
00114
00117 void
00118 BESBasicInterface::validate_data_request()
00119 {
00120 BESInterface::validate_data_request() ;
00121 }
00122
00127 void
00128 BESBasicInterface::build_data_request_plan()
00129 {
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 if( _dhi->data[RETURN_CMD] != "" )
00140 {
00141 BESDEBUG( "bes", "Finding transmitter: " << _dhi->data[RETURN_CMD] << " ... " << endl ) ;
00142 _transmitter = BESReturnManager::TheManager()->find_transmitter( _dhi->data[RETURN_CMD] ) ;
00143 if( !_transmitter )
00144 {
00145 string s = (string)"Unable to find transmitter "
00146 + _dhi->data[RETURN_CMD] ;
00147 throw BESSyntaxUserError( s, __FILE__, __LINE__ ) ;
00148 }
00149 BESDEBUG( "bes", "OK" << endl ) ;
00150 }
00151 }
00152
00160 void
00161 BESBasicInterface::execute_data_request_plan()
00162 {
00163 if( BESLog::TheLog()->is_verbose() )
00164 {
00165 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00166 << " from " << _dhi->data[REQUEST_FROM]
00167 << " [" << _dhi->data[DATA_REQUEST] << "] executing"
00168 << endl ;
00169 }
00170 BESInterface::execute_data_request_plan() ;
00171 }
00172
00180 void
00181 BESBasicInterface::invoke_aggregation()
00182 {
00183 if( _dhi->data[AGG_CMD] == "" )
00184 {
00185 if( BESLog::TheLog()->is_verbose() )
00186 {
00187 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00188 << " from " << _dhi->data[REQUEST_FROM]
00189 << " [" << _dhi->data[DATA_REQUEST] << "]"
00190 << " not aggregating, command empty"
00191 << endl ;
00192 }
00193 }
00194 else
00195 {
00196 BESAggregationServer *agg = BESAggFactory::TheFactory()->find_handler( _dhi->data[AGG_HANDLER] ) ;
00197 if( !agg )
00198 {
00199 if( BESLog::TheLog()->is_verbose() )
00200 {
00201 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00202 << " from " << _dhi->data[REQUEST_FROM]
00203 << " [" << _dhi->data[DATA_REQUEST] << "]"
00204 << " not aggregating, no handler"
00205 << endl ;
00206 }
00207 }
00208 else
00209 {
00210 if( BESLog::TheLog()->is_verbose() )
00211 {
00212 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00213 << " from " << _dhi->data[REQUEST_FROM]
00214 << " [" << _dhi->data[DATA_REQUEST]
00215 << "] aggregating" << endl ;
00216 }
00217 }
00218 }
00219 BESInterface::invoke_aggregation() ;
00220 }
00221
00229 void
00230 BESBasicInterface::transmit_data()
00231 {
00232 if( BESLog::TheLog()->is_verbose() )
00233 {
00234 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00235 << " from " << _dhi->data[REQUEST_FROM]
00236 << " [" << _dhi->data[DATA_REQUEST]
00237 << "] transmitting" << endl ;
00238 }
00239 BESInterface::transmit_data() ;
00240 }
00241
00246 void
00247 BESBasicInterface::log_status()
00248 {
00249 string result = "completed" ;
00250 if( _dhi->error_info )
00251 result = "failed" ;
00252 if( BESLog::TheLog()->is_verbose() )
00253 {
00254 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00255 << " from " << _dhi->data[REQUEST_FROM]
00256 << " [" << _dhi->data[DATA_REQUEST] << "] "
00257 << result << endl ;
00258 }
00259 }
00260
00269 void
00270 BESBasicInterface::clean()
00271 {
00272 BESInterface::clean() ;
00273 if( BESLog::TheLog()->is_verbose() )
00274 {
00275 *(BESLog::TheLog()) << _dhi->data[SERVER_PID]
00276 << " from " << _dhi->data[REQUEST_FROM]
00277 << " [" << _dhi->data[DATA_REQUEST] << "] cleaning"
00278 << endl ;
00279 }
00280 }
00281
00288 void
00289 BESBasicInterface::dump( ostream &strm ) const
00290 {
00291 strm << BESIndent::LMarg << "BESBasicInterface::dump - ("
00292 << (void *)this << ")" << endl ;
00293 BESIndent::Indent() ;
00294 BESInterface::dump( strm ) ;
00295 BESIndent::UnIndent() ;
00296
00297
00298 }
00299