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

Remove old and usused configuration locking code.

Some new code that does this job is being written against 5.1. This code is
largely removed from that work.
parent 9dd20d77
...@@ -834,14 +834,6 @@ extern const GlobalSignalNumber NO_OF_SIGNAL_NAMES; ...@@ -834,14 +834,6 @@ extern const GlobalSignalNumber NO_OF_SIGNAL_NAMES;
/* Start Global Replication */ /* Start Global Replication */
#define GSN_GREP_REQ 656 #define GSN_GREP_REQ 656
/**
* Management server
*/
#define GSN_MGM_LOCK_CONFIG_REQ 657
#define GSN_MGM_LOCK_CONFIG_REP 658
#define GSN_MGM_UNLOCK_CONFIG_REQ 659
#define GSN_MGM_UNLOCK_CONFIG_REP 660
#define GSN_UTIL_CREATE_LOCK_REQ 132 #define GSN_UTIL_CREATE_LOCK_REQ 132
#define GSN_UTIL_CREATE_LOCK_REF 133 #define GSN_UTIL_CREATE_LOCK_REF 133
#define GSN_UTIL_CREATE_LOCK_CONF 188 #define GSN_UTIL_CREATE_LOCK_CONF 188
......
...@@ -179,90 +179,3 @@ void Config::printConfigFile(NdbOut &out) const { ...@@ -179,90 +179,3 @@ void Config::printConfigFile(NdbOut &out) const {
} }
#endif #endif
} }
Uint32
Config::getGenerationNumber() const {
#if 0
Uint32 ret;
const Properties *prop = NULL;
get("SYSTEM", &prop);
if(prop != NULL)
if(prop->get("ConfigGenerationNumber", &ret))
return ret;
return 0;
#else
return 0;
#endif
}
int
Config::setGenerationNumber(Uint32 gen) {
#if 0
Properties *prop = NULL;
getCopy("SYSTEM", &prop);
if(prop != NULL) {
MGM_REQUIRE(prop->put("ConfigGenerationNumber", gen, true));
MGM_REQUIRE(put("SYSTEM", prop, true));
return 0;
}
return -1;
#else
return -1;
#endif
}
bool
Config::change(const BaseString &section,
const BaseString &param,
const BaseString &value) {
#if 0
const char *name;
Properties::Iterator it(this);
for(name = it.first(); name != NULL; name = it.next()) {
Properties *prop = NULL;
if(strcasecmp(section.c_str(), name) == 0) {
getCopy(name, &prop);
if(prop == NULL) /* doesn't exist */
return false;
if(value == "") {
prop->remove(param.c_str());
put(section.c_str(), prop, true);
} else {
PropertiesType t;
if(!prop->getTypeOf(param.c_str(), &t)) /* doesn't exist */
return false;
switch(t) {
case PropertiesType_Uint32:
long val;
char *ep;
errno = 0;
val = strtol(value.c_str(), &ep, 0);
if(value.length() == 0 || *ep != '\0') /* not a number */
return false;
if(errno == ERANGE)
return false;
prop->put(param.c_str(), (unsigned int)val, true);
put(section.c_str(), prop, true);
break;
case PropertiesType_char:
prop->put(param.c_str(), value.c_str(), true);
put(section.c_str(), prop, true);
break;
default:
return false;
}
}
break;
}
}
return true;
#else
return false;
#endif
}
...@@ -60,16 +60,6 @@ public: ...@@ -60,16 +60,6 @@ public:
printConfigFile(ndb); printConfigFile(ndb);
} }
Uint32 getGenerationNumber() const;
int setGenerationNumber(Uint32);
/** Change configuration
*/
bool change(const BaseString &section,
const BaseString &param,
const BaseString &value);
/** /**
* Info * Info
*/ */
......
...@@ -2086,26 +2086,6 @@ MgmtSrvr::repCommand(Uint32* repReqId, Uint32 request, bool waitCompleted) ...@@ -2086,26 +2086,6 @@ MgmtSrvr::repCommand(Uint32* repReqId, Uint32 request, bool waitCompleted)
return 0; return 0;
} }
NodeId
MgmtSrvr::getPrimaryNode() const {
#if 0
Uint32 tmp;
const Properties *prop = NULL;
getConfig()->get("SYSTEM", &prop);
if(prop == NULL)
return 0;
prop->get("PrimaryMGMNode", &tmp);
return tmp;
#else
return 0;
#endif
}
MgmtSrvr::Allocated_resources::Allocated_resources(MgmtSrvr &m) MgmtSrvr::Allocated_resources::Allocated_resources(MgmtSrvr &m)
: m_mgmsrv(m) : m_mgmsrv(m)
{ {
......
...@@ -214,27 +214,6 @@ public: ...@@ -214,27 +214,6 @@ public:
// NO_CONTACT_WITH_PROCESS, PROCESS_NOT_CONFIGURED, WRONG_PROCESS_TYPE, // NO_CONTACT_WITH_PROCESS, PROCESS_NOT_CONFIGURED, WRONG_PROCESS_TYPE,
// COULD_NOT_ALLOCATE_MEMORY, SEND_OR_RECEIVE_FAILED // COULD_NOT_ALLOCATE_MEMORY, SEND_OR_RECEIVE_FAILED
/**
* Lock configuration
*/
int lockConf();
/**
* Unlock configuration, and commit it if commit is true
*/
int unlockConf(bool commit);
/**
* Commit new configuration
*/
int commitConfig();
/**
* Rollback configuration
*/
int rollbackConfig();
/** /**
* Save a configuration to permanent storage * Save a configuration to permanent storage
*/ */
...@@ -462,13 +441,6 @@ public: ...@@ -462,13 +441,6 @@ public:
*/ */
const Config * getConfig() const; const Config * getConfig() const;
/**
* Change configuration paramter
*/
bool changeConfig(const BaseString &section,
const BaseString &param,
const BaseString &value);
/** /**
* Returns the node count for the specified node type. * Returns the node count for the specified node type.
* *
...@@ -477,11 +449,6 @@ public: ...@@ -477,11 +449,6 @@ public:
*/ */
int getNodeCount(enum ndb_mgm_node_type type) const; int getNodeCount(enum ndb_mgm_node_type type) const;
/**
* Returns the nodeId of the management master
*/
NodeId getPrimaryNode() const;
/** /**
* Returns the port number. * Returns the port number.
* @return port number. * @return port number.
...@@ -572,9 +539,6 @@ private: ...@@ -572,9 +539,6 @@ private:
// Returns: - // Returns: -
//************************************************************************** //**************************************************************************
void handle_MGM_LOCK_CONFIG_REQ(NdbApiSignal *signal);
void handle_MGM_UNLOCK_CONFIG_REQ(NdbApiSignal *signal);
//************************************************************************** //**************************************************************************
// Specific signal handling data // Specific signal handling data
//************************************************************************** //**************************************************************************
......
...@@ -23,232 +23,6 @@ ...@@ -23,232 +23,6 @@
#include <ConfigRetriever.hpp> #include <ConfigRetriever.hpp>
#include <ndb_version.h> #include <ndb_version.h>
#if 0 // code must be rewritten to use SignalSender
void
MgmtSrvr::handle_MGM_LOCK_CONFIG_REQ(NdbApiSignal *signal) {
NodeId sender = refToNode(signal->theSendersBlockRef);
const MgmLockConfigReq * const req = CAST_CONSTPTR(MgmLockConfigReq, signal->getDataPtr());
NdbApiSignal *reply = getSignal();
if(signal == NULL)
return; /** @todo handle allocation failure */
reply->set(TestOrd::TraceAPI,
MGMSRV,
GSN_MGM_LOCK_CONFIG_REP,
MgmLockConfigRep::SignalLength);
MgmLockConfigRep *lockRep = CAST_PTR(MgmLockConfigRep, reply->getDataPtrSend());
lockRep->errorCode = MgmLockConfigRep::UNKNOWN_ERROR;
if(req->newConfigGeneration < m_nextConfigGenerationNumber) {
lockRep->errorCode = MgmLockConfigRep::GENERATION_MISMATCH;
goto done;
}
NdbMutex_Lock(m_configMutex);
m_nextConfigGenerationNumber = req->newConfigGeneration+1;
lockRep->errorCode = MgmLockConfigRep::OK;
done:
sendSignal(sender, NO_WAIT, reply, true);
NdbMutex_Unlock(m_configMutex);
return;
}
void
MgmtSrvr::handle_MGM_UNLOCK_CONFIG_REQ(NdbApiSignal *signal) {
NodeId sender = refToNode(signal->theSendersBlockRef);
const MgmUnlockConfigReq * const req = CAST_CONSTPTR(MgmUnlockConfigReq, signal->getDataPtr());
MgmUnlockConfigRep *unlockRep;
NdbApiSignal *reply = getSignal();
if(signal == NULL)
goto error; /** @todo handle allocation failure */
reply->set(TestOrd::TraceAPI,
MGMSRV,
GSN_MGM_UNLOCK_CONFIG_REP,
MgmUnlockConfigRep::SignalLength);
unlockRep = CAST_PTR(MgmUnlockConfigRep, reply->getDataPtrSend());
unlockRep->errorCode = MgmUnlockConfigRep::UNKNOWN_ERROR;
NdbMutex_Lock(m_configMutex);
if(req->commitConfig == 1) {
m_newConfig = fetchConfig();
commitConfig();
} else
rollbackConfig();
unlockRep->errorCode = MgmUnlockConfigRep::OK;
sendSignal(sender, NO_WAIT, reply, true);
error:
NdbMutex_Unlock(m_configMutex);
return;
}
/**
* Prepare all MGM nodes for configuration changes
*
* @returns 0 on success, or -1 on failure
*/
int
MgmtSrvr::lockConf() {
int result = -1;
MgmLockConfigReq* lockReq;
NodeId node = 0;
/* Check if this is the master node */
if(getPrimaryNode() != _ownNodeId)
goto done;
if(NdbMutex_Trylock(m_configMutex) != 0)
return -1;
m_newConfig = new Config(*_config); /* copy the existing config */
_config = m_newConfig;
m_newConfig = new Config(*_config);
m_nextConfigGenerationNumber++;
/* Make sure the new configuration _always_ is at least one step older */
if(m_nextConfigGenerationNumber < m_newConfig->getGenerationNumber()+1)
m_nextConfigGenerationNumber = _config->getGenerationNumber()+1;
m_newConfig->setGenerationNumber(m_nextConfigGenerationNumber);
node = 0;
while(getNextNodeId(&node, NDB_MGM_NODE_TYPE_MGM)) {
if(node != _ownNodeId) {
NdbApiSignal* signal = getSignal();
if (signal == NULL) {
result = COULD_NOT_ALLOCATE_MEMORY;
goto done;
}
lockReq = CAST_PTR(MgmLockConfigReq, signal->getDataPtrSend());
signal->set(TestOrd::TraceAPI,
MGMSRV,
GSN_MGM_LOCK_CONFIG_REQ,
MgmLockConfigReq::SignalLength);
lockReq->newConfigGeneration = m_nextConfigGenerationNumber;
result = sendSignal(node, NO_WAIT, signal, true);
NdbApiSignal *reply =
m_signalRecvQueue.waitFor(GSN_MGM_LOCK_CONFIG_REP, 0);
if(reply == NULL) {
/** @todo handle timeout/error */
ndbout << __FILE__ << ":" << __LINE__ << endl;
result = -1;
goto done;
}
}
}
done:
NdbMutex_Unlock(m_configMutex);
return result;
}
/**
* Unlocks configuration
*
* @returns 0 on success, ! 0 on error
*/
int
MgmtSrvr::unlockConf(bool commit) {
int result = -1;
MgmUnlockConfigReq* unlockReq;
NodeId node = 0;
/* Check if this is the master node */
if(getPrimaryNode() != _ownNodeId)
goto done;
errno = 0;
if(NdbMutex_Lock(m_configMutex) != 0)
return -1;
if(commit)
commitConfig();
else
rollbackConfig();
node = 0;
while(getNextNodeId(&node, NDB_MGM_NODE_TYPE_MGM)) {
if(node != _ownNodeId) {
NdbApiSignal* signal = getSignal();
if (signal == NULL) {
result = COULD_NOT_ALLOCATE_MEMORY;
goto done;
}
unlockReq = CAST_PTR(MgmUnlockConfigReq, signal->getDataPtrSend());
signal->set(TestOrd::TraceAPI,
MGMSRV,
GSN_MGM_UNLOCK_CONFIG_REQ,
MgmUnlockConfigReq::SignalLength);
unlockReq->commitConfig = commit;
result = sendSignal(node, NO_WAIT, signal, true);
NdbApiSignal *reply =
m_signalRecvQueue.waitFor(GSN_MGM_UNLOCK_CONFIG_REP, 0);
if(reply == NULL) {
/** @todo handle timeout/error */
result = -1;
goto done;
}
}
}
done:
NdbMutex_Unlock(m_configMutex);
return result;
}
#endif // code must be rewritten to use SignalSender
/**
* Commit the new configuration
*/
int
MgmtSrvr::commitConfig() {
int ret = saveConfig(m_newConfig);
delete _config;
_config = m_newConfig;
m_newConfig = NULL;
ndbout << "commit " << ret << endl;
return ret;
}
/**
* Rollback to the old configuration
*/
int
MgmtSrvr::rollbackConfig() {
delete m_newConfig;
m_newConfig = NULL;
ndbout << "rollback" << endl;
return saveConfig(_config);
}
/** /**
* Save a configuration to the running configuration file * Save a configuration to the running configuration file
*/ */
...@@ -292,12 +66,3 @@ MgmtSrvr::fetchConfig() { ...@@ -292,12 +66,3 @@ MgmtSrvr::fetchConfig() {
} }
return 0; return 0;
} }
bool
MgmtSrvr::changeConfig(const BaseString &section,
const BaseString &param,
const BaseString &value) {
if(m_newConfig == NULL)
return false;
return m_newConfig->change(section, param, value);
}
...@@ -221,21 +221,6 @@ ParserRow<MgmApiSession> commands[] = { ...@@ -221,21 +221,6 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("level", Int, Mandatory, "Severety level"), MGM_ARG("level", Int, Mandatory, "Severety level"),
MGM_ARG("enable", Int, Mandatory, "1=disable, 0=enable, -1=toggle"), MGM_ARG("enable", Int, Mandatory, "1=disable, 0=enable, -1=toggle"),
MGM_CMD("config lock", &MgmApiSession::configLock, ""),
MGM_CMD("config unlock", &MgmApiSession::configUnlock, ""),
MGM_ARG("commit", Int, Mandatory, "Commit changes"),
MGM_CMD("config change", &MgmApiSession::configChange, ""),
MGM_ARG("section", String, Mandatory, "Section"),
MGM_ARG("parameter", String, Mandatory, "Parameter"),
MGM_ARG("value", String, Mandatory, "Value"),
MGM_CMD("config lock", &MgmApiSession::configLock, ""),
MGM_CMD("config unlock", &MgmApiSession::configUnlock, ""),
MGM_ARG("commit", Int, Mandatory, "Commit changes"),
MGM_CMD("set parameter", &MgmApiSession::setParameter, ""), MGM_CMD("set parameter", &MgmApiSession::setParameter, ""),
MGM_ARG("node", String, Mandatory, "Node"), MGM_ARG("node", String, Mandatory, "Node"),
MGM_ARG("parameter", String, Mandatory, "Parameter"), MGM_ARG("parameter", String, Mandatory, "Parameter"),
...@@ -1200,50 +1185,6 @@ MgmApiSession::setLogFilter(Parser_t::Context &ctx, ...@@ -1200,50 +1185,6 @@ MgmApiSession::setLogFilter(Parser_t::Context &ctx,
m_output->println(""); m_output->println("");
} }
void
MgmApiSession::configLock(Parser_t::Context &,
Properties const &) {
#if 0 // not implemented
int ret = m_mgmsrv.lockConf();
#else
int ret = -1;
#endif
m_output->println("config lock reply");
m_output->println("result: %d", ret);
m_output->println("");
}
void
MgmApiSession::configUnlock(Parser_t::Context &,
Properties const &args) {
Uint32 commit;
args.get("commit", &commit);
#if 0 // not implemented
int ret = m_mgmsrv.unlockConf(commit == 1);
#else
int ret = -1;
#endif
m_output->println("config unlock reply");
m_output->println("result: %d", ret);
m_output->println("");
}
void
MgmApiSession::configChange(Parser_t::Context &,
Properties const &args) {
BaseString section, param, value;
args.get("section", section);
args.get("parameter", param);
args.get("value", value);
int ret = m_mgmsrv.changeConfig(section.c_str(),
param.c_str(),
value.c_str());
m_output->println("config change reply");
m_output->println("result: %d", ret);
m_output->println("");
}
static NdbOut& static NdbOut&
operator<<(NdbOut& out, const LogLevel & ll) operator<<(NdbOut& out, const LogLevel & ll)
{ {
......
...@@ -83,9 +83,6 @@ public: ...@@ -83,9 +83,6 @@ public:
void setClusterLogLevel(Parser_t::Context &ctx, void setClusterLogLevel(Parser_t::Context &ctx,
const class Properties &args); const class Properties &args);
void setLogFilter(Parser_t::Context &ctx, const class Properties &args); 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 setParameter(Parser_t::Context &ctx, const class Properties &args);
void listen_event(Parser_t::Context &ctx, const class Properties &args); void listen_event(Parser_t::Context &ctx, const class Properties &args);
......
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