IConstDomainInfo * cachedHostDomain() { if (!hostDomain) { StringBuffer ipText; queryHostIP().getIpText(ipText); hostDomain.setown(getDomainFromIp(ipText.str())); } return hostDomain; }
void TransferServer::deserializeAction(MemoryBuffer & msg, unsigned action) { SocketEndpoint ep; ep.deserialize(msg); if (!ep.isLocal()) { StringBuffer host, expected; queryHostIP().getIpText(host); ep.getIpText(expected); throwError2(DFTERR_WrongComputer, expected.str(), host.str()); } srcFormat.deserialize(msg); tgtFormat.deserialize(msg); msg.read(calcInputCRC); msg.read(calcOutputCRC); deserialize(partition, msg); msg.read(numParallelSlaves); msg.read(updateFrequency); msg.read(replicate); msg.read(mirror); msg.read(isSafeMode); srand((unsigned)get_cycles_now()); int adjust = (rand() * rand() * rand()) % updateFrequency - (updateFrequency/2); lastTick = msTick() + adjust; StringBuffer localFilename; if (action == FTactionpull) { partition.item(0).outputName.getPath(localFilename); LOG(MCdebugProgress, unknownJob, "Process Pull Command: %s", localFilename.str()); } else { partition.item(0).inputName.getPath(localFilename); LOG(MCdebugProgress, unknownJob, "Process Push Command: %s", localFilename.str()); } LOG(MCdebugProgress, unknownJob, "Num Parallel Slaves=%d Adjust=%d/%d", numParallelSlaves, adjust, updateFrequency); LOG(MCdebugProgress, unknownJob, "replicate(%d) mirror(%d) safe(%d) incrc(%d) outcrc(%d)", replicate, mirror, isSafeMode, calcInputCRC, calcOutputCRC); displayPartition(partition); unsigned numProgress; msg.read(numProgress); for (unsigned i = 0; i < numProgress; i++) { OutputProgress & next = *new OutputProgress; next.deserializeCore(msg); progress.append(next); } if (msg.remaining()) msg.read(throttleNicSpeed); if (msg.remaining()) msg.read(compressedInput).read(compressOutput); if (msg.remaining()) msg.read(copyCompressed); if (msg.remaining()) msg.read(transferBufferSize); if (msg.remaining()) msg.read(encryptKey).read(decryptKey); if (msg.remaining()) { srcFormat.deserializeExtra(msg, 1); tgtFormat.deserializeExtra(msg, 1); } ForEachItemIn(i1, progress) progress.item(i1).deserializeExtra(msg, 1); LOG(MCdebugProgress, unknownJob, "throttle(%d), transferBufferSize(%d)", throttleNicSpeed, transferBufferSize); PROGLOG("compressedInput(%d), compressedOutput(%d), copyCompressed(%d)", compressedInput?1:0, compressOutput?1:0, copyCompressed?1:0); PROGLOG("encrypt(%d), decrypt(%d)", encryptKey.isEmpty()?0:1, decryptKey.isEmpty()?0:1); //---Finished deserializing --- displayProgress(progress); totalLengthRead = 0; totalLengthToRead = 0; ForEachItemIn(idx, partition) totalLengthToRead += partition.item(idx).inputLength; }
int main(int argc,char **argv) { InitModuleObjects(); EnableSEHtoExceptionMapping(); #ifndef __64BIT__ // Restrict stack sizes on 32-bit systems Thread::setDefaultStackSize(0x10000); // 64K stack (also set in windows DSP) #endif Owned<IFile> sentinelFile = createSentinelTarget(); removeSentinelFile(sentinelFile); SocketEndpoint listenep; unsigned sendbufsize = 0; unsigned recvbufsize = 0; int i = 1; bool isdaemon = (memicmp(argv[0]+strlen(argv[0])-4,".exe",4)==0); // bit of a kludge for windows - if .exe not specified then not daemon bool locallisten = false; const char *logdir=NULL; bool requireauthenticate = false; StringBuffer logDir; StringBuffer instanceName; //Get SSL Settings const char * sslCertFile; bool useSSL; unsigned short dafsPort;//DAFILESRV_PORT or SECURE_DAFILESRV_PORT querySecuritySettings(&useSSL, &dafsPort, &sslCertFile, NULL); unsigned parallelRequestLimit = DEFAULT_PARALLELREQUESTLIMIT; unsigned throttleDelayMs = DEFAULT_THROTTLEDELAYMS; unsigned throttleCPULimit = DEFAULT_THROTTLECPULIMIT; Owned<IPropertyTree> env = getHPCCEnvironment(); if (env) { StringBuffer dafilesrvPath("Software/DafilesrvProcess"); if (instanceName.length()) dafilesrvPath.appendf("[@name=\"%s\"]", instanceName.str()); IPropertyTree *daFileSrv = env->queryPropTree(dafilesrvPath); if (daFileSrv) { // global DaFileSrv settings: parallelRequestLimit = daFileSrv->getPropInt("@parallelRequestLimit", DEFAULT_PARALLELREQUESTLIMIT); throttleDelayMs = daFileSrv->getPropInt("@throttleDelayMs", DEFAULT_THROTTLEDELAYMS); throttleCPULimit = daFileSrv->getPropInt("@throttleCPULimit", DEFAULT_THROTTLECPULIMIT); // any overrides by Instance definitions? // NB: This won't work if netAddress is "." or if we start supporting hostnames there StringBuffer ipStr; queryHostIP().getIpText(ipStr); VStringBuffer daFileSrvPath("Instance[@netAddress=\"%s\"]", ipStr.str()); IPropertyTree *dafileSrvInstance = daFileSrv->queryPropTree(daFileSrvPath); if (dafileSrvInstance) { parallelRequestLimit = dafileSrvInstance->getPropInt("@parallelRequestLimit", parallelRequestLimit); throttleDelayMs = dafileSrvInstance->getPropInt("@throttleDelayMs", throttleDelayMs); throttleCPULimit = dafileSrvInstance->getPropInt("@throttleCPULimit", throttleCPULimit); } } } while (argc>i) { if (stricmp(argv[i],"-D")==0) { i++; isdaemon = true; } else if (stricmp(argv[i],"-R")==0) { // for remote run i++; #ifdef _WIN32 isdaemon = false; #else isdaemon = true; #endif } else if (stricmp(argv[i],"-A")==0) { i++; requireauthenticate = true; } else if ((argv[i][0]=='-')&&(toupper(argv[i][1])=='T')&&(!argv[i][2]||isdigit(argv[i][2]))) { if (argv[i][2]) setDafsTrace(NULL,(byte)atoi(argv[i]+2)); i++; isdaemon = false; } else if ((argc>i+1)&&(stricmp(argv[i],"-L")==0)) { i++; logDir.clear().append(argv[i++]); } else if ((argc>i+1)&&(stricmp(argv[i],"-I")==0)) { i++; instanceName.clear().append(argv[i++]); } else if (stricmp(argv[i],"-LOCAL")==0) { i++; locallisten = true; } else if (stricmp(argv[i],"-NOSSL")==0) {//overrides config setting i++; if (useSSL) { PROGLOG("DaFileSrv SSL specified in config but overridden by -NOSSL in command line"); useSSL = false; dafsPort = DAFILESRV_PORT; } } else break; } if (useSSL && !sslCertFile) { ERRLOG("DaFileSrv SSL specified but certificate file information missing from environment.conf"); exit(-1); } if (0 == logDir.length()) { getConfigurationDirectory(NULL,"log","dafilesrv",instanceName.str(),logDir); if (0 == logDir.length()) logDir.append("."); } if (instanceName.length()) { addPathSepChar(logDir); logDir.append(instanceName.str()); } #ifdef _WIN32 if ((argc>i)&&(stricmp(argv[i],"-install")==0)) { if (installService(DAFS_SERVICE_NAME,DAFS_SERVICE_DISPLAY_NAME,NULL)) { PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Installed"); return 0; } return 1; } if ((argc>i)&&(stricmp(argv[i],"-remove")==0)) { if (uninstallService(DAFS_SERVICE_NAME,DAFS_SERVICE_DISPLAY_NAME)) { PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Uninstalled"); return 0; } return 1; } #endif if (argc == i) listenep.port = dafsPort; else { if (strchr(argv[i],'.')||!isdigit(argv[i][0])) listenep.set(argv[i], dafsPort); else listenep.port = atoi(argv[i]); if (listenep.port==0) { usage(); exit(-1); } sendbufsize = (argc>i+1)?(atoi(argv[i+1])*1024):0; recvbufsize = (argc>i+2)?(atoi(argv[i+2])*1024):0; } if (isdaemon) { #ifdef _WIN32 class cserv: public CService { bool stopped; bool started; SocketEndpoint listenep; bool useSSL; bool requireauthenticate; class cpollthread: public Thread { cserv *parent; public: cpollthread( cserv *_parent ) : Thread("CService::cpollthread"), parent(_parent) { } int run() { while (parent->poll()) Sleep(1000); return 1; } } pollthread; Owned<IRemoteFileServer> server; public: cserv(SocketEndpoint _listenep, bool _useSSL) : listenep(_listenep),useSSL(_useSSL),pollthread(this) { stopped = false; started = false; } virtual ~cserv() { stopped = true; if (started) pollthread.join(); } bool init() { PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Initialized"); started = true; pollthread.start(); return true; } bool poll() { if (stopped||!running()) { PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Stopping"); if (server) { server->stop(); server.clear(); } return false; } return true; } void run() { // Get params from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DaFileSrv\Parameters int requireauthenticate=0; HKEY hkey; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\DaFileSrv\\Parameters", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) { DWORD dwType = 0; DWORD dwSize = sizeof(requireauthenticate); RegQueryValueEx(hkey, "RequireAuthentication", NULL, &dwType, (BYTE*)&requireauthenticate, &dwSize); RegCloseKey(hkey); } StringBuffer eps; if (listenep.isNull()) eps.append(listenep.port); else listenep.getUrlStr(eps); enableDafsAuthentication(requireauthenticate!=0); PROGLOG("Opening " DAFS_SERVICE_DISPLAY_NAME " on %s%s", useSSL?"SECURE ":"",eps.str()); const char * verstring = remoteServerVersionString(); PROGLOG("Version: %s", verstring); PROGLOG("Authentication:%s required",requireauthenticate?"":" not"); PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Running"); server.setown(createRemoteFileServer(parallelRequestLimit, throttleDelayMs, throttleCPULimit)); try { server->run(listenep, useSSL); } catch (IException *e) { EXCLOG(e,DAFS_SERVICE_NAME); e->Release(); } PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Stopped"); stopped = true; } } service(listenep, useSSL); service.start(); return 0; #else int ret = initDaemon(); if (ret) return ret; #endif } { Owned<IComponentLogFileCreator> lf = createComponentLogFileCreator(logDir.str(), "DAFILESRV"); lf->setCreateAliasFile(false); lf->setMaxDetail(TopDetail); lf->beginLogging(); } PROGLOG("Parallel request limit = %d, throttleDelayMs = %d, throttleCPULimit = %d", parallelRequestLimit, throttleDelayMs, throttleCPULimit); const char * verstring = remoteServerVersionString(); StringBuffer eps; if (listenep.isNull()) eps.append(listenep.port); else listenep.getUrlStr(eps); enableDafsAuthentication(requireauthenticate); PROGLOG("Opening Dali File Server on %s%s", useSSL?"SECURE ":"",eps.str()); PROGLOG("Version: %s", verstring); PROGLOG("Authentication:%s required",requireauthenticate?"":" not"); startPerformanceMonitor(10*60*1000, PerfMonStandard); server.setown(createRemoteFileServer(parallelRequestLimit, throttleDelayMs, throttleCPULimit)); writeSentinelFile(sentinelFile); try { server->run(listenep, useSSL); } catch (IException *e) { EXCLOG(e,"DAFILESRV"); e->Release(); } if (server) server->stop(); server.clear(); PROGLOG("Stopped Dali File Server"); return 0; }
int main(int argc, char** argv) { InitModuleObjects(); const char* out_envname = NULL; const char* in_ipfilename; StringBuffer ipAddrs; int roxieNodes=0, thorNodes=0, slavesPerNode=1; MapStringTo<StringBuffer> dirMap; int i = 1; bool writeToFiles = false; int port = 80; while(i<argc) { if(stricmp(argv[i], "-help") == 0 || stricmp(argv[i], "-?") == 0) { usage(); releaseAtoms(); return 0; } else if (stricmp(argv[i], "-env") == 0) { i++; out_envname = argv[i++]; } else if (stricmp(argv[i], "-roxienodes") == 0) { i++; roxieNodes = atoi(argv[i++]); } else if (stricmp(argv[i], "-thornodes") == 0) { i++; thorNodes = atoi(argv[i++]); } else if (stricmp(argv[i], "-slavespernode") == 0) { i++; slavesPerNode = atoi(argv[i++]); } else if (stricmp(argv[i], "-ip") == 0) { i++; ipAddrs.append(argv[i++]); } else if(stricmp(argv[i], "-ipfile") == 0) { i++; in_ipfilename = argv[i++]; ipAddrs.loadFile(in_ipfilename); } else if(stricmp(argv[i], "-o") == 0) { i++; StringArray sbarr; DelimToStringArray(argv[i++], sbarr, "="); if (sbarr.length() != 2) continue; if (strstr(sbarr.item(1), "[NAME]") && (strstr(sbarr.item(1), "[INST]") || strstr(sbarr.item(1), "[COMPONENT]"))) dirMap.setValue(sbarr.item(0), sbarr.item(1)); else { fprintf(stderr, "Error: Directory Override must contain [NAME] and either [INST] or [COMPONENT]\n"); releaseAtoms(); return 1; } } else { fprintf(stderr, "Error: unknown command line parameter: %s\n", argv[i]); usage(); releaseAtoms(); return 1; } } if (!out_envname) { fprintf(stderr, "Error: Output environment xml file is required. Please specify.\n"); usage(); releaseAtoms(); return 1; } if (ipAddrs.length() == 0) { fprintf(stderr, "Error: Ip addresses are required. Please specify.\n"); usage(); releaseAtoms(); return 1; } try { validateIPS(ipAddrs.str()); StringBuffer optionsXml, envXml; const char* pServiceName = "WsDeploy_wsdeploy_esp"; Owned<IPropertyTree> pCfg = createPTreeFromXMLFile(ENVGEN_PATH_TO_ESP_CONFIG); optionsXml.appendf("<XmlArgs roxieNodes=\"%d\" thorNodes=\"%d\" slavesPerNode=\"%d\" ipList=\"%s\"/>", roxieNodes, thorNodes, slavesPerNode, ipAddrs.str()); buildEnvFromWizard(optionsXml, pServiceName, pCfg, envXml, &dirMap); if(envXml.length()) { StringBuffer env; StringBuffer thisip; queryHostIP().getIpText(thisip); env.appendf("<"XML_HEADER">\n<!-- Generated with envgen on ip %s -->\n", thisip.str()); env.append(envXml); Owned<IEnvironmentFactory> factory = getEnvironmentFactory(); Owned<IConstEnvironment> constEnv = factory->loadLocalEnvironment(env); validateEnv(constEnv); Owned<IFile> pFile; pFile.setown(createIFile(out_envname)); Owned<IFileIO> pFileIO; pFileIO.setown(pFile->open(IFOcreaterw)); pFileIO->write(0, env.length(), env.str()); } } catch(IException *excpt) { StringBuffer errMsg; fprintf(stderr, "Exception: %d:\n%s\n", excpt->errorCode(), excpt->errorMessage(errMsg).str()); releaseAtoms(); excpt->Release(); return 1; } catch(...) { fprintf(stderr, "Unknown exception\n"); releaseAtoms(); return 1; } releaseAtoms(); return 0; }
void Cws_machineEx::ConvertAddress( const char* originalAddress, StringBuffer& newAddress) { if (!originalAddress || !*originalAddress) throw MakeStringException(ECLWATCH_INVALID_IP_OR_COMPONENT, "No network address or computer name specified!"); StringArray sArray; sArray.appendList(originalAddress, ":"); if (sArray.ordinality() < 4) throw MakeStringException(ECLWATCH_MISSING_PARAMS, "Incomplete arguments"); const char* address = sArray.item(0); const char* compType= sArray.item(1); const char* compName= sArray.item(2); const char* OS = sArray.item(3); const char* path = sArray.item(4); StringBuffer process; if (sArray.ordinality() > 5) { const char* ClusterType = sArray.item(5); if (ClusterType && *ClusterType) { if (strcmp("THORMACHINES",ClusterType) == 0) { process.append("ThorMasterProcess"); } else if (strcmp("ROXIEMACHINES",ClusterType) == 0) { process.append("RoxieServerProcess"); } } } if (strchr(address, '.')) //have an IP address { newAddress.clear().append(originalAddress); return; } StringBuffer xpath; if (!strcmp(compType, "RoxieCluster")) { xpath.append("RoxieServer"); } else if (!strcmp(compType, "ThorCluster")) { xpath.append("ThorMaster"); } else if (!strcmp(compType, "HoleCluster")) { xpath.append("HoleControl"); } else throw MakeStringException(ECLWATCH_INVALID_COMPONENT_TYPE, "Failed to resolve address for component type '%s'", compType); Owned<IPropertyTree> pComponent = getComponent(compType, address); xpath.append("Process[1]/@computer"); const char* computer = pComponent->queryProp(xpath.str()); if (!computer || !*computer) throw MakeStringException(ECLWATCH_INVALID_COMPONENT_INFO, "Failed to resolve computer for %s '%s'!", compType, address); Owned<IConstEnvironment> pConstEnv = getConstEnvironment(); Owned<IConstMachineInfo> pConstMc = pConstEnv->getMachine(computer); SCMStringBuffer sAddress; pConstMc->getNetAddress(sAddress); #ifndef OLD_START_STOP { StringBuffer sConfigAddress; sConfigAddress.append(sAddress.str()); if (!strcmp(sAddress.str(), ".")) { StringBuffer ipStr; IpAddress ipaddr = queryHostIP(); ipaddr.getIpText(ipStr); if (ipStr.length() > 0) { #ifdef MACHINE_IP sAddress.set(MACHINE_IP); #else sAddress.set(ipStr.str()); #endif } } if (process.length() > 0) newAddress.clear().appendf("%s|%s:%s:%s:%s:%s", sAddress.str(), sConfigAddress.str(), process.str(), compName, OS, path); else newAddress.clear().appendf("%s|%s:%s:%s:%s:%s", sAddress.str(), sConfigAddress.str(), compType, compName, OS, path); } #else if (process.length() > 0) newAddress.clear().appendf("%s:%s:%s:%s:%s", sAddress.str(), process.str(), compName, OS, path); else newAddress.clear().appendf("%s:%s:%s:%s:%s", sAddress.str(), compType, compName, OS, path); //newAddress.clear().appendf("%s:ThorMasterProcess:%s:%s:%s", sAddress.str(), compName, OS, path); #endif return; }
virtual void doWork() { if (m_useHPCCInit) { //address specified can be either IP or name of component const char* address = m_sAddress.str(); const char* configAddress = m_sConfigAddress.str(); if (!address || !*address) throw MakeStringException(ECLWATCH_INVALID_IP_OR_COMPONENT, "Invalid address or component name was specified!"); if (!strchr(address, '.')) //not an IP address { const char* compType = m_pResult->getCompType(); const char* compName = address; if (!compType || !*compType) throw MakeStringException(ECLWATCH_INVALID_COMPONENT_TYPE, "No component type specified!"); StringBuffer xpath; if (!strcmp(compType, "RoxieCluster")) { xpath.append("RoxieServer"); } else if (!strcmp(compType, "ThorCluster")) { xpath.append("ThorMaster"); } else if (!strcmp(compType, "HoleCluster")) { xpath.append("HoleControl"); } else throw MakeStringException(ECLWATCH_INVALID_COMPONENT_TYPE, "Failed to resolve component type '%s'", compType); Owned<IPropertyTree> pComponent = m_pService->getComponent(compType, compName); xpath.append("Process[1]/@computer"); const char* computer = pComponent->queryProp(xpath.str()); if (!computer || !*computer) throw MakeStringException(ECLWATCH_INVALID_COMPONENT_INFO, "Failed to resolve computer for %s '%s'!", compType, compName); Owned<IConstEnvironment> pConstEnv = m_pService->getConstEnvironment(); Owned<IConstMachineInfo> pConstMc = pConstEnv->getMachine(computer); SCMStringBuffer sAddress; pConstMc->getNetAddress(sAddress); if (!stricmp(m_sAddress.str(), m_sConfigAddress.str())) { m_sAddress.clear().append(sAddress.str()); m_sConfigAddress = m_sAddress; m_pResult->setAddress( sAddress.str() ); } else { m_sAddress.clear().append(sAddress.str()); m_pResult->setAddress( sAddress.str() ); if (configAddress && !strchr(configAddress, '.')) //not an IP address { Owned<IPropertyTree> pComponent = m_pService->getComponent(compType, configAddress); xpath.append("Process[1]/@computer"); const char* computer = pComponent->queryProp(xpath.str()); if (!computer || !*computer) throw MakeStringException(ECLWATCH_INVALID_COMPONENT_INFO, "Failed to resolve computer for %s '%s'!", compType, configAddress); Owned<IConstEnvironment> pConstEnv = m_pService->getConstEnvironment(); Owned<IConstMachineInfo> pConstMc = pConstEnv->getMachine(computer); SCMStringBuffer sAddress; pConstMc->getNetAddress(sAddress); m_sConfigAddress.clear().append(sAddress.str()); } } } if ((m_sAddress.length() > 0) && !stricmp(m_sAddress.str(), ".")) { StringBuffer ipStr; IpAddress ipaddr = queryHostIP(); ipaddr.getIpText(ipStr); if (ipStr.length() > 0) { #ifdef MACHINE_IP m_sAddress.clear().append(MACHINE_IP); #else m_sAddress.clear().append(ipStr.str()); #endif m_pResult->setAddress( m_sAddress.str() ); } } #ifdef OLD_START_STOP int OS = m_pResult->getOS(); StringBuffer sPath( m_pResult->getPath() ); if (OS == 0) sPath.replace('$', ':'); else if (sPath.charAt(0) != '/') sPath.insert(0, '/'); m_sCommand.clear().append(sPath).append( OS==0 ? '\\' : '/'); m_sCommand.append(m_bStop ? "stop" : "startup"); if (OS == 0) m_sCommand.append(".bat"); m_sCommand.append(' '); m_sCommand.append(sPath); #else StringBuffer sPath( m_pResult->getPath() ); if (sPath.charAt(sPath.length() - 1) == '/') sPath.setLength(sPath.length() - 1); if (sPath.length() > 0) { char* pStr = (char*) sPath.str(); char* ppStr = strchr(pStr, '/'); while (ppStr) { ppStr++; pStr = ppStr; ppStr = strchr(pStr, '/'); } if (!m_bStop) m_sCommand.appendf("sudo /etc/init.d/hpcc-init -c %s start", pStr); else m_sCommand.appendf("sudo /etc/init.d/hpcc-init -c %s stop", pStr); } #endif m_pResult->setCommand( m_sCommand.str() ); } else { //address specified can be either IP or name of component const char* address = m_sAddress.str(); if (!address || !*address) throw MakeStringException(ECLWATCH_INVALID_IP_OR_COMPONENT, "Invalid address or component name was specified!"); if (!strchr(address, '.')) //not an IP address { const char* compType = m_pResult->getCompType(); const char* compName = address; if (!compType || !*compType) throw MakeStringException(ECLWATCH_INVALID_COMPONENT_TYPE, "No component type specified!"); StringBuffer xpath; if (!strcmp(compType, "RoxieCluster")) { xpath.append("RoxieServer"); } else if (!strcmp(compType, "ThorCluster")) { xpath.append("ThorMaster"); } else if (!strcmp(compType, "HoleCluster")) { xpath.append("HoleControl"); } else throw MakeStringException(ECLWATCH_INVALID_COMPONENT_TYPE, "Failed to resolve component type '%s'", compType); Owned<IPropertyTree> pComponent = m_pService->getComponent(compType, compName); xpath.append("Process[1]/@computer"); const char* computer = pComponent->queryProp(xpath.str()); if (!computer || !*computer) throw MakeStringException(ECLWATCH_INVALID_COMPONENT_INFO, "Failed to resolve computer for %s '%s'!", compType, compName); Owned<IConstEnvironment> pConstEnv = m_pService->getConstEnvironment(); Owned<IConstMachineInfo> pConstMc = pConstEnv->getMachine(computer); SCMStringBuffer sAddress; pConstMc->getNetAddress(sAddress); m_sAddress.clear().append(sAddress.str()); m_pResult->setAddress( sAddress.str() ); } int OS = m_pResult->getOS(); StringBuffer sPath( m_pResult->getPath() ); if (OS == 0) sPath.replace('$', ':'); else if (sPath.charAt(0) != '/') sPath.insert(0, '/'); m_sCommand.clear().append(sPath).append( OS==0 ? '\\' : '/'); m_sCommand.append(m_bStop ? "stop" : "startup"); if (OS == 0) m_sCommand.append(".bat"); m_sCommand.append(' '); m_sCommand.append(sPath); m_pResult->setCommand( m_sCommand.str() ); } CRemoteExecThreadParam::doWork(); }
IPropertyTree* CFileSpraySoapBindingEx::createPTreeForXslt(const char* method, const char* dfuwuid) { Owned<IEnvironmentFactory> factory = getEnvironmentFactory(); Owned<IConstEnvironment> m_constEnv = factory->openEnvironment(); Owned<IPropertyTree> pEnvRoot = &m_constEnv->getPTree(); IPropertyTree* pEnvSoftware = pEnvRoot->queryPropTree("Software"); Owned<IPropertyTree> pRoot = createPTreeFromXMLString("<Environment/>"); IPropertyTree* pSoftware = pRoot->addPropTree("Software", createPTree("Software")); if (pEnvSoftware) { StringBuffer dfuwuidSourcePartIP, wuxml; if(dfuwuid && *dfuwuid) { Owned<IDFUWorkUnitFactory> dfuwu_factory = getDFUWorkUnitFactory(); Owned<IConstDFUWorkUnit> dfuwu = dfuwu_factory->openWorkUnit(dfuwuid, false); if(dfuwu) { dfuwu->toXML(wuxml); Owned<IPropertyTree> wu = createPTreeFromXMLString(wuxml.str()); if (wu) { const char* ip = wu->queryProp("Source/Part/@node"); if (ip && *ip) dfuwuidSourcePartIP.append(ip); } } } Owned<IPropertyTreeIterator> it = pEnvSoftware->getElements("DropZone"); ForEach(*it) { IPropertyTree* pDropZone = pSoftware->addPropTree("DropZone", &it->get()); //get IP Address of the computer associated with this drop zone const char* pszComputer = it->query().queryProp("@computer"); if (!strcmp(pszComputer, ".")) pszComputer = "localhost"; StringBuffer xpath; xpath.appendf("Hardware/Computer[@name='%s']/@netAddress", pszComputer); StringBuffer sNetAddr; const char* pszNetAddr = pEnvRoot->queryProp(xpath.str()); if (strcmp(pszNetAddr, ".")) { sNetAddr.append(pszNetAddr); } else { StringBuffer ipStr; IpAddress ipaddr = queryHostIP(); ipaddr.getIpText(ipStr); if (ipStr.length() > 0) { #ifdef MACHINE_IP sNetAddr.append(MACHINE_IP); #else sNetAddr.append(ipStr.str()); #endif } } pDropZone->addProp("@netAddress", sNetAddr.str()); if ((dfuwuidSourcePartIP.length() > 0) && (sNetAddr.length() > 0)) { IpAddress ip1(dfuwuidSourcePartIP.str()), ip2(sNetAddr.str()); if (ip1.ipequals(ip2)) pDropZone->addProp("@sourceNode", "1"); } Owned<IConstMachineInfo> machine; if (strcmp(pszNetAddr, ".")) machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str())); else { machine.setown(m_constEnv->getMachineByAddress(pszNetAddr)); if (!machine) machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str())); } if (machine) { //int os = machine->getOS(); StringBuffer dir; pDropZone->getProp("@directory", dir); if (machine->getOS() == MachineOsLinux || machine->getOS() == MachineOsSolaris) { dir.replace('\\', '/');//replace all '\\' by '/' pDropZone->setProp("@linux", "true"); } else { dir.replace('/', '\\'); dir.replace('$', ':'); } pDropZone->setProp("@directory", dir); } } //For Spray files on Thor Cluster, fetch all the group names for all the thor instances (and dedup them) BoolHash uniqueThorClusterGroupNames; it.setown(pEnvSoftware->getElements("ThorCluster")); ForEach(*it) { StringBuffer thorClusterGroupName; IPropertyTree& cluster = it->query(); getClusterGroupName(cluster, thorClusterGroupName); if (!thorClusterGroupName.length()) continue; bool* found = uniqueThorClusterGroupNames.getValue(thorClusterGroupName.str()); if (found && *found) continue; uniqueThorClusterGroupNames.setValue(thorClusterGroupName.str(), true); IPropertyTree* newClusterTree = pSoftware->addPropTree("ThorCluster", &it->get()); newClusterTree->setProp("@name", thorClusterGroupName.str()); //set group name into @name for spray target } it.setown(pEnvSoftware->getElements("EclAgentProcess")); ForEach(*it) { IPropertyTree &cluster = it->query(); const char* name = cluster.queryProp("@name"); if (!name||!*name) continue; unsigned ins = 0; Owned<IPropertyTreeIterator> insts = cluster.getElements("Instance"); ForEach(*insts) { const char *na = insts->query().queryProp("@netAddress"); if (!na || !*na) { insts->query().setProp("@gname", name); continue; } SocketEndpoint ep(na); if (ep.isNull()) continue; ins++; StringBuffer gname("hthor__"); //StringBuffer gname; gname.append(name); if (ins>1) gname.append('_').append(ins); insts->query().setProp("@gname", gname.str()); } pSoftware->addPropTree("EclAgentProcess", &it->get()); } if (stricmp(method, "CopyInput") == 0) //Limit for this method only { it.setown(pEnvSoftware->getElements("RoxieCluster")); ForEach(*it) pSoftware->addPropTree("RoxieCluster", &it->get()); } if (wuxml.length() > 0) pSoftware->addPropTree("DfuWorkunit", createPTreeFromXMLString(wuxml.str())); } return pRoot.getClear(); }