CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/EventFilter/StorageManager/src/SharedResources.cc

Go to the documentation of this file.
00001 
00004 
00006 #include "EventFilter/StorageManager/interface/Configuration.h"
00007 #include "EventFilter/StorageManager/interface/DiscardManager.h"
00008 #include "EventFilter/StorageManager/interface/DiskWriterResources.h"
00009 #include "EventFilter/StorageManager/interface/DQMEventProcessorResources.h"
00010 #include "EventFilter/StorageManager/interface/InitMsgCollection.h"
00011 #include "EventFilter/StorageManager/interface/RegistrationCollection.h"
00012 #include "EventFilter/StorageManager/interface/SharedResources.h"
00013 #include "EventFilter/StorageManager/interface/StateMachine.h"
00014 #include "EventFilter/StorageManager/interface/StatisticsReporter.h"
00015 
00016 #include "xcept/tools.h"
00017 
00018 #include "boost/date_time/posix_time/posix_time_types.hpp"
00019 
00020 #include <fstream>
00021 #include <iostream>
00022 #include <unistd.h>
00023 
00024 
00025 namespace stor
00026 {
00027 
00028   void SharedResources::moveToFailedState( xcept::Exception& exception )
00029   {
00030     std::string errorMsg = "Failed to process FAIL exception: "
00031       + xcept::stdformat_exception_history(exception) + " due to ";
00032 
00033     try
00034     {
00035       statisticsReporter_->alarmHandler()->notifySentinel(AlarmHandler::FATAL, exception);
00036       statisticsReporter_->getStateMachineMonitorCollection().setStatusMessage( 
00037         xcept::stdformat_exception_history(exception)
00038       );
00039       EventPtr_t stMachEvent( new Fail() );
00040       // wait maximum 5 seconds until enqueuing succeeds
00041       if ( ! commandQueue_->enqTimedWait( stMachEvent, boost::posix_time::seconds(5) ) )
00042       {
00043         XCEPT_DECLARE_NESTED( stor::exception::StateTransition,
00044           sentinelException, "Failed to enqueue FAIL event", exception );
00045         statisticsReporter_->alarmHandler()->
00046           notifySentinel(AlarmHandler::FATAL, sentinelException);
00047       }
00048     }
00049     catch(xcept::Exception &e)
00050     {
00051       errorMsg += xcept::stdformat_exception_history(e);
00052       localDebug( errorMsg );
00053     }
00054     catch(std::exception &e)
00055     {
00056       errorMsg += e.what();
00057       localDebug( errorMsg );
00058     }
00059     catch( ... )
00060     {
00061       errorMsg += "an unknown exception.";
00062       localDebug( errorMsg );
00063     }
00064   }
00065 
00066 
00067   void SharedResources::localDebug( const std::string& message ) const
00068   {
00069     std::ostringstream fname_oss;
00070     fname_oss << "/tmp/storage_manager_debug_" << 
00071       configuration_->getDiskWritingParams().smInstanceString_ <<
00072       "_" << getpid();
00073     const std::string fname = fname_oss.str();
00074     std::ofstream f( fname.c_str(), std::ios_base::ate | std::ios_base::out | std::ios_base::app );
00075     if( f.is_open() )
00076     {
00077       try
00078       {
00079         f << message << std::endl;
00080         f.close();
00081       }
00082       catch(...)
00083       {}
00084     }
00085   }
00086 
00087     
00088 } // namespace stor
00089