Commit 8c01aba7 authored by unknown's avatar unknown
Browse files

added config parameter Group on connection

    moved NdbWaiter, m_ndb_cluster_connection, to impl class
    moved node selection things to cluster connection
    moved all private things to impl class
    added opts for shared memory and node selection
    changed opts handling somewhat; introduced enum for options and common handling of option variables
    added checks for transporter support
    automatic addition of shared mem transporters
    moved wait_until_ready code to cluster connection
    added control of usage of new node selection method


ndb/include/mgmapi/mgmapi_config_parameters.h:
  added config parameter Group on connection
ndb/include/ndbapi/Ndb.hpp:
  moved NdbWaiter, m_ndb_cluster_connection, to impl class
  moved node selection things to cluster connection
ndb/include/ndbapi/ndb_cluster_connection.hpp:
  moved all private things to impl class
ndb/include/util/ndb_opts.h:
  added opts for shared memory and node selection
ndb/src/kernel/vm/Configuration.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/src/mgmclient/main.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/src/mgmsrv/ConfigInfo.cpp:
  added checks for transporter support
  automatic addition of shared mem transporters
ndb/src/mgmsrv/MgmtSrvr.cpp:
  in alloc node id first choose connection with specified hostname
ndb/src/mgmsrv/main.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/src/ndbapi/DictCache.hpp:
  added include file
ndb/src/ndbapi/Ndb.cpp:
  enabled using new node selection method
  moved wait_until_ready code to cluster connection
  moved node selection (hint) to cluster connection
  removed start transaction dgroup
ndb/src/ndbapi/NdbDictionaryImpl.hpp:
  removed and added inclusde files
ndb/src/ndbapi/NdbImpl.hpp:
  moved things from Ndb into Impl class
  moved waiter things to new file NdbWaiter.hpp
ndb/src/ndbapi/NdbScanOperation.cpp:
  ndbwaiter is no in impl class
ndb/src/ndbapi/Ndbif.cpp:
  ndbwaiter is no in impl class
ndb/src/ndbapi/Ndbinit.cpp:
  moved some Ndb things into impl class
ndb/src/ndbapi/TransporterFacade.hpp:
  changed friend declaration
ndb/src/ndbapi/ndb_cluster_connection.cpp:
  moved node selection things to cluster connection
  moved things from cluster connection to cluster connection impl class
ndb/test/ndbapi/testNdbApi.cpp:
  removed start transaction dgroup
ndb/tools/delete_all.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/tools/desc.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/tools/drop_index.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/tools/drop_tab.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/tools/listTables.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/tools/restore/restore_main.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/tools/select_all.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/tools/select_count.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
ndb/tools/waiter.cpp:
  changed opts handling somewhat; introduced enum for options and common handling of option variables
sql/ha_ndbcluster.cc:
  added control of usage of new node selection method
sql/mysqld.cc:
  added control of usage of new node selection method
parent 6cbcd342
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@
#define CFG_CONNECTION_SERVER_PORT    406
#define CFG_CONNECTION_HOSTNAME_1     407
#define CFG_CONNECTION_HOSTNAME_2     408
#define CFG_CONNECTION_GROUP          409

#define CFG_TCP_SERVER                452
#define CFG_TCP_SEND_BUFFER_SIZE      454
+0 −83
Original line number Diff line number Diff line
@@ -901,23 +901,6 @@ typedef void (* NdbEventCallback)(NdbEventOperation*, Ndb*, void*);
                                      NDB_MAX_SCHEMA_NAME_SIZE + \
                                      NDB_MAX_TAB_NAME_SIZE*2

#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
class NdbWaiter {
public:
  NdbWaiter();
  ~NdbWaiter();

  void wait(int waitTime);
  void nodeFail(Uint32 node);
  void signal(Uint32 state);

  Uint32 m_node;
  Uint32 m_state;
  void * m_mutex;
  struct NdbCondition * m_condition;  
};
#endif

/**
 * @class Ndb 
 * @brief Represents the NDB kernel and is the main class of the NDB API.
@@ -1199,39 +1182,6 @@ public:
				  const char *  keyData = 0, 
				  Uint32        keyLen = 0);

#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
  /**
   * This method is a modification of Ndb::startTransaction, 
   * in which we use only the first two chars of keyData to 
   * select transaction coordinator.
   * This is referred to as a distribution group. 
   * There are two ways to use the method: 
   * - In the first, the two characters are used directly as 
   *   the distribution key, and 
   * - in the second the distribution is calculated as:
   *   (10 * (char[0] - 0x30) + (char[1] - 0x30)). 
   *   Thus, in the second way, the two ASCII digits '78' 
   *   will provide the distribution key = 78.
   *
   * @note Transaction priorities are not yet supported.
   *
   * @param aPrio   Priority of the transaction.<br>
   * 	Priority 0 is the highest priority and is used for short transactions 
   *      with requirements on low delay.<br>
   * 	Priority 1 is a medium priority for short transactions.<br>
   * 	Priority 2 is a medium priority for long transactions.<br>
   * 	Priority 3 is a low priority for long transactions.
   * @param keyData is a string of which the two first characters 
   *        is used to compute which fragement the data is stored in.
   * @param type is the type of distribution group.<br> 
   *        0 means direct usage of the two characters, and<br>
   *        1 means the ASCII digit variant.
   * @return NdbConnection, or NULL if it failed.
   */
  NdbConnection* startTransactionDGroup(Uint32 aPrio, 
					const char * keyData, int type);
#endif

  /**
   * When a transactions is completed, the transaction has to be closed.
   *
@@ -1586,8 +1536,6 @@ private:
/******************************************************************************
 *	These are the private variables in this class.	
 *****************************************************************************/
  Ndb_cluster_connection   *m_ndb_cluster_connection;

  NdbConnection**       thePreparedTransactionsArray;
  NdbConnection**       theSentTransactionsArray;
  NdbConnection**       theCompletedTransactionsArray;
@@ -1601,8 +1549,6 @@ private:

  Uint32                theNextConnectNode;

  NdbWaiter             theWaiter;
  
  bool fullyQualifiedNames;

  // Ndb database name.
@@ -1658,35 +1604,6 @@ private:
    InitConfigError
  } theInitState;

  /**
   * Computes fragement id for primary key
   *
   * Note that keydata has to be "shaped" as it is being sent in KEYINFO
   */
  Uint32 computeFragmentId(const char * keyData, Uint32 keyLen);
  Uint32 getFragmentId(Uint32 hashValue);
  
  /**
   * Make a guess to which node is the primary for the fragment
   */
  Uint32 guessPrimaryNode(Uint32 fragmentId);
  
  /**
   * Structure containing values for guessing primary node
   */
  struct StartTransactionNodeSelectionData {
    StartTransactionNodeSelectionData():
      fragment2PrimaryNodeMap(0) {};
    Uint32 kValue;
    Uint32 hashValueMask;
    Uint32 hashpointerValue;
    Uint32 noOfFragments;
    Uint32 * fragment2PrimaryNodeMap;
    
    void init(Uint32 noOfNodes, Uint8 nodeIds[]);
    void release();
  } startTransactionNodeSelectionData;
  
  NdbApiSignal* theCommitAckSignal;


+18 −13
Original line number Diff line number Diff line
@@ -18,13 +18,7 @@
#ifndef CLUSTER_CONNECTION_HPP
#define CLUSTER_CONNECTION_HPP

class TransporterFacade;
class ConfigRetriever;
struct NdbThread;

extern "C" {
  void* run_ndb_cluster_connection_connect_thread(void*);
}
struct Ndb_cluster_connection_node_iter;

class Ndb_cluster_connection {
public:
@@ -32,16 +26,27 @@ public:
  ~Ndb_cluster_connection();
  int connect(int no_retries, int retry_delay_in_seconds, int verbose);
  int start_connect_thread(int (*connect_callback)(void)= 0);

  // add check coupled to init state of cluster connection
  // timeout_after_first_alive negative - ok only if all alive
  // timeout_after_first_alive positive - ok if some alive
  int wait_until_ready(int timeout_for_first_alive,
		       int timeout_after_first_alive);

  const char *get_connectstring(char *buf, int buf_sz) const;
  int get_connected_port() const;
  const char *get_connected_host() const;

  void set_optimized_node_selection(int val);

  Uint32 no_db_nodes();

private:
  friend void* run_ndb_cluster_connection_connect_thread(void*);
  void connect_thread();
  TransporterFacade *m_facade;
  ConfigRetriever *m_config_retriever;
  NdbThread *m_connect_thread;
  int (*m_connect_callback)(void);
  friend class Ndb;
  friend class NdbImpl;
  friend class Ndb_cluster_connection_impl;
  class Ndb_cluster_connection_impl & m_impl;
  Ndb_cluster_connection(Ndb_cluster_connection_impl&);
};

#endif
+37 −22
Original line number Diff line number Diff line
@@ -17,47 +17,62 @@
#ifndef _NDB_OPTS_H
#define _NDB_OPTS_H

#include <ndb_global.h>
#include <my_sys.h>
#include <my_getopt.h>
#include <mysql_version.h>
#include <ndb_version.h>

#ifndef DBUG_OFF
#define NDB_STD_OPTS(prog_name) \
  { "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", \
    0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, \
  { "usage", '?', "Display this help and exit.", \
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
  { "help", '?', "Display this help and exit.", \
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
  { "version", 'V', "Output version information and exit.", 0, 0, 0, \
    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
  { "ndb-connectstring", 'c', \
    "Set connect string for connecting to ndb_mgmd. " \
    "Syntax: \"[nodeid=<id>;][host=]<hostname>[:<port>]\". " \
    "Overides specifying entries in NDB_CONNECTSTRING and Ndb.cfg", \
    (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, \
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\
  { "connect-string", 'c', "same as --ndb-connectstring",\
    (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, \
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }
#define NDB_STD_OPTS_VARS \
const char *opt_connect_str= 0;\
my_bool opt_ndb_shm;\
my_bool	opt_ndb_optimized_node_selection

#define NDB_STD_OPTS_OPTIONS \
OPT_NDB_SHM= 256,\
OPT_NDB_OPTIMIZED_NODE_SELECTION

#define OPT_NDB_CONNECTSTRING 'c'

#ifdef NDB_SHM_TRANSPORTER
#define OPT_NDB_SHM_DEFAULT 1
#else
#define NDB_STD_OPTS(prog_name) \
#define OPT_NDB_SHM_DEFAULT 0
#endif

#define NDB_STD_OPTS_COMMON \
  { "usage", '?', "Display this help and exit.", \
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
  { "help", '?', "Display this help and exit.", \
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
  { "version", 'V', "Output version information and exit.", 0, 0, 0, \
    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
  { "ndb-connectstring", 'c', \
  { "ndb-connectstring", OPT_NDB_CONNECTSTRING, \
    "Set connect string for connecting to ndb_mgmd. " \
    "Syntax: \"[nodeid=<id>;][host=]<hostname>[:<port>]\". " \
    "Overides specifying entries in NDB_CONNECTSTRING and Ndb.cfg", \
    (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, \
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\
  { "connect-string", 'c', "same as --ndb-connectstring",\
  { "ndb-shm", OPT_NDB_SHM,\
    "Allow optimizing using shared memory connections when available",\
    (gptr*) &opt_ndb_shm, (gptr*) &opt_ndb_shm, 0,\
    GET_BOOL, NO_ARG, OPT_NDB_SHM_DEFAULT, 0, 0, 0, 0, 0 },\
  {"ndb-optimized-node-selection", OPT_NDB_OPTIMIZED_NODE_SELECTION,\
    "Select nodes for transactions in a more optimal way",\
    (gptr*) &opt_ndb_optimized_node_selection,\
    (gptr*) &opt_ndb_optimized_node_selection, 0,\
    GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},\
  { "connect-string", OPT_NDB_CONNECTSTRING, "same as --ndb-connectstring",\
    (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0,\
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }

#ifndef DBUG_OFF
#define NDB_STD_OPTS(prog_name) \
  { "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", \
    0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, \
  NDB_STD_OPTS_COMMON
#else
#define NDB_STD_OPTS(prog_name) NDB_STD_OPTS_COMMON
#endif

#endif /*_NDB_OPTS_H */
+9 −3
Original line number Diff line number Diff line
@@ -46,7 +46,13 @@ extern "C" {
#include <EventLogger.hpp>
extern EventLogger g_eventLogger;

static const char* opt_connect_str= 0;
enum ndbd_options {
  NDB_STD_OPTS_OPTIONS,
  OPT_INITIAL,
  OPT_NODAEMON
};

NDB_STD_OPTS_VARS;
static int _daemon, _no_daemon, _initial, _no_start;
/**
 * Arguments to NDB process
@@ -54,7 +60,7 @@ static int _daemon, _no_daemon, _initial, _no_start;
static struct my_option my_long_options[] =
{
  NDB_STD_OPTS("ndbd"),
  { "initial", 256,
  { "initial", OPT_INITIAL,
    "Perform initial start of ndbd, including cleaning the file system. "
    "Consult documentation before using this",
    (gptr*) &_initial, (gptr*) &_initial, 0,
@@ -66,7 +72,7 @@ static struct my_option my_long_options[] =
  { "daemon", 'd', "Start ndbd as daemon (default)",
    (gptr*) &_daemon, (gptr*) &_daemon, 0,
    GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
  { "nodaemon", 257,
  { "nodaemon", OPT_NODAEMON,
    "Do not start ndbd as daemon, provided for testing purposes",
    (gptr*) &_no_daemon, (gptr*) &_no_daemon, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
Loading