void doCreate(const char *partname, const char *xml, unsigned updateFlags, StringArray &filesNotFound) { createPart(partname, xml); if (pmExisting) { if (!checkFlag(PKGADD_MAP_REPLACE)) throw MakeStringException(PKG_NAME_EXISTS, "PackageMap %s already exists, either delete it or specify overwrite", pmid.str()); } cloneDfsInfo(updateFlags, filesNotFound); if (pmExisting) packageMaps->removeTree(pmExisting); Owned<IPropertyTree> pmTree = createPTree("PackageMap", ipt_ordered); pmTree->setProp("@id", pmid); pmTree->setPropBool("@multipart", true); pmTree->addPropTree("Part", pmPart.getClear()); packageMaps->addPropTree("PackageMap", pmTree.getClear()); VStringBuffer xpath("PackageMap[@id='%s'][@querySet='%s']", pmid.str(), target.get()); Owned<IPropertyTree> pkgSet = getPkgSetRegistry(process, false); IPropertyTree *psEntry = pkgSet->queryPropTree(xpath); if (!psEntry) { psEntry = pkgSet->addPropTree("PackageMap", createPTree("PackageMap")); psEntry->setProp("@id", pmid); psEntry->setProp("@querySet", target); } makePackageActive(pkgSet, psEntry, target, checkFlag(PKGADD_MAP_ACTIVATE)); }
IRemoteConnection* CWSESPControlEx::querySDSConnection(const char* xpath, unsigned mode, unsigned timeout) { Owned<IRemoteConnection> globalLock = querySDS().connect(xpath, myProcessSession(), mode, timeout); if (!globalLock) throw MakeStringException(ECLWATCH_INTERNAL_ERROR, "Unable to connect to ESP Session information in dali %s", xpath); return globalLock.getClear(); }
IConstWorkUnit *processQuerySetWorkunit(SCMStringBuffer &wuid, IRoxieQueryCompileInfo &compileInfo, IRoxieQueryProcessingInfo &processingInfo, SCMStringBuffer &status ) { Owned<IConstWorkUnit> workunit; try { Owned<IRoxieQueryCompiler> compiler = createRoxieQueryCompiler(); workunit.setown(compiler->compileEcl(wuid, user, password, compileInfo, processingInfo, status)); if (!workunit) { DBGLOG("ERROR compiling query %s", status.str()); return NULL; } } catch(IException *e) { // don't try and update a workunit - eclserver already did it StringBuffer msg; e->errorMessage(msg); status.set(msg.str()); DBGLOG("ERROR compiling query %s", msg.str()); e->Release(); return NULL; } Owned<IWorkUnit> wu = &workunit->lock(); wu->setState(WUStateCompiled); return workunit.getClear(); }
extern DLLSERVER_API ILoadedDllEntry * createDllEntry(const char *path, bool isGlobal, const IFileIO *dllFile) { Owned<HelperDll> result = new HelperDll(path, dllFile); if (!result->load(isGlobal, true)) throw MakeStringException(0, "Failed to create ILoadedDllEntry for dll %s", path); return result.getClear(); }
void *CJHTreeNode::allocMem(size32_t len) { char *ret = (char *) malloc(len); if (!ret) { Owned<IException> E = MakeStringException(MSGAUD_operator,0, "Out of memory in CJHTreeNode::allocMem, requesting %d bytes", len); EXCLOG(E); if (flushJHtreeCacheOnOOM) { clearKeyStoreCache(false); ret = (char *) malloc(len); } if (!ret) throw E.getClear(); } unsigned __int64 _totalAllocatedCurrent; unsigned __int64 _totalAllocatedEver; unsigned _countAllocationsCurrent; unsigned _countAllocationsEver; { SpinBlock b(spin); totalAllocatedCurrent += len; totalAllocatedEver += len; countAllocationsCurrent ++; countAllocationsEver ++; _totalAllocatedCurrent = totalAllocatedCurrent; _totalAllocatedEver = totalAllocatedEver; _countAllocationsCurrent = countAllocationsCurrent; _countAllocationsEver = countAllocationsEver; } if (traceJHtreeAllocations) DBGLOG("JHTREE memory usage: Allocated %d - %" I64F "d currently allocated in %d allocations", len, _totalAllocatedCurrent, _countAllocationsCurrent); return ret; }
bool CDfuPlusHelper::runLocalDaFileSvr(SocketEndpoint &listenep,bool requireauthenticate, unsigned timeout) { Owned<CDafsThread> thr = new CDafsThread(listenep,requireauthenticate); if (!thr->ok()) return false; thr->start(); StringBuffer eps; if (listenep.isNull()) progress("Started local Dali file server on port %d\n", listenep.port?listenep.port:DAFILESRV_PORT); else progress("Started local Dali file server on %s\n", listenep.getUrlStr(eps).str()); if (timeout==0) { setDafsTrace(NULL,0); // disable client tracing dafsthread.setown(thr.getClear()); } else { loop { Sleep(500); if (thr->idleTime()>timeout) { thr->stop(); break; } } } return true; }
IPropertyTree *getPkgSetRegistry(const char *process, bool readonly) { Owned<IRemoteConnection> globalLock = querySDS().connect("/PackageSets/", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT); if (!globalLock) throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to connect to PackageSet information in dali /PackageSets"); IPropertyTree *pkgSets = globalLock->queryRoot(); if (!pkgSets) throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to open PackageSet information in dali /PackageSets"); if (!process || !*process) process = "*"; StringBuffer id; buildPkgSetId(id, process); //Only lock the branch for the target we're interested in. VStringBuffer xpath("/PackageSets/PackageSet[@id='%s']", id.str()); Owned<IRemoteConnection> conn = querySDS().connect(xpath.str(), myProcessSession(), readonly ? RTM_LOCK_READ : RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT); if (!conn) { if (readonly) return NULL; Owned<IPropertyTree> pkgSet = createPTree(); pkgSet->setProp("@id", id.str()); pkgSet->setProp("@process", process); pkgSets->addPropTree("PackageSet", pkgSet.getClear()); globalLock->commit(); conn.setown(querySDS().connect(xpath.str(), myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT)); } return (conn) ? conn->getRoot() : NULL; }
void main() { for (;;) { Owned<PrefetchInfo> fetchRow = pullRecord(); CriticalBlock b(crit); if (!eoi) prefetchQueue.enqueue(fetchRow.getClear()); if (blocked) { blocked = false; blockedSem.signal(); } if (eoi) break; if (prefetchQueue.ordinality() >= parent.preload) { full = true; CriticalUnblock b(crit); fullSem.wait(); if (stopped) break; } } }
void expandManifestDirectory(IPropertyTree *manifestSrc, IPropertyTree &res, StringBuffer &dir, IDirectoryIterator *it, const char*mask, bool recursive) { if (!it) return; ForEach(*it) { if (it->isDir()) { if (recursive) expandManifestDirectory(manifestSrc, res, dir, it->query().directoryFiles(mask, false, true), mask, recursive); continue; } StringBuffer reldir; Owned<IPropertyTree> newRes = createPTreeFromIPT(&res); reldir.append(splitRelativePath(it->query().queryFilename(), dir, reldir)); VStringBuffer xpath("Resource[@filename='%s']", reldir.str()); if (manifestSrc->hasProp(xpath)) continue; newRes->setProp("@filename", reldir.str()); updateManifestResourcePaths(*newRes, dir.str()); if (manifestSrc->hasProp(xpath.setf("resource[@resourcePath='%s']", newRes->queryProp("@resourcePath")))) continue; manifestSrc->addPropTree("Resource", newRes.getClear()); } }
void listPkgInfo(double version, const char *target, const char *process, const IPropertyTree* packageMaps, IPropertyTree* pkgSetRegistry, IArrayOf<IConstPackageListMapData>* results) { StringBuffer xpath("PackageMap"); if (target && *target) xpath.appendf("[@querySet='%s']", target); Owned<IPropertyTreeIterator> iter = pkgSetRegistry->getElements(xpath.str()); ForEach(*iter) { IPropertyTree &item = iter->query(); const char *id = item.queryProp("@id"); if (!id || !*id) continue; StringBuffer xpath; xpath.append("PackageMap[@id='").append(id).append("']"); IPropertyTree *mapTree = packageMaps->queryPropTree(xpath); if (!mapTree) continue; Owned<IEspPackageListMapData> res = createPackageListMapData("", ""); res->setActive(item.getPropBool("@active")); if (process && *process && (version >= 1.01)) res->setProcess(process); getPackageListInfo(mapTree, res); if (target && *target) res->setTarget(target); else res->setTarget(item.queryProp("@querySet")); results->append(*res.getClear()); } }
virtual int processCMD() { StringBuffer s; Owned<IClientWsWorkunits> client = createWsWorkunitsClient(); VStringBuffer url("http://%s:%s/WsWorkunits", optServer.sget(), optPort.sget()); client->addServiceUrl(url.str()); if (optUsername.length()) client->setUsernameToken(optUsername.get(), optPassword.sget(), NULL); Owned<IClientWUQuerySetAliasActionRequest> req = client->createWUQuerysetAliasActionRequest(); IArrayOf<IEspQuerySetAliasActionItem> aliases; Owned<IEspQuerySetAliasActionItem> item = createQuerySetAliasActionItem(); item->setName(optAlias.get()); aliases.append(*item.getClear()); req->setAliases(aliases); req->setAction("Deactivate"); req->setQuerySetName(optQuerySet.get()); Owned<IClientWUQuerySetAliasActionResponse> resp = client->WUQuerysetAliasAction(req); IArrayOf<IConstQuerySetAliasActionResult> &results = resp->getResults(); if (resp->getExceptions().ordinality()) outputMultiExceptions(resp->getExceptions()); else if (results.empty()) fprintf(stderr, "\nError Empty Result!\n"); else { IConstQuerySetAliasActionResult &item = results.item(0); if (item.getSuccess()) fprintf(stdout, "Deactivated alias %s/%s\n", optQuerySet.sget(), optAlias.sget()); else if (item.getCode()|| item.getMessage()) fprintf(stderr, "Error (%d) %s\n", item.getCode(), item.getMessage()); } return 0; }
IFvDataSource * IndexDataSource::cloneForFilter() { Owned<IndexDataSource> ret = new IndexDataSource(this); if (ret->init()) return ret.getClear(); return NULL; }
extern DLLSERVER_API ILoadedDllEntry * createExeDllEntry(const char *path) { Owned<HelperDll> result = new HelperDll(path, NULL); if (!result->loadCurrentExecutable()) throw MakeStringException(0, "Failed to create ILoadedDllEntry for current executable"); return result.getClear(); }
AggregateRowBuilder &RowAggregator::addRow(const void * row) { AggregateRowBuilder *result; unsigned hash = hasher->hash(row); void * match = find(hash, row); if (match) { result = static_cast<AggregateRowBuilder *>(match); totalSize -= result->querySize(); size32_t sz = helper.processNext(*result, row); result->setSize(sz); totalSize += sz; } else { Owned<AggregateRowBuilder> rowBuilder = new AggregateRowBuilder(rowAllocator, hash); helper.clearAggregate(*rowBuilder); size32_t sz = helper.processFirst(*rowBuilder, row); rowBuilder->setSize(sz); result = rowBuilder.getClear(); addNew(result, hash); totalSize += sz; overhead += ROWAGG_PERROWOVERHEAD; } return *result; }
void ResourceManager::addManifest(const char *filename) { StringBuffer path; Owned<IPropertyTree> t = createPTree(); t->setProp("@originalFilename", makeAbsolutePath(filename, path).str()); ensureManifestInfo()->addPropTree("Include", t.getClear()); addManifestFile(filename); }
static IKeyManager *getKeyManager(IKeyIndex *keyIndex, IHThorIndexReadBaseArg *helper, size32_t fixedDiskRecordSize) { Owned<IKeyManager> klManager = createKeyManager(keyIndex, fixedDiskRecordSize, NULL); helper->createSegmentMonitors(klManager); klManager->finishSegmentMonitors(); klManager->reset(); return klManager.getClear(); }
void PackageMapAndSet::load(unsigned flags) { Owned<IPropertyTree> t = createPTreeFromIPT(tree); if (flags & PMAS_RELOAD_PACKAGE_SET) load("PackageSets", t); if (flags & PMAS_RELOAD_PACKAGE_MAP) load("PackageMaps", t); tree.setown(t.getClear()); }
extern esp_http_decl IEspCache* createESPCache(const char* setting) { #ifdef USE_LIBMEMCACHED Owned<ESPMemCached> espCache = new ESPMemCached(); if (espCache->init(setting)) return espCache.getClear(); #endif return nullptr; }
IRowStream * doLocalSelfJoin() { #if THOR_TRACE_LEVEL > 5 ActPrintLog("SELFJOIN: Performing local self-join"); #endif Owned<IThorRowLoader> iLoader = createThorRowLoader(*this, ::queryRowInterfaces(input), compare, isUnstable() ? stableSort_none : stableSort_earlyAlloc, rc_mixed, SPILL_PRIORITY_SELFJOIN); Owned<IRowStream> rs = iLoader->load(inputStream, abortSoon); mergeStats(spillStats, iLoader); // Not sure of the best policy if rs spills later on. PARENT::stop(); return rs.getClear(); }
IRowStream * doLocalSelfJoin() { #if THOR_TRACE_LEVEL > 5 ActPrintLog("SELFJOIN: Performing local self-join"); #endif Owned<IThorRowLoader> iLoader = createThorRowLoader(*this, ::queryRowInterfaces(input), compare, isUnstable() ? stableSort_none : stableSort_earlyAlloc, rc_mixed, SPILL_PRIORITY_SELFJOIN); Owned<IRowStream> rs = iLoader->load(input, abortSoon); stopInput(input); input = NULL; return rs.getClear(); }
void CBuildSetManager::setBuildSetArray(const StringArray &strArray) { m_buildSetArray.kill(); for (int idx = 0; idx < strArray.length(); idx++) { Owned<CBuildSet> pBSet = new CBuildSet(nullptr, strArray.item(idx), nullptr, strArray.item(idx)); assert (pBSet != nullptr); m_buildSetArray.append(*pBSet.getClear()); } }
void CCassandraLogAgent::executeUpdateLogStatement(StringBuffer& st) { cassSession->connect(); CassandraFuture futurePrep(cass_session_prepare_n(cassSession->querySession(), st.str(), st.length())); futurePrep.wait("prepare statement"); Owned<CassandraPrepared> prepared = new CassandraPrepared(cass_future_get_prepared(futurePrep), NULL); CassandraStatement statement(prepared.getClear()); CassandraFuture future(cass_session_execute(cassSession->querySession(), statement)); future.wait("execute"); cassSession->disconnect(); }
const void *nextRow() { OwnedConstThorRow row = smartbuf->nextRow(); if (getexception) throw getexception.getClear(); if (!row) { #ifdef _FULL_TRACE ActPrintLog(&activity, "ThorLookaheadCache eos %x",(unsigned)(memsize_t)this); #endif } return row.getClear(); }
IRemoteConnection * getEntryConnection(const char * name, unsigned mode) { StringBuffer xpath; getNewXPath(xpath, name); Owned<IRemoteConnection> connection = querySDS().connect(xpath.str(), myProcessSession(), mode, CONNECTION_TIMEOUT); if (connection) return connection.getClear(); //Retain backwards compatibility for the moment getOldXPath(xpath.clear(), name); return querySDS().connect(xpath.str(), myProcessSession(), mode, CONNECTION_TIMEOUT); }
void CHpccPackageSet::load(IPropertyTree *xml) { Owned<IPropertyTreeIterator> it = xml->getElements("PackageMap[@active='1']"); //only active for now ForEach(*it) { IPropertyTree &tree = it->query(); if (!tree.hasProp("@id")) continue; Owned<CHpccPackageMap> pm = new CHpccPackageMap(tree.queryProp("@id"), tree.queryProp("@querySet"), true); pm->load(tree.queryProp("@id")); packageMaps.append(*pm.getClear()); } }
CppEchoPersonInfoResponse* EsdlExampleService::CppEchoPersonInfo(EsdlContext* context, CppEchoPersonInfoRequest* request) { Owned<CppEchoPersonInfoResponse> resp = new CppEchoPersonInfoResponse(); //Fill in logic resp->count.setown(new Integer(0)); if(request->Name) { resp->count.setown(new Integer(1)); resp->Name.set(request->Name.get()); } appendArray(resp->Addresses, request->Addresses); return resp.getClear(); }
//Create using given key filespecs //Caller must release when no longer needed IDigitalSignatureManager * createDigitalSignatureManagerInstanceFromFiles(const char * pubKeyFileName, const char *privKeyFileName, const char * passPhrase) { #if defined(_USE_OPENSSL) && !defined(_WIN32) Owned<CLoadedKey> pubKey, privKey; Owned<IMultiException> exceptions; if (!isEmptyString(pubKeyFileName)) { try { pubKey.setown(loadPublicKeyFromFile(pubKeyFileName, passPhrase)); } catch (IException * e) { if (!exceptions) exceptions.setown(makeMultiException("createDigitalSignatureManagerInstanceFromFiles")); exceptions->append(* makeWrappedExceptionV(e, -1, "createDigitalSignatureManagerInstanceFromFiles:Cannot load public key file")); e->Release(); } } if (!isEmptyString(privKeyFileName)) { try { privKey.setown(loadPrivateKeyFromFile(privKeyFileName, passPhrase)); } catch (IException * e) { if (!exceptions) exceptions.setown(makeMultiException("createDigitalSignatureManagerInstanceFromFiles")); exceptions->append(* makeWrappedExceptionV(e, -1, "createDigitalSignatureManagerInstanceFromFiles:Cannot load private key file")); e->Release(); } } // NB: allow it continue if 1 of the keys successfully loaded. if (exceptions && exceptions->ordinality()) { if (!pubKey && !privKey) throw exceptions.getClear(); else EXCLOG(exceptions, nullptr); } return new CDigitalSignatureManager(pubKey, privKey); #else return nullptr; #endif }
void start() { #ifdef _FULL_TRACE ActPrintLog(&activity, "ThorLookaheadCache start %x",(unsigned)(memsize_t)this); #endif stopped = false; asyncstart = notify&¬ify->startAsync(); thread.start(); if (!asyncstart) { startsem.wait(); if (startexception) throw startexception.getClear(); } }
void convertExisting() { Linked<IPropertyTree> pmPart = pmExisting; const char *s = strstr(pmid.str(), "::"); if (s) pmPart->addProp("@id", s+2); packageMaps->removeTree(pmExisting); Owned<IPropertyTree> pmTree = createPTree("PackageMap", ipt_ordered); pmTree->setProp("@id", pmid); pmTree->setPropBool("@multipart", true); pmTree->addPropTree("Part", pmPart.getClear()); pmExisting = packageMaps->addPropTree("PackageMap", pmTree.getClear()); }
IClientWsEclResp* CClientWsEclService::searchEx(IClientWsEclRequest* request,const char* URL, const char *user, const char *pw, const char *realm) { if(strlen(URL) == 0) throw MakeStringException(-1, "url not set"); CClientWsEclRequest* eclrequest = dynamic_cast<CClientWsEclRequest*>(request); Owned<CClientWsEclResponse> eclresponse = new CClientWsEclResponse; eclresponse->setRequestId(m_reqId); m_reqId++; eclrequest->post(URL, *eclresponse, user, pw, realm); return eclresponse.getClear(); }