Commit 9e87252c authored by stewart@mysql.com's avatar stewart@mysql.com

Merge mysql.com:/home/stewart/Documents/MySQL/4.1/main

into  mysql.com:/home/stewart/Documents/MySQL/4.1/mgmd
parents 45f667cd 1b07fe2e
......@@ -553,7 +553,6 @@ extern const GlobalSignalNumber NO_OF_SIGNAL_NAMES;
#define GSN_STATISTICS_CONF 454
#define GSN_START_ORD 455
/* 456 unused */
/* 457 unused */
#define GSN_EVENT_SUBSCRIBE_REQ 458
......@@ -835,14 +834,6 @@ extern const GlobalSignalNumber NO_OF_SIGNAL_NAMES;
/* Start Global Replication */
#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_REF 133
#define GSN_UTIL_CREATE_LOCK_CONF 188
......@@ -900,6 +891,7 @@ extern const GlobalSignalNumber NO_OF_SIGNAL_NAMES;
#define GSN_RESUME_REQ 682
#define GSN_STOP_REQ 443
#define GSN_STOP_REF 444
#define GSN_STOP_CONF 456
#define GSN_API_VERSION_REQ 697
#define GSN_API_VERSION_CONF 698
......
......@@ -49,12 +49,11 @@ class ApiVersionConf {
*/
friend class MgmtSrv;
public:
STATIC_CONST( SignalLength = 3 );
STATIC_CONST( SignalLength = 4 );
Uint32 senderRef;
Uint32 nodeId; //api node id
Uint32 version; // Version of API node
Uint32 inet_addr;
};
#endif
......@@ -133,9 +133,9 @@ public:
CreateLogBytes = 48,
InfoEvent = 49,
//GREP
GrepSubscriptionInfo = 52,
GrepSubscriptionAlert = 53,
// SINGLE USER
SingleUser = 52,
/* unused 53 */
//BACKUP
BackupStarted = 54,
......
......@@ -67,6 +67,13 @@ public:
static bool getStopAbort(const Uint32 & requestInfo);
};
struct StopConf
{
STATIC_CONST( SignalLength = 2 );
Uint32 senderData;
Uint32 nodeState;
};
class StopRef
{
/**
......@@ -86,7 +93,8 @@ public:
OK = 0,
NodeShutdownInProgress = 1,
SystemShutdownInProgress = 2,
NodeShutdownWouldCauseSystemCrash = 3
NodeShutdownWouldCauseSystemCrash = 3,
TransactionAbortFailed = 4
};
public:
......
This diff is collapsed.
......@@ -1966,6 +1966,11 @@ Ndbcntr::execRESUME_REQ(Signal* signal){
//ResumeRef * const ref = (ResumeRef *)&signal->theData[0];
jamEntry();
signal->theData[0] = EventReport::SingleUser;
signal->theData[1] = 2;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
//Uint32 senderData = req->senderData;
//BlockReference senderRef = req->senderRef;
NodeState newState(NodeState::SL_STARTED);
......@@ -2004,12 +2009,11 @@ Ndbcntr::execSTOP_REQ(Signal* signal){
return;
}
if(c_stopRec.stopReq.senderRef != 0 && !singleuser){
jam();
if(c_stopRec.stopReq.senderRef != 0){
/**
* Requested a system shutdown
*/
if(StopReq::getSystemStop(req->requestInfo)){
if(!singleuser && StopReq::getSystemStop(req->requestInfo)){
jam();
sendSignalWithDelay(reference(), GSN_STOP_REQ, signal, 100,
StopReq::SignalLength);
......@@ -2031,22 +2035,27 @@ Ndbcntr::execSTOP_REQ(Signal* signal){
c_stopRec.stopReq = * req;
c_stopRec.stopInitiatedTime = NdbTick_CurrentMillisecond();
if(StopReq::getSystemStop(c_stopRec.stopReq.requestInfo) && !singleuser) {
if(!singleuser) {
if(StopReq::getSystemStop(c_stopRec.stopReq.requestInfo)) {
jam();
if(StopReq::getPerformRestart(c_stopRec.stopReq.requestInfo)){
((Configuration&)theConfiguration).stopOnError(false);
}
}
if(!singleuser) {
if(!c_stopRec.checkNodeFail(signal)){
jam();
return;
}
}
signal->theData[0] = EventReport::NDBStopStarted;
signal->theData[1] = StopReq::getSystemStop(c_stopRec.stopReq.requestInfo) ? 1 : 0;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
}
else
{
signal->theData[0] = EventReport::SingleUser;
signal->theData[1] = 0;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
}
NodeState newState(NodeState::SL_STOPPING_1,
StopReq::getSystemStop(c_stopRec.stopReq.requestInfo));
......@@ -2129,9 +2138,11 @@ Ndbcntr::StopRecord::checkNodeFail(Signal* signal){
stopReq.senderRef = 0;
if (cntr.getNodeState().startLevel != NodeState::SL_SINGLEUSER)
{
NodeState newState(NodeState::SL_STARTED);
cntr.updateNodeState(signal, newState);
}
signal->theData[0] = EventReport::NDBStopAborted;
cntr.sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 1, JBB);
......@@ -2227,12 +2238,24 @@ void Ndbcntr::execABORT_ALL_CONF(Signal* signal){
jamEntry();
if(c_stopRec.stopReq.singleuser) {
jam();
NodeState newState(NodeState::SL_SINGLEUSER);
newState.setSingleUser(true);
newState.setSingleUserApi(c_stopRec.stopReq.singleUserApi);
updateNodeState(signal, newState);
c_stopRec.stopInitiatedTime = NdbTick_CurrentMillisecond();
StopConf * const stopConf = (StopConf *)&signal->theData[0];
stopConf->senderData = c_stopRec.stopReq.senderData;
stopConf->nodeState = (Uint32) NodeState::SL_SINGLEUSER;
sendSignal(c_stopRec.stopReq.senderRef, GSN_STOP_CONF, signal, StopConf::SignalLength, JBB);
c_stopRec.stopReq.senderRef = 0; // the command is done
signal->theData[0] = EventReport::SingleUser;
signal->theData[1] = 1;
signal->theData[2] = c_stopRec.stopReq.singleUserApi;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 3, JBB);
}
else
{
......@@ -2250,7 +2273,13 @@ void Ndbcntr::execABORT_ALL_CONF(Signal* signal){
void Ndbcntr::execABORT_ALL_REF(Signal* signal){
jamEntry();
ndbrequire(false);
AbortAllRef *abortAllRef = (AbortAllRef *)&signal->theData[0];
AbortAllRef::ErrorCode errorCode = (AbortAllRef::ErrorCode) abortAllRef->errorCode;
StopRef * const stopRef = (StopRef *)&signal->theData[0];
stopRef->senderData = c_stopRec.stopReq.senderData;
stopRef->errorCode = StopRef::TransactionAbortFailed;
sendSignal(c_stopRec.stopReq.senderRef, GSN_STOP_REF, signal, StopRef::SignalLength, JBB);
}
void
......
......@@ -2012,6 +2012,8 @@ Qmgr::execAPI_VERSION_REQ(Signal * signal) {
else
conf->version = 0;
conf->nodeId = nodeId;
struct in_addr in= globalTransporterRegistry.get_connect_address(nodeId);
conf->inet_addr= in.s_addr;
sendSignal(senderRef,
GSN_API_VERSION_CONF,
......
......@@ -1430,9 +1430,8 @@ CommandInterpreter::executeEnterSingleUser(char* parameters)
ndbout_c("Entering single user mode for node %d failed", nodeId);
printError();
} else {
ndbout_c("Entering single user mode");
ndbout_c("Access will be granted for API node %d only.", nodeId);
ndbout_c("Use ALL STATUS to see when single user mode has been entered.");
ndbout_c("Single user mode entered");
ndbout_c("Access is granted for API node %d only.", nodeId);
}
}
......@@ -1445,7 +1444,7 @@ CommandInterpreter::executeExitSingleUser(char* parameters)
printError();
} else {
ndbout_c("Exiting single user mode in progress.");
ndbout_c("Use ALL STATUS to see when single user mode has been exited.");
ndbout_c("Use ALL STATUS or SHOW to see when single user mode has been exited.");
}
}
......
......@@ -179,90 +179,3 @@ void Config::printConfigFile(NdbOut &out) const {
}
#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:
printConfigFile(ndb);
}
Uint32 getGenerationNumber() const;
int setGenerationNumber(Uint32);
/** Change configuration
*/
bool change(const BaseString &section,
const BaseString &param,
const BaseString &value);
/**
* Info
*/
......
This diff is collapsed.
......@@ -22,15 +22,17 @@
#include <NdbCondition.h>
#include <mgmapi.h>
#include <NdbTCP.h>
#include <ConfigRetriever.hpp>
#include <Vector.hpp>
#include <NodeBitmask.hpp>
#include <signaldata/ManagementServer.hpp>
#include "SignalQueue.hpp"
#include <ndb_version.h>
#include <EventLogger.hpp>
#include <signaldata/EventSubscribeReq.hpp>
#include <SignalSender.hpp>
/**
* @desc Block number for Management server.
* @todo This should probably be somewhere else. I don't know where atm.
......@@ -199,51 +201,26 @@ public:
~MgmtSrvr();
int status(int processId,
/**
* Get status on a node.
* address may point to a common area (e.g. from inet_addr)
* There is no gaurentee that it is preserved across calls.
* Copy the string if you are not going to use it immediately.
*/
int status(int nodeId,
ndb_mgm_node_status * status,
Uint32 * version,
Uint32 * phase,
bool * systemShutdown,
Uint32 * dynamicId,
Uint32 * nodeGroup,
Uint32 * connectCount);
Uint32 * connectCount,
const char **address);
// All the functions below may return any of this error codes:
// NO_CONTACT_WITH_PROCESS, PROCESS_NOT_CONFIGURED, WRONG_PROCESS_TYPE,
// COULD_NOT_ALLOCATE_MEMORY, SEND_OR_RECEIVE_FAILED
typedef void (* StopCallback)(int nodeId, void * anyData, int errorCode);
typedef void (* VersionCallback)(int nodeId, int version,
void * anyData, int errorCode);
typedef void (* EnterSingleCallback)(int nodeId, void * anyData,
int errorCode);
typedef void (* ExitSingleCallback)(int nodeId, void * anyData,
int errorCode);
/**
* 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
*/
......@@ -272,12 +249,12 @@ public:
* @param processId: Id of the DB process to stop
* @return 0 if succeeded, otherwise: as stated above, plus:
*/
int stopNode(int nodeId, bool abort = false, StopCallback = 0, void *any= 0);
int stopNode(int nodeId, bool abort = false);
/**
* Stop the system
*/
int stop(int * cnt = 0, bool abort = false, StopCallback = 0, void *any = 0);
int stop(int * cnt = 0, bool abort = false);
/**
* print version info about a node
......@@ -285,27 +262,18 @@ public:
* @param processId: Id of the DB process to stop
* @return 0 if succeeded, otherwise: as stated above, plus:
*/
int versionNode(int nodeId, bool abort = false,
VersionCallback = 0, void *any= 0);
/**
* print version info about all node in the system
*/
int version(int * cnt = 0, bool abort = false,
VersionCallback = 0, void *any = 0);
int versionNode(int nodeId, Uint32 &version, const char **address);
/**
* Maintenance on the system
*/
int enterSingleUser(int * cnt = 0, Uint32 singleuserNodeId = 0,
EnterSingleCallback = 0, void *any = 0);
int enterSingleUser(int * cnt = 0, Uint32 singleuserNodeId = 0);
/**
* Resume from maintenance on the system
*/
int exitSingleUser(int * cnt = 0, bool abort = false,
ExitSingleCallback = 0, void *any = 0);
int exitSingleUser(int * cnt = 0, bool abort = false);
/**
* Start DB process.
......@@ -319,15 +287,14 @@ public:
* @param processId: Id of the DB process to start
*/
int restartNode(int processId, bool nostart, bool initialStart,
bool abort = false,
StopCallback = 0, void * anyData = 0);
bool abort = false);
/**
* Restart the system
*/
int restart(bool nostart, bool initialStart,
bool abort = false,
int * stopCount = 0, StopCallback = 0, void * anyData = 0);
int * stopCount = 0);
struct BackupEvent {
enum Event {
......@@ -481,13 +448,6 @@ public:
*/
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.
*
......@@ -496,11 +456,6 @@ public:
*/
int getNodeCount(enum ndb_mgm_node_type type) const;
/**
* Returns the nodeId of the management master
*/
NodeId getPrimaryNode() const;
/**
* Returns the port number.
* @return port number.
......@@ -517,7 +472,16 @@ public:
private:
//**************************************************************************
int setEventReportingLevel(int processId, LogLevel::EventCategory, Uint32);
int send(SignalSender &ss, SimpleSignal &ssig, Uint32 node, Uint32 node_type);
int sendSTOP_REQ(NodeId nodeId,
NodeBitmask &stoppedNodes,
Uint32 singleUserNodeId,
bool abort,
bool stop,
bool restart,
bool nostart,
bool initialStart);
/**
* Check if it is possible to send a signal to a (DB) process
......@@ -582,9 +546,6 @@ private:
// Returns: -
//**************************************************************************
void handle_MGM_LOCK_CONFIG_REQ(NdbApiSignal *signal);
void handle_MGM_UNLOCK_CONFIG_REQ(NdbApiSignal *signal);
//**************************************************************************
// Specific signal handling data
//**************************************************************************
......@@ -608,60 +569,9 @@ private:
enum WaitSignalType {
NO_WAIT, // We don't expect to receive any signal
WAIT_SET_VAR, // Accept SET_VAR_CONF and SET_VAR_REF
WAIT_SUBSCRIBE_CONF, // Accept event subscription confirmation
WAIT_STOP,
WAIT_BACKUP_STARTED,
WAIT_BACKUP_COMPLETED,
WAIT_VERSION,
WAIT_NODEFAILURE
WAIT_SUBSCRIBE_CONF // Accept event subscription confirmation
};
/**
* Get an unused signal
* @return A signal if succeeded, NULL otherwise
*/
NdbApiSignal* getSignal();
/**
* Add a signal to the list of unused signals
* @param signal: The signal to add
*/
void releaseSignal(NdbApiSignal* signal);
/**
* Remove a signal from the list of unused signals and delete
* the memory for it.
*/
void freeSignal();
/**
* Send a signal
* @param processId: Id of the receiver process
* @param waitState: State denoting a set of signals we accept to receive
* @param signal: The signal to send
* @return 0 if succeeded, -1 otherwise
*/
int sendSignal(Uint16 processId, WaitSignalType waitState,
NdbApiSignal* signal, bool force = false);
/**
* Send a signal and wait for an answer signal
* @param processId: Id of the receiver process
* @param waitState: State denoting a set of signals we accept to receive.
* @param signal: The signal to send
* @return 0 if succeeded, -1 otherwise (for example failed to send or
* failed to receive expected signal).
*/
int sendRecSignal(Uint16 processId, WaitSignalType waitState,
NdbApiSignal* signal, bool force = false,
int waitTime = WAIT_FOR_RESPONSE_TIMEOUT);
/**
* Wait for a signal to arrive.
* @return 0 if signal arrived, -1 otherwise
*/
int receiveOptimisedResponse(int waitTime);
/**
* This function is called from "outside" of MgmtSrvr
* when a signal is sent to MgmtSrvr.
......@@ -708,31 +618,7 @@ private:
class TransporterFacade * theFacade;
class SignalQueue m_signalRecvQueue;
struct StopRecord {
StopRecord(){ inUse = false; callback = 0; singleUserMode = false;}
bool inUse;
bool singleUserMode;
int sentCount;
int reply;
int nodeId;
void * anyData;
StopCallback callback;
};
StopRecord m_stopRec;
struct VersionRecord {
VersionRecord(){ inUse = false; callback = 0;}
bool inUse;
Uint32 version[MAX_NODES];
VersionCallback callback;
};
VersionRecord m_versionRec;
int sendVersionReq( int processId);
void handleStopReply(NodeId nodeId, Uint32 errCode);
int sendVersionReq( int processId, Uint32 &version, const char **address);
int translateStopRef(Uint32 errCode);
bool _isStopThread;
......@@ -753,14 +639,8 @@ private:
static void *logLevelThread_C(void *);
void logLevelThreadRun();
struct NdbThread *m_signalRecvThread;
static void *signalRecvThread_C(void *);
void signalRecvThreadRun();
Config *_props;
int send(class NdbApiSignal* signal, Uint32 node, Uint32 node_type);
ConfigRetriever *m_config_retriever;
};
......
......@@ -23,228 +23,6 @@
#include <ConfigRetriever.hpp>
#include <ndb_version.h>
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;
}
/**
* 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
*/
......@@ -288,12 +66,3 @@ MgmtSrvr::fetchConfig() {
}
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);
}
......@@ -20,123 +20,3 @@
// Some kind of reuse should be preferred.
//******************************************************************************
#include "MgmtSrvr.hpp"
#include <NdbApiSignal.hpp>
#include <NdbTick.h>
NdbApiSignal*
MgmtSrvr::getSignal()
{
NdbApiSignal* tSignal;
tSignal = theSignalIdleList;
if (tSignal != NULL){
NdbApiSignal* tSignalNext = tSignal->next();
tSignal->next(NULL);
theSignalIdleList = tSignalNext;
return tSignal;
} else
{
tSignal = new NdbApiSignal(_ownReference);
if (tSignal != NULL)
tSignal->next(NULL);
}
return tSignal;
}
void
MgmtSrvr::releaseSignal(NdbApiSignal* aSignal)
{
aSignal->next(theSignalIdleList);
theSignalIdleList = aSignal;
}
void
MgmtSrvr::freeSignal()
{
NdbApiSignal* tSignal = theSignalIdleList;
theSignalIdleList = tSignal->next();
delete tSignal;
}
int
MgmtSrvr::sendSignal(Uint16 aNodeId,
WaitSignalType aWaitState,
NdbApiSignal* aSignal,
bool force)
{
int tReturnCode;
theFacade->lock_mutex();
if(force){
tReturnCode = theFacade->sendSignalUnCond(aSignal,
aNodeId);
} else {
tReturnCode = theFacade->sendSignal(aSignal,
aNodeId);
}
releaseSignal(aSignal);
if (tReturnCode == -1) {
theFacade->unlock_mutex();
return -1;
}
theWaitState = aWaitState;
theFacade->unlock_mutex();
return 0;
}
int
MgmtSrvr::sendRecSignal(Uint16 aNodeId,
WaitSignalType aWaitState,
NdbApiSignal* aSignal,
bool force,
int waitTime)
{
int tReturnCode;
theFacade->lock_mutex();
if(force){
tReturnCode = theFacade->sendSignalUnCond(aSignal, aNodeId);
} else {
tReturnCode = theFacade->sendSignalUnCond(aSignal, aNodeId);
}
releaseSignal(aSignal);
if (tReturnCode == -1) {
theFacade->unlock_mutex();
return -1;
}
theWaitState = aWaitState;
theWaitNode = aNodeId;
return receiveOptimisedResponse(waitTime);
}
int
MgmtSrvr::receiveOptimisedResponse(int waitTime)
{
int tResultCode;
theFacade->checkForceSend(_blockNumber);
NDB_TICKS maxTime = NdbTick_CurrentMillisecond() + waitTime;
while (theWaitState != NO_WAIT && theWaitState != WAIT_NODEFAILURE
&& waitTime > 0) {
NdbCondition_WaitTimeout(theMgmtWaitForResponseCondPtr,
theFacade->theMutexPtr,
waitTime);
if(theWaitState == NO_WAIT || theWaitState == WAIT_NODEFAILURE)
break;
waitTime = (maxTime - NdbTick_CurrentMillisecond());
}//while
if(theWaitState == NO_WAIT) {
tResultCode = 0;
} else {
tResultCode = -1;
}
theFacade->unlock_mutex();
return tResultCode;
}
......@@ -221,21 +221,6 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("level", Int, Mandatory, "Severety level"),
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_ARG("node", String, Mandatory, "Node"),
MGM_ARG("parameter", String, Mandatory, "Parameter"),
......@@ -918,8 +903,10 @@ printNodeStatus(OutputStream *output,
nodeGroup = 0,
connectCount = 0;
bool system;
const char *address= NULL;
mgmsrv.status(nodeId, &status, &version, &startPhase,
&system, &dynamicId, &nodeGroup, &connectCount);
&system, &dynamicId, &nodeGroup, &connectCount,
&address);
output->println("node.%d.type: %s",
nodeId,
ndb_mgm_get_node_type_string(type));
......@@ -931,7 +918,7 @@ printNodeStatus(OutputStream *output,
output->println("node.%d.dynamic_id: %d", nodeId, dynamicId);
output->println("node.%d.node_group: %d", nodeId, nodeGroup);
output->println("node.%d.connect_count: %d", nodeId, connectCount);
output->println("node.%d.address: %s", nodeId, mgmsrv.get_connect_address(nodeId));
output->println("node.%d.address: %s", nodeId, address);
}
}
......@@ -1200,42 +1187,6 @@ MgmApiSession::setLogFilter(Parser_t::Context &ctx,
m_output->println("");
}
void
MgmApiSession::configLock(Parser_t::Context &,
Properties const &) {
int ret = m_mgmsrv.lockConf();
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);
int ret = m_mgmsrv.unlockConf(commit == 1);
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&
operator<<(NdbOut& out, const LogLevel & ll)
{
......
......@@ -83,9 +83,6 @@ public:
void setClusterLogLevel(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 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