static int get_multithreaded_config(EmulatorData& ed) { // multithreaded is compiled in ndbd/ndbmtd for now globalData.isNdbMt = SimulatedBlock::isMultiThreaded(); if (!globalData.isNdbMt) { ndbout << "NDBMT: non-mt" << endl; return 0; } THRConfig & conf = ed.theConfiguration->m_thr_config; Uint32 threadcount = conf.getThreadCount(); ndbout << "NDBMT: MaxNoOfExecutionThreads=" << threadcount << endl; globalData.isNdbMtLqh = true; { if (conf.getMtClassic()) { globalData.isNdbMtLqh = false; } } if (!globalData.isNdbMtLqh) return 0; Uint32 threads = conf.getThreadCount(THRConfig::T_LDM); Uint32 workers = threads; { ndb_mgm_configuration * conf = ed.theConfiguration->getClusterConfig(); if (conf == 0) { abort(); } ndb_mgm_configuration_iterator * p = ndb_mgm_create_configuration_iterator(conf, CFG_SECTION_NODE); if (ndb_mgm_find(p, CFG_NODE_ID, globalData.ownId)) { abort(); } ndb_mgm_get_int_parameter(p, CFG_NDBMT_LQH_WORKERS, &workers); } #ifdef VM_TRACE // testing { const char* p; p = NdbEnv_GetEnv("NDBMT_LQH_WORKERS", (char*)0, 0); if (p != 0) workers = atoi(p); } #endif ndbout << "NDBMT: workers=" << workers << " threads=" << threads << endl; assert(workers != 0 && workers <= MAX_NDBMT_LQH_WORKERS); assert(threads != 0 && threads <= MAX_NDBMT_LQH_THREADS); assert(workers % threads == 0); globalData.ndbMtLqhWorkers = workers; globalData.ndbMtLqhThreads = threads; return 0; }
bool ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32 nodeid){ char buf[255]; ndb_mgm_configuration_iterator * it; it = ndb_mgm_create_configuration_iterator((struct ndb_mgm_configuration *)conf, CFG_SECTION_NODE); if(it == 0){ BaseString::snprintf(buf, 255, "Unable to create config iterator"); setError(CR_ERROR, buf); return false; } NdbAutoPtr<ndb_mgm_configuration_iterator> ptr(it); if(ndb_mgm_find(it, CFG_NODE_ID, nodeid) != 0){ BaseString::snprintf(buf, 255, "Unable to find node with id: %d", nodeid); setError(CR_ERROR, buf); return false; } const char * hostname; if(ndb_mgm_get_string_parameter(it, CFG_NODE_HOST, &hostname)){ BaseString::snprintf(buf, 255, "Unable to get hostname(%d) from config",CFG_NODE_HOST); setError(CR_ERROR, buf); return false; } const char * datadir; if(!ndb_mgm_get_string_parameter(it, CFG_NODE_DATADIR, &datadir)){ NdbConfig_SetPath(datadir); } if (hostname && hostname[0] != 0 && !SocketServer::tryBind(0,hostname)) { BaseString::snprintf(buf, 255, "Config hostname(%s) don't match a local interface," " tried to bind, error = %d - %s", hostname, errno, strerror(errno)); setError(CR_ERROR, buf); return false; } unsigned int _type; if(ndb_mgm_get_int_parameter(it, CFG_TYPE_OF_SECTION, &_type)){ BaseString::snprintf(buf, 255, "Unable to get type of node(%d) from config", CFG_TYPE_OF_SECTION); setError(CR_ERROR, buf); return false; } if(_type != m_node_type){ const char *type_s, *alias_s, *type_s2, *alias_s2; alias_s= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)m_node_type, &type_s); alias_s2= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)_type, &type_s2); BaseString::snprintf(buf, 255, "This node type %s(%s) and config " "node type %s(%s) don't match for nodeid %d", alias_s, type_s, alias_s2, type_s2, nodeid); setError(CR_ERROR, buf); return false; } /** * Check hostnames */ ndb_mgm_configuration_iterator iter(* conf, CFG_SECTION_CONNECTION); for(iter.first(); iter.valid(); iter.next()){ Uint32 type = CONNECTION_TYPE_TCP + 1; if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue; if(type != CONNECTION_TYPE_TCP) continue; Uint32 nodeId1, nodeId2, remoteNodeId; if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue; if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2)) continue; if(nodeId1 != nodeid && nodeId2 != nodeid) continue; remoteNodeId = (nodeid == nodeId1 ? nodeId2 : nodeId1); const char * name; struct in_addr addr; BaseString tmp; if(!iter.get(CFG_CONNECTION_HOSTNAME_1, &name) && strlen(name)){ if(Ndb_getInAddr(&addr, name) != 0){ tmp.assfmt("Unable to lookup/illegal hostname %s, " "connection from node %d to node %d", name, nodeid, remoteNodeId); setError(CR_ERROR, tmp.c_str()); return false; } } if(!iter.get(CFG_CONNECTION_HOSTNAME_2, &name) && strlen(name)){ if(Ndb_getInAddr(&addr, name) != 0){ tmp.assfmt("Unable to lookup/illegal hostname %s, " "connection from node %d to node %d", name, nodeid, remoteNodeId); setError(CR_ERROR, tmp.c_str()); return false; } } } return true; }