ExecStreamGovernor.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/exec/ExecStreamGovernor.h#9 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2005-2009 SQLstream, Inc.
00006 // Copyright (C) 2005-2009 LucidEra, Inc.
00007 // Portions Copyright (C) 1999-2009 John V. Sichi
00008 //
00009 // This program is free software; you can redistribute it and/or modify it
00010 // under the terms of the GNU General Public License as published by the Free
00011 // Software Foundation; either version 2 of the License, or (at your option)
00012 // any later version approved by The Eigenbase Project.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with this program; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 */
00023 
00024 #ifndef Fennel_ExecStreamGovernor_Included
00025 #define Fennel_ExecStreamGovernor_Included
00026 
00027 #include "fennel/common/SharedTypes.h"
00028 #include "fennel/common/TraceSource.h"
00029 #include "fennel/common/StatsSource.h"
00030 #include "fennel/exec/ExecStreamDefs.h"
00031 #include "fennel/synch/SynchObj.h"
00032 
00033 #include <boost/utility.hpp>
00034 #include <map>
00035 
00036 FENNEL_BEGIN_NAMESPACE
00037 
00041 enum ExecStreamResourceKnobType {
00042     EXEC_KNOB_EXPECTED_CONCURRENT_STATEMENTS,
00043     EXEC_KNOB_CACHE_RESERVE_PERCENTAGE
00044 };
00045 
00050 struct FENNEL_EXEC_EXPORT ExecStreamResourceKnobs
00051 {
00055     uint expectedConcurrentStatements;
00056 
00060     uint cacheReservePercentage;
00061 };
00062 
00066 enum ExecStreamResourceType {
00067     EXEC_RESOURCE_THREADS,
00068     EXEC_RESOURCE_CACHE_PAGES
00069 };
00070 
00074 struct FENNEL_EXEC_EXPORT ExecStreamResourceRequirements
00075 {
00076     uint minReqt;
00077     uint optReqt;
00078     ExecStreamResourceSettingType optType;
00079 };
00080 
00089 class FENNEL_EXEC_EXPORT ExecStreamGovernor
00090     : public boost::noncopyable, public virtual TraceSource,
00091     public StatsSource
00092 {
00093 protected:
00094     typedef std::map<ExecStreamGraph *, SharedExecStreamResourceQuantity>
00095         ExecStreamGraphResourceMap;
00096 
00100     ExecStreamResourceKnobs knobSettings;
00101 
00106     ExecStreamResourceQuantity resourcesAvailable;
00107 
00111     ExecStreamResourceQuantity resourcesAssigned;
00112 
00117     ExecStreamGraphResourceMap resourceMap;
00118 
00122     StrictMutex mutex;
00123 
00134     explicit ExecStreamGovernor(
00135         ExecStreamResourceKnobs const &knobSettings,
00136         ExecStreamResourceQuantity const &resourcesAvailable,
00137         SharedTraceTarget pTraceTarget,
00138         std::string name);
00139 
00148     void traceCachePageRequest(
00149         uint assigned, ExecStreamResourceRequirements const &reqt,
00150         std::string const &name);
00151 
00152 public:
00153     virtual ~ExecStreamGovernor();
00154 
00168     virtual bool setResourceKnob(
00169         ExecStreamResourceKnobs const &knob,
00170         ExecStreamResourceKnobType knobType) = 0;
00171 
00185     virtual bool setResourceAvailability(
00186         ExecStreamResourceQuantity const &available,
00187         ExecStreamResourceType resourceType) = 0;
00188 
00196     virtual void requestResources(ExecStreamGraph &graph) = 0;
00197 
00205     virtual void returnResources(ExecStreamGraph &graph) = 0;
00206 
00207     // implement StatsSource
00208     void writeStats(StatsTarget &target);
00209 };
00210 
00211 FENNEL_END_NAMESPACE
00212 
00213 #endif
00214 
00215 // End ExecStreamGovernor.h

Generated on Mon Jun 22 04:00:18 2009 for Fennel by  doxygen 1.5.1