CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/EventFilter/StorageManager/src/Operations.cc

Go to the documentation of this file.
00001 // $Id: Operations.cc,v 1.11 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #include "EventFilter/StorageManager/interface/I2OChain.h"
00005 #include "EventFilter/StorageManager/interface/StateMachine.h"
00006 
00007 #include <iostream>
00008 
00009 #include <boost/statechart/event_base.hpp>
00010 
00011 #include "xcept/tools.h"
00012 
00013 using namespace std;
00014 using namespace stor;
00015 using namespace boost::statechart;
00016 
00017 Operations::Operations()
00018 {
00019   //TransitionRecord tr( stateName(), true );
00020   //outermost_context().updateHistory( tr );
00021 }
00022 
00023 Operations::~Operations()
00024 {
00025   //TransitionRecord tr( stateName(), false );
00026   //outermost_context().updateHistory( tr );
00027 }
00028 
00029 void Operations::processI2OFragment( I2OChain& frag ) const
00030 {
00031   do_processI2OFragment( frag );
00032 }
00033 
00034 void Operations::noFragmentToProcess() const
00035 {
00036   do_noFragmentToProcess();
00037 }
00038 
00039 std::string Operations::stateName() const
00040 {
00041   return do_stateName();
00042 }
00043 
00044 void Operations::moveToFailedState( xcept::Exception& exception ) const
00045 {
00046   do_moveToFailedState( exception );
00047 }
00048 
00049 
00051 // Default implementation for (some) virtual functions.
00053 
00054 void 
00055 Operations::do_processI2OFragment( I2OChain& frag ) const
00056 {
00057   //std::cout << stateName() << "::processI2OFragment()" << std::endl;
00058 
00059   // 20-Mar-2009, KAB: if we get a fragment when we are not supposed to get
00060   // one, should we still send a discard message to the resource broker?
00061   // If we don't, couldn't that cause problems upstream?  If we do, though,
00062   // we could end up sending duplicate discard messages (one per fragment).
00063   // At a minimum, we should make sure that we don't try to use the discard
00064   // manager before it is available.
00065   // Of course, if we want to do this, we need to implement a way to get
00066   // a handle to the discard manager since outermost_context() doesn't
00067   // actually work here.
00068   //
00069   //if ( outermost_context().getSharedResources().get() != 0 &&
00070   //     outermost_context().getSharedResources()->discardManager_.get() != 0)
00071   //  {
00072   //    outermost_context().getSharedResources()->discardManager_->sendDiscardMessage(frag);
00073   //  }
00074 }
00075 
00076 
00077 void Operations::safeEntryAction()
00078 {
00079   const std::string unknown = "unknown exception";
00080   std::string msg = "Error going into " + stateName() + " state: ";
00081   try
00082   {
00083     do_entryActionWork();
00084   }
00085   catch( xcept::Exception& e )
00086   {
00087     XCEPT_DECLARE_NESTED( stor::exception::StateTransition,
00088       sentinelException, msg, e );
00089     moveToFailedState( sentinelException );
00090   }
00091   catch( std::exception& e )
00092   {
00093     msg += e.what();
00094     XCEPT_DECLARE( stor::exception::StateTransition,
00095       sentinelException, msg );
00096     moveToFailedState( sentinelException );
00097   }
00098   catch(...)
00099   {
00100     msg += "unknown exception";
00101     XCEPT_DECLARE( stor::exception::StateTransition,
00102       sentinelException, msg );
00103     moveToFailedState( sentinelException );
00104   }
00105 }
00106 
00107 
00108 void Operations::safeExitAction()
00109 {
00110   const std::string unknown = "unknown exception";
00111   std::string msg = "Error leaving " + stateName() + " state: ";
00112   try
00113   {
00114     do_exitActionWork();
00115   }
00116   catch( xcept::Exception& e )
00117   {
00118     XCEPT_DECLARE_NESTED( stor::exception::StateTransition,
00119       sentinelException, msg, e );
00120     moveToFailedState( sentinelException );
00121   }
00122   catch( std::exception& e )
00123   {
00124     msg += e.what();
00125     XCEPT_DECLARE( stor::exception::StateTransition,
00126       sentinelException, msg );
00127     moveToFailedState( sentinelException );
00128   }
00129   catch(...)
00130   {
00131     msg += "unknown exception";
00132     XCEPT_DECLARE( stor::exception::StateTransition,
00133       sentinelException, msg );
00134     moveToFailedState( sentinelException );
00135   }
00136 }
00137 
00138 
00139 void 
00140 Operations::do_noFragmentToProcess() const
00141 {
00142   //std::cout << stateName() << "::noFragmentToProcess()" << std::endl;
00143 }
00144 
00145 
00146 
00153