~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_IMPL_HPP
 
20
#define CLUSTER_CONNECTION_IMPL_HPP
 
21
 
 
22
#include <ndb_cluster_connection.hpp>
 
23
#include <Vector.hpp>
 
24
#include <NdbMutex.h>
 
25
#include "DictCache.hpp"
 
26
 
 
27
extern NdbMutex *g_ndb_connection_mutex;
 
28
 
 
29
class TransporterFacade;
 
30
class ConfigRetriever;
 
31
struct NdbThread;
 
32
struct ndb_mgm_configuration;
 
33
class Ndb;
 
34
 
 
35
extern "C" {
 
36
  void* run_ndb_cluster_connection_connect_thread(void*);
 
37
}
 
38
 
 
39
struct NdbApiConfig
 
40
{
 
41
  NdbApiConfig() :
 
42
    m_scan_batch_size(MAX_SCAN_BATCH_SIZE),
 
43
    m_batch_byte_size(SCAN_BATCH_SIZE),
 
44
    m_batch_size(DEF_BATCH_SIZE),
 
45
    m_waitfor_timeout(120000),
 
46
    m_default_queue_option(0)
 
47
    {}
 
48
 
 
49
  Uint32 m_scan_batch_size;
 
50
  Uint32 m_batch_byte_size;
 
51
  Uint32 m_batch_size;
 
52
  Uint32 m_waitfor_timeout; // in milli seconds...
 
53
  Uint32 m_default_queue_option;
 
54
};
 
55
 
 
56
class Ndb_cluster_connection_impl : public Ndb_cluster_connection
 
57
{
 
58
  Ndb_cluster_connection_impl(const char *connectstring,
 
59
                              Ndb_cluster_connection *main_connection,
 
60
                              int force_api_nodeid);
 
61
  ~Ndb_cluster_connection_impl();
 
62
 
 
63
  void do_test();
 
64
 
 
65
  void init_get_next_node(Ndb_cluster_connection_node_iter &iter);
 
66
  Uint32 get_next_node(Ndb_cluster_connection_node_iter &iter);
 
67
  Uint32 get_next_alive_node(Ndb_cluster_connection_node_iter &iter);
 
68
 
 
69
  inline unsigned get_connect_count() const;
 
70
  inline unsigned get_min_db_version() const;
 
71
public:
 
72
  inline Uint64 *get_latest_trans_gci() { return &m_latest_trans_gci; }
 
73
 
 
74
private:
 
75
  friend class Ndb;
 
76
  friend class NdbImpl;
 
77
  friend void* run_ndb_cluster_connection_connect_thread(void*);
 
78
  friend class Ndb_cluster_connection;
 
79
  friend class NdbEventBuffer;
 
80
  friend class SignalSender;
 
81
  
 
82
  struct Node
 
83
  {
 
84
    Node(Uint32 _g= 0, Uint32 _id= 0) : this_group(0),
 
85
                                        next_group(0),
 
86
                                        group(_g),
 
87
                                        id(_id) {};
 
88
    Uint32 this_group;
 
89
    Uint32 next_group;
 
90
    Uint32 group;
 
91
    Uint32 id;
 
92
  };
 
93
 
 
94
  Vector<Node> m_all_nodes;
 
95
  int init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config);
 
96
  int configure(Uint32 nodeid, const ndb_mgm_configuration &config);
 
97
  void connect_thread();
 
98
  void set_name(const char *name);
 
99
  Uint32 get_db_nodes(Uint8 nodesarray[MAX_NDB_NODES]) const;
 
100
 
 
101
  int connect(int no_retries,
 
102
              int retry_delay_in_seconds,
 
103
              int verbose);
 
104
 
 
105
  Ndb_cluster_connection *m_main_connection;
 
106
  GlobalDictCache *m_globalDictCache;
 
107
  TransporterFacade *m_transporter_facade;
 
108
  ConfigRetriever *m_config_retriever;
 
109
  NdbThread *m_connect_thread;
 
110
  int (*m_connect_callback)(void);
 
111
 
 
112
  int m_optimized_node_selection;
 
113
  int m_run_connect_thread;
 
114
  NdbMutex *m_event_add_drop_mutex;
 
115
  Uint64 m_latest_trans_gci;
 
116
 
 
117
  NdbMutex* m_new_delete_ndb_mutex;
 
118
  Ndb* m_first_ndb_object;
 
119
  void link_ndb_object(Ndb*);
 
120
  void unlink_ndb_object(Ndb*);
 
121
 
 
122
  BaseString m_latest_error_msg;
 
123
  unsigned m_latest_error;
 
124
 
 
125
  // Scan batch configuration parameters
 
126
  NdbApiConfig m_config;
 
127
  
 
128
  // keep initial transId's increasing...
 
129
  Uint32 m_max_trans_id;
 
130
 
 
131
  // Base offset for stats, from Ndb objects that are no 
 
132
  // longer with us
 
133
  Uint64 globalApiStatsBaseline[ Ndb::NumClientStatistics ];
 
134
};
 
135
 
 
136
#endif