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; }
bool DumpHelper::doit(FILE * fp) { SCMStringBuffer xml; // If we were given a workunit dump that one workunit, otherwise moan if (globals->hasProp("WUID")) { const char* wuid = globals->queryProp("WUID"); const char *whichPath = globals->queryProp("prop"); if (whichPath) { if (stricmp(whichPath, "ecl")==0) { Owned<IClientWUInfoRequest> inforeq = wuclient->createWUInfoRequest(); inforeq->setWuid(wuid); Owned<IClientWUInfoResponse> inforesp = wuclient->WUInfo(inforeq); if(!inforesp) { printf("Workunit %s not found\n", wuid); return false; } IConstECLWorkunit* wu = &inforesp->getWorkunit(); IConstECLQuery* query = &wu->getQuery(); if(query) xml.set(query->getText()); } else { printf("Unrecognized parameter prop=%s", whichPath); return false; } } else { Owned<IClientWULogFileRequest> req = wuclient->createWUFileRequest(); req->setWuid(wuid); req->setType("XML"); Owned<IClientWULogFileResponse> resp = wuclient->WUFile(req); if(!resp) { printf("Workunit %s not found\n", wuid); return false; } const IMultiException* excep = &resp->getExceptions(); if(excep != NULL && excep->ordinality()) { unsigned i = 0; while (i < excep->ordinality()) { StringBuffer msg; excep->item(i).errorMessage(msg); unsigned code = excep->item(i).errorCode(); printf("<Error><code>%d</code><message>%s</message></Error>\n", code, msg.str()); } return false; } const MemoryBuffer & xmlmem = resp->getThefile(); StringBuffer xmlbuf; xmlbuf.append(xmlmem.length(), xmlmem.toByteArray()); xml.set(xmlbuf.str()); } // Print the results if (fp != NULL) { fprintf(fp, "%s", xml.str()); } return true; } return false; }