Commit b1fca876 authored by stewart@mysql.com's avatar stewart@mysql.com

Merge mysql.com:/home/stewart/Documents/MySQL/5.0/ndb

into mysql.com:/home/stewart/Documents/MySQL/5.0/ndb-dynamic-port
parents 9cc5abd2 b0c03011
......@@ -131,6 +131,24 @@ extern "C" {
int param,
const char * value,
struct ndb_mgm_reply* reply);
/**
* Set an integer parameter for a connection
*
* @param handle the NDB management handle.
* @param node1 the node1 id
* @param node2 the node2 id
* @param param the parameter (e.g. CFG_CONNECTION_SERVER_PORT)
* @param value what to set it to
* @param reply from ndb_mgmd
*/
int ndb_mgm_set_connection_int_parameter(NdbMgmHandle handle,
int node1,
int node2,
int param,
unsigned value,
struct ndb_mgm_reply* reply);
#ifdef __cplusplus
}
#endif
......
......@@ -73,6 +73,7 @@ public:
Uint32 get_mgmd_port() const;
const char *get_mgmd_host() const;
const char *get_connectstring(char *buf, int buf_sz) const;
NdbMgmHandle get_mgmHandle() { return m_handle; };
Uint32 get_configuration_nodeid() const;
private:
......
......@@ -221,11 +221,16 @@ public:
class Transporter_interface {
public:
NodeId m_remote_nodeId;
unsigned short m_service_port;
const char *m_interface;
};
Vector<Transporter_interface> m_transporter_interface;
void add_transporter_interface(const char *interface, unsigned short port);
void add_transporter_interface(NodeId remoteNodeId,
const char *interface, unsigned short port);
Transporter* get_transporter(NodeId nodeId);
NodeId get_localNodeId() { return localNodeId; };
protected:
private:
......
......@@ -367,7 +367,7 @@ IPCConfig::configureTransporters(Uint32 nodeId,
Uint32 server_port= 0;
if(iter.get(CFG_CONNECTION_SERVER_PORT, &server_port)) break;
if (nodeId <= nodeId1 && nodeId <= nodeId2) {
tr.add_transporter_interface(localHostName, server_port);
tr.add_transporter_interface(nodeId2, localHostName, server_port);
}
DBUG_PRINT("info", ("Transporter between this node %d and node %d using port %d, signalId %d, checksum %d",
nodeId, remoteNodeId, server_port, sendSignalId, checksum));
......
......@@ -1180,7 +1180,8 @@ TransporterRegistry::stop_clients()
}
void
TransporterRegistry::add_transporter_interface(const char *interface,
TransporterRegistry::add_transporter_interface(NodeId remoteNodeId,
const char *interface,
unsigned short port)
{
DBUG_ENTER("TransporterRegistry::add_transporter_interface");
......@@ -1204,6 +1205,7 @@ TransporterRegistry::add_transporter_interface(const char *interface,
}
}
Transporter_interface t;
t.m_remote_nodeId= remoteNodeId;
t.m_service_port= port;
t.m_interface= interface;
m_transporter_interface.push_back(t);
......@@ -1329,4 +1331,9 @@ NdbOut & operator <<(NdbOut & out, SignalHeader & sh){
return out;
}
Transporter*
TransporterRegistry::get_transporter(NodeId nodeId) {
return theTransporters[nodeId];
};
template class Vector<TransporterRegistry::Transporter_interface>;
......@@ -19,6 +19,7 @@
#include <ndb_version.h>
#include "Configuration.hpp"
#include <ConfigRetriever.hpp>
#include <TransporterRegistry.hpp>
#include "vm/SimBlockList.hpp"
......@@ -36,6 +37,8 @@
#include <NdbAutoPtr.hpp>
#include <mgmapi_debug.h>
#if defined NDB_SOLARIS // ok
#include <sys/processor.h> // For system informatio
#endif
......@@ -192,6 +195,17 @@ int main(int argc, char** argv)
socket_server.startServer();
struct ndb_mgm_reply mgm_reply;
for(unsigned int i=0;i<globalTransporterRegistry.m_transporter_interface.size();i++)
ndb_mgm_set_connection_int_parameter(theConfig->get_config_retriever()->get_mgmHandle(),
globalTransporterRegistry.get_localNodeId(),
globalTransporterRegistry.m_transporter_interface[i].m_remote_nodeId,
CFG_CONNECTION_SERVER_PORT,
globalTransporterRegistry.m_transporter_interface[i].m_service_port,
&mgm_reply);
// theConfig->closeConfiguration();
globalEmulatorData.theThreadConfig->ipControlLoop();
......
......@@ -68,6 +68,7 @@ public:
Uint32 get_mgmd_port() const {return m_mgmd_port;};
const char *get_mgmd_host() const {return m_mgmd_host;};
ConfigRetriever* get_config_retriever() { return m_config_retriever; };
class LogLevel * m_logLevel;
private:
......
......@@ -1975,4 +1975,47 @@ ndb_mgm_check_connection(NdbMgmHandle handle){
return -1;
}
extern "C"
int
ndb_mgm_set_connection_int_parameter(NdbMgmHandle handle,
int node1,
int node2,
int param,
unsigned value,
struct ndb_mgm_reply* mgmreply){
DBUG_ENTER("ndb_mgm_set_connection_int_parameter");
CHECK_HANDLE(handle, 0);
CHECK_CONNECTED(handle, 0);
Properties args;
args.put("node1: ", node1);
args.put("node2: ", node2);
args.put("param: ", param);
args.put("value: ", value);
const ParserRow<ParserDummy> reply[]= {
MGM_CMD("set connection parameter reply", NULL, ""),
MGM_ARG("result", String, Mandatory, "Error message"),
MGM_END()
};
const Properties *prop;
prop= ndb_mgm_call(handle, reply, "set connection parameter", &args);
CHECK_REPLY(prop, -1);
int res= -1;
do {
const char * buf;
if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
ndbout_c("ERROR Message: %s\n", buf);
break;
}
res= 0;
} while(0);
delete prop;
return res;
}
template class Vector<const ParserRow<ParserDummy>*>;
......@@ -2732,6 +2732,60 @@ MgmtSrvr::setDbParameter(int node, int param, const char * value,
return 0;
}
int
MgmtSrvr::setConnectionDbParameter(int node1,
int node2,
int param,
int value,
BaseString& msg){
Uint32 current_value,new_value;
DBUG_ENTER("MgmtSrvr::setConnectionDbParameter");
ndb_mgm_configuration_iterator iter(* _config->m_configValues,
CFG_SECTION_CONNECTION);
if(iter.first() != 0){
msg.assign("Unable to find connection section (iter.first())");
return -1;
}
for(;iter.valid();iter.next()) {
Uint32 n1,n2;
iter.get(CFG_CONNECTION_NODE_1, &n1);
iter.get(CFG_CONNECTION_NODE_2, &n2);
if(n1 == (unsigned)node1 && n2 == (unsigned)node2)
break;
}
if(!iter.valid()) {
msg.assign("Unable to find connection between nodes");
return -1;
}
if(iter.get(param, &current_value) < 0) {
msg.assign("Unable to get current value of parameter");
return -1;
}
ConfigValues::Iterator i2(_config->m_configValues->m_config,
iter.m_config);
if(i2.set(param, (unsigned)value) < 0) {
msg.assign("Unable to set new value of parameter");
return -1;
}
if(iter.get(param, &new_value) < 0) {
msg.assign("Unable to get parameter after setting it.");
return -1;
}
msg.assfmt("%u -> %u",current_value,new_value);
return 1;
}
template class Vector<SigMatch>;
#if __SUNPRO_CC != 0x560
template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch*&, NdbApiSignal*&, unsigned);
......
......@@ -500,6 +500,9 @@ public:
int getPort() const;
int setDbParameter(int node, int parameter, const char * value, BaseString&);
int setConnectionDbParameter(int node1, int node2, int param, int value,
BaseString& msg);
const char *get_connect_address(Uint32 node_id) { return inet_ntoa(m_connect_address[node_id]); }
void get_connected_nodes(NodeBitmask &connected_nodes) const;
......
......@@ -238,6 +238,13 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("parameter", String, Mandatory, "Parameter"),
MGM_ARG("value", String, Mandatory, "Value"),
MGM_CMD("set connection parameter",
&MgmApiSession::setConnectionParameter, ""),
MGM_ARG("node1", String, Mandatory, "Node1 ID"),
MGM_ARG("node2", String, Mandatory, "Node2 ID"),
MGM_ARG("param", String, Mandatory, "Parameter"),
MGM_ARG("value", String, Mandatory, "Value"),
MGM_CMD("listen event", &MgmApiSession::listen_event, ""),
MGM_ARG("node", Int, Optional, "Node"),
MGM_ARG("filter", String, Mandatory, "Event category"),
......@@ -1347,6 +1354,29 @@ MgmApiSession::setParameter(Parser_t::Context &,
m_output->println("");
}
void
MgmApiSession::setConnectionParameter(Parser_t::Context &ctx,
Properties const &args) {
BaseString node1, node2, param, value;
args.get("node1", node1);
args.get("node2", node2);
args.get("param", param);
args.get("value", value);
BaseString result;
int ret = m_mgmsrv.setConnectionDbParameter(atoi(node1.c_str()),
atoi(node2.c_str()),
atoi(param.c_str()),
atoi(value.c_str()),
result);
m_output->println("set connection parameter reply");
m_output->println("message: %s", result.c_str());
m_output->println("result: %s", (ret>0)?"Ok":"Failed");
m_output->println("");
}
void
MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx,
Properties const & args) {
......
......@@ -88,6 +88,9 @@ public:
void configChange(Parser_t::Context &ctx, const class Properties &args);
void setParameter(Parser_t::Context &ctx, const class Properties &args);
void setConnectionParameter(Parser_t::Context &ctx,
const class Properties &args);
void listen_event(Parser_t::Context &ctx, const class Properties &args);
void purge_stale_sessions(Parser_t::Context &ctx, const class Properties &args);
......
......@@ -111,6 +111,8 @@ public:
Uint32 get_batch_byte_size();
Uint32 get_batch_size();
TransporterRegistry* get_registry() { return theTransporterRegistry;};
private:
/**
* Send a signal unconditional of node status (used by ClusterMgr)
......
......@@ -26,6 +26,7 @@
#include <ndb_limits.h>
#include <ConfigRetriever.hpp>
#include <ndb_version.h>
#include <mgmapi_debug.h>
static int g_run_connect_thread= 0;
......@@ -146,6 +147,8 @@ int Ndb_cluster_connection::start_connect_thread(int (*connect_callback)(void))
int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds, int verbose)
{
struct ndb_mgm_reply mgm_reply;
DBUG_ENTER("Ndb_cluster_connection::connect");
const char* error = 0;
do {
......@@ -160,7 +163,19 @@ int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds,
ndb_mgm_configuration * props = m_config_retriever->getConfig();
if(props == 0)
break;
DBUG_PRINT("Before start_instance",("Before start_instance2"));
m_facade->start_instance(nodeId, props);
DBUG_PRINT("After start_instance",("before start_instance2"));
// report port here.
DBUG_PRINT("set_conn",("%d",m_facade->get_registry()->m_transporter_interface.size()));
for(int i=0;i<m_facade->get_registry()->m_transporter_interface.size();i++)
ndb_mgm_set_connection_int_parameter(m_config_retriever->get_mgmHandle(),
nodeId,
m_facade->get_registry()->m_transporter_interface[i].m_remote_nodeId,
CFG_CONNECTION_SERVER_PORT,
m_facade->get_registry()->m_transporter_interface[i].m_service_port,
&mgm_reply);
ndb_mgm_destroy_configuration(props);
m_facade->connected();
DBUG_RETURN(0);
......
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