CATCH_NEXTROW() { ActivityTimer t(totalCycles, timeActivities, NULL); if(abortSoon || eof || eogNext) { eogNext = false; return NULL; } if (refill) { refill=false; index=0; try { group.reset(false); loop { OwnedConstThorRow row = input->nextRow(); if (!row) break; group.append(row.getClear()); if (group.isFull()) { StringBuffer errStr("GROUPSORT"); errStr.append("(").append(container.queryId()).append(") "); errStr.append("exceeded available memory. records=").append(group.ordinality()).append(", memory usage=").append((unsigned)(group.totalSize()/1024)).append('k'); IException *e = MakeActivityException(this, TE_TooMuchData, "%s", errStr.str()); EXCLOG(e, NULL); throw e; } } if (group.ordinality()==0) { eof = true; return NULL; } group.sort(*icompare,!unstable); } catch (IOutOfMemException *e) { StringBuffer errStr("GROUPSORT"); errStr.append("(").append(container.queryId()).append(") "); errStr.append("exceeded available memory. records=").append(group.ordinality()).append(", memory usage=").append((unsigned)(group.totalSize()/1024)).append('k'); errStr.append(": ").append(e->errorCode()).append(", "); e->errorMessage(errStr); e->Release(); IException *e2 = MakeActivityException(this, TE_TooMuchData, "%s", errStr.str()); EXCLOG(e2, NULL); throw e2; } } if(index >= group.ordinality()) { refill = true; return NULL; // eog } const void *row = group.itemClear(index++); assertex(row); dataLinkIncrement(); return row; }
void CDiskWriteSlaveActivityBase::process() { calcFileCrc = false; uncompressedBytesWritten = 0; replicateDone = 0; StringBuffer tmpStr; fName.set(getPartFilename(*partDesc, 0, tmpStr).str()); if (diskHelperBase->getFlags() & TDXtemporary && !container.queryJob().queryUseCheckpoints()) container.queryTempHandler()->registerFile(fName, container.queryOwner().queryGraphId(), usageCount, true); try { ActPrintLog("handling fname : %s", fName.get()); try { open(); assertex(out||outraw); write(); } catch (IException *) { abortSoon = true; try { close(); } catch (IException *e) { EXCLOG(e, "close()"); e->Release(); } throw; } catch (CATCHALL) { abortSoon = true; try { close(); } catch (IException *e) { EXCLOG(e, "close()"); e->Release(); } throw; } close(); } catch (IException *) { calcFileCrc = false; throw; } catch(CATCHALL) { calcFileCrc = false; throw; } unsigned crc = compress?~0:fileCRC.get(); ActPrintLog("Wrote %" RCPF "d records%s", processed & THORDATALINK_COUNT_MASK, calcFileCrc?StringBuffer(", crc=0x").appendf("%X", crc).str() : ""); }
static bool deleteEmptyDir(IFile *dir) { // this is a bit odd - basically we already know no files but there may be empty sub-dirs Owned<IDirectoryIterator> iter = dir->directoryFiles(NULL,false,true); IArrayOf<IFile> subdirs; bool candelete = true; ForEach(*iter) { if (iter->isDir()) subdirs.append(iter->get()); else candelete = false; } if (!candelete) return false; try { ForEachItemIn(i,subdirs) { if (!deleteEmptyDir(&subdirs.item(i))) candelete = false; } } catch (IException *e) { EXCLOG(e,"deleteEmptyDir"); candelete = false; } if (!candelete) return false; static CriticalSection sect; CriticalBlock block(sect); // don't want to actually remove in parallel dir->remove(); return !dir->exists(); }
virtual void main() { running = true; loop { INode *senderNode; CMessageBuffer msg; if (!queryWorldCommunicator().recv(msg, NULL, MPTAG_THORREGISTRATION, &senderNode)) return; rank_t sender = queryNodeGroup().rank(senderNode); SocketEndpoint ep = senderNode->endpoint(); StringBuffer url; ep.getUrlStr(url); if (RANK_NULL == sender) { PROGLOG("Node %s trying to deregister is not part of this cluster", url.str()); continue; } RegistryCode code; msg.read((int &)code); if (rc_deregister != code) throwUnexpected(); Owned<IException> e = deserializeException(msg); if (e.get()) EXCLOG(e, "Slave unregistered with exception"); registry.deregisterNode(sender-1); } running = false; }
//cloned from hthor - a candidate for commoning up. static IKeyIndex *openKeyFile(IDistributedFilePart *keyFile) { unsigned numCopies = keyFile->numCopies(); assertex(numCopies); for (unsigned copy=0; copy < numCopies; copy++) { RemoteFilename rfn; try { OwnedIFile ifile = createIFile(keyFile->getFilename(rfn,copy)); unsigned __int64 thissize = ifile->size(); if (thissize != -1) { StringBuffer remotePath; rfn.getRemotePath(remotePath); unsigned crc = 0; keyFile->getCrc(crc); return createKeyIndex(remotePath.str(), crc, false, false); } } catch (IException *E) { EXCLOG(E, "While opening index file"); E->Release(); } } RemoteFilename rfn; StringBuffer url; keyFile->getFilename(rfn).getRemotePath(url); throw MakeStringException(1001, "Could not open key file at %s%s", url.str(), (numCopies > 1) ? " or any alternate location." : "."); }
int main(int argc, char * const * argv) { InitModuleObjects(); try { KeyPatchParams params; getParams(argc, argv, params); Owned<IKeyDiffApplicator> applicator; if(params.mode == KEYPATCH_explicit) applicator.setown(createKeyDiffApplicator(params.patch.str(), params.oldIndex.str(), params.newIndex.str(), params.newTLK.str(), params.overwrite, params.ignoreTLK)); else applicator.setown(createKeyDiffApplicator(params.patch.str(), params.overwrite, params.ignoreTLK)); if(params.mode == KEYPATCH_info) showInfo(params.patch.str(), applicator); else { if(params.xmitTLK) applicator->setTransmitTLK(new CNodeSender(params.tlkPort, params.xmitEp)); else if(params.recvTLK) applicator->setReceiveTLK(new CNodeReceiver(params.tlkPort), params.recvNum); if(params.progressFrequency) applicator->setProgressCallback(new KeyPatchProgressCallback, params.progressFrequency); applicator->run(); } } catch(IException * e) { EXCLOG(e); e->Release(); releaseAtoms(); return 1; } releaseAtoms(); return 0; }
int main(int argc, char* argv[]) { InitModuleObjects(); EnableSEHtoExceptionMapping(); if (argc<6) { usage(); return 0; } try { const char *filename = argv[1]; Owned<IDaliCapabilityCreator> cc = createDaliCapabilityCreator(); cc->setSystemID(argv[2]); cc->setServerPassword(argv[3]); for (unsigned i=4;i<argc;i++) { const char *cmd = argv[i++]; if (i==argc) break; const char *param = argv[i]; if (stricmp(cmd,"THORWIDTH")==0) { cc->setLimit(DCR_ThorSlave,atoi(param)); } else if (stricmp(cmd,"DALINODE")==0) { StringBuffer mac; if (strchr(param,'.')) { // must be ip IpAddress ip; ip.set(param); if (!getMAC(ip,mac)) { printf("ERROR: could mot get MAC address for %s\n",param); return 1; } } else mac.append(param); cc->addCapability(DCR_DaliServer,mac.str()); } else { printf("ERROR: unknown command %s\n",cmd); return 1; } } StringBuffer results; cc->save(results); Owned<IFile> ifile = createIFile(filename); Owned<IFileIO> ifileio = ifile->open(IFOcreate); ifileio->write(0,results.length(),results.str()); printf("Dali Capabilities sucessfully exported to %s\n", filename); } catch (IException *e) { EXCLOG(e); e->Release(); } releaseAtoms(); return 0; }
ISmartSocket *CSmartSocketFactory::connect_timeout( unsigned timeoutms) { SmartSocketEndpoint *ss = nextSmartEndpoint(); if (!ss) throw createSmartSocketException(0, "smartsocket failed to get nextEndpoint"); ISocket *sock = NULL; SocketEndpoint ep; try { { synchronized block(lock); ss->checkHost(dnsInterval); ep = ss->ep; } if (timeoutms) sock = ISocket::connect_timeout(ep, timeoutms); else sock = ISocket::connect(ep); return new CSmartSocket(sock, ep, this); } catch (IException *e) { StringBuffer s("CSmartSocketFactory::connect "); ep.getUrlStr(s); EXCLOG(e,s.str()); ss->status=false; if (sock) sock->Release(); throw; } }
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; }
void Do(unsigned i) { CriticalBlock block(crit); if (parent->stopped) return; CFileCrcItem &item = parent->list.item(i); RemoteFilename &rfn = item.filename; Owned<IFile> partfile; StringBuffer eps; try { partfile.setown(createIFile(rfn)); // PROGLOG("VERIFY: part %s on %s",partfile->queryFilename(),rfn.queryEndpoint().getUrlStr(eps).str()); if (partfile) { if (parent->stopped) return; CriticalUnblock unblock(crit); item.crc = partfile->getCRC(); } else ok = false; } catch (IException *e) { StringBuffer s; s.appendf("VERIFY: part %s on %s",partfile->queryFilename(),rfn.queryEndpoint().getUrlStr(eps).str()); EXCLOG(e, s.str()); e->Release(); ok = false; } }
bool SafePluginMap::addPlugin(const char *path, const char *dllname) { if (!endsWithIgnoreCase(path, SharedObjectExtension)) { if (trace) DBGLOG("Ecl plugin %s ignored", path); return false; } try { CriticalBlock b(crit); ILoadedDllEntry *dll = map.getValue(dllname); if (!dll) { Owned<PluginDll> n = new PluginDll(path, NULL); if (!n->load(true, false) || !n->init(pluginCtx)) throw MakeStringException(0, "Failed to load plugin %s", path); if (trace) n->logLoaded(); map.setValue(dllname, n); // note: setValue links arg return true; } return false; } catch (IException * e) // MORE - not sure why we don't throw exceptions back here... { EXCLOG(e, "Loading plugin"); e->Release(); return false; } }
void CEclAgentExecutionServer::start(StringBuffer & codeDir) { if (started) { WARNLOG("START called when already started\n"); assert(false); } codeDirectory = codeDir; StringBuffer propertyFile = codeDirectory; addPathSepChar(propertyFile); propertyFile.append("agentexec.xml"); Owned<IPropertyTree> properties; try { DBGLOG("AgentExec: Loading properties file '%s'\n", propertyFile.str()); properties.setown(createPTreeFromXMLFile(propertyFile.str())); } catch (IException *e) { EXCLOG(e, "Error processing properties file\n"); throwUnexpected(); } { //Build logfile from component properties settings Owned<IComponentLogFileCreator> lf = createComponentLogFileCreator(properties, "eclagent"); lf->setCreateAliasFile(false); lf->setMsgFields(MSGFIELD_timeDate | MSGFIELD_msgID | MSGFIELD_process | MSGFIELD_thread | MSGFIELD_code); lf->beginLogging(); PROGLOG("Logging to %s",lf->queryLogFileSpec()); } //get name of workunit job queue StringBuffer sb; properties->getProp("@name", sb.clear()); agentName.set(sb); if (!agentName.length()) { ERRLOG("'name' not specified in properties file\n"); throwUnexpected(); } //get dali server(s) properties->getProp("@daliServers", daliServers); if (!daliServers.length()) { ERRLOG("'daliServers' not specified in properties file\n"); throwUnexpected(); } started = true; Thread::start(); Thread::join(); }
bool notifySelected(ISocket *sock,unsigned selected) { while (!done) { try { if (closing) { closing = false; #ifdef _FULL_TRACE PROGLOG("notifySelected calling closedown"); #endif closedown(); #ifdef _FULL_TRACE PROGLOG("notifySelected called closedown"); #endif done = true; donesem.signal(); return false; } } catch (IException *e) { EXCLOG(e,"CSortMerge notifySelected.1"); exception.setown(e); done = true; donesem.signal(); return false; } try { if (processRows()) return false; // false correct here } catch (IException *e) { EXCLOG(e,"CSortMerge notifySelected.2"); exception.setown(e); } closing = true; CriticalBlock block(crit); if (!sock||!socket) break; if (sock->avail_read()==0) break; } return false; // false correct here }
int main( int argc, char *argv[] ) { int res=0; if (argc < 3) { printf ("frunssh <nodelistfile> \"command\" [options] \n" " options: -i:<identity-file> \n" " -u:<user> \n" " -n:<number_of_threads>\n" " -t:<connect-timeout-secs>\n" " -a:<connect-attempts>\n" " -d:<working_directory>\n" " -s -- strict, must match known_hosts\n" " -b -- background\n" " -pw:<password> -- INSECURE: requires pssh (NB identity file preferred)\n" " -pe:<password> -- INSECURE: as -pw except encrypted password\n" " -pl -- use plink (on windows)\n" " -v -- verbose, lists commands run\n" " -d -- dry run (for testing, enables verbose)\n" ); return 255; } InitModuleObjects(); #ifndef __64BIT__ // Restrict stack sizes on 32-bit systems Thread::setDefaultStackSize(0x10000); // NB under windows requires linker setting (/stack:) #endif try { StringBuffer logname; splitFilename(argv[0], NULL, NULL, &logname, NULL); Owned<IComponentLogFileCreator> lf = createComponentLogFileCreator("frunssh"); lf->setCreateAliasFile(false); lf->setMsgFields(MSGFIELD_prefix); lf->beginLogging(); Owned<IFRunSSH> runssh = createFRunSSH(); runssh->init(argc,argv); runssh->exec(); } catch(IException *e) { EXCLOG(e,"frunssh"); e->Release(); res=255; } releaseAtoms(); return res; }
virtual void done() { StringBuffer scopedName; OwnedRoxieString outputName(helper->getOutputName()); queryThorFileManager().addScope(container.queryJob(), outputName, scopedName); Owned<IWorkUnit> wu = &container.queryJob().queryWorkUnit().lock(); Owned<IWUResult> r = wu->updateResultBySequence(helper->getSequence()); r->setResultStatus(ResultStatusCalculated); r->setResultLogicalName(scopedName.str()); r.clear(); wu.clear(); IPropertyTree &patchProps = patchDesc->queryProperties(); if (0 != (helper->getFlags() & KDPexpires)) setExpiryTime(patchProps, helper->getExpiryDays()); IPropertyTree &originalProps = originalDesc->queryProperties();; if (originalProps.queryProp("ECL")) patchProps.setProp("ECL", originalProps.queryProp("ECL")); if (originalProps.getPropBool("@local")) patchProps.setPropBool("@local", true); container.queryTempHandler()->registerFile(outputName, container.queryOwner().queryGraphId(), 0, false, WUFileStandard, &clusters); Owned<IDistributedFile> patchFile; // set part sizes etc queryThorFileManager().publish(container.queryJob(), outputName, false, *patchDesc, &patchFile, 0, false); try { // set file size if (patchFile) { __int64 fs = patchFile->getFileSize(true,false); if (fs!=-1) patchFile->queryAttributes().setPropInt64("@size",fs); } } catch (IException *e) { EXCLOG(e,"keydiff setting file size"); e->Release(); } // Add a new 'Patch' description to the secondary key. DistributedFilePropertyLock lock(newIndexFile); IPropertyTree &fileProps = lock.queryAttributes(); StringBuffer path("Patch[@name=\""); path.append(scopedName.str()).append("\"]"); IPropertyTree *patch = fileProps.queryPropTree(path.str()); if (!patch) patch = fileProps.addPropTree("Patch", createPTree()); patch->setProp("@name", scopedName.str()); unsigned checkSum; if (patchFile->getFileCheckSum(checkSum)) patch->setPropInt64("@checkSum", checkSum); IPropertyTree *index = patch->setPropTree("Index", createPTree()); index->setProp("@name", originalIndexFile->queryLogicalName()); if (originalIndexFile->getFileCheckSum(checkSum)) index->setPropInt64("@checkSum", checkSum); originalIndexFile->setAccessed(); newIndexFile->setAccessed(); }
void CSDSServerStatus::stop() { try { ::Release(conn); } catch (IException *e) // Dali server may have stopped { EXCLOG(e,"CSDSServerStatus::stop"); e->Release(); } conn = NULL; };
int main( int argc, char *argv[] ) { int res=0; if (argc < 3) { printf ("frunssh <nodelistfile> \"command\" [options] \n" " options: -i:<identity-file> \n" " -u:<user> \n" " -n:<number_of_threads>\n" " -t:<connect-timeout-secs>\n" " -a:<connect-attempts>\n" " -d:<working_directory>\n" " -s -- strict, must match known_hosts\n" " -b -- background\n" " -pw:<password> -- INSECURE: requires pssh (NB identity file preferred)\n" " -pe:<password> -- INSECURE: as -pw except encrypted password\n" " -pl -- use plink (on windows)\n" " -v -- verbose, lists commands run\n" " -d -- dry run (for testing, enables verbose)\n" ); return 255; } InitModuleObjects(); try { StringBuffer logname; splitFilename(argv[0], NULL, NULL, &logname, NULL); StringBuffer logdir; if (getConfigurationDirectory(NULL,"log","frunssh",logname.str(),logdir)) { recursiveCreateDirectory(logdir.str()); StringBuffer tmp(logname); addPathSepChar(logname.clear().append(logdir)).append(tmp); } addFileTimestamp(logname, true); logname.append(".log"); appendLogFile(logname.str(),0,false); queryStderrLogMsgHandler()->setMessageFields(MSGFIELD_prefix); Owned<IFRunSSH> runssh = createFRunSSH(); runssh->init(argc,argv); runssh->exec(); } catch(IException *e) { EXCLOG(e,"frunssh"); e->Release(); res=255; } releaseAtoms(); return res; }
void stop() { try { if (server) server->stop(); } catch (IException *e) { EXCLOG(e,"dfuplus(dafilesrvstop)"); e->Release(); } server.clear(); }
//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 CDiskPartHandlerBase::open() { unsigned location; StringBuffer filePath; if (!(globals->getPropBool("@autoCopyBackup", true)?ensurePrimary(&activity, *partDesc, iFile, location, filePath):getBestFilePart(&activity, *partDesc, iFile, location, filePath, &activity))) { StringBuffer locations; IException *e = MakeActivityException(&activity, TE_FileNotFound, "No physical file part for logical file %s, found at given locations: %s (Error = %d)", activity.logicalFilename.get(), getFilePartLocations(*partDesc, locations).str(), GetLastError()); EXCLOG(e, NULL); throw e; } filename.set(iFile->queryFilename()); ActPrintLog(&activity, "%s[part=%d]: reading physical file '%s' (logical file = %s)", kindStr, which, filePath.str(), activity.logicalFilename.get()); if (checkFileCrc) { CDateTime createTime, modifiedTime, accessedTime; iFile->getTime(&createTime, &modifiedTime, &accessedTime); const char *descModTimeStr = partDesc->queryProperties().queryProp("@modified"); CDateTime descModTime; descModTime.setString(descModTimeStr); if (!descModTime.equals(modifiedTime, false)) { StringBuffer diskTimeStr; ActPrintLog(&activity, "WARNING: file (%s); modified date stamps on disk (%s) are not equal to published modified data (%s)", filePath.str(), modifiedTime.getString(diskTimeStr).str(), descModTimeStr); } } ActPrintLog(&activity, "%s[part=%d]: Base offset to %"I64F"d", kindStr, which, fileBaseOffset); if (compressed) { ActPrintLog(&activity, "Reading %s compressed file: %s", (NULL != activity.eexp.get())?"encrypted":blockCompressed?"block":"row", filename.get()); if (checkFileCrc) { checkFileCrc = false; if (activity.crcCheckCompressed) // applies to encrypted too, (optional, default off) { ActPrintLog(&activity, "Calculating crc for file: %s", filename.get()); unsigned calcCrc = iFile->getCRC(); // NB: for compressed files should always be ~0 ActPrintLog(&activity, "Calculated crc = %x, storedCrc = %x", calcCrc, storedCrc); if (calcCrc != storedCrc) { IThorException *e = MakeActivityException(&activity, TE_FileCrc, "CRC Failure validating compressed file: %s", iFile->queryFilename()); e->setAudience(MSGAUD_operator); throw e; } } } } }
void CEclAgentExecutionServer::start() { if (started) { WARNLOG("START called when already started\n"); assert(false); } Owned<IPropertyTree> properties; try { DBGLOG("AgentExec: Loading properties file 'agentexec.xml'"); properties.setown(createPTreeFromXMLFile("agentexec.xml")); } catch (IException *e) { EXCLOG(e, "Error processing properties file\n"); throwUnexpected(); } { //Build logfile from component properties settings Owned<IComponentLogFileCreator> lf = createComponentLogFileCreator(properties, "eclagent"); lf->setCreateAliasFile(false); lf->beginLogging(); PROGLOG("Logging to %s",lf->queryLogFileSpec()); } //get name of workunit job queue StringBuffer sb; properties->getProp("@name", sb.clear()); agentName.set(sb); if (!agentName.length()) { ERRLOG("'name' not specified in properties file\n"); throwUnexpected(); } setStatisticsComponentName(SCThthor, agentName, true); //get dali server(s) properties->getProp("@daliServers", daliServers); if (!daliServers.length()) { ERRLOG("'daliServers' not specified in properties file\n"); throwUnexpected(); } started = true; Thread::start(); Thread::join(); }
int run() { try { server->run(listenep); } catch (IException *e) { EXCLOG(e,"dfuplus(dafilesrv)"); if (exc.get()) e->Release(); else exc.setown(e); } return 0; }
void main(CMessageBuffer &mb) { if (hasexceptionhandler) (parent->*handler)(mb); else { try { (parent->*handler)(mb); } catch (IException *e) { EXCLOG(e, name); e->Release(); } } mb.resetBuffer(); }
static IWorkUnitFactory * getWorkunitFactory(ICodeContext * ctx) { IEngineContext *engineCtx = ctx->queryEngineContext(); if (engineCtx && !engineCtx->allowDaliAccess()) { Owned<IException> e = MakeStringException(-1, "workunitservices cannot access Dali in this context - this normally means it is being called from a thor slave"); EXCLOG(e, NULL); throw e.getClear(); } //MORE: These should really be set up correctly - probably should be returned from IEngineContext ISecManager *secmgr = NULL; ISecUser *secuser = NULL; return getWorkUnitFactory(secmgr, secuser); }
static IKeyIndex *openKeyPart(CActivityBase *activity, const char *logicalFilename, IPartDescriptor &partDesc) { unsigned location; StringBuffer filePath; OwnedIFile ifile; if (!(globals->getPropBool("@autoCopyBackup", true)?ensurePrimary(activity, partDesc, ifile, location, filePath):getBestFilePart(activity, partDesc, ifile, location, filePath, activity))) { StringBuffer locations; IException *e = MakeActivityException(activity, TE_FileNotFound, "No physical file part for logical key file %s, found at given locations: %s (Error = %d)", logicalFilename, getFilePartLocations(partDesc, locations).str(), GetLastError()); EXCLOG(e, NULL); throw e; } unsigned crc; partDesc.getCrc(crc); return createKeyIndex(filePath.str(), crc, false, false); }
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(maxThreads, maxThreadsDelayMs, maxAsyncCopy)); server->setThrottle(ThrottleStd, parallelRequestLimit, throttleDelayMs, throttleCPULimit); server->setThrottle(ThrottleSlow, parallelSlowRequestLimit, throttleSlowDelayMs, throttleSlowCPULimit); try { server->run(listenep, useSSL); } catch (IException *e) { EXCLOG(e,DAFS_SERVICE_NAME); e->Release(); } PROGLOG(DAFS_SERVICE_DISPLAY_NAME " Stopped"); stopped = true; }
int LogMsgChildReceiverThread::run() { INode * sender; char ctrl; while(!done) { try { if(queryWorldCommunicator().recv(in, 0, MPTAG_JLOG_CONNECT_TO_PARENT, &sender)) { in.read(ctrl); if(ctrl=='A') { MPLogId pid; in.read(pid); MPLogId cid = addChildToManager(pid, sender, false, true); StringBuffer buff; in.clear().append(cid); queryWorldCommunicator().reply(in, MP_ASYNC_SEND); } else if(ctrl=='D') { MPLogId cid; in.read(cid); removeChildFromManager(cid, true); } else ERRLOG("LogMsgChildReceiverThread::run() : unknown control character on received message"); if(sender) sender->Release(); } } catch(IException * e) { EXCLOG(e, "LogMsgChildReceiverThread::run()"); e->Release(); } catch(...) { ERRLOG("LogMsgChildReceiverThread::run() : unknown exception"); } } return 0; }
int init(const char *caller,const char *_path, bool allscopes,bool allfiles) { if (_path==NULL) path.set(""); else path.set(_path); err = 0; try { if (!queryDistributedFileDirectory().loadScopeContents(_path,allscopes?&scopes:NULL,allfiles?&supers:NULL,allfiles?&files:NULL,true)) err = -ENOENT; else if (allfiles) donefiles = true; } catch (IException *e) { EXCLOG(e,caller); err = -EFAULT; } return err; }
void stop() { RECHECK(busy); if (!stopped) { stopped = true; try { #ifdef _FULL_TRACE PROGLOG("CSocketRowStream.stop(%x)",(unsigned)(memsize_t)socket.get()); #endif bool eof = true; socket->write(&eof,sizeof(eof)); // confirm stop #ifdef _FULL_TRACE PROGLOG("CSocketRowStream.stopped(%x)",(unsigned)(memsize_t)socket.get()); #endif } catch (IException *e) { EXCLOG(e,"CSocketRowStream::stop"); e->Release(); } } }
int run() { ICoven &coven=queryCoven(); CMessageHandler<CSessionRequestServer> handler("CSessionRequestServer",this,&CSessionRequestServer::processMessage); stopped = false; CMessageBuffer mb; while (!stopped) { try { mb.clear(); if (coven.recv(mb,RANK_ALL,MPTAG_DALI_SESSION_REQUEST,NULL)) handler.handleMessage(mb); else stopped = true; } catch (IException *e) { EXCLOG(e, "CDaliPublisherServer"); e->Release(); } } return 0; }