Commit c7e20e20 authored by unknown's avatar unknown

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.1-new

into  poseidon.ndb.mysql.com:/home/tomas/mysql-5.1-new

parents a22bd444 67e16225
...@@ -5813,7 +5813,11 @@ static bool ndbcluster_init() ...@@ -5813,7 +5813,11 @@ static bool ndbcluster_init()
opt_ndbcluster_connectstring)); opt_ndbcluster_connectstring));
goto ndbcluster_init_error; goto ndbcluster_init_error;
} }
{
char buf[128];
my_snprintf(buf, sizeof(buf), "mysqld --server-id=%d", server_id);
g_ndb_cluster_connection->set_name(buf);
}
g_ndb_cluster_connection->set_optimized_node_selection g_ndb_cluster_connection->set_optimized_node_selection
(opt_ndb_optimized_node_selection); (opt_ndb_optimized_node_selection);
......
...@@ -468,6 +468,14 @@ extern "C" { ...@@ -468,6 +468,14 @@ extern "C" {
*/ */
void ndb_mgm_destroy_handle(NdbMgmHandle * handle); void ndb_mgm_destroy_handle(NdbMgmHandle * handle);
/**
* Set a name of the handle. Name is reported in cluster log.
*
* @param handle Management handle
* @param name Name
*/
void ndb_mgm_set_name(NdbMgmHandle handle, const char *name);
/** @} *********************************************************************/ /** @} *********************************************************************/
/** /**
* @name Functions: Connect/Disconnect Management Server * @name Functions: Connect/Disconnect Management Server
......
...@@ -54,6 +54,14 @@ public: ...@@ -54,6 +54,14 @@ public:
Ndb_cluster_connection(const char * connectstring = 0); Ndb_cluster_connection(const char * connectstring = 0);
~Ndb_cluster_connection(); ~Ndb_cluster_connection();
/**
* Set a name on the connection, which will be reported in cluster log
*
* @param name
*
*/
void set_name(const char *name);
/** /**
* Connect to a cluster management server * Connect to a cluster management server
* *
......
...@@ -102,6 +102,7 @@ struct ndb_mgm_handle { ...@@ -102,6 +102,7 @@ struct ndb_mgm_handle {
FILE* logfile; FILE* logfile;
#endif #endif
FILE *errstream; FILE *errstream;
char *m_name;
}; };
#define SET_ERROR(h, e, s) setError(h, e, __LINE__, s) #define SET_ERROR(h, e, s) setError(h, e, __LINE__, s)
...@@ -156,6 +157,7 @@ ndb_mgm_create_handle() ...@@ -156,6 +157,7 @@ ndb_mgm_create_handle()
h->write_timeout = 100; h->write_timeout = 100;
h->cfg_i = -1; h->cfg_i = -1;
h->errstream = stdout; h->errstream = stdout;
h->m_name = 0;
strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE); strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE);
...@@ -170,6 +172,14 @@ ndb_mgm_create_handle() ...@@ -170,6 +172,14 @@ ndb_mgm_create_handle()
DBUG_RETURN(h); DBUG_RETURN(h);
} }
extern "C"
void
ndb_mgm_set_name(NdbMgmHandle handle, const char *name)
{
my_free(handle->m_name, MYF(MY_ALLOW_ZERO_PTR));
handle->m_name= my_strdup(name, MYF(MY_WME));
}
extern "C" extern "C"
int int
ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv) ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv)
...@@ -216,6 +226,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle) ...@@ -216,6 +226,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle)
} }
#endif #endif
(*handle)->cfg.~LocalConfig(); (*handle)->cfg.~LocalConfig();
my_free((*handle)->m_name, MYF(MY_ALLOW_ZERO_PTR));
my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR)); my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR));
* handle = 0; * handle = 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -1875,6 +1886,8 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype) ...@@ -1875,6 +1886,8 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype)
args.put("password", "mysqld"); args.put("password", "mysqld");
args.put("public key", "a public key"); args.put("public key", "a public key");
args.put("endian", (endian_check.c[sizeof(long)-1])?"big":"little"); args.put("endian", (endian_check.c[sizeof(long)-1])?"big":"little");
if (handle->m_name)
args.put("name", handle->m_name);
const ParserRow<ParserDummy> reply[]= { const ParserRow<ParserDummy> reply[]= {
MGM_CMD("get nodeid reply", NULL, ""), MGM_CMD("get nodeid reply", NULL, ""),
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <base64.h> #include <base64.h>
extern bool g_StopServer; extern bool g_StopServer;
extern EventLogger g_eventLogger;
static const unsigned int MAX_READ_TIMEOUT = 1000 ; static const unsigned int MAX_READ_TIMEOUT = 1000 ;
static const unsigned int MAX_WRITE_TIMEOUT = 100 ; static const unsigned int MAX_WRITE_TIMEOUT = 100 ;
...@@ -135,6 +136,7 @@ ParserRow<MgmApiSession> commands[] = { ...@@ -135,6 +136,7 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("password", String, Mandatory, "Password"), MGM_ARG("password", String, Mandatory, "Password"),
MGM_ARG("public key", String, Mandatory, "Public key"), MGM_ARG("public key", String, Mandatory, "Public key"),
MGM_ARG("endian", String, Optional, "Endianness"), MGM_ARG("endian", String, Optional, "Endianness"),
MGM_ARG("name", String, Optional, "Name of connection"),
MGM_CMD("get version", &MgmApiSession::getVersion, ""), MGM_CMD("get version", &MgmApiSession::getVersion, ""),
...@@ -411,6 +413,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &, ...@@ -411,6 +413,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
const char * password; const char * password;
const char * public_key; const char * public_key;
const char * endian= NULL; const char * endian= NULL;
const char * name= NULL;
union { long l; char c[sizeof(long)]; } endian_check; union { long l; char c[sizeof(long)]; } endian_check;
args.get("version", &version); args.get("version", &version);
...@@ -421,6 +424,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &, ...@@ -421,6 +424,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
args.get("password", &password); args.get("password", &password);
args.get("public key", &public_key); args.get("public key", &public_key);
args.get("endian", &endian); args.get("endian", &endian);
args.get("name", &name);
endian_check.l = 1; endian_check.l = 1;
if(endian if(endian
...@@ -489,6 +493,9 @@ MgmApiSession::get_nodeid(Parser_t::Context &, ...@@ -489,6 +493,9 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
m_output->println(""); m_output->println("");
m_allocated_resources->reserve_node(tmp); m_allocated_resources->reserve_node(tmp);
if (name)
g_eventLogger.info("Node %d: %s", tmp, name);
return; return;
} }
......
...@@ -262,7 +262,8 @@ Ndb_cluster_connection::wait_until_ready(int timeout, ...@@ -262,7 +262,8 @@ Ndb_cluster_connection::wait_until_ready(int timeout,
Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char * Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
connect_string) connect_string)
: Ndb_cluster_connection(*this), : Ndb_cluster_connection(*this),
m_optimized_node_selection(1) m_optimized_node_selection(1),
m_name(0)
{ {
DBUG_ENTER("Ndb_cluster_connection"); DBUG_ENTER("Ndb_cluster_connection");
DBUG_PRINT("enter",("Ndb_cluster_connection this=0x%x", this)); DBUG_PRINT("enter",("Ndb_cluster_connection this=0x%x", this));
...@@ -287,7 +288,11 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char * ...@@ -287,7 +288,11 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
delete m_config_retriever; delete m_config_retriever;
m_config_retriever= 0; m_config_retriever= 0;
} }
if (m_name)
{
NdbMgmHandle h= m_config_retriever->get_mgmHandle();
ndb_mgm_set_name(h, m_name);
}
m_transporter_facade= m_transporter_facade=
TransporterFacade::theFacadeInstance= TransporterFacade::theFacadeInstance=
new TransporterFacade(); new TransporterFacade();
...@@ -326,9 +331,25 @@ Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl() ...@@ -326,9 +331,25 @@ Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl()
ndb_print_state_mutex= NULL; ndb_print_state_mutex= NULL;
} }
#endif #endif
if (m_name)
free(m_name);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void
Ndb_cluster_connection_impl::set_name(const char *name)
{
if (m_name)
free(m_name);
m_name= strdup(name);
if (m_config_retriever && m_name)
{
NdbMgmHandle h= m_config_retriever->get_mgmHandle();
ndb_mgm_set_name(h, m_name);
}
}
void void
Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid, Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
const ndb_mgm_configuration const ndb_mgm_configuration
...@@ -480,6 +501,11 @@ Ndb_cluster_connection_impl::do_test() ...@@ -480,6 +501,11 @@ Ndb_cluster_connection_impl::do_test()
delete [] nodes; delete [] nodes;
} }
void Ndb_cluster_connection::set_name(const char *name)
{
m_impl.set_name(name);
}
int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds, int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds,
int verbose) int verbose)
{ {
......
...@@ -62,6 +62,7 @@ private: ...@@ -62,6 +62,7 @@ private:
Vector<Node> m_all_nodes; Vector<Node> m_all_nodes;
void init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config); void init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config);
void connect_thread(); void connect_thread();
void set_name(const char *name);
TransporterFacade *m_transporter_facade; TransporterFacade *m_transporter_facade;
ConfigRetriever *m_config_retriever; ConfigRetriever *m_config_retriever;
...@@ -69,6 +70,7 @@ private: ...@@ -69,6 +70,7 @@ private:
int (*m_connect_callback)(void); int (*m_connect_callback)(void);
int m_optimized_node_selection; int m_optimized_node_selection;
char *m_name;
}; };
#endif #endif
...@@ -30,6 +30,8 @@ static Uint32 get_part_id(const NdbDictionary::Table *table, ...@@ -30,6 +30,8 @@ static Uint32 get_part_id(const NdbDictionary::Table *table,
Uint32 hash_value); Uint32 hash_value);
extern const char * g_connect_string; extern const char * g_connect_string;
extern BaseString g_options;
bool bool
BackupRestore::init() BackupRestore::init()
{ {
...@@ -39,6 +41,7 @@ BackupRestore::init() ...@@ -39,6 +41,7 @@ BackupRestore::init()
return true; return true;
m_cluster_connection = new Ndb_cluster_connection(g_connect_string); m_cluster_connection = new Ndb_cluster_connection(g_connect_string);
m_cluster_connection->set_name(g_options.c_str());
if(m_cluster_connection->connect(12, 5, 1) != 0) if(m_cluster_connection->connect(12, 5, 1) != 0)
{ {
return false; return false;
......
...@@ -58,6 +58,7 @@ static int _print_log = 0; ...@@ -58,6 +58,7 @@ static int _print_log = 0;
static int _restore_data = 0; static int _restore_data = 0;
static int _restore_meta = 0; static int _restore_meta = 0;
static int _no_restore_disk = 0; static int _no_restore_disk = 0;
BaseString g_options("ndb_restore");
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
{ {
...@@ -450,6 +451,18 @@ main(int argc, char** argv) ...@@ -450,6 +451,18 @@ main(int argc, char** argv)
exitHandler(NDBT_FAILED); exitHandler(NDBT_FAILED);
} }
g_options.appfmt(" -b %d", ga_backupId);
g_options.appfmt(" -n %d", ga_nodeId);
if (_restore_meta)
g_options.appfmt(" -m");
if (_restore_data)
g_options.appfmt(" -r");
if (ga_restore_epoch)
g_options.appfmt(" -e");
if (_restore_disk)
g_options.appfmt(" -d");
g_options.appfmt(" -p %d", ga_nParallelism);
g_connect_string = opt_connect_str; g_connect_string = opt_connect_str;
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment