std_chain_storage.hpp

См. документацию.
00001 /*
00002 
00003 Copyright (c) 2002-2005, Yauheni Akhotnikau
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008 
00009 - Redistributions of source code must retain the above copyright notice, this
00010 list of conditions and the following disclaimer.
00011 
00012 - Redistributions in binary form must reproduce the above copyright notice, this
00013 list of conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.
00015 
00016 - The name of the author may not be used to endorse or promote products derived
00017 from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00022 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00024 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00027 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00028 OF SUCH DAMAGE.
00029 
00030 */
00031 
00038 #if !defined( _OESS_1__DB__STORAGE__IMPL__STD_CHAIN_STORAGE_HPP_ )
00039 #define _OESS_1__DB__STORAGE__IMPL__STD_CHAIN_STORAGE_HPP_
00040 
00041 #include <auto_ptr_3/h/obj_ptr.hpp>
00042 
00043 #include <oess_1/file/h/file.hpp>
00044 
00045 #include <oess_1/db/storage/h/dirty_page_storage.hpp>
00046 #include <oess_1/db/storage/h/chain_storage.hpp>
00047 
00048 #include <oess_1/db/storage/trx/h/types.hpp>
00049 
00050 #include <oess_1/db/storage/impl/h/cache.hpp>
00051 #include <oess_1/db/storage/impl/h/page_accessor.hpp>
00052 #include <oess_1/db/storage/impl/h/header_processor.hpp>
00053 
00054 namespace oess_1 {
00055 
00056 namespace db {
00057 
00058 namespace storage {
00059 
00060 namespace impl {
00061 
00062 //
00063 // std_chain_storage_t
00064 //
00065 
00070 class std_chain_storage_t
00071   : public chain_storage_t
00072   {
00073   public :
00079     std_chain_storage_t(
00081       const std::string & physic_name,
00083       const std::string & main_file_name,
00086       const std::string & work_file_name,
00088       const config_t & config,
00090       bool is_read_only,
00093       bool is_auto_repair_enabled );
00094 
00095     virtual ~std_chain_storage_t();
00096 
00099     virtual void
00100     trx_start();
00101 
00102     virtual void
00103     trx_commit();
00104 
00105     virtual void
00106     trx_rollback();
00107 
00108     virtual chain_id_t
00109     chain_create(
00110       oess_1::io::istream_t & from,
00111       oess_1::uint_t length );
00112 
00113     virtual void
00114     chain_destroy(
00115       const chain_id_t & chain );
00116 
00117     virtual void
00118     chain_load(
00119       const chain_id_t & chain,
00120       oess_1::io::ostream_t & to,
00121       oess_1::uint_t max_length );
00122 
00123     virtual void
00124     chain_update(
00125       const chain_id_t & chain,
00126       oess_1::io::istream_t & from,
00127       oess_1::uint_t length );
00129 
00130   private :
00132     const std::string m_physic_name;
00134     const std::string m_main_file_name;
00137     const std::string m_work_file_name;
00139     const config_t  m_config;
00141     page_index_calculator_t m_calculator;
00142 
00144     bool m_is_read_only;
00145 
00147 
00152     bool m_is_ok;
00153 
00155     bool  m_is_trx;
00156 
00160     std::auto_ptr<
00161         oess_1::db::storage::trx::trace_stream_t >
00162       m_trace_stream;
00163 
00167     oess_1::file::file_t  m_main_file;
00178     oess_1::uint_t  m_main_file_logic_length;
00179 
00181     std::auto_ptr< cache_t >  m_cache;
00182 
00184     std::auto_ptr< dirty_page_storage_t > m_dirty_pages;
00185 
00189     std::auto_ptr< page_accessor_t > m_page_accessor;
00190 
00193 
00197     std::auto_ptr< header_processor_t > m_header_processor;
00198 
00202     void
00203     lo_trx_commit();
00204 
00206     void
00207     lo_trx_rollback();
00208 
00210     chain_id_t
00211     lo_chain_create(
00212       oess_1::io::istream_t & from,
00213       oess_1::uint_t length );
00214 
00216     void
00217     lo_chain_destroy(
00218       const chain_id_t & head );
00219 
00221     void
00222     lo_chain_load(
00223       const chain_id_t & chain,
00224       oess_1::io::ostream_t & to, 
00225       oess_1::uint_t max_length );
00226 
00228     void
00229     lo_chain_update(
00230       const chain_id_t & chain,
00231       oess_1::io::istream_t & from,
00232       oess_1::uint_t length );
00234 
00242     void
00243     cleanup();
00244 
00252     void
00253     try_open_main_file(
00254       bool is_repair_enabled );
00255 
00261     void
00262     try_recover_main_file();
00263     
00273       void
00274     try_open_existing_main_file();
00275     
00280     void
00281     initialize_open_storage();
00282 
00286     void
00287     ensure_trx_started();
00288 
00292     void
00293     make_transaction_log();
00294 
00301     void
00302     commit_transaction_to_main_file();
00303 
00304 //FIX ME: должен быть метод ensure_valid_chain_id, который бы порождал
00305 //исключение, если chain_id == invalid_chain_id.
00306 
00319     chain_id_t
00320     write_chain(
00321       page_accessor_t & page_accessor,
00322       header_processor_t & header_processor,
00323       const chain_id_t & head,
00325       oess_1::io::istream_t & from,
00327       oess_1::uint_t length );
00328 
00332     void
00333     deallocate_chain(
00334       page_accessor_t & page_accessor,
00335       header_processor_t & header_processor,
00336       const chain_id_t & head );
00337 
00341     void
00342     load_chain(
00343       page_accessor_t & page_accessor,
00344       header_processor_t & header_processor,
00345       const chain_id_t & head,
00347       oess_1::io::ostream_t & to,
00349       oess_1::uint_t length );
00350 
00357     oess_1::uint_t
00358     write_block(
00359       page_accessor_t & page_accessor,
00361       const chain_id_t & block,
00363       oess_1::io::istream_t & from,
00365       oess_1::uint_t length );
00366 
00372     oess_1::uint_t
00373     load_block(
00374       page_accessor_t & page_accessor,
00376       const chain_id_t & block,
00378       oess_1::io::ostream_t & to,
00380       oess_1::uint_t length );
00381 
00386     header_processor_t &
00387     get_header_processor();
00388   };
00389 
00390 } /* namespace impl */
00391 
00392 } /* namespace storage */
00393 
00394 } /* namespace db */
00395 
00396 } /* namespace oess_1 */
00397 
00398 #endif
00399 
00400 

Документация по ObjESSty. Последние изменения: Fri Oct 13 18:35:35 2006. Создано системой  doxygen 1.4.7
Hosted by uCoz