MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ndb_cluster_connection.hpp
1 /*
2  Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
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 as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 
19 #ifndef CLUSTER_CONNECTION_HPP
20 #define CLUSTER_CONNECTION_HPP
21 #include <ndb_types.h>
22 
24 {
25  friend class Ndb_cluster_connection_impl;
26 public:
27  Ndb_cluster_connection_node_iter() : scan_state(~0),
28  init_pos(0),
29  cur_pos(0) {};
30 private:
31  unsigned char scan_state;
32  unsigned char init_pos;
33  unsigned char cur_pos;
34 };
35 
36 class Ndb;
37 
50 public:
57  Ndb_cluster_connection(const char * connectstring = 0);
58 
68  Ndb_cluster_connection(const char * connectstring, int force_api_nodeid);
69 
70 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
71  Ndb_cluster_connection(const char * connectstring,
72  Ndb_cluster_connection *main_connection);
73 #endif
75 
82  void set_name(const char *name);
83 
100  int set_timeout(int timeout_ms);
101 
119  int connect(int no_retries=0, int retry_delay_in_seconds=1, int verbose=0);
120 
121 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
122  int start_connect_thread(int (*connect_callback)(void)= 0);
123 #endif
124 
137  int wait_until_ready(int timeout_for_first_alive,
138  int timeout_after_first_alive);
139 
144  void lock_ndb_objects();
145 
149  void unlock_ndb_objects();
150 
158  const Ndb* get_next_ndb_object(const Ndb* p);
159 
160  int get_latest_error() const;
161  const char *get_latest_error_msg() const;
162 
167  void set_auto_reconnect(int value);
168  int get_auto_reconnect() const;
169 
181  Uint32 collect_client_stats(Uint64* statsArr, Uint32 sz);
182 
183 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
184  int get_no_ready();
185  const char *get_connectstring(char *buf, int buf_sz) const;
186  int get_connected_port() const;
187  const char *get_connected_host() const;
188 
189  void set_optimized_node_selection(int val);
190 
191  unsigned no_db_nodes();
192  unsigned max_nodegroup();
193  unsigned node_id();
194  unsigned get_connect_count() const;
195  unsigned get_min_db_version() const;
196 
197  void init_get_next_node(Ndb_cluster_connection_node_iter &iter);
198  unsigned int get_next_node(Ndb_cluster_connection_node_iter &iter);
199  unsigned int get_next_alive_node(Ndb_cluster_connection_node_iter &iter);
200  unsigned get_active_ndb_objects() const;
201 
202  Uint64 *get_latest_trans_gci();
203 #endif
204 
205 private:
206  friend class Ndb;
207  friend class NdbImpl;
208  friend class Ndb_cluster_connection_impl;
209  friend class SignalSender;
210  class Ndb_cluster_connection_impl & m_impl;
212 
213  Ndb_cluster_connection(const Ndb_cluster_connection&); // Not impl.
215 };
216 
217 #endif