df_Writer Class Reference
[IVD Data format.]

#include <df.h>

Inheritance diagram for df_Writer:

Inheritance graph
[legend]
Collaboration diagram for df_Writer:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 669 of file df.h.


Public Member Functions

 df_Writer (UInt32_t a_blkType, bbt_BufType_t a_bufType, UInt32_t a_blkSize)
virtual ~df_Writer ()
virtual void EndOfData ()
void WaitAllReaders () const
void NewFRIBuffer (const string &a_id, bool a_createNew=false, bool a_createOnTmp=false, bool a_createInto=false, cmn_Path a_intoPath="", const string a_extension="")
void NewFRIBuffer (const string &a_id, ivd_MigrationID_t a_migrationID, UInt32_t a_copyNumber, UInt32_t a_mediumKey, UInt32_t a_medVolNum, i_FSC_ptr a_fsc)
virtual void NewDiskBuffer (const string &a_id, const string &a_diskBufferFS, const ivd_FileSize_t a_dbFileSize, bool a_append=false)
virtual void NewNetBuffer (i_UploadAgent_ptr a_uploadAgt)
virtual void NewStdIOBuffer (const string &a_id)
virtual void Go ()

Protected Member Functions

virtual void GetNewBlock ()
virtual void FlushBlock ()

Private Attributes

 log_CLASSID_m
auto_ptr< df_BlockManagerm_manager
auto_ptr< df_MgrWriterm_mgrWriter

Constructor & Destructor Documentation

df_Writer::df_Writer ( UInt32_t  a_blkType,
bbt_BufType_t  a_bufType,
UInt32_t  a_blkSize 
)

Definition at line 33 of file df_writer.cpp.

References bbt_DISK_BUF, bbt_DISK_FRI, bbt_DISK_FRI_RECOVERY, bbt_REMOTE_BUF, bbt_SHMEM_BUF, bbt_TAPE_READ, df_BlockManager, df_DISKBUF_BLOCKS_c, df_DISKFRI_BLOCKS_c, df_MEMBUF_BLOCKS_c, df_REMOTEBUF_BLOCKS_c, df_TAPEBUF_c, log_FUNC_m, and m_manager.

00038   : df_BlockProxyWriter(a_blkType, a_blkSize) {
00039 
00040     log_FUNC_m(df_Writer);
00041 
00042     UInt32_t count(4);
00043 
00044     switch (a_bufType) {
00045         case bbt_DISK_BUF:          count = df_DISKBUF_BLOCKS_c; break;
00046         case bbt_SHMEM_BUF:         count = df_MEMBUF_BLOCKS_c; break;
00047         case bbt_REMOTE_BUF:        count = df_REMOTEBUF_BLOCKS_c; break;
00048         case bbt_DISK_FRI:          count = df_DISKFRI_BLOCKS_c; break;
00049         case bbt_DISK_FRI_RECOVERY: count = df_DISKFRI_BLOCKS_c; break;
00050         case bbt_TAPE_READ:         count = df_TAPEBUF_c; break;
00051     };
00052 
00053     m_manager.reset(new df_BlockManager(a_blkSize, count) );
00054 
00055 }

df_Writer::~df_Writer (  )  [virtual]

Definition at line 58 of file df_writer.cpp.

References log_FUNC_m.

00058                       {
00059     log_FUNC_m(~df_Writer);
00060 }


Member Function Documentation

void df_Writer::EndOfData (  )  [virtual]

Reimplemented from df_BlockProxyWriter.

Definition at line 62 of file df_writer.cpp.

References df_BlockProxyWriter::EndOfData(), log_FUNC_m, m_mgrWriter, and NULL.

Referenced by df_FRI::MediumVolumeEnd().

00062                           {
00063     log_FUNC_m(EndOfData);
00064 
00065     // flush current block - there is probably some data there
00066     df_BlockProxyWriter::EndOfData();
00067 
00068     // Just destroy the MgrWriter. It will set end of data.
00069     if (m_mgrWriter.get() != NULL) {
00070         m_mgrWriter.reset();
00071     };
00072 }

Here is the call graph for this function:

Here is the caller graph for this function:

void df_Writer::WaitAllReaders (  )  const

Definition at line 74 of file df_writer.cpp.

References log_FUNC_m, and m_manager.

Referenced by df_FRI::MediumVolumeEnd().

00074                                      {
00075     log_FUNC_m(WaitAllReaders);
00076 
00077     m_manager->WaitAllReaders();
00078 }

Here is the caller graph for this function:

void df_Writer::NewFRIBuffer ( const string &  a_id,
bool  a_createNew = false,
bool  a_createOnTmp = false,
bool  a_createInto = false,
cmn_Path  a_intoPath = "",
const string  a_extension = "" 
)

Definition at line 124 of file df_writer.cpp.

References log_FUNC_A_m, m_manager, and cmn_Thread::Start().

Referenced by df_FRI::MediumVolumeStart(), and NewFRIBuffer().

00130                                  {
00131 
00132     log_FUNC_A_m(NewFRIBuffer, "id: " << a_id);
00133 
00134     blk_DiskFRIWriter *fri_p =
00135         new blk_DiskFRIWriter( *m_manager.get(), 
00136                                 a_id,
00137                                 a_createOnTmp, 
00138                                 a_createNew, 
00139                                 a_createInto, 
00140                                 a_intoPath, 
00141                                 a_extension);
00142     fri_p->Start();
00143 }

Here is the call graph for this function:

Here is the caller graph for this function:

void df_Writer::NewFRIBuffer ( const string &  a_id,
ivd_MigrationID_t  a_migrationID,
UInt32_t  a_copyNumber,
UInt32_t  a_mediumKey,
UInt32_t  a_medVolNum,
i_FSC_ptr  a_fsc 
)

Definition at line 145 of file df_writer.cpp.

References log_FUNC_A_m, m_manager, NewFRIBuffer(), and cmn_Thread::Start().

00151                                {
00152 
00153     log_FUNC_A_m(NewFRIBuffer,
00154         "id: " << a_id <<
00155         "migID: " << a_migrationID <<
00156         "copy: " << a_copyNumber);
00157 
00158     blk_DiskFRIWriter *fri_p =
00159         new blk_DiskFRIWriter(
00160             *m_manager.get(),
00161             a_id,
00162             a_migrationID,
00163             a_copyNumber,
00164             a_mediumKey,
00165             a_medVolNum,
00166             a_fsc);
00167 
00168     fri_p->Start();
00169 }

Here is the call graph for this function:

void df_Writer::NewDiskBuffer ( const string &  a_id,
const string &  a_diskBufferFS,
const ivd_FileSize_t  a_dbFileSize,
bool  a_append = false 
) [virtual]

Implements df_BlockProxyWriter.

Definition at line 172 of file df_writer.cpp.

References log_FUNC_A_m, m_manager, and cmn_Thread::Start().

00175                                               {
00176                                 
00177     log_FUNC_A_m(NewDiskBuffer, "file: " << a_diskBufferFS << a_id);
00178 
00179     blk_DiskBufferWriter *db_p =
00180         new blk_DiskBufferWriter(*m_manager.get(), a_id, a_diskBufferFS, a_diskBufferSize, a_append);
00181     db_p->Start();
00182 }

Here is the call graph for this function:

void df_Writer::NewNetBuffer ( i_UploadAgent_ptr  a_uploadAgt  )  [virtual]

Reimplemented from df_BlockProxyWriter.

Definition at line 185 of file df_writer.cpp.

References log_FUNC_A_m, m_manager, and cmn_Thread::Start().

00185                                                           {
00186     log_FUNC_A_m(NewNetBuffer, "uloadAgt: " << a_uploadAgt);
00187 
00188     blk_NetWriter *nw_p =
00189         new blk_NetWriter(*m_manager.get(), a_uploadAgt);
00190     nw_p->Start();
00191 }

Here is the call graph for this function:

void df_Writer::NewStdIOBuffer ( const string &  a_id  )  [virtual]

Reimplemented from df_BlockProxyWriter.

Definition at line 193 of file df_writer.cpp.

References log_FUNC_m, m_manager, and cmn_Thread::Start().

00193                                                     {
00194     log_FUNC_m(NewStdIOBuffer);
00195 
00196     blk_StdIOWriter *db_p =
00197         new blk_StdIOWriter(*m_manager.get(), a_fName);
00198     db_p->Start();
00199 }

Here is the call graph for this function:

void df_Writer::Go (  )  [virtual]

Reimplemented from df_BlockProxyWriter.

Definition at line 201 of file df_writer.cpp.

References df_BlockProxyWriter::Go(), log_FUNC_m, m_manager, and m_mgrWriter.

Referenced by df_FRI::MediumVolumeStart().

00201                    {
00202     log_FUNC_m(Go);
00203 
00204     m_mgrWriter.reset(new df_MgrWriter(*m_manager.get()) );
00205 
00206     df_BlockProxyWriter::Go();
00207 
00208 }

Here is the call graph for this function:

Here is the caller graph for this function:

void df_Writer::GetNewBlock (  )  [protected, virtual]

Reimplemented from df_BlockProxyWriter.

Definition at line 80 of file df_writer.cpp.

References df_BlockProxyWriter::GetNewBlock(), ie_IMPOSSIBLE, df_DataBlock::IsClosed(), log_FUNC_INT_m, df_BlockProxyWriter::m_curBlk_p, and m_mgrWriter.

00080                             {
00081     log_FUNC_INT_m(GetNewBlock);
00082 
00083     df_BlockProxyWriter::GetNewBlock();
00084 
00085     // Blocks if all blocks in df_BlockManager are used (closed)
00086     m_curBlk_p = m_mgrWriter->GetFree();
00087 
00088     if (m_curBlk_p->IsClosed()) {
00089         throw ivd_InternalError(ie_IMPOSSIBLE, "Got closed block in GetNewBlock().");
00090     }
00091 }

Here is the call graph for this function:

void df_Writer::FlushBlock (  )  [protected, virtual]

Reimplemented from df_BlockProxyWriter.

Definition at line 94 of file df_writer.cpp.

References df_BlockProxyWriter::FlushBlock(), df_DataBlock::GetUsedSize(), hton(), ie_DF_INV_BLK, log_FUNC_INT_m, log_FUNC_m, log_WRN_m, df_BlockProxyWriter::m_blkHdr_p, df_BlockProxyWriter::m_curBlk_p, m_manager, m_mgrWriter, NULL, and df_BlockHeader_t::used.

00094                            {
00095     log_FUNC_INT_m(FlushBlock);
00096 
00097     df_BlockProxyWriter::FlushBlock();
00098 
00099     if (m_blkHdr_p != NULL) {
00100         UInt32_t blkUsed = m_curBlk_p->GetUsedSize();
00101         if (blkUsed < sizeof(df_BlockHeader_t)) {
00102             log_FUNC_m(FlushBlock);
00103             throw ivd_InternalError(
00104                 ie_DF_INV_BLK,
00105                 "BUG: m_hasBlkHdr set but block probably doesn't contain header.");
00106         }
00107 
00108         if (m_manager->GetBlocksWritten() > 0) {
00109             if (blkUsed == sizeof(df_BlockHeader_t)) {
00110                 log_FUNC_m(FlushBlock);
00111                 // TODO: should we really just ignore? - maybe only for last block?
00112                 log_WRN_m("CHECK THIS: FlushBlock: no records in block - ignored");
00113             }
00114         }
00115 
00116         m_blkHdr_p->used = hton(blkUsed);
00117     }
00118     m_mgrWriter->Flush();
00119     m_curBlk_p = NULL;
00120 }

Here is the call graph for this function:


Member Data Documentation

Reimplemented from df_BlockProxyWriter.

Definition at line 716 of file df.h.

auto_ptr<df_MgrWriter> df_Writer::m_mgrWriter [private]

Definition at line 719 of file df.h.

Referenced by EndOfData(), FlushBlock(), GetNewBlock(), and Go().


The documentation for this class was generated from the following files:

Generated on Mon Feb 27 19:13:58 2012 for OPENARCHIVE by  doxygen 1.5.6