vrj::PerformanceMediator Class Reference

Performance mediator used by the kernel to communicate with performance monitoring plug-ins. More...

#include <vrj/Performance/PerformanceMediator.h>

Collaboration diagram for vrj::PerformanceMediator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PerformanceMediator ()
virtual ~PerformanceMediator ()
void setPerfPlugin (vrj::PerfPlugin *plugin)

Protected Member Functions

void loadPerfPlugin ()
 Enables the remote performance monitoring interface object.
 PerformanceMediator (const PerformanceMediator &)
void operator= (const PerformanceMediator &)

Detailed Description

Performance mediator used by the kernel to communicate with performance monitoring plug-ins.

Definition at line 57 of file PerformanceMediator.h.


Constructor & Destructor Documentation

vrj::PerformanceMediator::PerformanceMediator (  ) 

Definition at line 57 of file PerformanceMediator.cpp.

References loadPerfPlugin().

00058    : mPerfIf(NULL)
00059    {
00060       loadPerfPlugin();
00061    }

vrj::PerformanceMediator::~PerformanceMediator (  )  [virtual]

Definition at line 63 of file PerformanceMediator.cpp.

References vrj::PerfPlugin::disable(), and vrj::PerfPlugin::isEnabled().

00064    {
00065       if ( NULL != mPerfIf && mPerfIf->isEnabled() )
00066       {
00067          mPerfIf->disable();
00068 
00069          delete mPerfIf;
00070          mPerfIf = NULL;
00071       }
00072    }

vrj::PerformanceMediator::PerformanceMediator ( const PerformanceMediator  )  [inline, protected]

Definition at line 69 of file PerformanceMediator.h.

00070       {
00071          ;
00072       }


Member Function Documentation

void vrj::PerformanceMediator::setPerfPlugin ( vrj::PerfPlugin plugin  ) 

Definition at line 198 of file PerformanceMediator.cpp.

References vrj::PerfPlugin::disable(), vrj::PerfPlugin::enable(), vrj::PerfPlugin::init(), and vrj::PerfPlugin::isEnabled().

00199    {
00200       // If we already have a remote performance monitoring plug-in, discard it
00201       // first.
00202       if ( NULL != mPerfIf )
00203       {
00204          vprDEBUG(jcclDBG_RECONFIG, vprDBG_STATE_LVL)
00205          << "[PerformanceMediator::setPerfPlugin()] "
00206             << "Removing old remote performance monitoring plug-in\n"
00207             << vprDEBUG_FLUSH;
00208 
00209          if ( mPerfIf->isEnabled() )
00210          {
00211             mPerfIf->disable();
00212          }
00213 
00214          delete mPerfIf;
00215       }
00216 
00217       vprDEBUG(jcclDBG_RECONFIG, vprDBG_VERB_LVL)
00218       << "[PerformanceMediator::setPerfPlugin()] "
00219          << "Enabling new remote performance monitoring plug-in\n"
00220          << vprDEBUG_FLUSH;
00221       mPerfIf = plugin;
00222 
00223       if ( NULL != mPerfIf )
00224       {
00225          // Attempt to initialize the remote performance monitoring component.
00226          if ( mPerfIf->init().success() )
00227          {
00228             // Now, attempt to enable remote performance monitoring hooks.
00229             if ( ! mPerfIf->enable().success() )
00230             {
00231                vprDEBUG(jcclDBG_RECONFIG, vprDBG_WARNING_LVL)
00232                << clrOutBOLD(clrYELLOW, "WARNING:")
00233                << " Failed to enable remote performance monitoring hooks.\n"
00234                   << vprDEBUG_FLUSH;
00235                delete mPerfIf;
00236                mPerfIf = NULL;
00237             }
00238          }
00239          // Initialization failed.
00240          else
00241          {
00242             vprDEBUG(jcclDBG_RECONFIG, vprDBG_WARNING_LVL)
00243             << clrOutBOLD(clrYELLOW, "WARNING:")
00244             << " Failed to initialize remote performance monitoring hooks.\n"
00245                << vprDEBUG_FLUSH;
00246             delete mPerfIf;
00247             mPerfIf = NULL;
00248          }
00249       }
00250    }

void vrj::PerformanceMediator::loadPerfPlugin (  )  [protected]

Enables the remote performance monitoring interface object.

Definition at line 122 of file PerformanceMediator.cpp.

Referenced by PerformanceMediator().

00123    {
00124       vprASSERT(NULL == mPerfIf && "PerformanceMediator interface object already instantiated.");
00125 
00126       const std::string vj_base_dir("VJ_BASE_DIR");
00127       std::string base_dir;
00128 
00129       if ( ! vpr::System::getenv(vj_base_dir, base_dir).success() )
00130       {
00131          return;
00132       }
00133 
00134       const std::string no_perf_plugin("NO_PERF_PLUGIN");
00135       std::string junk;
00136 
00137       // If the user has the environment variable NO_PERF_PLUGIN set (to any
00138       // value), do not attempt to load the plug-in.
00139       if ( vpr::System::getenv(no_perf_plugin, junk).success() )
00140       {
00141          vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00142             << "Remote performance visualization plug-in loading disabled "
00143             << "via NO_PERF_PLUGIN." << std::endl << vprDEBUG_FLUSH;
00144          return;
00145       }
00146 
00147 #if defined(VPR_OS_IRIX) && defined(_ABIN32)
00148       const std::string bit_suffix("32");
00149 #elif defined(VPR_OS_IRIX) && defined(_ABI64) || \
00150       defined(VPR_OS_Linux) && defined(__x86_64__)
00151       const std::string bit_suffix("64");
00152 #else
00153       const std::string bit_suffix("");
00154 #endif
00155 
00156       std::vector<fs::path> search_path(1);
00157       search_path[0] = fs::path(base_dir, fs::native) /
00158                        (std::string("lib") + bit_suffix) /
00159                        std::string("vrjuggler") / std::string("plugins");
00160 
00161       // In the long run, we may not want to hard-code the base name of the
00162       // plug-in we load.  If we ever reach a point where we have multiple ways
00163       // of implementing remote performance monitoring, we could have options
00164       // for which plug-in to load.
00165       const std::string perf_mon_dso("corba_perf_mon");
00166       const std::string init_func("initPlugin");
00167       Callable functor(this);
00168       vpr::ReturnStatus status;
00169       status =
00170          vpr::LibraryLoader::findDSOAndCallEntryPoint(perf_mon_dso,
00171                                                       search_path, init_func,
00172                                                       functor, mPluginDSO);
00173 
00174       if ( ! status.success() )
00175       {
00176          vprDEBUG(vprDBG_ALL, vprDBG_WARNING_LVL)
00177             << "Failed to load the remote performance monitoring plug-in."
00178             << std::endl << vprDEBUG_FLUSH;
00179          vprDEBUG_NEXT(vprDBG_ALL, vprDBG_WARNING_LVL)
00180             << "Remote performance monitoring is disabled." << std::endl
00181             << vprDEBUG_FLUSH;
00182          vprDEBUG_NEXT(vprDBG_ALL, vprDBG_WARNING_LVL)
00183             << "(This is not a fatal error.)" << std::endl << vprDEBUG_FLUSH;
00184 
00185          // The plug-in is not usable, so we can unload it.
00186          if ( mPluginDSO.get() != NULL )
00187          {
00188             if ( mPluginDSO->isLoaded() )
00189             {
00190                mPluginDSO->unload();
00191             }
00192 
00193             mPluginDSO.reset();
00194          }
00195       }
00196    }

void vrj::PerformanceMediator::operator= ( const PerformanceMediator  )  [inline, protected]

Definition at line 73 of file PerformanceMediator.h.

00074       {
00075          ;
00076       }


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:58:31 2007 for VR Juggler by  doxygen 1.5.1