/*Open DomNamedb */ bool OpenDOMNAME(string name, bool create) { if(name.empty()) { ERR_POST("[OpenDOMNAME]: No table name given"); return false; } /*Init codeBase if not init yet*/ if(!IsCodeBaseInit() && !InitCodeBase()){ ERR_POST(Fatal<<"[OpenDOMNAME]:Cannot initiate CodeBase for RPSDB&DOMNAME"); return false; } if(create){ domnamedb.create(codeBase, name.c_str(), f4domname, t4domname); ERR_POST(Info<<"[OpenDOMNAME]: Creating new DomName table"); } else { domnamedb.open(codeBase, name.c_str()); } if(!domnamedb.isValid()){ ERR_POST("[OpenDOMNAME]:failed to open "<<name); return false; } pf4dnaccession.init(domnamedb,"ACCESSION"); pf4dnname.init(domnamedb,"NAME"); pf4dnpdbid.init(domnamedb,"PDBID"); pf4dnasn1.init(domnamedb,"ASN1"); tagdnaccession.init(domnamedb,"ACCESSION"); tagdnname.init(domnamedb,"NAME"); tagdnpdbid.init(domnamedb,"PDBID"); return true; }
int Run(void) { CMyThread* thr[10]; for (int i = 0; i < 10; ++i) { thr[i] = new CMyThread(i); thr[i]->Run(); } //for (int i = 0; i < 10; ++i) { for (;;) { string errMsg; list<string> servers; CSDBAPI::EMirrorStatus status = CSDBAPI::UpdateMirror("MSDEV", &servers, &errMsg); if(status == CSDBAPI::eMirror_Unavailable) ERR_POST("SQL mirror check failed, error: " << errMsg); else if(status == CSDBAPI::eMirror_NewMaster) ERR_POST(Warning << "Master server has been switched. New master: " << (servers.empty() ? kEmptyStr : servers.front())); else if(status != CSDBAPI::eMirror_Steady) ERR_POST("DB connection pool unknown status."); SleepMilliSec(1000); } for (int i = 0; i < 10; ++i) { thr[i]->Join(); } return 0; }
void CMSPeak::ReadAndProcess(const CMSSpectrum& Spectrum, const CMSSearchSettings& Settings) { if(Read(Spectrum, Settings) != 0) { ERR_POST(Error << "omssa: unable to read spectrum into CMSPeak"); return; } SetName().clear(); if(Spectrum.CanGetIds()) SetName() = Spectrum.GetIds(); if(Spectrum.CanGetNumber()) SetNumber() = Spectrum.GetNumber(); SetPeakLists()[eMSPeakListOriginal]->Sort(eMSPeakListSortMZ); SetComputedCharge(Settings.GetChargehandling(), Spectrum); InitHitList(Settings.GetMinhit()); CullAll(Settings); // this used to look at the filtered list. changed to look at original // to simplify the code. if(GetPeakLists()[eMSPeakListOriginal]->GetNum() < Settings.GetMinspectra()) { ERR_POST(Info << "omssa: not enough peaks in spectra"); SetError(eMSHitError_notenuffpeaks); } }
void CTestConnectionHandler::OnMessage(BUF buf) { char data[1024]; CSocket& socket = GetSocket(); size_t msg_size = BUF_Read(buf, data, sizeof(data)); if (msg_size > 0) { ERR_POST(Info << "Got \"" << string(data, msg_size) << "\""); } else { ERR_POST(Info << "Got empty line"); } if (m_State != Read) { ERR_POST(Info << "... ignored"); return; } socket.Write("Goodbye!\n", sizeof("Goodbye!\n") - 1); socket.Close(); int this_client_number = m_Server->RegisterClient(); int max_number_of_clients = m_Server->GetMaxNumberOfClients(); ERR_POST(Info << "Processed " << this_client_number << "/" << max_number_of_clients); if (this_client_number == max_number_of_clients) { ERR_POST(Info << "All clients processed"); m_Server->RequestShutdown(); } }
void CNetCacheAPI::Remove(const string& blob_id) { CNetCacheKey key(blob_id); try { m_Impl->ExecMirrorAware(key, m_Impl->MakeCmd("RMV2 ", key)); } catch (std::exception& e) { ERR_POST("Could not remove blob \"" << blob_id << "\": " << e.what()); } catch (...) { ERR_POST("Could not remove blob \"" << blob_id << "\""); } }
void CBlastScopeSource::x_InitBlastDatabaseDataLoader(CRef<CSeqDB> db_handle) { if ( !m_Config.m_UseBlastDbs ) { return; } if (db_handle.Empty()) { ERR_POST(Warning << "No BLAST database handle provided"); } else { try { m_BlastDbLoaderName = CBlastDbDataLoader::RegisterInObjectManager (*m_ObjMgr, db_handle, m_Config.m_UseFixedSizeSlices, CObjectManager::eNonDefault).GetLoader()->GetName(); _ASSERT( !m_BlastDbLoaderName.empty() ); _TRACE("Registered BLAST DB data loader '" << m_BlastDbLoaderName << "' as non-default"); } catch (const exception& e) { // in case of error when initializing the BLAST database, just // ignore the exception as the remote BLAST database data loader // will be the fallback (just issue a warning) ERR_POST(Warning << "Error initializing local BLAST database data " << "loader: '" << e.what() << "'"); const CBlastDbDataLoader::EDbType dbtype = db_handle->GetSequenceType() == CSeqDB::eProtein ? CBlastDbDataLoader::eProtein : CBlastDbDataLoader::eNucleotide; try { m_BlastDbLoaderName = CRemoteBlastDbDataLoader::RegisterInObjectManager (*m_ObjMgr, db_handle->GetDBNameList(), dbtype, m_Config.m_UseFixedSizeSlices, CObjectManager::eNonDefault, CObjectManager::kPriority_NotSet) .GetLoader()->GetName(); _ASSERT( !m_BlastDbLoaderName.empty() ); _TRACE("Registered BLAST DB data loader '" << m_BlastDbLoaderName << "' as non-default"); } catch (const CSeqDBException& e) { ERR_POST(Warning << "Error initializing remote BLAST database " << "data loader: " << e.GetMsg()); } } } }
// If the client identification - client_node and/or client_session - breaks // the length limit then it should be 'normalized'. Basically it is shortening // the values in a special way embedding the MD5 checksum. // See CXX-2617 string CNSClientId::x_NormalizeNodeOrSession(const string & val, const string & key) { if (val.size() < kMaxWorkerNodeIdSize) return val; // The limit is broken. Let's calculate the value MD5 CChecksum checksum(CChecksum::eMD5); string checksum_as_string; checksum.AddLine(val); checksum_as_string = checksum.GetHexSum(); string normalized; if (checksum_as_string.size() >= kMaxWorkerNodeIdSize - 2) { // Very defensive: if kMaxWorkerNodeIdSize is defined a way too small normalized = checksum_as_string.substr(0, kMaxWorkerNodeIdSize - 1); } else { size_t outer_lenght = ((kMaxWorkerNodeIdSize - 1) - // available 2 - // separators checksum_as_string.size()) // md5 / 2; normalized = val.substr(0, outer_lenght) + "/" + checksum_as_string + "/" + val.substr(val.size() - outer_lenght, outer_lenght); } ERR_POST("Client identification parameter " << key << " exceeds the max allowed length of " << kMaxWorkerNodeIdSize - 1 << " bytes. It will be replaced with " << normalized); return normalized; }
ERW_Result CMyReaderWriter::Flush(void) { ERR_POST(Info << "Flush @" << setw(8) << CMyReader::m_Pos << '/' << setw(7) << CMyWriter::m_Pos); return CMyWriter::Flush(); }
int CMSPeak::Read(const CMSSpectrum& Spectrum, const CMSSearchSettings& Settings) { try { SetTolerance(Settings.GetMsmstol()); SetPrecursorTol(Settings.GetPeptol()); // note that there are two scales -- input scale and computational scale // Precursormz = MSSCALE * (Spectrum.GetPrecursormz()/(double)MSSCALE); // for now, we assume one scale Precursormz = Spectrum.GetPrecursormz(); const CMSSpectrum::TMz& Mz = Spectrum.GetMz(); const CMSSpectrum::TAbundance& Abundance = Spectrum.GetAbundance(); SetPeakLists()[eMSPeakListOriginal]->CreateLists(Mz.size()); int i; for (i = 0; i < SetPeakLists()[eMSPeakListOriginal]->GetNum(); i++) { // for now, we assume one scale SetPeakLists()[eMSPeakListOriginal]->GetMZI()[i].SetMZ() = Mz[i]; SetPeakLists()[eMSPeakListOriginal]->GetMZI()[i].SetIntensity() = Abundance[i]; } SetPeakLists()[eMSPeakListOriginal]->Sort(eMSPeakListSortMZ); } catch (NCBI_NS_STD::exception& e) { ERR_POST(Info << "Exception in CMSPeak::Read: " << e.what()); throw; } return 0; }
const AtomInfo * GetAtomInfo(int aID) const { AtomInfoMap::const_iterator info=atomInfos.find(aID); if (info != atomInfos.end()) return (*info).second; ERR_POST(ncbi::Warning << "Residue #" << id << ": can't find atom #" << aID); return NULL; }
void CGridCgiSampleApplication::OnJobDone(CGridClient& grid_client, CGridCgiContext& ctx) { CNcbiIstream& is = grid_client.GetIStream(); int count; // Get the result m_Doubles.clear(); is >> count; for (int i = 0; i < count; ++i) { if (!is.good()) { ERR_POST( "Input stream error. Index : " << i ); break; } double d; is >> d; m_Doubles.push_back(d); } // Render the result page CHTMLText* inp_text = new CHTMLText( "<p/>Job is done.<br/>" "<p>Result received : <@OUTPUT_DATA@> <br/>" "<INPUT TYPE=\"submit\" NAME=\"Submit new Data\" " "VALUE=\"Submit new Data\">"); ctx.GetHTMLPage().AddTagMap("VIEW", inp_text); CHTMLPlainText* idoubles = new CHTMLPlainText(VectorToString(m_Doubles)); ctx.GetHTMLPage().AddTagMap("OUTPUT_DATA",idoubles); }
void CMSHit::RecordMatchesScan(CLadder& Ladder, int& iHitInfo, CMSPeak *Peaks, EMSPeakListTypes Which, int NOffset, int COffset) { try { SetSum() += Ladder.GetSum(); SetM() += Ladder.GetM(); // examine hits array int i; for(i = 0; i < Ladder.size(); i++) { // if hit, add to hitlist if(Ladder.GetHit()[i] > 0) { SetHitInfo(iHitInfo).SetCharge() = (char) Ladder.GetCharge(); SetHitInfo(iHitInfo).SetIonSeries() = (char) Ladder.GetType(); // if(kIonDirection[Ladder.GetType()] == 1) SetHitInfo(iHitInfo).SetNumber() = (short) i + NOffset; // else SetHitInfo(iHitInfo).SetNumber() = (short) i + COffset; SetHitInfo(iHitInfo).SetNumber() = Ladder.GetLadderNumber()[i]; SetHitInfo(iHitInfo).SetIntensity() = Ladder.GetIntensity()[i]; // for poisson test SetHitInfo(iHitInfo).SetMZ() = Ladder[i]; SetHitInfo(iHitInfo).SetDelta() = Ladder.GetDelta()[i]; // iHitInfo++; } } } catch (NCBI_NS_STD::exception& e) { ERR_POST(Info << "Exception caught in CMSHit::RecordMatchesScan: " << e.what()); throw; } }
bool SeqTreeAPI::makeTree() { if (m_triedTreeMaking) //if already tried, don't try again return m_seqTree != 0; if (m_seqTree != 0) { delete m_seqTree; m_seqTree = 0; m_seqTree = new SeqTree; } if (!m_loadOnly) { if (m_ma.getFirstCD() == 0) m_ma.setAlignment(*m_family); if(!m_ma.isBlockAligned()) { ERR_POST("Sequence tree is not made for " <<m_ma.getFirstCD()->GetAccession() <<" because it does not have a consistent block alognment."); } else { if ((m_treeOptions.distMethod == eScoreBlastFoot) || (m_treeOptions.distMethod == eScoreBlastFull)) m_treeOptions.distMethod = eScoreAligned; m_seqTree = TreeFactory::makeTree(&m_ma, m_treeOptions); } if (m_seqTree) m_seqTree->fixRowName(m_ma, SeqTree::eGI); } m_triedTreeMaking = true; return m_seqTree != 0; }
bool CSoapServerApplication::x_ProcessSoapRequest(CCgiResponse& response, const CCgiRequest& request) { bool input_ok=true; string fault_text; CSoapMessage soap_in, soap_out; soap_out.SetDefaultObjectNamespaceName(GetDefaultNamespaceName()); vector< TTypeInfoGetter >::const_iterator types_in; for (types_in = m_Types.begin(); types_in != m_Types.end(); ++types_in) { soap_in.RegisterObjectType(*types_in); } // read request if (request.GetInputStream()) { try { auto_ptr<CObjectIStream> is(CObjectIStream::Open(eSerial_Xml,*request.GetInputStream())); if (m_OmitScopePrefixes) { dynamic_cast<CObjectIStreamXml*>(is.get())->SetEnforcedStdXml(true); } *is >> soap_in; } catch (CException& e) { input_ok = false; ERR_POST(e); fault_text = e.ReportAll(m_FaultPostFlags); } catch (exception& e) { input_ok = false; fault_text = e.what(); } } #if 1 else {
string CGenomicCollectionsService::ValidateChrType(string chrType, string chrLoc) { CGCClient_ValidateChrTypeLocRequest req; CGCClientResponse reply; req.SetType(chrType); req.SetLocation(chrLoc); #ifdef _DEBUG ostringstream ostrstrm; ostrstrm << "Making request -" << MSerial_AsnText << req; LOG_POST(Info << ostrstrm.str()); #endif try { return AskGet_chrtype_valid(req, &reply); } catch (CException& ex) { if(reply.Which() == CGCClientResponse::e_Srvr_error) { ERR_POST(Error << " at Server side (will be propagated) ...\n" << reply.GetSrvr_error().GetError_id() << ": " << reply.GetSrvr_error().GetDescription()); NCBI_THROW(CException, eUnknown, reply.GetSrvr_error().GetDescription()); } throw; } }
CRef<CGC_Assembly> CGenomicCollectionsService::GetAssembly(string acc, int level, int asmAttrFlags, int chrAttrFlags, int scafAttrFlags, int compAttrFlags) { CGCClient_GetAssemblyRequest req; CGCClientResponse reply; req.SetAccession(acc); req.SetLevel(level); req.SetAssm_flags(asmAttrFlags); req.SetChrom_flags(chrAttrFlags); req.SetScaf_flags(scafAttrFlags); req.SetComponent_flags(compAttrFlags); #ifdef _DEBUG ostringstream ostrstrm; ostrstrm << "Making request - " << MSerial_AsnText << req; LOG_POST(Info << ostrstrm.str()); #endif try { return AskGet_assembly(req, &reply); } catch (CException& ex) { if(reply.Which() == CGCClientResponse::e_Srvr_error) { ERR_POST(Error << " at Server side (will be propagated) ...\nErrId:" << reply.GetSrvr_error().GetError_id() << ": " << reply.GetSrvr_error().GetDescription()); NCBI_THROW(CException, eUnknown, reply.GetSrvr_error().GetDescription()); } throw; } }
int CServerTestApp::Run(void) { SetDiagPostLevel(eDiag_Info); SetDiagPostAllFlags(eDPF_Severity | eDPF_OmitInfoSev | eDPF_ErrorID); #if defined(NCBI_OS_MSWIN) || defined(NCBI_OS_CYGWIN) CRequestRateControl rate_control(6); #else CRequestRateControl rate_control(CRequestRateControl::kNoLimit); #endif CFastMutex rate_mutex; const CArgs& args = GetArgs(); unsigned short port = 4096; { CListeningSocket listener; while (++port & 0xFFFF) { if (listener.Listen(port, 5, fSOCK_BindAny | fSOCK_LogOff) == eIO_Success) break; } if (port == 0) { ERR_POST("CServer test: unable to find a free port to listen on"); return 2; } } SServer_Parameters params; params.init_threads = args["srvthreads"].AsInteger(); params.max_threads = args["maxsrvthreads"].AsInteger(); params.accept_timeout = &kAcceptTimeout; int max_number_of_clients = args["requests"].AsInteger(); CTestServer server(max_number_of_clients, args["maxdelay"].AsInteger()); server.SetParameters(params); server.AddListener(new CTestConnectionFactory(&server), port); server.StartListening(); CStdPoolOfThreads pool(args["maxclthreads"].AsInteger(), max_number_of_clients); pool.Spawn(args["clthreads"].AsInteger()); for (int i = max_number_of_clients; i > 0; i--) { pool.AcceptRequest(CRef<ncbi::CStdRequest> (new CConnectionRequest(port, rate_control, rate_mutex))); } server.Run(); pool.KillAllThreads(true); return 0; }
double operator [] (unsigned int i) const { if (i == 0) return x; else if (i == 1) return y; else if (i == 2) return z; else ERR_POST(ncbi::Error << "Vector operator [] access out of range : " << i); return 0.0; }
double operator [] (unsigned int i) const { if (i > 15) { ERR_POST(ncbi::Error << "Matrix operator [] access out of range : " << i); return 0.0; } return m[i]; }
double& operator [] (unsigned int i) { static double err = 0.0; if (i > 15) { ERR_POST(ncbi::Error << "Matrix operator [] access out of range : " << i); return err; } return m[i]; }
int CNetCacheBlobFetchApp::OnException(std::exception& e, CNcbiOstream& os) { union { CArgException* arg_exception; CNetCacheException* nc_exception; }; string status_str; string message; if ((arg_exception = dynamic_cast<CArgException*>(&e)) != NULL) { status_str = "400 Bad Request"; message = arg_exception->GetMsg(); SetHTTPStatus(CRequestStatus::e400_BadRequest); } else if ((nc_exception = dynamic_cast<CNetCacheException*>(&e)) != NULL) { switch (nc_exception->GetErrCode()) { case CNetCacheException::eAccessDenied: status_str = "403 Forbidden"; message = nc_exception->GetMsg(); SetHTTPStatus(CRequestStatus::e403_Forbidden); break; case CNetCacheException::eBlobNotFound: status_str = "404 Not Found"; message = nc_exception->GetMsg(); SetHTTPStatus(CRequestStatus::e404_NotFound); break; default: return CCgiApplication::OnException(e, os); } } else return CCgiApplication::OnException(e, os); // Don't try to write to a broken output if (!os.good()) { return -1; } try { // HTTP header os << "Status: " << status_str << HTTP_EOL << "Content-Type: text/plain" HTTP_EOL HTTP_EOL << "ERROR: " << status_str << " " HTTP_EOL HTTP_EOL << message << HTTP_EOL; // Check for problems in sending the response if (!os.good()) { ERR_POST("CNetCacheBlobFetchApp::OnException() " "failed to send error page back to the client"); return -1; } } catch (exception& e) { NCBI_REPORT_EXCEPTION("(CGI) CNetCacheBlobFetchApp::OnException", e); } return 0; }
double& operator [] (unsigned int i) { static double err = 0.0; if (i == 0) return x; else if (i == 1) return y; else if (i == 2) return z; else ERR_POST(ncbi::Error << "Vector operator [] access out of range : " << i); return err; }
bool CStdAnnotTypes::LoadTypes(const string& iniFile) { static const string ID("id"); bool result = false; int id; int accessFlags = (IRegistry::fCaseFlags | IRegistry::fInternalSpaces); int readFlags = (IRegistry::fCaseFlags | IRegistry::fInternalSpaces); string value; list<string> categories, names; // Use CMemoryRegistry simply to leverage registry file format parser. CMemoryRegistry dummyRegistry; auto_ptr<CNcbiIfstream> iniIn(new CNcbiIfstream(iniFile.c_str(), IOS_BASE::in | IOS_BASE::binary)); if (*iniIn) { result = true; ERR_POST(ncbi::Trace << "loading predefined annotation types " << iniFile); dummyRegistry.Read(*iniIn, readFlags); dummyRegistry.EnumerateSections(&categories, accessFlags); // Loop over all type categories ITERATE (list<string>, cit, categories) { if (*cit == kEmptyStr) continue; // reject 'id' if it equals m_invalidType; otherwise allow negative values id = dummyRegistry.GetInt(*cit, ID, m_invalidType, accessFlags, CMemoryRegistry::eReturn); if (id != m_invalidType) { TTypeNamesPair& typeNamesPair = m_stdAnnotTypeData[id]; TTypeNames& values = typeNamesPair.second; typeNamesPair.first = *cit; // Get all named fields for this section. dummyRegistry.EnumerateEntries(*cit, &names, accessFlags); // Add value for each non-id named field; sort alphabetically on completion. ITERATE (list<string>, eit, names) { if (*eit == ID || *eit == kEmptyStr) continue; value = dummyRegistry.GetString(*cit, *eit, kEmptyStr, accessFlags); NStr::TruncateSpacesInPlace(value); if (value != kEmptyStr) { values.push_back(value); } } sort(values.begin(), values.end()); /*cout << "\nTesting sort for " << *cit << endl; ITERATE (vector<string>, vit, values) { cout << *vit << endl; }*/ } } }
/*Open RPSDB table*/ bool OpenRPSDB(const char* tableName, bool create ) { if(tableName==NULL) { ERR_POST("[OpenRPSDB]: No table name given"); return false; } if(!IsCodeBaseInit() && !InitCodeBase()){ ERR_POST(Fatal<<"[OpenRPSDB]:Cannot initiate CodeBase for RPSDB&DOMNAME"); return false; } if (create) { rpsdb.create(codeBase, tableName, f4rpsdb, t4rpsdb); } else{ rpsdb.open(codeBase, tableName); } if(!rpsdb.isValid()){ ERR_POST("[OpenRPSDB]: failed to open "<<tableName); return false; } pf4rpsgi.init(rpsdb,"GI"); pf4rpsdomid.init(rpsdb,"DOMID"); pf4rpsfrom.init(rpsdb,"FROM"); pf4rpsalignlen.init(rpsdb,"ALIGN_LEN"); pf4rpsevalue.init(rpsdb,"EVALUE"); pf4rpsmisN.init(rpsdb,"MISSING_N"); pf4rpsmisC.init(rpsdb,"MISSING_C"); pf4rpsnumdom.init(rpsdb,"NUMDOM"); pf4rpscddid.init(rpsdb,"CDDID"); tagrpscddid.init(rpsdb, "CDDID"); pf4rpsbitscore.init(rpsdb,"BITSCORE"); pf4rpsscore.init(rpsdb,"SCORE"); tagrpsgi.init(rpsdb,"GI"); tagrpsdomid.init(rpsdb, "DOMID"); tagrpslen.init(rpsdb,"ALIGN_LEN"); tagrpsnumdom.init(rpsdb, "NUMDOM"); return true; }
bool CCSRATestApp::TestApp_Exit(void) { if ( m_ErrorCount ) { ERR_POST("Errors found: "<<m_ErrorCount); } else { LOG_POST("Done."); } return !m_ErrorCount; }
/* search domname for domain label by accession */ string SearchDOMNAME(string accession) { int rc=-20; if(accession.empty()) { ERR_POST("[SearchDOMNAME]: empty string"); return NULL; } domnamedb.select(tagdnaccession); domnamedb.top(); rc=domnamedb.seek(accession.c_str()); if(rc!=r4success){ ERR_POST(Info<<"[SearchDOMNAME]: no record found for "<<accession); return NULL; } Str4large strfield; strfield.assign(pf4dnname); strfield.trim(); string s=strfield.str(); return s; }
void CTSE_Info_Object::x_Update(TNeedUpdateFlags flags) const { int retry_count = 3; while ( m_NeedUpdateFlags & flags ) { if ( --retry_count < 0 ) { ERR_POST("CTSE_Info_Object::x_Update("<<flags<<"): " "Failed to update "<<m_NeedUpdateFlags); break; } const_cast<CTSE_Info_Object*>(this)-> x_DoUpdate(flags&m_NeedUpdateFlags); } }
int Run(void) { CONNECT_Init(&CNcbiApplication::Instance()->GetConfig()); const CNcbiArguments& app_args = GetArguments(); m_Seed = app_args.Size() > 1 ? (unsigned int)atoi(app_args[1].c_str()) : (unsigned int)time(0); // Set error posting and tracing on maximum SetDiagTrace(eDT_Enable); SetDiagPostLevel(eDiag_Info); SetDiagPostAllFlags(SetDiagPostAllFlags(eDPF_Default) | eDPF_All | eDPF_OmitInfoSev); UnsetDiagPostFlag(eDPF_Line); UnsetDiagPostFlag(eDPF_File); UnsetDiagPostFlag(eDPF_Location); UnsetDiagPostFlag(eDPF_LongFilename); SetDiagTraceAllFlags(SetDiagPostAllFlags(eDPF_Default)); string host = "www.ncbi.nlm.nih.gov"; string path = "/Service/bounce.cgi"; string args = kEmptyStr; string uhdr = kEmptyStr; ERR_POST(Info << "Seed = " << m_Seed); srand(m_Seed); ERR_POST(Info << "Creating HTTP connection to " "http://" + host + path + &"?"[args.empty() ? 1 : 0] + args); CConn_HttpStream ios(host, path, args, uhdr); int n = TEST_StreamPushback(ios, false/*no rewind*/); // Manual CONNECT_UnInit (for implicit CONNECT_Init() by HTTP stream ctor) CORE_SetREG(0); CORE_SetLOG(0); CORE_SetLOCK(0); return n; }
void CStdPoolOfThreads::KillAllThreads(TKillFlags flags) { TACValue n, old_max; bool queuing_was_forbidden; {{ CMutexGuard guard(m_Mutex); old_max = m_MaxThreads; queuing_was_forbidden = m_QueuingForbidden; m_MaxThreads = 0; // Forbid spawning new threads m_QueuingForbidden = false; // Always queue normally here. n = m_ThreadCount.Get(); // Capture for use without mutex }} {{ TACValue n2 = TACValue(m_Threads.size()); if (n != n2) { ERR_POST(Warning << "Registered " << n2 << " threads but expected " << n); if (n < n2) { n = n2; } } }} CRef<CStdRequest> poison(new CFatalRequest); for (TACValue i = 0; i < n; ) { try { WaitForRoom(); AcceptRequest(poison); ++i; } catch (CBlockingQueueException&) { // guard against races continue; } } NON_CONST_ITERATE(TThreads, it, m_Threads) { if ((flags & fKill_Wait) != 0) { (*it)->Join(); } else { (*it)->Detach(); } } m_Threads.clear(); CMutexGuard guard(m_Mutex); m_QueuingForbidden = queuing_was_forbidden; if ((flags & fKill_Reopen) != 0) { m_MaxThreads = old_max; } }
void CBlastScopeSource::x_InitBlastDatabaseDataLoader(const string& dbname, EDbType dbtype) { if ( !m_Config.m_UseBlastDbs ) { return; } try { m_BlastDbLoaderName = CBlastDbDataLoader::RegisterInObjectManager (*m_ObjMgr, dbname, dbtype, m_Config.m_UseFixedSizeSlices, CObjectManager::eNonDefault, CObjectManager::kPriority_NotSet) .GetLoader()->GetName(); _ASSERT( !m_BlastDbLoaderName.empty() ); } catch (const CSeqDBException& e) { // if the database isn't found, ignore the exception as the // remote BLAST database data loader will be tried next if (e.GetMsg().find("No alias or index file found ") != NPOS) { ERR_POST(Warning << "Error initializing local BLAST database " << "data loader: '" << e.GetMsg() << "'"); _TRACE("Error initializing local BLAST database " << "data loader: '" << e.GetMsg() << "'"); } try { m_BlastDbLoaderName = CRemoteBlastDbDataLoader::RegisterInObjectManager (*m_ObjMgr, dbname, dbtype, m_Config.m_UseFixedSizeSlices, CObjectManager::eNonDefault, CObjectManager::kPriority_NotSet) .GetLoader()->GetName(); _ASSERT( !m_BlastDbLoaderName.empty() ); } catch (const CSeqDBException& e) { ERR_POST(Warning << "Error initializing remote BLAST database " << "data loader: " << e.GetMsg()); _TRACE("Error initializing remote BLAST database " << "data loader: '" << e.GetMsg() << "'"); } } }