virtual void* Main(void) { //for (int i = 0; i < 10; ++i) { for (;;) { try { CDatabase db("MSDEV"); db.Connect(); CQuery q = db.NewQuery("select serverproperty('servername')"); q.Execute(); LOG_POST("Thread " << m_Num << " connected to " << q.begin()[1].AsString()); try { q.SetSql("drop table #t"); q.Execute(); } catch (CSDB_Exception&) { // } q.SetSql("create table #t (tt varchar(100))"); q.Execute(); q.SetSql("insert into #t values (@tt)"); for (int i = 0; i < 500; ++i) { q.SetParameter("@tt", i, eSDB_String); q.Execute(); } SleepMilliSec(100); } catch (CSDB_Exception& ex) { LOG_POST("Error from SDBAPI in thread " << m_Num << ": " << ex); } } return NULL; }
void SNS_Parameters::CheckAffinityGarbageCollectorSettings(void) { bool well_formed = true; if (affinity_high_mark_percentage >= 100) { LOG_POST(Message << Warning << "INI file sets affinity_high_mark_percentage >= 100. " "All the affinity garbage collector settings are reset to default."); well_formed = false; } if (well_formed && affinity_low_mark_percentage >= affinity_high_mark_percentage) { LOG_POST(Message << Warning << "INI file sets affinity_low_mark_percentage >= affinity_high_mark_percentage. " "All the affinity garbage collector settings are reset to default."); well_formed = false; } if (well_formed && affinity_dirt_percentage >= affinity_low_mark_percentage) { LOG_POST(Message << Warning << "INI file sets affinity_dirt_percentage >= affinity_low_mark_percentage. " "All the affinity garbage collector settings are reset to default."); well_formed = false; } if (well_formed == false) { affinity_high_mark_percentage = default_affinity_high_mark_percentage; affinity_low_mark_percentage = default_affinity_low_mark_percentage; affinity_high_removal = default_affinity_high_removal; affinity_low_removal = default_affinity_low_removal; affinity_dirt_percentage = default_affinity_dirt_percentage; } return; }
void CTest::x_TestSeverity() { SetDiagPostLevel(eDiag_Info); SetDiagFilter(eDiagFilter_All, "[Error]module [Info]!module"); LOG_POST(Warning << MDiagModule("module") << "Test error 1"); LOG_POST(Error << MDiagModule("module") << "Test error 2"); LOG_POST(Warning << MDiagModule("module2") << "Test error 3"); LOG_POST(Info << MDiagModule("module3") << "Test error 4"); }
void SequenceTable::dump(string filename) { CNcbiOfstream outStream(filename.c_str(), IOS_BASE::out | IOS_BASE::binary); string err; if (!outStream) { err = "Cannot open file for writing"; } SeqidToBioseqMap::iterator sit = m_table.begin(); for (; sit != m_table.end(); sit++) { if (!WriteASNToStream(outStream, *(sit->first), false,&err)) LOG_POST("Failed to write to "<<filename<<" because of "<<err); if (!WriteASNToStream(outStream, *(sit->second), false,&err)) LOG_POST("Failed to write to "<<filename<< "because of "<<err); } }
void CSampleJobCleanupListener::HandleEvent( EWorkerNodeCleanupEvent cleanup_event) { LOG_POST(m_CleanupType << (cleanup_event == IWorkerNodeCleanupEventListener::eRegularCleanup ? " regular clean-up" : " clean-up during force exit")); }
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; } }
CRef<CGC_Assembly> CGenomicCollectionsService::GetAssembly(int releaseId, int level, int asmAttrFlags, int chrAttrFlags, int scafAttrFlags, int compAttrFlags) { CGCClient_GetAssemblyRequest req; CGCClientResponse reply; req.SetRelease_id(releaseId); 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) { NCBI_THROW(CException, eUnknown, reply.GetSrvr_error().GetDescription()); } throw; } }
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; } }
NCBITEST_INIT_TREE() { if ( s_Random.GetSeed() == 0 ) { s_Random.Randomize(); LOG_POST("Random seed: "<<s_Random.GetSeed()); } }
/********************************************************************* * @brief : REST API handler to clear the bst stats * * @param[in] cookie : pointer to the cookie * @param[in] asicId : asic id * @param[in] id : unit id * @param[in] pCommand : pointer to the input command structure * * @retval : BVIEW_STATUS_SUCCESS : the message is successfully posted to bst queue. * @retval : BVIEW_STATUS_FAILURE : failed to post the message to bst. * @retval : BVIEW_STATUS_INVALID_PARAMETER : invalid parameter. * * @note : This api posts the request to bst application to clear stats. * *********************************************************************/ BVIEW_STATUS bstjson_clear_bst_statistics_impl (void *cookie, int asicId, int id, BSTJSON_CLEAR_BST_STATISTICS_t * pCommand) { BVIEW_BST_REQUEST_MSG_t msg_data; BVIEW_STATUS rv; /* copy the params from the request */ memset (&msg_data, 0, sizeof (BVIEW_BST_REQUEST_MSG_t)); msg_data.unit = asicId; msg_data.cookie = cookie; msg_data.id = id; msg_data.msg_type = BVIEW_BST_CMD_API_CLEAR_STATS; /* send message to bst application */ rv = bst_send_request (&msg_data); if (BVIEW_STATUS_SUCCESS != rv) { _BST_LOG(_BST_DEBUG_ERROR, "bstjson_clear_bst_statistics_impl: failed to post clear bst stats request to bst queue. err = %d.\r\n",rv); LOG_POST (BVIEW_LOG_ERROR, "failed to post clear bst stats request to bst queue. err = %d.\r\n",rv); } return rv; }
/********************************************************************* * @brief : REST API handler to configure the bst track params * * @param[in] cookie : pointer to the cookie * @param[in] asicId : asic id * @param[in] id : unit id * @param[in] pCommand : pointer to the input command structure * * @retval : BVIEW_STATUS_SUCCESS : the message is successfully posted to bst queue. * @retval : BVIEW_STATUS_FAILURE : failed to post the message to bst. * @retval : BVIEW_STATUS_INVALID_PARAMETER : invalid parameter. * * @note : This api posts the request to bst application to set the track params. * * @end *********************************************************************/ BVIEW_STATUS bstjson_configure_bst_tracking_impl (void *cookie, int asicId, int id, BSTJSON_CONFIGURE_BST_TRACKING_t * pCommand) { BVIEW_BST_REQUEST_MSG_t msg_data; BVIEW_STATUS rv; if (NULL == pCommand) return BVIEW_STATUS_INVALID_PARAMETER; memset (&msg_data, 0, sizeof (BVIEW_BST_REQUEST_MSG_t)); msg_data.unit = asicId; msg_data.cookie = cookie; msg_data.msg_type = BVIEW_BST_CMD_API_SET_TRACK; msg_data.id = id; msg_data.request.track = *pCommand; /* send message to bst application */ rv = bst_send_request (&msg_data); if (BVIEW_STATUS_SUCCESS != rv) { LOG_POST (BVIEW_LOG_ERROR, "failed to post configure bst tracking to bst queue. err = %d.\r\n",rv); } return rv; }
/********************************************************************* * @brief : REST API handler to get the bst threshold * * @param[in] cookie : pointer to the cookie * @param[in] asicId : asic id * @param[in] id : unit id * @param[in] pCommand : pointer to the input command structure * * @retval : BVIEW_STATUS_SUCCESS : the message is successfully posted to bst queue. * @retval : BVIEW_STATUS_FAILURE : failed to post the message to bst. * @retval : BVIEW_STATUS_INVALID_PARAMETER : invalid parameter. * * @note : This api posts the request to bst application to get the bst thresholds. * *********************************************************************/ BVIEW_STATUS bstjson_get_bst_thresholds_impl (void *cookie, int asicId, int id, BSTJSON_GET_BST_THRESHOLDS_t * pCommand) { BVIEW_BST_REQUEST_MSG_t msg_data; BVIEW_STATUS rv; if (NULL == pCommand) return BVIEW_STATUS_INVALID_PARAMETER; memset (&msg_data, 0, sizeof (BVIEW_BST_REQUEST_MSG_t)); msg_data.unit = asicId; msg_data.cookie = cookie; msg_data.msg_type = BVIEW_BST_CMD_API_GET_THRESHOLD; msg_data.id = id; memcpy (&msg_data.request.collect, pCommand, sizeof(BSTJSON_GET_BST_THRESHOLDS_t)); /* send message to bst application */ rv = bst_send_request (&msg_data); if (BVIEW_STATUS_SUCCESS != rv) { LOG_POST (BVIEW_LOG_ERROR, "failed to post get bst thresholds to bst queue. err = %d.\r\n",rv); } return rv; }
inline void add_step() { CAtomicCounter::TValue c = current_step.Add(1); if ( c % 1000000 == 0 ) { LOG_POST("step "<<c<<" of "<<total_steps); } }
void LogRequest(const TReq& req) { #ifdef _DEBUG ostringstream ostrstrm; ostrstrm << "Making request -" << MSerial_AsnText << req; LOG_POST(Info << ostrstrm.str()); #endif }
void Dump(void) const { unsigned total_locks = 0; ITERATE ( TLocks, it, m_Locks ) { ++total_locks; LOG_POST("Locked<"<<sx_MonitorType->name()<<">" "("<<it->first<<","<<m_Object<<")" " @ " << *it->second); }
bool CTestTlsObjectApp::TestApp_Exit(void) { check_cnts(~0u); LOG_POST("Max memory VS: " << (double)max_total/(1024*1024.) << " MB" << " RSS: " << (double)max_resident/(1024*1024.) << " MB" << " SHR: " << (double)max_shared/(1024*1024.) << " MB"); NcbiCout << "Test completed." << NcbiEndl; return true; }
void CNetCacheServerListener::OnWarning(const string& warn_msg, SNetServerImpl* server) { if (m_EventHandler) m_EventHandler->OnWarning(warn_msg, server); else { LOG_POST(Warning << server->m_ServerInPool->m_Address.AsString() << ": " << warn_msg); } }
bool CCSRATestApp::TestApp_Exit(void) { if ( m_ErrorCount ) { ERR_POST("Errors found: "<<m_ErrorCount); } else { LOG_POST("Done."); } return !m_ErrorCount; }
//------------------------------------------------------------------------------ int CWinMaskCountsConverter::operator()() { CRef< CSeqMaskerOstat > ostat( 0 ); if( os == 0 ) { ostat = CSeqMaskerOstatFactory::create( oformat, ofname, true ); } else ostat = CSeqMaskerOstatFactory::create( oformat, *os, true ); Uint4 unit_size = istat->UnitSize(); _TRACE( "set unit size to " << unit_size ); ostat->setUnitSize( unit_size ); Uint8 num_units = (unit_size < 16) ? (1ULL<<(2*unit_size)) : 0x100000000ULL; LOG_POST( "converting counts..." ); for( Uint8 i = 0; i < num_units; ++i ) { Uint4 ri = CSeqMaskerUtil::reverse_complement( i, unit_size ); if( i <= ri ) { Uint4 count = istat->trueat( i ); if( count != 0 ) ostat->setUnitCount( i, count ); } } LOG_POST( "converting parameters..." ); ostat->setBlank(); ostat->setBlank(); Uint4 t_low = istat->get_min_count(); Uint4 t_extend = istat->get_textend(); Uint4 t_threshold = istat->get_threshold(); Uint4 t_high = istat->get_max_count(); ostat->setParam( "t_low ", t_low ); ostat->setParam( "t_extend ", t_extend ); ostat->setParam( "t_threshold", t_threshold ); ostat->setParam( "t_high ", t_high ); ostat->setBlank(); LOG_POST( "final processing..." ); ostat->finalize(); return 0; }
//---------------------------------------------------------------------------- void CWinMaskUtil::CIdSet_SeqId::insert( const string & id_str ) { try { CRef<CSeq_id> id(new CSeq_id(id_str)); idset.insert(CSeq_id_Handle::GetHandle(*id)); } catch (CSeqIdException& e) { LOG_POST(Error << "CWinMaskConfig::FillIdList(): can't understand id: " << id_str << ": " << e.what() << ": ignoring"); } }
void x_Init(const string& NC_registry_section) { LOG_POST(Trace << "NS queue NC: " << NC_registry_section); m_NC_api = CNetCacheAPI(CNetCacheAPI::eAppRegistry, NC_registry_section); m_Grid_cli.reset(new CGridClient(m_NS_api.GetSubmitter(), m_NC_api, CGridClient::eManualCleanup, CGridClient::eProgressMsgOn ) ); }
int CSeqDBPerfApp::x_ScanDatabase() { CStopWatch sw; sw.Start(); Uint8 num_letters = m_BlastDb->GetTotalLength(); const bool kScanUncompressed = GetArgs()["scan_uncompressed"]; vector<int> oids2iterate; for (int oid = 0; m_DbHandles.front()->CheckOrFindOID(oid); oid++) { oids2iterate.push_back(oid); } LOG_POST(Info << "Will go over " << oids2iterate.size() << " sequences"); #pragma omp parallel default(none) num_threads(m_DbHandles.size()) \ shared(oids2iterate) if(m_DbHandles.size() > 1) { int thread_id = 0; #ifdef _OPENMP thread_id = omp_get_thread_num(); #endif #pragma omp for schedule(static, (oids2iterate.size()/m_DbHandles.size())) nowait for (size_t i = 0; i < oids2iterate.size(); i++) { int oid = oids2iterate[i]; const char* buffer = NULL; int seqlen = 0; if (m_DbIsProtein || kScanUncompressed) { int encoding = m_DbIsProtein ? 0 : kSeqDBNuclBlastNA8; m_DbHandles[thread_id]->GetAmbigSeq(oid, &buffer, encoding); seqlen = m_DbHandles[thread_id]->GetSeqLength(oid); } else { m_DbHandles[thread_id]->GetSequence(oid, &buffer); seqlen = m_DbHandles[thread_id]->GetSeqLength(oid) / 4; } for (int i = 0; i < seqlen; i++) { char base = buffer[i]; base = base; // dummy statement } if (m_DbIsProtein || kScanUncompressed) { m_DbHandles[thread_id]->RetAmbigSeq(&buffer); } else { m_DbHandles[thread_id]->RetSequence(&buffer); } } x_UpdateMemoryUsage(thread_id); } // end of omp parallel sw.Stop(); Uint8 bases = static_cast<Uint8>(num_letters / sw.Elapsed()); cout << "Scanning rate: " << NStr::NumericToString(bases, NStr::fWithCommas) << " bases/second" << endl; return 0; }
bool CTestRegApp::TestApp_Init(void) { LOG_POST("Testing NCBITIME " + NStr::UIntToString(s_NumThreads) + " threads..."); // Set err.-posting and tracing to maximum SetDiagTrace(eDT_Enable); SetDiagPostFlag(eDPF_All); SetDiagPostLevel(eDiag_Info); return true; }
void CGenomicCollectionsService::x_Connect() { #ifdef _DEBUG LOG_POST(Info << "Connecting to url:" << x_GetURL().c_str()); #endif STimeout to5Min; to5Min.sec=600; to5Min.usec=0; SetTimeout(&to5Min); x_ConnectURL(x_GetURL()); }
int CNetCacheBlobFetchApp::ProcessRequest(CCgiContext& ctx) { const CCgiRequest& request = ctx.GetRequest(); CCgiResponse& reply = ctx.GetResponse(); bool is_found; string key = request.GetEntry("key", &is_found); if (key.empty() || !is_found) { NCBI_THROW(CArgException, eNoArg, "CGI entry 'key' is missing"); } string fmt = request.GetEntry("fmt", &is_found); if (fmt.empty() || !is_found) fmt = "image/png"; string filename(request.GetEntry("filename", &is_found)); if (is_found && !filename.empty()) { string is_inline(request.GetEntry("inline", &is_found)); reply.SetHeaderValue("Content-Disposition", (is_found && NStr::StringToBool(is_inline) ? "inline; filename=" : "attachment; filename=") + filename); } reply.SetContentType(fmt); reply.WriteHeader(); CNetStorageObject netstorage_object(m_NetStorage.Open(key)); char buffer[NETSTORAGE_IO_BUFFER_SIZE]; size_t total_bytes_written = 0; while (!netstorage_object.Eof()) { size_t bytes_read = netstorage_object.Read(buffer, sizeof(buffer)); reply.out().write(buffer, bytes_read); total_bytes_written += bytes_read; if (bytes_read < sizeof(buffer)) break; } netstorage_object.Close(); LOG_POST(Info << "retrieved data: " << total_bytes_written << " bytes"); return 0; }
void message(const char* msg, const char* msg1, double t1, const char* msg2, double t2, size_t COUNT) { if ( 0 ) { LOG_POST(msg <<'\n'<<setw(40) << msg1 << ": "<< t1 * 1e9/(double)COUNT << " usec" <<'\n'<<setw(40) << msg2 << ": "<< t2 * 1e9/(double)COUNT << " usec"); } size_t total, resident, shared; if ( GetMemoryUsage(&total, &resident, &shared) ) { max_total = max(max_total, total); max_resident = max(max_resident, resident); max_shared = max(max_shared, shared); if ( 0 ) { LOG_POST("Alloc: "<<alloc_count.Get()<< " "<<object_count.Get()<<'\n'<< "Current memory: "<<total<<" "<<resident<<" "<<shared); } } }
//------------------------------------------------------------------------------ CWinMaskCountsConverter::CWinMaskCountsConverter( const string & input_fname, CNcbiOstream & out_stream, const string & counts_oformat ) : istat( 0 ), ofname( "" ), oformat( counts_oformat ), os( &out_stream ) { if( input_fname == "-" ) { NCBI_THROW( Exception, eBadOption, "input file name must be non-empty" ); } LOG_POST( "reading counts..." ); istat = CSeqMaskerIstatFactory::create( input_fname, 0, 0, 0, 0, 0, 0, true ); }
//Use it for testing CRef <CSeq_annot> createAnnot(string rid) { CRef <CSeq_annot> m_Annot(new CSeq_annot); string path_cgi = CNcbiApplication::Instance()->GetProgramExecutablePath(); string path_base = CDirEntry(path_cgi).GetDir(); string ASN1FilePath = CDirEntry::MakePath(path_base, "testSeqAnnot.txt"); LOG_POST(path_cgi); LOG_POST(path_base); LOG_POST(ASN1FilePath); try { auto_ptr<CObjectIStream> in (CObjectIStream::Open(eSerial_AsnText,ASN1FilePath)); *in >> *m_Annot; } catch (CException& e) { cerr << "Exception reading SeqAnnot exception message: " + e.GetMsg() << endl; } cerr << MSerial_AsnText << *m_Annot; return m_Annot; }
//------------------------------------------------------------------------------ void tracker::report_match( Uint4 queryseq, Uint4 match_count, string::size_type s_off, string::size_type q_off ) { string query_id( table.seqid( queryseq ) ); LOG_POST( Warning << "Possible duplication of sequences:\n" << "subject: " << subject_id << " and query: " << query_id << "\n" << "at intervals\n" << "subject: " << s_off - match_count*SAMPLE_SKIP << " --- " << s_off - SAMPLE_SKIP << "\n" << "query : " << q_off - match_count*SAMPLE_SKIP << " --- " << q_off - SAMPLE_SKIP << "\n" ); }
/********************************************************************* * @brief Function used to initialize various system components * Each component is initialized using a proper API * * @param[in] NA * * @retval NA * * @note NA * * @end *********************************************************************/ void system_init() { /* Initialize platform */ VENDOR_PLATFORM_INIT(); /*Initialize logging, Not handling error as openlog() does not return anything*/ logging_init(); /*Initialize Module manager*/ if (modulemgr_init() != BVIEW_STATUS_SUCCESS) { LOG_POST (BVIEW_LOG_CRITICAL, "Failed to initialize Module Manager\r\n"); } /*Initialize south-bound plugin*/ if (sb_redirector_init() != BVIEW_STATUS_SUCCESS) { LOG_POST (BVIEW_LOG_CRITICAL, "Failed to initialize south-bound plugin\r\n"); } /*Initialize south-bound BST plugin*/ if (sbplugin_common_init() != BVIEW_STATUS_SUCCESS) { LOG_POST (BVIEW_LOG_CRITICAL, "Failed to initialize south-bound BST plugin r\n"); } /*Initialize BST application*/ if (bst_main() != BVIEW_STATUS_SUCCESS) { LOG_POST (BVIEW_LOG_CRITICAL, "Failed to initialize BST application\r\n"); } /*Initialize REST*/ if (rest_init() != BVIEW_STATUS_SUCCESS) { LOG_POST (BVIEW_LOG_CRITICAL, "Failed to initialize REST \n All components must be De-initialized\r\n"); system_deinit(); } }