Below is the list of changes that have just been committed into a local
5.1 repository of stewart. When stewart does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1907 05/09/01 18:30:56 stewart@stripped +8 -0
WL#2703 config reload
support configuration locking across multiple mgm servers.
TODO:
- drop lock when mgm server holding the lock fails
storage/ndb/src/mgmsrv/Services.hpp
1.16 05/09/01 18:30:45 stewart@stripped +0 -1
remove old configChange()
storage/ndb/src/mgmsrv/Services.cpp
1.51 05/09/01 18:30:45 stewart@stripped +18 -8
Add propagate argument to 'config lock'. if true, this mgm server will lock the config
on other mgm server nodes. if false, the lock is just for this mgm server.
Add local argument to config reload. If true, load from local file. Otherwise load
from network.
storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp
1.8 05/09/01 18:30:45 stewart@stripped +94 -14
Support cofig locks spread across multiple mgm servers.
storage/ndb/src/mgmsrv/MgmtSrvr.hpp
1.37 05/09/01 18:30:45 stewart@stripped +3 -9
prototype for 'propagate' parameter to lockConf()
prototype for 'local' parameter to config_reload()
remove old prototype for changeConfig
Add member Vector m_mgm_handles to be used when config is locked.
storage/ndb/src/mgmsrv/MgmtSrvr.cpp
1.82 05/09/01 18:30:45 stewart@stripped +6 -2
support local parameter to config_reload
storage/ndb/src/mgmclient/CommandInterpreter.cpp
1.56 05/09/01 18:30:45 stewart@stripped +1 -1
'config reload' should reload from local file
storage/ndb/src/mgmapi/mgmapi.cpp
1.54 05/09/01 18:30:44 stewart@stripped +66 -1
Add local argument to ndb_mgm_config_reload.
If set, load configuration out of local file.
Add ndb_mgm_config_(un)lock() apis.
storage/ndb/include/mgmapi/mgmapi.h
1.47 05/09/01 18:30:44 stewart@stripped +5 -1
Add option to ndb_mgm_config_reload to indicate if the load should be from a local
file or over the network.
add prototypes for ndb_mgm_config_(un)lock()
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: stewart
# Host: kennedy.(none)
# Root: /home/stewart/Documents/MySQL/5.1/wl2703
--- 1.46/storage/ndb/include/mgmapi/mgmapi.h 2005-08-25 22:54:42 +10:00
+++ 1.47/storage/ndb/include/mgmapi/mgmapi.h 2005-09-01 18:30:44 +10:00
@@ -973,10 +973,11 @@
* Reload Configuration
*
* @param handle NDB management handle.
+ * @param local load configuration from local file
*
* @return < 0 on error
*/
- int ndb_mgm_config_reload(NdbMgmHandle handle);
+ int ndb_mgm_config_reload(NdbMgmHandle handle, int local);
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/** @} *********************************************************************/
@@ -1007,6 +1008,9 @@
* Get the node id of the mgm server we're connected to
*/
Uint32 ndb_mgm_get_mgmd_nodeid(NdbMgmHandle handle);
+
+ int ndb_mgm_config_lock(NdbMgmHandle handle, int propagate);
+ int ndb_mgm_config_unlock(NdbMgmHandle handle, int commit);
/**
* Config iterator
--- 1.53/storage/ndb/src/mgmapi/mgmapi.cpp 2005-08-29 12:19:09 +10:00
+++ 1.54/storage/ndb/src/mgmapi/mgmapi.cpp 2005-09-01 18:30:44 +10:00
@@ -2287,7 +2287,7 @@
extern "C"
int
-ndb_mgm_config_reload(NdbMgmHandle handle)
+ndb_mgm_config_reload(NdbMgmHandle handle, int local)
{
Uint32 result=0;
@@ -2296,6 +2296,7 @@
CHECK_CONNECTED(handle, 0);
Properties args;
+ args.put("local", local);
const ParserRow<ParserDummy> reply[]= {
MGM_CMD("config reload reply", NULL, ""),
@@ -2305,6 +2306,70 @@
const Properties *prop;
prop = ndb_mgm_call(handle, reply, "config reload", &args);
+ CHECK_REPLY(prop, 0);
+
+ if(!prop->get("result",&result)){
+ ndbout_c("Unable to get value");
+ return 0;
+ }
+
+ delete prop;
+ DBUG_RETURN(result);
+}
+
+extern "C"
+int
+ndb_mgm_config_lock(NdbMgmHandle handle, int propagate)
+{
+ Uint32 result=0;
+
+ DBUG_ENTER("ndb_mgm_config_lock");
+ CHECK_HANDLE(handle, 0);
+ CHECK_CONNECTED(handle, 0);
+
+ Properties args;
+ args.put("propagate", propagate);
+
+ const ParserRow<ParserDummy> reply[]= {
+ MGM_CMD("config lock reply", NULL, ""),
+ MGM_ARG("result", Int, Mandatory, "Result"),
+ MGM_END()
+ };
+
+ const Properties *prop;
+ prop = ndb_mgm_call(handle, reply, "config lock", &args);
+ CHECK_REPLY(prop, 0);
+
+ if(!prop->get("result",&result)){
+ ndbout_c("Unable to get value");
+ return 0;
+ }
+
+ delete prop;
+ DBUG_RETURN(result);
+}
+
+extern "C"
+int
+ndb_mgm_config_unlock(NdbMgmHandle handle, int commit)
+{
+ Uint32 result=0;
+
+ DBUG_ENTER("ndb_mgm_config_unlock");
+ CHECK_HANDLE(handle, 0);
+ CHECK_CONNECTED(handle, 0);
+
+ Properties args;
+ args.put("commit", commit);
+
+ const ParserRow<ParserDummy> reply[]= {
+ MGM_CMD("config unlock reply", NULL, ""),
+ MGM_ARG("result", Int, Mandatory, "Result"),
+ MGM_END()
+ };
+
+ const Properties *prop;
+ prop = ndb_mgm_call(handle, reply, "config unlock", &args);
CHECK_REPLY(prop, 0);
if(!prop->get("result",&result)){
--- 1.55/storage/ndb/src/mgmclient/CommandInterpreter.cpp 2005-08-25 22:54:43 +10:00
+++ 1.56/storage/ndb/src/mgmclient/CommandInterpreter.cpp 2005-09-01 18:30:45 +10:00
@@ -2326,7 +2326,7 @@
ndbout << "Reloading configuration..." << endl;
ndbout << "Config Reload result: "
- << ndb_mgm_config_reload(m_mgmsrv)
+ << ndb_mgm_config_reload(m_mgmsrv,true)
<< endl;
return;
--- 1.81/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2005-08-29 12:19:09 +10:00
+++ 1.82/storage/ndb/src/mgmsrv/MgmtSrvr.cpp 2005-09-01 18:30:45 +10:00
@@ -2863,7 +2863,7 @@
return ndb_mgm_set_connectstring(m_config_retriever->get_mgmHandle(),str);
}
-int MgmtSrvr::config_reload()
+int MgmtSrvr::config_reload(int local)
{
NodeId nodeId= 0;
bool next;
@@ -2877,7 +2877,11 @@
DBUG_RETURN(-1);
}
delete _config;
- _config= readConfig();
+ if(local)
+ _config= readConfig();
+ else
+ _config= fetchConfig();
+
unlock_config();
DBUG_RETURN(retval);
--- 1.36/storage/ndb/src/mgmsrv/MgmtSrvr.hpp 2005-08-25 22:54:43 +10:00
+++ 1.37/storage/ndb/src/mgmsrv/MgmtSrvr.hpp 2005-09-01 18:30:45 +10:00
@@ -229,7 +229,7 @@
/**
* Lock configuration
*/
- int lockConf();
+ int lockConf(bool propagate);
/**
* Unlock configuration, and commit it if commit is true
@@ -484,13 +484,6 @@
const Config * getConfig() const;
/**
- * Change configuration paramter
- */
- bool changeConfig(const BaseString §ion,
- const BaseString ¶m,
- const BaseString &value);
-
- /**
* Returns the node count for the specified node type.
*
* @param type The node type.
@@ -512,7 +505,7 @@
int set_connect_string(const char *str);
- int config_reload();
+ int config_reload(int local);
void transporter_connect(NDB_SOCKET_TYPE sockfd);
@@ -557,6 +550,7 @@
Config * m_oldConfig; // used in configuration updates
BaseString m_configFilename;
Uint32 m_nextConfigGenerationNumber;
+ Vector<NdbMgmHandle> m_mgm_handles;
int lock_config();
int unlock_config();
--- 1.7/storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp 2005-08-25 22:11:09 +10:00
+++ 1.8/storage/ndb/src/mgmsrv/MgmtSrvrConfig.cpp 2005-09-01 18:30:45 +10:00
@@ -22,29 +22,100 @@
#include <InitConfigFileParser.hpp>
#include <ConfigRetriever.hpp>
#include <ndb_version.h>
+#include <mgmapi.h>
+#include <mgmapi_configuration.hpp>
+#include <mgmapi_config_parameters.h>
int
-MgmtSrvr::lockConf() {
+MgmtSrvr::lockConf(bool propagate) {
int result = 0;
- MgmLockConfigReq* lockReq;
+ int i;
NodeId node = 0;
+ DBUG_ENTER("MgmtSrvr::lockConf");
+
if(!lock_config())
- return -1;
+ DBUG_RETURN(-1);
+
+ ndb_mgm_configuration_iterator
+ iter(* _config->m_configValues, CFG_SECTION_NODE);
+
+ if(iter.first() != 0){
+ result= -2;
+ DBUG_PRINT("info",("failed iterator"));
+ goto error;
+ }
_config->setGenerationNumber(_config->getGenerationNumber()+1);
m_oldConfig= new Config(*_config); /* copy the existing config */
- node = 0;
- while(getNextNodeId(&node, NDB_MGM_NODE_TYPE_MGM)) {
- if(node != _ownNodeId) {
- // connect and lock
+ if(!propagate)
+ goto done;
+
+ for(;iter.valid();iter.next()) {
+ Uint32 type, id;
+ if(iter.get(CFG_TYPE_OF_SECTION, &type))
+ continue;
+ if(type != NODE_TYPE_MGM)
+ continue;
+
+ if(iter.get(CFG_NODE_ID, &id))
+ continue;
+
+ if(id==_ownNodeId)
+ continue;
+
+ const char* hostname;
+ Uint32 port;
+ BaseString connect_string;
+
+ if(iter.get(CFG_NODE_HOST, &hostname)) continue;
+ if( strlen(hostname) == 0 ) continue;
+ if(iter.get(CFG_MGM_PORT, &port)) continue;
+ connect_string.appfmt("%s:%u",hostname,port);
+
+ DBUG_PRINT("info",("connect string: %s",connect_string.c_str()));
+
+ NdbMgmHandle h= ndb_mgm_create_handle();
+ if ( h && connect_string.length() > 0 )
+ {
+ ndb_mgm_set_connectstring(h,connect_string.c_str());
+ if(ndb_mgm_connect(h,1,0,0))
+ {
+ result= -3;
+ DBUG_PRINT("info",("failed ndb_mgm_connect"));
+ goto error;
+ }
+ if(ndb_mgm_config_lock(h,false)!=0)
+ {
+ result= -4;
+ DBUG_PRINT("info",("failed remote lock"));
+ goto error;
+ }
+ m_mgm_handles.push_back(h);
+ }
+ else
+ {
+ result= -5;
+ goto error;
}
}
- done:
- return result;
+done:
+ DBUG_RETURN(result);
+
+error:
+ for(i=0;i<m_mgm_handles.size();i++)
+ {
+ if(ndb_mgm_is_connected(m_mgm_handles[i]))
+ ndb_mgm_config_unlock(m_mgm_handles[i],0);
+ ndb_mgm_destroy_handle(&m_mgm_handles[i]);
+ }
+ m_mgm_handles.clear();
+
+ unlock_config();
+ DBUG_RETURN(result);
}
/**
@@ -55,6 +126,7 @@
int
MgmtSrvr::unlockConf(bool commit) {
int result = 0;
+ int i;
MgmUnlockConfigReq* unlockReq;
NodeId node = 0;
@@ -65,15 +137,21 @@
else
rollbackConfig();
- node = 0;
- while(getNextNodeId(&node, NDB_MGM_NODE_TYPE_MGM)) {
- if(node != _ownNodeId) {
- // fetch new, unlock & commit
+ NdbMutex_Unlock(m_configMutex);
+
+ for(i=0;i<m_mgm_handles.size();i++)
+ {
+ if(ndb_mgm_is_connected(m_mgm_handles[i]))
+ {
+ if(commit)
+ ndb_mgm_config_reload(m_mgm_handles[i],false);
+ ndb_mgm_config_unlock(m_mgm_handles[i],commit);
}
+ ndb_mgm_destroy_handle(&m_mgm_handles[i]);
}
+ m_mgm_handles.clear();
done:
- NdbMutex_Unlock(m_configMutex);
return result;
}
@@ -160,3 +238,5 @@
return 0;
return 1;
}
+
+template class Vector<NdbMgmHandle>;
--- 1.50/storage/ndb/src/mgmsrv/Services.cpp 2005-08-25 22:54:43 +10:00
+++ 1.51/storage/ndb/src/mgmsrv/Services.cpp 2005-09-01 18:30:45 +10:00
@@ -223,6 +223,7 @@
MGM_ARG("enable", Int, Mandatory, "1=disable, 0=enable, -1=toggle"),
MGM_CMD("config lock", &MgmApiSession::configLock, ""),
+ MGM_ARG("propagate", Int, Mandatory, "Distribute lock to others"),
MGM_CMD("config unlock", &MgmApiSession::configUnlock, ""),
MGM_ARG("commit", Int, Mandatory, "Commit changes"),
@@ -259,6 +260,7 @@
MGM_CMD("get mgmd nodeid", &MgmApiSession::get_mgmd_nodeid, ""),
MGM_CMD("config reload", &MgmApiSession::config_reload, ""),
+ MGM_ARG("local", Int, Mandatory, "Load from local file"),
MGM_END()
};
@@ -1217,22 +1219,26 @@
}
void
-MgmApiSession::configLock(Parser_t::Context &,
- Properties const &) {
- int ret = m_mgmsrv.lockConf();
+MgmApiSession::configLock(Parser_t::Context &ctx,
+ const class Properties &args)
+{
+ Uint32 propagate;
+ args.get("propagate", &propagate);
+ int ret = m_mgmsrv.lockConf(propagate);
m_output->println("config lock reply");
- m_output->println("result: %d", ret);
+ m_output->println("result:%u", ret);
m_output->println("");
}
void
-MgmApiSession::configUnlock(Parser_t::Context &,
- Properties const &args) {
+MgmApiSession::configUnlock(Parser_t::Context &ctx,
+ const class Properties &args)
+{
Uint32 commit;
args.get("commit", &commit);
int ret = m_mgmsrv.unlockConf(commit == 1);
m_output->println("config unlock reply");
- m_output->println("result: %d", ret);
+ m_output->println("result:%u", ret);
m_output->println("");
}
@@ -1604,8 +1610,12 @@
MgmApiSession::config_reload(Parser_t::Context &ctx,
Properties const &args)
{
+ BaseString local;
+
+ args.get("local", local);
+
m_output->println("config reload reply");
- m_output->println("result:%u",m_mgmsrv.config_reload());
+ m_output->println("result:%u",m_mgmsrv.config_reload(atoi(local.c_str())));
m_output->println("");
}
--- 1.15/storage/ndb/src/mgmsrv/Services.hpp 2005-08-25 22:54:43 +10:00
+++ 1.16/storage/ndb/src/mgmsrv/Services.hpp 2005-09-01 18:30:45 +10:00
@@ -85,7 +85,6 @@
void setLogFilter(Parser_t::Context &ctx, const class Properties &args);
void configLock(Parser_t::Context &ctx, const class Properties &args);
void configUnlock(Parser_t::Context &ctx, const class Properties &args);
- 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,
| Thread |
|---|
| • bk commit into 5.1 tree (stewart:1.1907) | Stewart Smith | 1 Sep |