1 /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ 22 23 #ifndef NDB_PGMAN_PROXY_HPP 24 #define NDB_PGMAN_PROXY_HPP 25 26 #include <LocalProxy.hpp> 27 #include <signaldata/LCP.hpp> 28 #include <signaldata/ReleasePages.hpp> 29 #include "pgman.hpp" 30 31 class PgmanProxy : public LocalProxy { 32 public: 33 PgmanProxy(Block_context& ctx); 34 virtual ~PgmanProxy(); 35 BLOCK_DEFINES(PgmanProxy); 36 37 protected: 38 virtual SimulatedBlock* newWorker(Uint32 instanceNo); 39 40 // GSN_LCP_FRAG_ORD 41 struct Ss_LCP_FRAG_ORD : SsParallel { 42 /* 43 * Sent once from LQH proxy (at LCP) and LGMAN (at SR). 44 * The pgman instances only set a flag and do not reply. 45 */ namePgmanProxy::Ss_LCP_FRAG_ORD46 static const char* name() { return "LCP_FRAG_ORD"; } 47 LcpFragOrd m_req; Ss_LCP_FRAG_ORDPgmanProxy::Ss_LCP_FRAG_ORD48 Ss_LCP_FRAG_ORD() { 49 m_sendREQ = (SsFUNCREQ)&PgmanProxy::sendLCP_FRAG_ORD; 50 m_sendCONF = (SsFUNCREP)0; 51 } 52 enum { poolSize = 1 }; poolPgmanProxy::Ss_LCP_FRAG_ORD53 static SsPool<Ss_LCP_FRAG_ORD>& pool(LocalProxy* proxy) { 54 return ((PgmanProxy*)proxy)->c_ss_LCP_FRAG_ORD; 55 } 56 }; 57 SsPool<Ss_LCP_FRAG_ORD> c_ss_LCP_FRAG_ORD; getSsId(const LcpFragOrd * req)58 static Uint32 getSsId(const LcpFragOrd* req) { 59 return SsIdBase | (req->lcpId & 0xFFFF); 60 } 61 void execLCP_FRAG_ORD(Signal*); 62 void sendLCP_FRAG_ORD(Signal*, Uint32 ssId, SectionHandle*); 63 64 // GSN_END_LCP_REQ 65 struct Ss_END_LCP_REQ : SsParallel { 66 /* 67 * Sent once from LQH proxy (at LCP) and LGMAN (at SR). 68 * Each pgman instance runs LCP before we send a CONF. 69 */ namePgmanProxy::Ss_END_LCP_REQ70 static const char* name() { return "END_LCP_REQ"; } 71 EndLcpReq m_req; Ss_END_LCP_REQPgmanProxy::Ss_END_LCP_REQ72 Ss_END_LCP_REQ() { 73 m_sendREQ = (SsFUNCREQ)&PgmanProxy::sendEND_LCP_REQ; 74 m_sendCONF = (SsFUNCREP)&PgmanProxy::sendEND_LCP_CONF; 75 // extra worker (for extent pages) must run after others 76 m_extraLast = true; 77 } 78 enum { poolSize = 1 }; poolPgmanProxy::Ss_END_LCP_REQ79 static SsPool<Ss_END_LCP_REQ>& pool(LocalProxy* proxy) { 80 return ((PgmanProxy*)proxy)->c_ss_END_LCP_REQ; 81 } 82 }; 83 SsPool<Ss_END_LCP_REQ> c_ss_END_LCP_REQ; getSsId(const EndLcpReq * req)84 static Uint32 getSsId(const EndLcpReq* req) { 85 return SsIdBase | (req->backupId & 0xFFFF); 86 } getSsId(const EndLcpConf * conf)87 static Uint32 getSsId(const EndLcpConf* conf) { 88 return conf->senderData; 89 } getSsId(const ReleasePagesConf * conf)90 static Uint32 getSsId(const ReleasePagesConf* conf) { 91 return conf->senderData; 92 } 93 void execEND_LCP_REQ(Signal*); 94 void sendEND_LCP_REQ(Signal*, Uint32 ssId, SectionHandle*); 95 void execEND_LCP_CONF(Signal*); 96 void sendEND_LCP_CONF(Signal*, Uint32 ssId); 97 void execRELEASE_PAGES_CONF(Signal*); 98 99 // client methods 100 friend class Page_cache_client; 101 102 int get_page(Page_cache_client& caller, 103 Signal*, Page_cache_client::Request& req, Uint32 flags); 104 105 void update_lsn(Page_cache_client& caller, 106 Local_key key, Uint64 lsn); 107 108 int drop_page(Page_cache_client& caller, 109 Local_key key, Uint32 page_id); 110 111 Uint32 create_data_file(Signal*); 112 113 Uint32 alloc_data_file(Signal*, Uint32 file_no); 114 115 void map_file_no(Signal*, Uint32 file_no, Uint32 fd); 116 117 void free_data_file(Signal*, Uint32 file_no, Uint32 fd); 118 119 void send_data_file_ord(Signal*, Uint32 i, Uint32 ret, 120 Uint32 cmd, Uint32 file_no = RNIL, Uint32 fd = RNIL); 121 }; 122 123 #endif 124