Commit 02dab285 authored by tomas@poseidon.ndb.mysql.com's avatar tomas@poseidon.ndb.mysql.com

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

into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1-clean
parents 3519e554 c2c61833
......@@ -67,8 +67,7 @@ while test $# -gt 0; do
initial_ndb=1
;;
--debug*)
f=`echo "$1" | sed -e "s;--debug=;;"`
flags_ndb="$flags_ndb $f"
flags_ndb="$flags_ndb $1"
;;
--status)
status_ndb=1
......
......@@ -48,6 +48,11 @@ public:
static const EventRepLogLevelMatrix matrix[];
static const Uint32 matrixSize;
static int
EventLoggerBase::event_lookup(int eventType,
LogLevel::EventCategory &cat,
Uint32 &threshold,
Logger::LoggerLevel &severity);
};
/**
......
......@@ -73,7 +73,7 @@ public:
/**
* Note level is valid as 0-15
*/
void setLogLevel(EventCategory ec, Uint32 level = 7);
int setLogLevel(EventCategory ec, Uint32 level = 7);
/**
* Get the loglevel (0-15) for a category
......@@ -119,10 +119,14 @@ LogLevel::clear(){
}
inline
void
int
LogLevel::setLogLevel(EventCategory ec, Uint32 level){
assert(ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES);
logLevelData[ec] = (Uint8)level;
if (ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES)
{
logLevelData[ec] = (Uint8)level;
return 0;
}
return 1;
}
inline
......
......@@ -1342,27 +1342,41 @@ operator<<(NdbOut& out, const LogLevel & ll)
return out;
}
void
EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId,
const LogLevel* ll)
int
EventLoggerBase::event_lookup(int eventType,
LogLevel::EventCategory &cat,
Uint32 &threshold,
Logger::LoggerLevel &severity)
{
Uint32 threshold = 0;
Logger::LoggerLevel severity = Logger::LL_WARNING;
LogLevel::EventCategory cat= LogLevel::llInvalid;
for(unsigned i = 0; i<EventLoggerBase::matrixSize; i++){
if(EventLoggerBase::matrix[i].eventType == eventType){
cat = EventLoggerBase::matrix[i].eventCategory;
threshold = EventLoggerBase::matrix[i].threshold;
severity = EventLoggerBase::matrix[i].severity;
break;
return 0;
}
}
return 1;
}
void
EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId,
const LogLevel* ll)
{
Uint32 threshold = 0;
Logger::LoggerLevel severity = Logger::LL_WARNING;
LogLevel::EventCategory cat= LogLevel::llInvalid;
DBUG_ENTER("EventLogger::log");
DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId));
if (cat == LogLevel::llInvalid)
return;
if (EventLoggerBase::event_lookup(eventType,cat,threshold,severity))
DBUG_VOID_RETURN;
Uint32 set = ll?ll->getLogLevel(cat) : m_logLevel.getLogLevel(cat);
DBUG_PRINT("info",("threshold=%d, set=%d", threshold, set));
if (ll)
DBUG_PRINT("info",("m_logLevel.getLogLevel=%d", m_logLevel.getLogLevel(cat)));
if (threshold <= set){
switch (severity){
case Logger::LL_ALERT:
......@@ -1401,6 +1415,7 @@ EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId,
break;
}
} // if (..
DBUG_VOID_RETURN;
}
int
......
......@@ -22,7 +22,7 @@
extern "C"
int
Ndb_getInAddr(struct in_addr * dst, const char *address) {
DBUG_ENTER("Ndb_getInAddr");
// DBUG_ENTER("Ndb_getInAddr");
{
int tmp_errno;
struct hostent tmp_hostent, *hp;
......@@ -33,7 +33,7 @@ Ndb_getInAddr(struct in_addr * dst, const char *address) {
{
memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length));
my_gethostbyname_r_free();
DBUG_RETURN(0);
return 0; //DBUG_RETURN(0);
}
my_gethostbyname_r_free();
}
......@@ -47,11 +47,11 @@ Ndb_getInAddr(struct in_addr * dst, const char *address) {
#endif
)
{
DBUG_RETURN(0);
return 0; //DBUG_RETURN(0);
}
DBUG_PRINT("error",("inet_addr(%s) - %d - %s",
address, errno, strerror(errno)));
DBUG_RETURN(-1);
// DBUG_PRINT("error",("inet_addr(%s) - %d - %s",
// address, errno, strerror(errno)));
return -1; //DBUG_RETURN(-1);
}
#if 0
......
......@@ -193,21 +193,11 @@ void Cmvmi::execEVENT_REP(Signal* signal)
/**
* If entry is not found
*/
Uint32 threshold = 16;
LogLevel::EventCategory eventCategory = (LogLevel::EventCategory)0;
for(unsigned int i = 0; i< EventLoggerBase::matrixSize; i++){
if(EventLoggerBase::matrix[i].eventType == eventType){
eventCategory = EventLoggerBase::matrix[i].eventCategory;
threshold = EventLoggerBase::matrix[i].threshold;
break;
}
}
if(threshold > 15){
// No entry found in matrix (or event that should never be printed)
Uint32 threshold;
LogLevel::EventCategory eventCategory;
Logger::LoggerLevel severity;
if (EventLoggerBase::event_lookup(eventType,eventCategory,threshold,severity))
return;
}
SubscriberPtr ptr;
for(subscribers.first(ptr); ptr.i != RNIL; subscribers.next(ptr)){
......@@ -225,14 +215,15 @@ void Cmvmi::execEVENT_REP(Signal* signal)
// Print the event info
g_eventLogger.log(eventReport->getEventType(), signal->theData);
return;
}//execEVENT_REP()
void
Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){
EventSubscribeReq * subReq = (EventSubscribeReq *)&signal->theData[0];
SubscriberPtr ptr;
jamEntry();
DBUG_ENTER("Cmvmi::execEVENT_SUBSCRIBE_REQ");
/**
* Search for subcription
......@@ -269,11 +260,13 @@ Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){
category = (LogLevel::EventCategory)(subReq->theData[i] >> 16);
level = subReq->theData[i] & 0xFFFF;
ptr.p->logLevel.setLogLevel(category, level);
DBUG_PRINT("info",("entry %d: level=%d, category= %d", i, level, category));
}
}
signal->theData[0] = ptr.i;
sendSignal(ptr.p->blockRef, GSN_EVENT_SUBSCRIBE_CONF, signal, 1, JBB);
DBUG_VOID_RETURN;
}
void
......
......@@ -1102,15 +1102,18 @@ ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle handle, int nodeId,
"set cluster loglevel", &args);
CHECK_REPLY(reply, -1);
DBUG_ENTER("ndb_mgm_set_loglevel_clusterlog");
DBUG_PRINT("enter",("node=%d, category=%d, level=%d", nodeId, cat, level));
BaseString result;
reply->get("result", result);
if(strcmp(result.c_str(), "Ok") != 0) {
SET_ERROR(handle, EINVAL, result.c_str());
delete reply;
return -1;
DBUG_RETURN(-1);
}
delete reply;
return 0;
DBUG_RETURN(0);
}
extern "C"
......
......@@ -153,7 +153,7 @@ MgmtSrvr::logLevelThreadRun()
* Handle started nodes
*/
EventSubscribeReq req;
req = m_statisticsListner.m_clients[0].m_logLevel;
req = m_event_listner[0].m_logLevel;
req.blockRef = _ownReference;
SetLogLevelOrd ord;
......@@ -409,7 +409,7 @@ MgmtSrvr::MgmtSrvr(SocketServer *socket_server,
_ownReference(0),
theSignalIdleList(NULL),
theWaitState(WAIT_SUBSCRIBE_CONF),
m_statisticsListner(this)
m_event_listner(this)
{
DBUG_ENTER("MgmtSrvr::MgmtSrvr");
......@@ -547,16 +547,18 @@ MgmtSrvr::MgmtSrvr(SocketServer *socket_server,
}
}
// Setup clusterlog as client[0] in m_event_listner
{
MgmStatService::StatListener se;
Ndb_mgmd_event_service::Event_listener se;
se.m_socket = -1;
for(size_t t = 0; t<LogLevel::LOGLEVEL_CATEGORIES; t++){
se.m_logLevel.setLogLevel((LogLevel::EventCategory)t, 7);
}
se.m_logLevel.setLogLevel(LogLevel::llError, 15);
se.m_logLevel.setLogLevel(LogLevel::llConnection, 8);
se.m_logLevel.setLogLevel(LogLevel::llBackup, 15);
m_statisticsListner.m_clients.push_back(se);
m_statisticsListner.m_logLevel = se.m_logLevel;
m_event_listner.m_clients.push_back(se);
m_event_listner.m_logLevel = se.m_logLevel;
}
DBUG_VOID_RETURN;
......@@ -2071,21 +2073,18 @@ MgmtSrvr::handleStopReply(NodeId nodeId, Uint32 errCode)
void
MgmtSrvr::handleStatus(NodeId nodeId, bool alive)
{
DBUG_ENTER("MgmtSrvr::handleStatus");
Uint32 theData[25];
theData[1] = nodeId;
if (alive) {
m_started_nodes.push_back(nodeId);
Uint32 theData[25];
theData[0] = EventReport::Connected;
theData[1] = nodeId;
eventReport(_ownNodeId, theData);
} else {
handleStopReply(nodeId, 0);
Uint32 theData[25];
theData[0] = EventReport::Disconnected;
theData[1] = nodeId;
eventReport(_ownNodeId, theData);
}
eventReport(_ownNodeId, theData);
DBUG_VOID_RETURN;
}
//****************************************************************************
......@@ -2106,8 +2105,11 @@ void
MgmtSrvr::nodeStatusNotification(void* mgmSrv, Uint32 nodeId,
bool alive, bool nfComplete)
{
DBUG_ENTER("MgmtSrvr::nodeStatusNotification");
DBUG_PRINT("enter",("nodeid= %d, alive= %d, nfComplete= %d", nodeId, alive, nfComplete));
if(!(!alive && nfComplete))
((MgmtSrvr*)mgmSrv)->handleStatus(nodeId, alive);
DBUG_VOID_RETURN;
}
enum ndb_mgm_node_type
......@@ -2387,8 +2389,8 @@ MgmtSrvr::eventReport(NodeId nodeId, const Uint32 * theData)
EventReport::EventType type = eventReport->getEventType();
// Log event
g_EventLogger.log(type, theData, nodeId,
&m_statisticsListner.m_clients[0].m_logLevel);
m_statisticsListner.log(type, theData, nodeId);
&m_event_listner[0].m_logLevel);
m_event_listner.log(type, theData, nodeId);
}
/***************************************************************************
......@@ -2741,5 +2743,5 @@ template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch*&, NdbA
#endif
template class MutexVector<unsigned short>;
template class MutexVector<MgmStatService::StatListener>;
template class MutexVector<Ndb_mgmd_event_service::Event_listener>;
template class MutexVector<EventSubscribeReq>;
......@@ -43,27 +43,30 @@ class Config;
class SetLogLevelOrd;
class SocketServer;
class MgmStatService : public EventLoggerBase
class Ndb_mgmd_event_service : public EventLoggerBase
{
friend class MgmtSrvr;
public:
struct StatListener : public EventLoggerBase {
struct Event_listener : public EventLoggerBase {
NDB_SOCKET_TYPE m_socket;
};
private:
class MgmtSrvr * m_mgmsrv;
MutexVector<StatListener> m_clients;
MutexVector<Event_listener> m_clients;
public:
MgmStatService(class MgmtSrvr * m) : m_clients(5) {
Ndb_mgmd_event_service(class MgmtSrvr * m) : m_clients(5) {
m_mgmsrv = m;
}
void add_listener(const StatListener&);
void add_listener(const Event_listener&);
void log(int eventType, const Uint32* theData, NodeId nodeId);
void stopSessions();
void stop_sessions();
Event_listener& operator[](unsigned i) { return m_clients[i]; }
const Event_listener& operator[](unsigned i) const { return m_clients[i]; }
};
/**
......@@ -732,8 +735,8 @@ private:
LogLevel m_nodeLogLevel[MAX_NODES];
enum ndb_mgm_node_type nodeTypes[MAX_NODES];
friend class MgmApiSession;
friend class MgmStatService;
MgmStatService m_statisticsListner;
friend class Ndb_mgmd_event_service;
Ndb_mgmd_event_service m_event_listner;
/**
* Handles the thread wich upon a 'Node is started' event will
......
......@@ -208,12 +208,12 @@ ParserRow<MgmApiSession> commands[] = {
MGM_CMD("set loglevel", &MgmApiSession::setLogLevel, ""),
MGM_ARG("node", Int, Mandatory, "Node"),
MGM_ARG("category", String, Mandatory, "Event category"),
MGM_ARG("category", Int, Mandatory, "Event category"),
MGM_ARG("level", Int, Mandatory, "Log level (0-15)"),
MGM_CMD("set cluster loglevel", &MgmApiSession::setClusterLogLevel, ""),
MGM_ARG("node", Int, Mandatory, "Node"),
MGM_ARG("category", String, Mandatory, "Event category"),
MGM_ARG("category", Int, Mandatory, "Event category"),
MGM_ARG("level", Int, Mandatory, "Log level (0-15)"),
MGM_CMD("set logfilter", &MgmApiSession::setLogFilter, ""),
......@@ -781,20 +781,35 @@ MgmApiSession::bye(Parser<MgmApiSession>::Context &,
void
MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
Properties const &args) {
Uint32 node, level, category;
const char *reply= "set cluster loglevel reply";
Uint32 node, level, cat;
BaseString errorString;
SetLogLevelOrd logLevel;
int result;
DBUG_ENTER("MgmApiSession::setClusterLogLevel");
args.get("node", &node);
args.get("category", &category);
args.get("category", &cat);
args.get("level", &level);
DBUG_PRINT("enter",("node=%d, category=%d, level=%d", node, cat, level));
/* XXX should use constants for this value */
if(level > 15) {
m_output->println("set cluster loglevel reply");
m_output->println("result: Invalid loglevel");
m_output->println(reply);
m_output->println("result: Invalid loglevel %d", level);
m_output->println("");
return;
DBUG_VOID_RETURN;
}
LogLevel::EventCategory category=
(LogLevel::EventCategory)(cat-(int)CFG_MIN_LOGLEVEL);
if (m_mgmsrv.m_event_listner[0].m_logLevel.setLogLevel(category,level))
{
m_output->println(reply);
m_output->println("result: Invalid category %d", category);
m_output->println("");
DBUG_VOID_RETURN;
}
EventSubscribeReq req;
......@@ -802,10 +817,11 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
req.noOfEntries = 1;
req.theData[0] = (category << 16) | level;
m_mgmsrv.m_log_level_requests.push_back(req);
m_output->println("set cluster loglevel reply");
m_output->println(reply);
m_output->println("result: Ok");
m_output->println("");
DBUG_VOID_RETURN;
}
void
......@@ -1263,21 +1279,17 @@ operator<<(NdbOut& out, const LogLevel & ll)
}
void
MgmStatService::log(int eventType, const Uint32* theData, NodeId nodeId){
Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId){
Uint32 threshold = 0;
LogLevel::EventCategory cat= LogLevel::llInvalid;
Uint32 threshold;
LogLevel::EventCategory cat;
Logger::LoggerLevel severity;
int i;
DBUG_ENTER("Ndb_mgmd_event_service::log");
DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId));
for(i = 0; (unsigned)i<EventLogger::matrixSize; i++){
if(EventLogger::matrix[i].eventType == eventType){
cat = EventLogger::matrix[i].eventCategory;
threshold = EventLogger::matrix[i].threshold;
break;
}
}
if (cat == LogLevel::llInvalid)
return;
if (EventLoggerBase::event_lookup(eventType,cat,threshold,severity))
DBUG_VOID_RETURN;
char m_text[256];
EventLogger::getText(m_text, sizeof(m_text), eventType, theData, nodeId);
......@@ -1316,10 +1328,11 @@ MgmStatService::log(int eventType, const Uint32* theData, NodeId nodeId){
m_mgmsrv->m_log_level_requests.push_back(req);
}
}
DBUG_VOID_RETURN;
}
void
MgmStatService::add_listener(const StatListener& client){
Ndb_mgmd_event_service::add_listener(const Event_listener& client){
m_clients.push_back(client);
LogLevel tmp = m_logLevel;
tmp.set_max(client.m_logLevel);
......@@ -1334,7 +1347,7 @@ MgmStatService::add_listener(const StatListener& client){
}
void
MgmStatService::stopSessions(){
Ndb_mgmd_event_service::stop_sessions(){
for(int i = m_clients.size() - 1; i >= 0; i--){
if(m_clients[i].m_socket >= 0){
NDB_CLOSE_SOCKET(m_clients[i].m_socket);
......@@ -1374,7 +1387,7 @@ MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx,
int result = 0;
BaseString msg;
MgmStatService::StatListener le;
Ndb_mgmd_event_service::Event_listener le;
le.m_socket = m_socket;
Vector<BaseString> list;
......@@ -1419,7 +1432,7 @@ MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx,
goto done;
}
m_mgmsrv.m_statisticsListner.add_listener(le);
m_mgmsrv.m_event_listner.add_listener(le);
m_stop = true;
m_socket = -1;
......
......@@ -626,6 +626,9 @@ TransporterFacade::ReportNodeFailureComplete(NodeId tNodeId)
* After the restart the node is up again and the Ndb object
* might not have noticed the failure.
*/
DBUG_ENTER("TransporterFacade::ReportNodeFailureComplete");
DBUG_PRINT("enter",("nodeid= %d", tNodeId));
Uint32 sz = m_threads.m_statusNext.size();
for (Uint32 i = 0; i < sz ; i ++) {
if (m_threads.getInUse(i)){
......@@ -634,6 +637,7 @@ TransporterFacade::ReportNodeFailureComplete(NodeId tNodeId)
(*RegPC) (obj, tNodeId, false, true);
}
}
DBUG_VOID_RETURN;
}
void
......
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