int LogMsgLogReceiverThread::run() { while(!done) { try { if(queryWorldCommunicator().recv(in, childNode, MPTAG_JLOG_CHILD_TO_PARENT)) { msgBuffer.deserialize(in, true); if(isListener) listener->report(msgBuffer); else queryLogMsgManager()->report(msgBuffer); } } catch(IException * e) { done = true; CMessageBuffer out; out.append('D').append(cid); try { queryWorldCommunicator().send(out, queryMyNode(), MPTAG_JLOG_CONNECT_TO_PARENT, MP_ASYNC_SEND); } catch(IException * ee) { ee->Release(); } e->Release(); } } return 0; }
CSDSServerStatus::CSDSServerStatus(const char *servername) { conn = querySDS().connect("Status/Servers/Server", myProcessSession(), RTM_CREATE_ADD | RTM_LOCK_READ | RTM_DELETE_ON_DISCONNECT, 5*60*1000); if (conn) { IPropertyTree &root = *conn->queryRoot(); root.setProp("@name",servername); StringBuffer node; queryMyNode()->endpoint().getIpText(node); root.setProp("@node",node.str()); root.setPropInt("@mpport",queryMyNode()->endpoint().port); CDateTime dt; dt.setNow(); StringBuffer str; root.setProp("@started",dt.getString(str).str()); conn->commit(); } }
static void replyError(unsigned errorCode, const char *errorMsg) { SocketEndpoint myEp = queryMyNode()->endpoint(); StringBuffer str("Node '"); myEp.getUrlStr(str); str.append("' exception: ").append(errorMsg); Owned<IException> e = MakeStringException(errorCode, "%s", str.str()); CMessageBuffer msg; serializeException(e, msg); queryWorldCommunicator().send(msg, 0, MPTAG_THORREGISTRATION); }
CGraphProgressHandlerBase() : threaded("CGraphProgressHandler") { self = queryMyNode()->endpoint(); stopped = true; progressEnabled = globals->getPropBool("@watchdogProgressEnabled"); stopped = false; #ifdef _WIN32 threaded.adjustPriority(+1); // it is critical that watchdog packets get through. #endif threaded.init(this); }
CGraphProgressHandler() : threaded("CGraphProgressHandler") { self = queryMyNode()->endpoint(); stopped = true; StringBuffer ipStr; queryClusterGroup().queryNode(0).endpoint().getIpText(ipStr); sock.setown(ISocket::udp_connect(getFixedPort(getMasterPortBase(), TPORT_watchdog),ipStr.str())); progressEnabled = globals->getPropBool("@watchdogProgressEnabled"); sendData(); // send initial data stopped = false; #ifdef _WIN32 threaded.adjustPriority(+1); // it is critical that watchdog packets get through. #endif threaded.init(this); }
static bool RegisterSelf(SocketEndpoint &masterEp) { StringBuffer slfStr; StringBuffer masterStr; LOG(MCdebugProgress, thorJob, "registering %s - master %s",slfEp.getUrlStr(slfStr).toCharArray(),masterEp.getUrlStr(masterStr).toCharArray()); try { SocketEndpoint ep = masterEp; ep.port = getFixedPort(getMasterPortBase(), TPORT_mp); Owned<INode> masterNode = createINode(ep); CMessageBuffer msg; if (!queryWorldCommunicator().recv(msg, masterNode, MPTAG_THORREGISTRATION)) return false; PROGLOG("Initialization received"); unsigned vmajor, vminor; msg.read(vmajor); msg.read(vminor); if (vmajor != THOR_VERSION_MAJOR || vminor != THOR_VERSION_MINOR) { replyError("Thor master/slave version mismatch"); return false; } Owned<IGroup> group = deserializeIGroup(msg); setClusterGroup(group); SocketEndpoint myEp = queryMyNode()->endpoint(); rank_t groupPos = group->rank(queryMyNode()); if (RANK_NULL == groupPos) { replyError("Node not part of thorgroup"); return false; } if (globals->hasProp("@SLAVENUM") && (mySlaveNum != (unsigned)groupPos)) { VStringBuffer errStr("Slave group rank[%d] does not match provided cmd line slaveNum[%d]", mySlaveNum, (unsigned)groupPos); replyError(errStr.str()); return false; } globals->Release(); globals = createPTree(msg); mergeCmdParams(globals); // cmd line const char *_masterBuildTag = globals->queryProp("@masterBuildTag"); const char *masterBuildTag = _masterBuildTag?_masterBuildTag:"no build tag"; PROGLOG("Master build: %s", masterBuildTag); #ifndef _DEBUG if (!_masterBuildTag || 0 != strcmp(BUILD_TAG, _masterBuildTag)) { StringBuffer errStr("Thor master/slave build mismatch, master = "); replyError(errStr.append(masterBuildTag).append(", slave = ").append(BUILD_TAG).str()); return false; } #endif msg.read((unsigned &)masterSlaveMpTag); msg.clear(); msg.setReplyTag(MPTAG_THORREGISTRATION); if (!queryClusterComm().reply(msg)) return false; PROGLOG("Registration confirmation sent"); if (!queryClusterComm().recv(msg, 0, MPTAG_THORREGISTRATION)) // when all registered return false; PROGLOG("verifying mp connection to rest of cluster"); if (!queryClusterComm().verifyAll()) ERRLOG("Failed to connect to all nodes"); else PROGLOG("verified mp connection to rest of cluster"); ::masterNode = LINK(masterNode); LOG(MCdebugProgress, thorJob, "registered %s",slfStr.toCharArray()); } catch (IException *e) { FLLOG(MCexception(e), thorJob, e,"slave registration error"); e->Release(); return false; } return true; }