00001 /* 00002 // $Id: //open/dev/fennel/test/ExecStreamTestBase.cpp#20 $ 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) 2004-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 #include "fennel/common/CommonPreamble.h" 00025 #include "fennel/test/ExecStreamTestBase.h" 00026 #include "fennel/exec/ExecStreamGraph.h" 00027 #include "fennel/exec/ExecStreamGraphEmbryo.h" 00028 #include "fennel/exec/ExecStream.h" 00029 #include "fennel/exec/DfsTreeExecStreamScheduler.h" 00030 #include "fennel/exec/SimpleExecStreamGovernor.h" 00031 #include "fennel/cache/Cache.h" 00032 00033 #include <boost/test/test_tools.hpp> 00034 00035 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/test/ExecStreamTestBase.cpp#20 $"); 00036 00037 SharedExecStreamGraph ExecStreamTestBase::newStreamGraph() 00038 { 00039 SharedExecStreamGraph pGraph = ExecStreamGraph::newExecStreamGraph(); 00040 pGraph->enableDummyTxnId(true); 00041 return pGraph; 00042 } 00043 00044 SharedExecStreamGraphEmbryo 00045 ExecStreamTestBase::newStreamGraphEmbryo(SharedExecStreamGraph g) 00046 { 00047 return SharedExecStreamGraphEmbryo( 00048 new ExecStreamGraphEmbryo( 00049 g, pScheduler, pCache, pSegmentFactory)); 00050 } 00051 00052 ExecStreamScheduler *ExecStreamTestBase::newScheduler() 00053 { 00054 return new DfsTreeExecStreamScheduler( 00055 shared_from_this(), 00056 "DfsTreeExecStreamScheduler"); 00057 } 00058 00059 ExecStreamGovernor *ExecStreamTestBase::newResourceGovernor( 00060 ExecStreamResourceKnobs const &knobSettings, 00061 ExecStreamResourceQuantity const &resourcesAvailable) 00062 { 00063 return new SimpleExecStreamGovernor( 00064 knobSettings, resourcesAvailable, shared_from_this(), 00065 "SimpleExecStreamGovernor"); 00066 } 00067 00068 void ExecStreamTestBase::testCaseSetUp() 00069 { 00070 SegStorageTestBase::testCaseSetUp(); 00071 openStorage(DeviceMode::createNew); 00072 pScheduler.reset(newScheduler()); 00073 ExecStreamResourceKnobs knobSettings; 00074 knobSettings.cacheReservePercentage = DefaultCacheReservePercent; 00075 knobSettings.expectedConcurrentStatements = DefaultConcurrentStatements; 00076 ExecStreamResourceQuantity resourcesAvailable; 00077 resourcesAvailable.nCachePages = nMemPages; 00078 pResourceGovernor.reset( 00079 newResourceGovernor(knobSettings, resourcesAvailable)); 00080 } 00081 00082 void ExecStreamTestBase::testCaseTearDown() 00083 { 00084 // first stop the scheduler 00085 if (pScheduler) { 00086 pScheduler->stop(); 00087 } 00088 pCacheAccessor.reset(); 00089 // destroy the graph 00090 tearDownExecStreamTest(); 00091 // free the scheduler last, since an ExecStreamGraph holds a raw Scheduler 00092 // ptr 00093 pScheduler.reset(); 00094 assert(pResourceGovernor.unique()); 00095 pResourceGovernor.reset(); 00096 SegStorageTestBase::testCaseTearDown(); 00097 } 00098 00099 void ExecStreamTestBase::tearDownExecStreamTest() 00100 { 00101 } 00102 00103 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/test/ExecStreamTestBase.cpp#20 $"); 00104 00105 // End ExecStreamTestBase.cpp