1 /*
2   Copyright (c) 2015, 2021, Oracle and/or its affiliates.
3 
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License, version 2.0,
6   as published by the Free Software Foundation.
7 
8   This program is also distributed with certain software (including
9   but not limited to OpenSSL) that is licensed under separate terms,
10   as designated in a particular file or component or in included license
11   documentation.  The authors of MySQL hereby grant you an additional
12   permission to link the program and your derivative works with the
13   separately licensed software that they have included with MySQL.
14 
15   This program is distributed in the hope that it will be useful,
16   but WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   GNU General Public License, version 2.0, for more details.
19 
20   You should have received a copy of the GNU General Public License
21   along with this program; if not, write to the Free Software
22   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #ifndef MYSQLDUMP_TOOL_CHAIN_MAKER_INCLUDED
26 #define MYSQLDUMP_TOOL_CHAIN_MAKER_INCLUDED
27 
28 #include "mysql_object_reader.h"
29 #include "object_queue.h"
30 #include "i_chain_maker.h"
31 #include "i_object_reader.h"
32 #include "i_dump_task.h"
33 #include "chain_data.h"
34 #include "abstract_chain_element.h"
35 #include "abstract_mysql_chain_element_extension.h"
36 #include "mysqldump_tool_chain_maker_options.h"
37 #include <map>
38 #include <vector>
39 
40 namespace Mysql{
41 namespace Tools{
42 namespace Dump{
43 
44 /**
45   Chain maker implemented in Mysql_dump application, constructs chain based on
46   command line options that are compatible with these available in previous
47   implementation.
48  */
49 class Mysqldump_tool_chain_maker : public I_chain_maker,
50   public Abstract_chain_element, public Abstract_mysql_chain_element_extension
51 {
52 public:
53   Mysqldump_tool_chain_maker(
54     I_connection_provider* connection_provider,
55     Mysql::I_callable<bool, const Mysql::Tools::Base::Message_data&>*
56     message_handler, Simple_id_generator* object_id_generator,
57     Mysqldump_tool_chain_maker_options* options,
58     Mysql::Tools::Base::Abstract_program* program);
59 
60   ~Mysqldump_tool_chain_maker();
61 
62   I_object_reader* create_chain(
63     Chain_data* chain_data, I_dump_task* dump_task);
64 
65   void delete_chain(uint64 chain_id, I_object_reader* chain);
66 
67 private:
68   void mysql_thread_callback(bool is_starting);
69 
70   void stop_queues();
71 
72   Mysqldump_tool_chain_maker_options* m_options;
73 
74   Mysql_object_reader* m_main_object_reader;
75   std::map<int, Object_queue*> m_object_queues;
76   std::vector<I_chain_element*> m_all_created_elements;
77   Mysql::Tools::Base::Abstract_program* m_program;
78 };
79 
80 }
81 }
82 }
83 
84 #endif
85