ExecProcess *AgentThread::getProcess(int i) { if (i < getProcessCount()) return processPool[i]; else return NULL; };
void AgentThread::processCMDSTART_REQUEST(int socketHandle) { try { ConsoleServer::debugMsg(1,"Processing CMDSTART_REQUEST\n"); // read the serialized TestObject which we will execute TestObject *test = new TestObject(); test->readTestObject(socketHandle); // now send a signal indicating we are processing the request Utils::sendSignal(socketHandle,RESPONSE_PROCESSING); // execute the test ExecProcess *startedProcess = addProcess(new ExecProcess(test, debugLevel, showOutput)); startedProcess->run(); ConsoleServer::debugMsg(1, "Added pid %d to process pool (total %d processes)\n", startedProcess->getPid(), getProcessCount()); // now send a signal indicating we have finished Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); } catch (char *message) { ConsoleServer::debugMsg(1,"Error processing CMDSTART_REQUEST execute request:%s\n",message); Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR); } };
void AgentThread::processCMDCLEAN_REQUEST(int socketHandle) { try { ConsoleServer::debugMsg(1,"Processing CMDCLEAN_REQUEST\n"); // read the serialized TestObject which we will stop TestObject test; test.readTestObject(socketHandle); // now send a signal indicating we are processing the request Utils::sendSignal(socketHandle,RESPONSE_PROCESSING); //clean the files now for (int i = 0; i < getProcessCount(); i++) { // check for any instance of test running with the same id TestObject *curr = getProcess(i)->getTestObject(); if (curr->getTestID().compare(test.getTestID())==0) { // clean up the trace files ConsoleServer::debugMsg(1, "Cleaning environment file :%s\n", curr->getEnvFileName().c_str()); if (Utils::delete_file(curr->getEnvFileName())!=0) ConsoleServer::debugMsg(1,"No environment file was found :%s\n", curr->getEnvFileName().c_str()); ConsoleServer::debugMsg(1,"Cleaning stdout file :%s\n", curr->getStdOutFileName().c_str()); if (Utils::delete_file(curr->getStdOutFileName())!=0) ConsoleServer::debugMsg(1,"No stdout file was found :%s\n", curr->getStdOutFileName().c_str()); ConsoleServer::debugMsg(1,"Cleaning stderr file :%s\n", curr->getStdErrFileName().c_str()); if (Utils::delete_file(curr->getStdErrFileName())!=0) ConsoleServer::debugMsg(1,"No stderr file was found :%s\n", curr->getStdErrFileName().c_str()); // remove from our list of test objects ConsoleServer::debugMsg(1,"Removing process from process pool\n"); delProcess(i); break; } } // now send a signal indicating we have finished Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); } catch (char * message) { ConsoleServer::debugMsg(1,"Error processing CMDCLEAN_REQUEST request:%s\n",message); Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR); } };
void AgentThread::processCMDSTOP_REQUEST(int socketHandle) { try { ConsoleServer::debugMsg(1,"Processing CMDSTOP_REQUEST\n"); // read the serialized TestObject which we will stop TestObject test; test.readTestObject(socketHandle); // now send a signal indicating we are processing the request Utils::sendSignal(socketHandle,RESPONSE_PROCESSING); // find the exit code, blocking for requested timeout if neccesary int wasRunning = FALSE; int status; for (int i = 0; i < getProcessCount(); i++) { // check for any instance of test running with the same id TestObject *curr = getProcess(i)->getTestObject(); if (curr==NULL) { printf("Error: Null process found on process list"); return; } if (curr->getTestID().compare(test.getTestID())==0) { ConsoleServer::debugMsg(5,"Stopping process\n"); wasRunning = TRUE; status = getProcess(i)->checkExitValue(); // flush and close it's output streams getProcess(i)->interrupt(); Utils::sendSignal(socketHandle,status); break; } } if (!wasRunning) { // the process was never started, so assume it failed ConsoleServer::debugMsg(1,"Process was not running :%s\n",test.getTestID().c_str()); } else { // now send a signal indicating we have finished Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); } } catch (char * message) { ConsoleServer::debugMsg(1,"Error processing CMDSTOP_REQUEST request:%s\n",message); Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR); } };
void AgentThread::processGETTRACEPATHS_REQUEST(int socketHandle) { try { ConsoleServer::debugMsg(1,"Processing GETTRACEPATHS_REQUEST\n"); // read the serialized TestObject which we want the exit code of TestObject test; test.readTestObject(socketHandle); // now send a signal indicating we are processing the request Utils::sendSignal(socketHandle,RESPONSE_PROCESSING); int wasRun = FALSE; for (int i = 0; i < getProcessCount(); i++) { // check for any instance of test running with the same id TestObject *curr = getProcess(i)->getTestObject(); if (curr->getTestID().compare(test.getTestID())==0) { wasRun = true; Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); ConsoleServer::debugMsg(9,"Sending trace file paths\n"); ConsoleServer::debugMsg(9,"Env file :%s\n",curr->getEnvFileName().c_str()); ConsoleServer::debugMsg(9,"StdOut file :%s\n",curr->getStdOutFileName().c_str()); ConsoleServer::debugMsg(9,"StdErr file :%s\n",curr->getStdErrFileName().c_str()); // ---- send the env, stdout and stderr files -------------------- Utils::writeString(socketHandle,curr->getEnvFileName()); Utils::writeString(socketHandle,curr->getStdOutFileName()); Utils::writeString(socketHandle,curr->getStdErrFileName()); // ---------------------------------- break; } } if (!wasRun) { // the process was never started, so assume it failed ConsoleServer::debugMsg(1,"Process was never started :%s\n",test.getTestID().c_str()); Utils::writeInt(socketHandle,RESPONSE_FINISHED_ERROR); } else { // now send a signal indicating we have finished Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); } } catch (char *message) { ConsoleServer::debugMsg(1,"Error processing GETTRACEPATHS_REQUEST request:%s\n",message); Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR); } }
void AgentThread::processCMDSTATUS_REQUEST(int socketHandle) { TestObject test; try { ConsoleServer::debugMsg(1,"Processing CMDSTATUS_REQUEST\n"); // read the serialized TestObject which we will stop test.readTestObject(socketHandle); // now send a signal indicating we are processing the request Utils::sendSignal(socketHandle,RESPONSE_PROCESSING); // find the exit code, blocking if neccesary int wasRunning = FALSE; for (int i = 0; i < getProcessCount(); i++) { // check for any instance of test running with the same id TestObject *curr = getProcess(i)->getTestObject(); if (curr->getTestID().compare(test.getTestID())==0) { ConsoleServer::debugMsg(8,"Found started process :%s\n",test.getTestID().c_str()); int status = getProcess(i)->getExitValue(); ConsoleServer::debugMsg(5,"Returning CMDSTATUS value :%d\n",status); Utils::writeInt(socketHandle,status); wasRunning = TRUE; break; } } if (!wasRunning) { // the process was never started, so assume it failed ConsoleServer::debugMsg(1,"Process was never started :%s\n",test.getTestID().c_str()); Utils::writeInt(socketHandle,FAILED); } else { // now send a signal indicating we have finished Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); } } catch (char * message) { ConsoleServer::debugMsg(1,"Error processing CMDSTATUS_REQUEST request:%s\n",message); Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR); } }
void AgentThread::delProcess(int i) { grabMutex(); ExecProcess *processToDelete = getProcess(i); for (int j = i; j < getProcessCount(); j++) processPool[j] = processPool[j+1]; processPool[processCount] = NULL; processCount--; // remove from our list of test objects if (processToDelete) { ConsoleServer::debugMsg(1,"Garbage collecting the removed process resources for process %d\n",i); delete processToDelete; processToDelete = NULL; } freeMutex(); };
void InitPrimaryConfig() { static bool isPrimaryConfigInitialized = false; // Return if already initialized if ( isPrimaryConfigInitialized ) return; isPrimaryConfigInitialized = true; // ------------------------- GENERAL/GLOBAL CONFIG OPTIONS ---------------------------------- // Get screenshot format screenshotFmt = LoadConfigString("starcraft", "screenshots", "gif"); if ( !screenshotFmt.empty() ) screenshotFmt.insert(0, "."); // Check if warning dialogs should be shown showWarn = LoadConfigStringUCase("config", "show_warnings", "YES") == "YES"; // Check if shared memory should be enabled serverEnabled = LoadConfigStringUCase("config", "shared_memory", "ON") == "ON"; // Get process count gdwProcNum = getProcessCount("StarCraft.exe"); // ------------------------- WMODE CONFIG OPTIONS ---------------------------------- // Load windowed mode position and fullscreen setting windowRect.left = LoadConfigInt("window", "left"); windowRect.top = LoadConfigInt("window", "top"); windowRect.right = LoadConfigInt("window", "width"); windowRect.bottom = LoadConfigInt("window", "height"); switchToWMode = LoadConfigStringUCase("window", "windowed", "OFF") == "ON"; // Limit minimum w-mode size if ( windowRect.right < WMODE_MIN_WIDTH ) windowRect.right = WMODE_MIN_WIDTH; if ( windowRect.bottom < WMODE_MIN_HEIGHT ) windowRect.bottom = WMODE_MIN_HEIGHT; }
void ProcessList::resetProcess() { for (vector<Process*>::size_type i=0; i<getProcessCount(); i++) processList[i]->reset(); }
Process* ProcessList::getProcess(int id) { if (id >= 0 && id < getProcessCount() ) return(processList[id]); return(NULL); }
void CNProbeSetArray::setupGCCorrectionBins(int iGCBinCount) { AffxMultiDimensionalArray<float> vGcContent(getProcessCount()); int iIndex = 0; for (int iRowIndex = 0; (iRowIndex < getCount()); iRowIndex++) { CNProbeSet* p = getAt(iRowIndex); if (!p->isProcess() || !( p->processAsCN() || p->processAsSNP() )) { continue; } float fGcContent = p->getGCContent(); vGcContent.set(iIndex, fGcContent); iIndex++; } AffxMultiDimensionalArray<float> v(iGCBinCount); AffxMultiDimensionalArray<int> vCounts(iGCBinCount); float fPercentile = 0; for (int iBinIndex = 0; (iBinIndex < iGCBinCount); iBinIndex++) { fPercentile = vGcContent.percentile((1.0 / (double)iGCBinCount) * (iBinIndex + 1)); v.set(iBinIndex, fPercentile); } v.set((iGCBinCount - 1), 1); for (int iRowIndex = 0; (iRowIndex < getCount()); iRowIndex++) { CNProbeSet* pobjProbeSet = getAt(iRowIndex); if (!pobjProbeSet->isProcess() || !( pobjProbeSet->processAsCN() || pobjProbeSet->processAsSNP() )) { continue; } float fGcContent = pobjProbeSet->getGCContent(); for (int iBinIndex = 0; (iBinIndex < iGCBinCount); iBinIndex++) { if (fGcContent <= v.get(iBinIndex)) { if (iBinIndex == 0) { pobjProbeSet->setGCBinIndex(iBinIndex); vCounts.increment(iBinIndex); break; } else if (fGcContent > v.get(iBinIndex - 1)) { pobjProbeSet->setGCBinIndex(iBinIndex); vCounts.increment(iBinIndex); break; } } } if (pobjProbeSet->getGCBinIndex() == -1) { Verbose::out(1, pobjProbeSet->getProbeSetName() + " has no gc-bin assignment. " + ::getDouble(fGcContent, 6)); } } /* Verbose::out(1, "*"); AffxString str; for (int iBinIndex = 0; (iBinIndex < iGCBinCount); iBinIndex++) { if (iBinIndex == 0) { Verbose::out(1, str + "GC Correction Bin " + ::getInt(iBinIndex + 1) + "\t= 0 \t<= n <= " + ::getDouble(v.get(iBinIndex), 6) + "\tMarkerCount = " + ::getInt(vCounts.get(iBinIndex))); } else if (iBinIndex == (iGCBinCount - 1)) { Verbose::out(1, str + "GC Correction Bin " + ::getInt(iBinIndex + 1) + "\t= " + ::getDouble(v.get(iBinIndex - 1), 6) + "\t< n <= 1 \tMarkerCount = " + ::getInt(vCounts.get(iBinIndex))); } else { Verbose::out(1, str + "GC Correction Bin " + ::getInt(iBinIndex + 1) + "\t= " + ::getDouble(v.get(iBinIndex - 1), 6) + "\t< n <= " + ::getDouble(v.get(iBinIndex), 6) + "\tMarkerCount = " + ::getInt(vCounts.get(iBinIndex))); } } Verbose::out(1, "*"); */ }