//********************************************************************* // // SetProcessListText // // Format the process list text. // void SetProcessListText (PPERF_INSTANCE pInst, PPERF_COUNTER pCPU, PPERF_COUNTER pPRIV, PPERF_COUNTER pProcID, double fTime, LPTSTR str) { DWORD *pdwProcID; LARGE_INTEGER *liCPU; LARGE_INTEGER *liPRIV; double fCPU = 0; double fPRIV = 0; INT PcntPRIV = 0; INT PcntUSER = 0; TIME_FIELD TimeFld; TCHAR szTemp[100]; if (pCPU) { liCPU = (LARGE_INTEGER *) CounterData (pInst, pCPU); fCPU = Li2Double (*liCPU); } if (pPRIV) { liPRIV = (LARGE_INTEGER *) CounterData (pInst, pPRIV); fPRIV = Li2Double (*liPRIV); } if (fCPU > 0) { PcntPRIV = (INT)(fPRIV / fCPU * 100 + 0.5); PcntUSER = 100 - PcntPRIV; } if (pProcID) { pdwProcID = (DWORD *) CounterData (pInst, pProcID); wsprintf (szTemp, TEXT("%ls (%#x)"), InstanceName(pInst), *pdwProcID); } else wsprintf (szTemp, TEXT("%ls"), InstanceName(pInst)); FormatTimeFields (fCPU/1.0e7, &TimeFld); wsprintf (str, TEXT("%s\t%3ld:%02ld:%02ld.%03ld\t%3ld%%\t%3ld%%"), szTemp, TimeFld.Hours, TimeFld.Mins, TimeFld.Secs, TimeFld.mSecs, PcntPRIV, PcntUSER); }
//********************************************************************* // // RefreshPviewDlgThreadPC // // Update the thread PC value. This should be done after the ghCostlyData // is collected and is no refreshing. // void RefreshPviewDlgThreadPC (HWND hPviewDlg, LPTSTR szProcessName, LPTSTR szThreadName, PPERF_OBJECT pThreadDetailsObject, PPERF_DATA pCostlyData) { PPERF_COUNTER pCounter; PPERF_INSTANCE pInstance; PPERF_INSTANCE pParent; LPTSTR szInstanceName; LPTSTR szParentName; TCHAR str[20]; DWORD *pdwData; INT i = 0; if (pCounter = FindCounter (pThreadDetailsObject, PX_THREAD_PC)) { pInstance = FirstInstance (pThreadDetailsObject); while (pInstance && i < pThreadDetailsObject->NumInstances) { if (!(szInstanceName = InstanceName (pInstance))) // can't find name ; else if (lstrcmp (szThreadName, szInstanceName)) // the thread name is different ; else if (!(pParent = FindInstanceParent (pInstance, pCostlyData))) // can't find parent ; else if (!(szParentName = InstanceName (pParent))) // can't find parent's name ; else if (!lstrcmp (szProcessName, szParentName)) { // Parent's name matches, this is the right one. // pdwData = CounterData (pInstance, pCounter); wsprintf (str, TEXT("0x%08x"), *pdwData); SetDlgItemText (hPviewDlg, PVIEW_THREAD_PC, str); return; } pInstance = NextInstance (pInstance); i++; } } // We are here only because we can't find the data to display. // SetDlgItemText (hPviewDlg, PVIEW_THREAD_PC, NODATA); }
QueueRestorer::QueueRestorer(Persistency::IO::ConnectionPtrNN conn, Core::Types::SignedNodesFifo &queue) { const Logger::Node log("core.queuerestorer"); try { LOGMSG_INFO(log, "restoring data base's content"); // preapre environment assert( conn.get()!=NULL ); Transaction t( conn->createNewTransaction("meta_alerts_queue_restore") ); RestorerAutoPtr rest=conn->restorer(t); // read data base content Restorer::NodesVector tmp; LOGMSG_DEBUG(log, "reading meta-alerts"); rest->restoreAllInUse(tmp); t.commit(); // add all elements to queue LOGMSG_DEBUG_S(log)<<tmp.size()<<" meta-alerts read from persistency; appending to queue"; for(Restorer::NodesVector::const_iterator it=tmp.begin(); it!=tmp.end(); ++it) queue.push( Types::SignedNode(*it, TypeName(CC::defaultInputTypeName), InstanceName(CC::defaultInputInstanceName) ) ); LOGMSG_INFO_S(log)<<"restoring "<<tmp.size()<<" elements successful"; } catch(const std::exception &ex) { LOGMSG_ERROR_S(log)<<"unable to restore data base's content; error was: " <<ex.what()<<"; continuing any way..."; } }
void testObj::test<7>(void) { InterfaceImpl<TestStrategyNoParm> tmp( TypeName("sometype") , InstanceName("somename") ); ensure_equals("pre-condition failed", testStrategyNoParmHeartbeats, 0); tmp.heartbeat(42u); ensure_equals("process() is not virtual", testStrategyNoParmHeartbeats, 1); }
//********************************************************************* // // RefreshMemoryDlgImageList // // Refresh the image list for memory dialog. // void RefreshMemoryDlgImageList (HWND hImageList, DWORD ParentIndex, PPERF_OBJECT pImageObj) { PPERF_INSTANCE pImageInst; INT ListIndex; INT InstIndex = 0; ListIndex = SendMessage (hImageList, CB_ADDSTRING, 0, (DWORD)TEXT(" Total Commit")); SendMessage (hImageList, CB_SETITEMDATA, ListIndex, 0xFFFFFFFF); if (pImageObj) { pImageInst = FirstInstance (pImageObj); while (pImageInst && InstIndex < pImageObj->NumInstances) { if (ParentIndex == pImageInst->ParentObjectInstance) { ListIndex = SendMessage (hImageList, CB_ADDSTRING, 0, (DWORD)InstanceName(pImageInst)); SendMessage (hImageList, CB_SETITEMDATA, ListIndex, InstIndex); } pImageInst = NextInstance (pImageInst); InstIndex++; } } }
void testObj::test<5>(void) { InterfaceImpl<TestStrategyNoParm> tmp( TypeName("sometype") , InstanceName("somename") ); ensure_equals("pre-condition failed", testStrategyNoParmCalls, 0); Interface::ChangedNodes changed; tmp.process( makeNewLeaf(), changed ); ensure_equals("process() not forwarded", testStrategyNoParmCalls, 1); }
void testObj::test<2>(void) { Strategy s(InstanceName("myfiletrigger"), cfg_); Strategy::ChangedNodes nc; const time_t start=time(NULL); s.process( makeNewNode(), nc ); const time_t stop =time(NULL); testFileInRange(".", start, stop); }
void testObj::test<5>(void) { GraphNodePtrNN node=makeNewLeaf(); Strategy s(InstanceName("apprunner"), Config(cfg_.getPath(), Trigger::Simple::ThresholdConfig("99", "9") ) ); Strategy::ChangedNodes nc; remove("ext.log"); // ensure file is not present from previous runs s.process(node, nc); ensure("trigger called", exists("ext.log")==false ); }
void testObj::test<6>(void) { Data::Names skip; skip.push_back("cat"); Strategy s( InstanceName("myname"), Strategy::Parameters(123, skip) ); GraphNodePtrNN leaf1=makeNewLeaf( mkAlert("cat", "doom") ); s.process(leaf1, changed_); ensure_equals("something has been changed", changed_.size(), 0u); GraphNodePtrNN leaf2=makeNewLeaf( mkAlert("cat", "doom") ); s.process(leaf2, changed_); ensure_equals("correlation failed after first skip-match", changed_.size(), 1u); }
void testObj::test<3>(void) { const char *out="TEST_OUT_DIR"; if( mkdir(out, 0755)!=0 ) ensure("unable to create output dir", errno==EEXIST); const Config cfg(out, cfg_.getThresholdConfig() ); Strategy s(InstanceName("myfiletrigger"), cfg); Strategy::ChangedNodes nc; const time_t start=time(NULL); s.process( makeNewNode(), nc ); const time_t stop =time(NULL); testFileInRange(out, start, stop); }
//********************************************************************* // // RefreshMemoryDlg // // Refresh the memory detail dialog. // BOOL RefreshMemoryDlg (HWND hMemDlg, PPERF_INSTANCE pProcessInstance, PPERF_OBJECT pProcessObject, PPERF_OBJECT pAddressObject, PPERF_OBJECT pImageObject) { DWORD *pProcessID1; DWORD *pProcessID2; PPERF_COUNTER pCounter1; PPERF_COUNTER pCounter2; PPERF_INSTANCE pAddressInstance; HWND hImageList; TCHAR szTemp[40]; BOOL bStat = FALSE; INT InstIndex = 0; if ((pCounter1 = FindCounter (pProcessObject, PX_PROCESS_ID)) && (pCounter2 = FindCounter (pAddressObject, PX_PROCESS_ID))) { pProcessID1 = (DWORD *) CounterData (pProcessInstance, pCounter1); wsprintf (szTemp, TEXT("%s (%#x)"), InstanceName (pProcessInstance), *pProcessID1); SetDlgItemText (hMemDlg, MEMORY_PROCESS_ID, szTemp); pAddressInstance = FirstInstance (pAddressObject); while (pAddressInstance && InstIndex < pAddressObject->NumInstances) { pProcessID2 = (DWORD *) CounterData (pAddressInstance, pCounter2); if (*pProcessID1 == *pProcessID2) { PaintMemDlgAddrData (hMemDlg, pAddressInstance, pAddressObject); PaintMemDlgVMData (hMemDlg, pProcessInstance, pProcessObject); hImageList = GetDlgItem (hMemDlg, MEMORY_IMAGE); RefreshMemoryDlgImageList (hImageList, InstIndex, pImageObject); bStat = TRUE; break; } pAddressInstance = NextInstance (pAddressInstance); InstIndex++; } } return bStat; }
//----------------------------------------------------------------------------- // Function : InstanceBlock::clear // Purpose : empties out the block. // Special Notes : // Scope : public // Creator : Eric Keiter, SNL, Parallel Computational Sciences // Creation Date : 5/01/00 //----------------------------------------------------------------------------- void InstanceBlock::clear () { name_ = InstanceName(); modelName_ = ""; iNumNodes = 0; numIntVars = 0; numExtVars = 0; numStateVars = 0; modelFlag = 0; sourceFlag = 0; bsourceFlag = 0; offFlag = 0; off = 0; netlistLocation_ = NetlistLocation(); params.clear(); }
void testObj::test<3>(void) { // note that there is race condition in next two lines - it may happen that between // download of blacklisted IPs by strategy and download by donwloader it may change // thus there is some (small) probablilty that this test will randomly fail. const Downloader dwnl(1); // just one entry to download const DShieldParser dsp( dwnl.download() ); // parse it Strategy s( InstanceName("x"), Strategy::Parameters(1, 10, 0.5) ); // initiliaze strategy to use ensure("no entries parsed", dsp.begin()!=dsp.end() ); GraphNodePtrNN leaf=makeNewLeaf( (*dsp.begin()).to_string().c_str() ); // make leaf that is blacklisted // this host should be blacklisted s.process(leaf, changed_); ensure_equals("nothing changed", changed_.size(), 1u); changed_.clear(); // now it should NOT be blacklisted, since it has already changed s.process(leaf, changed_); ensure_equals("the same host has been black-listed twice", changed_.size(), 0u); }
void testObj::test<4>(void) { // this test main part has to fit in <1[s] window - retru 5 times // if it does not happen for(int i=0; i<5; ++i) { Strategy s(InstanceName("myfiletrigger"), cfg_); Strategy::ChangedNodes nc; // wait until seconds just changed - to make event as probable as possible // (yes - this is busy loop...) { time_t start=time(NULL); while( start==time(NULL) ) { } } // no make double write const time_t start=time(NULL); s.process( makeNewNode(), nc ); s.process( makeNewNode(), nc ); const time_t stop =time(NULL); // if second elapsed there is nothing that can be done if(start!=stop) continue; // check for output files ensure("first output file does not exist", testFile(".", start, 0)==0 ); ensure("second output file does not exist", testFile(".", start, 1)==0 ); // ok - if we're here, test succeeded. return; } // 5 fails means FAIL... fail("this test's main part has to fit in <1[s] time window and failed " "to do so 5 times. looks like your machine is to slow to perform " "this test - aborting"); }
boolean ScrollerCode::Definition (ostream& out) { boolean ok = true; if ( _emitProperty || _emitInstanceDecls || _emitForward || _emitClassHeaders || _emitHeaders ) { return CodeView::Definition(out); } else if (_emitExpHeader) { InteractorComp* icomp = GetIntComp(); MemberNameVar* mnamer = icomp->GetMemberNameVar(); SubclassNameVar* snamer = icomp->GetClassNameVar(); if (!snamer->IsSubclass()) { if ( _scope && mnamer->GetExport() && !_namelist->Search("scroller") ) { _namelist->Append("scroller"); out << "#include <InterViews/scroller.h>\n"; } } else { ok = ok && CodeView::Definition(out); } } else if (_emitCorehHeader) { InteractorComp* icomp = GetIntComp(); SubclassNameVar* snamer = icomp->GetClassNameVar(); const char* subclass = snamer->GetName(); if (snamer->IsSubclass() && strcmp(subclass, _classname) == 0) { if (!_namelist->Search("scroller")) { _namelist->Append("scroller"); out << "#include <InterViews/scroller.h>\n"; } } } else if (_emitInstanceInits) { InteractorComp* icomp = GetIntComp(); InteractorComp* ctarget = nil; const char* mname = icomp->GetMemberNameVar()->GetName(); MemberNameVar* mnamer = (MemberNameVar*) icomp->GetState( "AdjusteeVar" ); const char* scrollee = mnamer->GetName(); if (*scrollee == '\0') { if (_err_count < 10) { strcat(_errbuf, mname); strcat(_errbuf, " has undefined scrolling target.\n"); _err_count++; } return false; } else if (!Search(mnamer, ctarget)) { if (_err_count < 10) { strcat(_errbuf, mname); strcat( _errbuf, "'s scrolling target is not in the same hierarchy.\n" ); _err_count++; } return false; } else if (ctarget != nil && !icomp->IsRelatableTo(ctarget)) { if (_err_count < 10) { strcat(_errbuf, mname); strcat( _errbuf, "'s adjusting target is not subclassed nor adjustable.\n" ); _err_count++; } return false; } if (_instancelist->Find((void*) scrollee)) { if (!_instancelist->Find((void*) mname)) { _instancelist->Append(new UList((void*)mname)); scrollee = (*scrollee == '\0') ? "nil" : scrollee; BeginInstantiate(out); out << "("; InstanceName(out); out << scrollee << ")"; EndInstantiate(out); _icomplete = true; } } else { _icomplete = false; } } else if ( _emitBSDecls || _emitBSInits || _emitFunctionDecls || _emitFunctionInits ) { return true; } else if ( _emitCoreDecls || _emitCoreInits || _emitClassDecls || _emitClassInits ) { ok = ok && CodeView::Definition(out); } else if (_emitMain) { ok = ok && CodeView::Definition(out); } return out.good() && ok; }
void testObj::test<1>(void) { const Strategy s(InstanceName("mytrigger"), cfg_); ensure_equals("invalid trigger type", s.getTriggerType().str(), "file"); }
boolean TextEditCode::Definition (ostream& out) { boolean ok = true; if ( _emitProperty || _emitInstanceDecls || _emitClassHeaders || _emitHeaders || _emitForward ) { return CodeView::Definition(out); } else if (_emitExpHeader) { InteractorComp* icomp = GetIntComp(); MemberNameVar* mnamer = icomp->GetMemberNameVar(); SubclassNameVar* snamer = icomp->GetClassNameVar(); if (!snamer->IsSubclass()) { if ( _scope && mnamer->GetExport()&&!_namelist->Search("texteditor") ) { _namelist->Append("texteditor"); out << "#include <InterViews/texteditor.h>\n"; out << "#include <InterViews/textbuffer.h>\n"; } } else { ok = ok && CodeView::Definition(out); } } else if (_emitCorehHeader) { InteractorComp* icomp = GetIntComp(); SubclassNameVar* snamer = icomp->GetClassNameVar(); const char* subclass = snamer->GetName(); if (snamer->IsSubclass() && strcmp(subclass, _classname) == 0) { if (!_namelist->Search("texteditor")) { _namelist->Append("texteditor"); out << "#include <InterViews/texteditor.h>\n"; } } } else if (_emitInstanceInits) { InteractorComp* icomp = GetIntComp(); const char* mname = icomp->GetMemberNameVar()->GetName(); if (!_instancelist->Find((void*) mname)) { _instancelist->Append(new UList((void*)mname)); TextEditComp* tc = GetTextEditComp(); int rows, cols; BeginInstantiate(out); StrBrowserGraphic* graphic = tc->GetStrBrowserGraphic(); graphic->GetRowsCols(rows, cols); out << "("; InstanceName(out); out << rows << ", " << cols << ", " << 4 << ", Reversed" << ");\n"; out << " " << mname; out << "->Edit(new TextBuffer(new char[256], 0, 256))"; EndInstantiate(out); } } else if ( _emitFunctionDecls || _emitFunctionInits || _emitBSDecls || _emitBSInits ) { return true; } else if ( _emitCoreDecls || _emitCoreInits || _emitClassDecls || _emitClassInits ) { ok = ok && CodeView::Definition(out); } else if (_emitMain) { ok = ok && CodeView::Definition(out); } return out.good() && ok; }
void testObj::test<4>(void) { InterfaceImpl<TestStrategyNoParm> tmp( TypeName("sometype") , InstanceName("somename") ); }
void testObj::test<2>(void) { Strategy s( InstanceName("somename"), params_ ); s.process( makeNode(), changed_ ); ensure_equals("something changed", changed_.size(), 0u); }
//----------------------------------------------------------------------------- // Function : InstanceBlock::unpack // Purpose : Unpacks InstanceBlock from char buffer using MPI_UNPACK // Special Notes : // Scope : public // Creator : Rob Hoekstra, SNL, Parallel Computational Sciences // Creation Date : 5/24/00 //----------------------------------------------------------------------------- void InstanceBlock::unpack(char * pB, int bsize, int & pos, N_PDS_Comm * comm) { int size, length; int i; //----- unpack name comm->unpack( pB, bsize, pos, &length, 1 ); name_ = InstanceName(std::string( (pB+pos), length)); pos += length; //----- unpack getModelName() comm->unpack( pB, bsize, pos, &length, 1 ); modelName_ = std::string( (pB+pos), length); pos += length; //----- unpack params comm->unpack( pB, bsize, pos, &size, 1 ); params.clear(); Param dp; for( i = 0; i < size; ++i ) { dp.unpack( pB, bsize, pos, comm ); params.push_back( dp ); } //----- unpack iNumNodes comm->unpack( pB, bsize, pos, &iNumNodes, 1 ); //----- unpack numIntVars comm->unpack( pB, bsize, pos, &numIntVars, 1 ); //----- unpack numExtVars comm->unpack( pB, bsize, pos, &numExtVars, 1 ); //----- unpack numStateVars comm->unpack( pB, bsize, pos, &numStateVars, 1 ); //----- unpack modelFlag comm->unpack( pB, bsize, pos, &i, 1 ); modelFlag = ( i != 0 ); //----- unpack sourceFlag comm->unpack( pB, bsize, pos, &i, 1 ); sourceFlag = ( i != 0 ); //----- unpack bsourceFlag comm->unpack( pB, bsize, pos, &i, 1 ); bsourceFlag = ( i != 0 ); //----- unpack offFlag comm->unpack( pB, bsize, pos, &i, 1 ); offFlag = ( i != 0 ); //----- unpack off comm->unpack( pB, bsize, pos, &i, 1 ); off = ( i != 0 ); //----- unpack netlistFileName_ comm->unpack( pB, bsize, pos, &length, 1 ); netlistLocation_.setPath(std::string( (pB+pos), length)); pos += length; //----- unpack lineNumber_ int line_number = 0; comm->unpack( pB, bsize, pos, &line_number, 1 ); netlistLocation_.setLineNumber(line_number); #ifdef Xyce_DEBUG_TOPOLOGY Xyce::dout() << "Unpacked " << pos << " bytes for InstanceBlock: " << getInstanceName() << std::endl; #endif }
boolean StrBrowserCode::Definition (ostream& out) { boolean ok = true; InteractorComp* icomp = GetIntComp(); MemberNameVar* mnamer = icomp->GetMemberNameVar(); SubclassNameVar* snamer = icomp->GetClassNameVar(); ButtonStateVar* bsVar = icomp->GetButtonStateVar(); if ( _emitProperty || _emitBSDecls || _emitBSInits || _emitInstanceDecls || _emitHeaders || _emitFunctionDecls || _emitFunctionInits || _emitClassHeaders ) { return CodeView::Definition(out); } else if (_emitForward) { ok = ok && ButtonCode::Definition(out); } else if (_emitExpHeader) { if (!snamer->IsSubclass() || !bsVar->IsSubclass()) { if (_scope) { if ( mnamer->GetExport()&&!_namelist->Search("strbrowser") && !snamer->IsSubclass() ) { _namelist->Append("strbrowser"); out << "#include <InterViews/strbrowser.h>\n"; } if ( bsVar->GetExport() && !_namelist->Search("button") && !bsVar->IsSubclass() ) { _namelist->Append("button"); out << "#include <InterViews/button.h>\n"; } } ok = ok && CodeView::Definition(out); } else { ok = ok && ButtonCode::Definition(out); } } else if (_emitCorehHeader) { const char* subclass = snamer->GetName(); const char* bsclass = bsVar->GetSubclassName(); const char* fwname = GetFirewall(); if (snamer->IsSubclass() && strcmp(subclass, _classname) == 0) { if (!_namelist->Search("strbrowser")) { _namelist->Append("strbrowser"); out << "#include <InterViews/strbrowser.h>\n"; } } if (bsVar->IsSubclass() && strcmp(bsclass, _classname) == 0) { if (!_namelist->Search("button")) { _namelist->Append("button"); out << "#include <InterViews/button.h>\n"; } if (fwname != nil && !_namelist->Search(fwname)) { _namelist->Append(fwname); out << "#include \"" << fwname << "-core.h\"\n"; } } } else if (_emitInstanceInits) { InteractorComp* icomp = GetIntComp(); const char* mname = icomp->GetMemberNameVar()->GetName(); if (!_instancelist->Find((void*) mname)) { _instancelist->Append(new UList((void*)mname)); StrBrowserComp* strbcomp = GetStrBrowserComp(); int rows, cols; int uniqueSel = (int) strbcomp->GetUniqueSel()->GetBooleanState(); BeginInstantiate(out); StrBrowserGraphic* graphic = strbcomp->GetStrBrowserGraphic(); graphic->GetRowsCols(rows, cols); ButtonStateVar* bsVar = strbcomp->GetButtonStateVar(); out << "("; InstanceName(out); out << bsVar->GetName() << ", "; out << rows << ", " << cols << ", "; if (uniqueSel) { out << "true"; } else { out << "false"; } out << ")"; EndInstantiate(out); } } else if ( _emitCoreDecls || _emitCoreInits || _emitClassDecls || _emitClassInits ) { ok = ok && ButtonCode::Definition(out); } else if (_emitMain) { ok = ok && CodeView::Definition(out); } return out.good() && ok; }
void testObj::test<1>(void) { Strategy s(InstanceName("myscriptrunner"), cfg_); ensure_equals("invalid type", s.getTriggerType().str(), "extapp"); }