TracingSegment.cpp

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/segment/TracingSegment.cpp#11 $
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 #include "fennel/common/CommonPreamble.h"
00025 #include "fennel/segment/TracingSegment.h"
00026 #include "fennel/cache/CachePage.h"
00027 
00028 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/segment/TracingSegment.cpp#11 $");
00029 
00030 // NOTE:  tracing convention is TRACE_FINE for page allocation/deallocation;
00031 // TRACE_FINER for page writes; and TRACE_FINEST for all page accesses.  Higher
00032 // levels should not be used; see SegmentFactory::newTracingSegment for why.
00033 
00034 TracingSegment::TracingSegment(
00035     SharedSegment pDelegateSegment,
00036     SharedTraceTarget pTraceTarget,
00037     std::string sourceName)
00038     : DelegatingSegment(pDelegateSegment),
00039       TraceSource(pTraceTarget,sourceName)
00040 {
00041     FENNEL_TRACE(TRACE_FINE,"constructor");
00042 }
00043 
00044 TracingSegment::~TracingSegment()
00045 {
00046     FENNEL_TRACE(TRACE_FINE,"destructor");
00047 }
00048 
00049 void TracingSegment::setPageSuccessor(PageId pageId, PageId successorId)
00050 {
00051     FENNEL_TRACE(
00052         TRACE_FINER,
00053         "setPageSuccessor of PageId " << std::hex << pageId
00054         << " to PageId " << std::hex << successorId);
00055     DelegatingSegment::setPageSuccessor(pageId,successorId);
00056 }
00057 
00058 BlockId TracingSegment::translatePageId(PageId pageId)
00059 {
00060     BlockId blockId = DelegatingSegment::translatePageId(pageId);
00061     FENNEL_TRACE(
00062         TRACE_FINEST,
00063         "translatePageId " << std::hex << pageId << " returns BlockId "
00064         << std::hex << blockId);
00065     return blockId;
00066 }
00067 
00068 PageId TracingSegment::translateBlockId(BlockId blockId)
00069 {
00070     PageId pageId = DelegatingSegment::translateBlockId(blockId);
00071     FENNEL_TRACE(
00072         TRACE_FINEST,
00073         "translateBlockId " << std::hex << blockId << " returns PageId "
00074         << std::hex << pageId);
00075     return pageId;
00076 }
00077 
00078 PageId TracingSegment::allocatePageId(PageOwnerId ownerId)
00079 {
00080     PageId pageId = DelegatingSegment::allocatePageId(ownerId);
00081     FENNEL_TRACE(
00082         TRACE_FINE,
00083         "allocatePageId for PageOwnerId " << std::hex << ownerId
00084         << " returns PageId " << std::hex << pageId);
00085     return pageId;
00086 }
00087 
00088 bool TracingSegment::ensureAllocatedSize(BlockNum nPages)
00089 {
00090     bool b = DelegatingSegment::ensureAllocatedSize(nPages);
00091     FENNEL_TRACE(
00092         TRACE_FINE,
00093         "ensureAllocatedSize of " << nPages << " pages"
00094         << " returns " << b);
00095     return b;
00096 }
00097 
00098 void TracingSegment::deallocatePageRange(PageId startPageId,PageId endPageId)
00099 {
00100     FENNEL_TRACE(
00101         TRACE_FINE,
00102         "deallocatePageRange " << std::hex << startPageId << ", "
00103         << std::hex << endPageId);
00104     DelegatingSegment::deallocatePageRange(startPageId,endPageId);
00105 }
00106 
00107 void TracingSegment::notifyPageMap(CachePage &page)
00108 {
00109     FENNEL_TRACE(
00110         TRACE_FINEST,
00111         "notifyPageMap @" << &page << " BlockId "
00112         << std::hex << page.getBlockId());
00113     DelegatingSegment::notifyPageMap(page);
00114 }
00115 
00116 void TracingSegment::notifyPageUnmap(CachePage &page)
00117 {
00118     FENNEL_TRACE(
00119         TRACE_FINEST,
00120         "notifyPageUnmap @" << &page << " BlockId "
00121         << std::hex << page.getBlockId());
00122     DelegatingSegment::notifyPageUnmap(page);
00123 }
00124 
00125 void TracingSegment::notifyAfterPageRead(CachePage &page)
00126 {
00127     FENNEL_TRACE(
00128         TRACE_FINEST,
00129         "notifyAfterPageRead @" << &page << " BlockId "
00130         << std::hex << page.getBlockId());
00131     DelegatingSegment::notifyAfterPageRead(page);
00132 }
00133 
00134 void TracingSegment::notifyPageDirty(CachePage &page,bool bDataValid)
00135 {
00136     FENNEL_TRACE(
00137         TRACE_FINER,
00138         "notifyPageDirty @" << &page << " BlockId "
00139         << std::hex << page.getBlockId());
00140     DelegatingSegment::notifyPageDirty(page,bDataValid);
00141 }
00142 
00143 void TracingSegment::notifyBeforePageFlush(CachePage &page)
00144 {
00145     FENNEL_TRACE(
00146         TRACE_FINER,
00147         "notifyBeforePageFlush @" << &page << " BlockId "
00148         << std::hex << page.getBlockId());
00149     DelegatingSegment::notifyBeforePageFlush(page);
00150 }
00151 
00152 void TracingSegment::notifyAfterPageFlush(CachePage &page)
00153 {
00154     FENNEL_TRACE(
00155         TRACE_FINER,
00156         "notifyAfterPageFlush @" << &page << " BlockId "
00157         << std::hex << page.getBlockId());
00158     DelegatingSegment::notifyAfterPageFlush(page);
00159 }
00160 
00161 void TracingSegment::delegatedCheckpoint(
00162     Segment &delegatingSegment,
00163     CheckpointType checkpointType)
00164 {
00165     FENNEL_TRACE(
00166         TRACE_FINER,
00167         "checkpoint type=" << checkpointType);
00168     DelegatingSegment::delegatedCheckpoint(delegatingSegment,checkpointType);
00169 }
00170 
00171 MappedPageListener *TracingSegment::getMappedPageListener(BlockId blockId)
00172 {
00173     // We need to retrieve the listener associated with the delegating
00174     // segment, and then map the return value back to the parent tracing
00175     // segment.
00176     MappedPageListener *pListener =
00177         getDelegateSegment()->getMappedPageListener(blockId);
00178     FENNEL_TRACE(
00179         TRACE_FINEST,
00180         "getMappedPageListener for blockId " << std::hex << blockId
00181             << " = " << std::hex << pListener);
00182 
00183     return pListener->getTracingListener();
00184 }
00185 
00186 MappedPageListener *TracingSegment::notifyAfterPageCheckpointFlush(
00187     CachePage &page)
00188 {
00189     // We need to retrieve the listener associated with the delegating
00190     // segment, and then map the return value back to the parent tracing
00191     // segment.
00192     MappedPageListener *pListener =
00193         getDelegateSegment()->notifyAfterPageCheckpointFlush(page);
00194     if (pListener == NULL) {
00195         FENNEL_TRACE(
00196             TRACE_FINER,
00197             "notifyAfterPageCheckpointFlush for blockId " << std::hex <<
00198                 page.getBlockId() << " = NULL");
00199         return pListener;
00200     } else {
00201         FENNEL_TRACE(
00202             TRACE_FINER,
00203             "notifyAfterPageCheckpointFlush for blockId " << std::hex <<
00204                 page.getBlockId() << " = " << std::hex << pListener);
00205         return pListener->getTracingListener();
00206     }
00207 }
00208 
00209 bool TracingSegment::isWriteVersioned()
00210 {
00211     bool b = getDelegateSegment()->isWriteVersioned();
00212     FENNEL_TRACE(TRACE_FINEST,"isWriteVersioned returns " << b);
00213     return b;
00214 }
00215 
00216 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/segment/TracingSegment.cpp#11 $");
00217 
00218 // End TracingSegment.cpp

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