Commit fc855778 authored by unknown's avatar unknown

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

into  poseidon.ndb.mysql.com:/home/tomas/mysql-5.0
parents 3fce688b 91c01f82
......@@ -469,6 +469,14 @@ extern "C" {
*/
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
......
......@@ -40,6 +40,14 @@ public:
Ndb_cluster_connection(const char * connectstring = 0);
~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
*
......
......@@ -102,6 +102,7 @@ struct ndb_mgm_handle {
FILE* logfile;
#endif
FILE *errstream;
char *m_name;
};
#define SET_ERROR(h, e, s) setError(h, e, __LINE__, s)
......@@ -156,6 +157,7 @@ ndb_mgm_create_handle()
h->write_timeout = 100;
h->cfg_i = -1;
h->errstream = stdout;
h->m_name = 0;
strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE);
......@@ -170,6 +172,14 @@ ndb_mgm_create_handle()
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"
int
ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv)
......@@ -216,6 +226,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle)
}
#endif
(*handle)->cfg.~LocalConfig();
my_free((*handle)->m_name, MYF(MY_ALLOW_ZERO_PTR));
my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR));
* handle = 0;
DBUG_VOID_RETURN;
......@@ -1875,6 +1886,8 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype)
args.put("password", "mysqld");
args.put("public key", "a public key");
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[]= {
MGM_CMD("get nodeid reply", NULL, ""),
......
......@@ -35,6 +35,7 @@
#include <base64.h>
extern bool g_StopServer;
extern EventLogger g_eventLogger;
static const unsigned int MAX_READ_TIMEOUT = 1000 ;
static const unsigned int MAX_WRITE_TIMEOUT = 100 ;
......@@ -135,6 +136,7 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("password", String, Mandatory, "Password"),
MGM_ARG("public key", String, Mandatory, "Public key"),
MGM_ARG("endian", String, Optional, "Endianness"),
MGM_ARG("name", String, Optional, "Name of connection"),
MGM_CMD("get version", &MgmApiSession::getVersion, ""),
......@@ -411,6 +413,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
const char * password;
const char * public_key;
const char * endian= NULL;
const char * name= NULL;
union { long l; char c[sizeof(long)]; } endian_check;
args.get("version", &version);
......@@ -421,6 +424,7 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
args.get("password", &password);
args.get("public key", &public_key);
args.get("endian", &endian);
args.get("name", &name);
endian_check.l = 1;
if(endian
......@@ -489,6 +493,9 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
m_output->println("");
m_allocated_resources->reserve_node(tmp);
if (name)
g_eventLogger.info("Node %d: %s", tmp, name);
return;
}
......
......@@ -252,7 +252,8 @@ Ndb_cluster_connection::wait_until_ready(int timeout,
Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
connect_string)
: Ndb_cluster_connection(*this),
m_optimized_node_selection(1)
m_optimized_node_selection(1),
m_name(0)
{
DBUG_ENTER("Ndb_cluster_connection");
DBUG_PRINT("enter",("Ndb_cluster_connection this=0x%x", this));
......@@ -280,7 +281,11 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
delete m_config_retriever;
m_config_retriever= 0;
}
if (m_name)
{
NdbMgmHandle h= m_config_retriever->get_mgmHandle();
ndb_mgm_set_name(h, m_name);
}
m_transporter_facade=
TransporterFacade::theFacadeInstance=
new TransporterFacade();
......@@ -324,9 +329,25 @@ Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl()
ndb_print_state_mutex= NULL;
}
#endif
if (m_name)
free(m_name);
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
Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
const ndb_mgm_configuration
......@@ -478,6 +499,11 @@ Ndb_cluster_connection_impl::do_test()
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 verbose)
{
......
......@@ -70,6 +70,7 @@ private:
Vector<Node> m_all_nodes;
void init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config);
void connect_thread();
void set_name(const char *name);
TransporterFacade *m_transporter_facade;
ConfigRetriever *m_config_retriever;
......@@ -77,6 +78,7 @@ private:
int (*m_connect_callback)(void);
int m_optimized_node_selection;
char *m_name;
};
#endif
......@@ -27,6 +27,8 @@ extern FilteredNdbOut debug;
static void callback(int, NdbTransaction*, void*);
extern const char * g_connect_string;
extern BaseString g_options;
bool
BackupRestore::init()
{
......@@ -36,6 +38,7 @@ BackupRestore::init()
return true;
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)
{
return false;
......
......@@ -50,7 +50,8 @@ static int _print_data = 0;
static int _print_log = 0;
static int _restore_data = 0;
static int _restore_meta = 0;
BaseString g_options("ndb_restore");
static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_restore"),
......@@ -249,6 +250,14 @@ main(int argc, char** argv)
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");
g_options.appfmt(" -p %d", ga_nParallelism);
g_connect_string = opt_connect_str;
/**
......
......@@ -4805,7 +4805,11 @@ bool ndbcluster_init()
opt_ndbcluster_connectstring));
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
(opt_ndb_optimized_node_selection);
......
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