void appendSchemaResource(IPropertyTree &res, ILoadedDllEntry *dll) { if (!dll || (flags & WWV_OMIT_SCHEMAS)) return; if (res.getPropInt("@seq", -1)>=0 && res.hasProp("@id")) { int id = res.getPropInt("@id"); size32_t len = 0; const void *data = NULL; if (dll->getResource(len, data, "RESULT_XSD", (unsigned) id) && len>0) { buffer.append("<XmlSchema name=\"").append(res.queryProp("@name")).append("\">"); if (res.getPropBool("@compressed")) { StringBuffer decompressed; decompressResource(len, data, decompressed); if (flags & WWV_CDATA_SCHEMAS) buffer.append("<![CDATA["); buffer.append(decompressed.str()); if (flags & WWV_CDATA_SCHEMAS) buffer.append("]]>"); } else buffer.append(len, (const char *)data); buffer.append("</XmlSchema>"); } } }
IHqlExpression * XmlEclRepository::doLoadSymbol(IPropertyTree * repository, IAtom * modname, IAtom * attrname) { StringBuffer s; IPropertyTree* module = repository->queryPropTree(s.append("./Module[@name=\"").append(*modname).append("\"]").str()); if(!module) { if (logging()) DBGLOG("No data for module %s",modname->getAtomNamePtr()); return 0; } int access = module->getPropInt("@access",cs_full); s.clear().append("./Attribute[@name=\"").append(*attrname).append("\"]"); Owned<IPropertyTreeIterator> it = module->getElements(s.str()); for(it->first();it->isValid();it->next()) { Owned<IHqlExpression> item = toNamedSymbol(&it->query(), *modname,access); CHqlNamedSymbol* cur = QUERYINTERFACE(item.get(), CHqlNamedSymbol); if(cur) return LINK(cur); } return 0; }
int SWProcess::getDefaultPort() { IPropertyTree * portAttrNode = getPortDefinition(); if (!portAttrNode) return 0; int defaultValue = portAttrNode->getPropInt("@default"); if (!defaultValue) return 0; return defaultValue; }
bool XmlEclRepository::doLoadModule(IPropertyTree * repository, IHqlRemoteScope * rScope, IErrorReceiver *errs) { IHqlScope * scope = rScope->queryScope(); const char * scopeName = scope->queryName()->getAtomNamePtr(); StringBuffer s; const char * modName = scope->queryFullName(); IPropertyTree* module = repository->queryPropTree(s.append("./Module[@name=\"").append(modName).append("\"]").str()); if(!module) { if (logging()) DBGLOG("No data for module %s",scopeName); return false; } int access = module->getPropInt("@access",cs_full); if(module->queryProp("Text")) { const char * path = module->queryProp("@sourcePath"); Owned<ISourcePath> sourcePath = createSourcePath(path ? path : modName); Owned<IFileContents> text = createFileContentsFromText(module->queryProp("Text"), sourcePath); rScope->setText(text); } else { StringBuffer buf("./Attribute"); Owned<IPropertyTreeIterator> it = module->getElements(buf.str()); if (it->first()) { for(;it->isValid();it->next()) { Owned<IHqlExpression> item = toNamedSymbol(&it->query(), *scope->queryName(), access); ((CHqlScope*)scope)->defineSymbol(LINK(item)); } } else { if (logging()) DBGLOG("No definitions were added for module %s", scopeName); } } return true; }
CEclDirectSoapBindingEx::CEclDirectSoapBindingEx(IPropertyTree* cfg, const char *binding, const char *process):CEclDirectSoapBinding(cfg, binding, process) { StringBuffer xpath; xpath.appendf("Software/EspProcess[@name='%s']", process); IPropertyTree *procTree = cfg->queryPropTree(xpath.str()); if (!procTree) throw MakeStringException(-1, "EclDirect Configuration Error: unable to find process"); xpath.set("EspBinding[@name='").append(binding).append("']/@port"); int port = procTree->getPropInt(xpath.str()); if (port) { xpath.set("EspBinding[@type='ws_workunitsSoapBinding'][@port='").append(port).append("']"); redirect = procTree->hasProp(xpath.str()); } SCMStringBuffer s; Owned<IStringIterator> it = getTargetClusters(NULL, NULL); ForEach(*it) clusters.append(it->str(s).str()); supportRepository = false; }
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; }
void sendRequest() { if (!loggingManager) { printf("No logging manager.\n"); return; } StringBuffer action, option, status; testData->getProp("action", action); testData->getProp("option", option); if (action.length() && strieq(action.str(), "getTransactionSeed")) { StringBuffer transactionSeed; loggingManager->getTransactionSeed(transactionSeed, status); if (transactionSeed.length()) printf("Got transactionSeed: <%s>\n", transactionSeed.str()); } else if (action.length() && strieq(action.str(), "UpdateLog")) { IPropertyTree* logContentTree = testData->queryPropTree("LogContent"); if (!logContentTree) { printf("can't read log content.\n"); return; } StringBuffer logContentXML; toXML(logContentTree, logContentXML); printf("log content: <%s>.\n", logContentXML.str()); Owned<IEspContext> espContext = createEspContext(); const char* userName = logContentTree->queryProp("ESPContext/UserName"); const char* sourceIP = logContentTree->queryProp("ESPContext/SourceIP"); short servPort = logContentTree->getPropInt("ESPContext/Port"); espContext->setUserID(userName); espContext->setServAddress(sourceIP, servPort); const char* backEndResp = logContentTree->queryProp("BackEndResponse"); IPropertyTree* userContextTree = logContentTree->queryPropTree("MyUserContext"); IPropertyTree* userRequestTree = logContentTree->queryPropTree("MyUserRequest"); IPropertyTree* userRespTree = logContentTree->queryPropTree("MyUserResponseEx"); StringBuffer userContextXML, userRequestXML, userRespXML; toXML(userRespTree, userRespXML); toXML(userContextTree, userContextXML); toXML(userRequestTree, userRequestXML); printf("userContextXML: <%s>.\n", userContextXML.str()); printf("userRequestXML: <%s>.\n", userRequestXML.str()); printf("userRespXML: <%s>.\n", userRespXML.str()); printf("backEndResp: <%s>.\n", backEndResp); //Sleep(5000); //Waiting for loggingManager to start loggingManager->updateLog(option.str(), *espContext, userContextTree, userRequestTree, backEndResp, userRespXML.str(), status); } else if (action.length() && strieq(action.str(), "UpdateLog1")) { IPropertyTree* logContentTree = testData->queryPropTree("LogContent"); if (!logContentTree) { printf("can't read log content.\n"); return; } StringBuffer logContentXML; toXML(logContentTree, logContentXML); printf("log content: <%s>.\n", logContentXML.str()); //Sleep(5000); //Waiting for loggingManager to start loggingManager->updateLog(option.str(), logContentXML.str(), status); } else printf("Invalid action.\n"); }
CLocalDataLogger::CLocalDataLogger(IPropertyTree *cfg, const char *process, const char *service, const char* UrlRoot) { StringBuffer _directoryCache,xpath; xpath.appendf("Software/EspProcess[@name=\"%s\"]/EspService[@name=\"%s\"]/localCache/", process, service); IPropertyTree* cacheprop = cfg->queryBranch(xpath.str()); if(cacheprop==0) { WARNLOG(-1,"No local cache defined for %s service.",service); return; } Init(cacheprop->queryProp("@cache"),cacheprop->queryProp("@fileExtension"),UrlRoot,cacheprop->getPropInt("@timerPeriod"),cacheprop->getPropInt("@cacheTimeout")); }