Changeset 4dd16e for src/Fragmentation
- Timestamp:
- Jul 2, 2012, 7:54:12 AM (12 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 3add4f
- Parents:
- e032b4
- git-author:
- Frederik Heber <heber@…> (05/18/12 07:21:28)
- git-committer:
- Frederik Heber <heber@…> (07/02/12 07:54:12)
- Location:
- src/Fragmentation/Automation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Automation/FragmentController.cpp
re032b4 r4dd16e 34 34 #include "Operations/Controllers/SendJobsOperation.hpp" 35 35 #include "Operations/Controllers/ShutdownOperation.hpp" 36 37 #include "Jobs/MPQCCommandJob_MPQCData.hpp" 36 38 37 39 /** Constructor of class FragmentController. … … 78 80 } 79 81 82 83 /** Requests an available id from server 84 * 85 * @param host address of server 86 * @param service port/service of server 87 */ 88 void FragmentController::requestId( 89 const std::string &host, 90 const std::string &service) 91 { 92 GetNextJobIdOperation *getnextid = static_cast<GetNextJobIdOperation *>( 93 Commands.getByName("getnextjobid")); 94 (*getnextid)(host,service); 95 } 96 97 /** Returns another available id from a finished GetNextJobIdOperation. 98 * 99 * @return next available id 100 */ 101 JobId_t FragmentController::getAvailableId() 102 { 103 GetNextJobIdOperation *getnextid = static_cast<GetNextJobIdOperation *>( 104 Commands.getByName("getnextjobid")); 105 const JobId_t nextid = getnextid->getNextId(); 106 LOG(1, "INFO: Next available id is " << nextid << "."); 107 return nextid; 108 } 109 110 /** Adds a vector of jobs to the send operation. 111 * 112 * @param jobs jobs to add 113 */ 114 void FragmentController::addJobs(std::vector<FragmentJob::ptr> &jobs) 115 { 116 SendJobsOperation *sendjobs = static_cast<SendJobsOperation *>( 117 Commands.getByName("sendjobs")); 118 sendjobs->addJobs(jobs); 119 const size_t presentJobs = sendjobs->getPresentJobs(); 120 LOG(1, "INFO: #" << presentJobs << " jobs are now waiting to be transmitted."); 121 } 122 123 /** Sends contained jobs in operation to server 124 * 125 * @param host address of server 126 * @param service port/service of server 127 */ 128 void FragmentController::sendJobs( 129 const std::string &host, 130 const std::string &service) 131 { 132 SendJobsOperation *sendjobs = static_cast<SendJobsOperation *>( 133 Commands.getByName("sendjobs")); 134 const size_t presentJobs = sendjobs->getPresentJobs(); 135 LOG(1, "INFO: #" << presentJobs << " jobs are being sent to the server."); 136 (*sendjobs)(host, service); 137 } 138 139 /** Obtains scheduled and done jobs from server 140 * 141 * @param host address of server 142 * @param service port/service of server 143 */ 144 void FragmentController::checkResults( 145 const std::string &host, 146 const std::string &service) 147 { 148 CheckResultsOperation *checkres = static_cast<CheckResultsOperation *>( 149 Commands.getByName("checkresults")); 150 (*checkres)(host, service); 151 } 152 153 /** Prints scheduled and done jobs. 154 * 155 */ 156 void FragmentController::printDoneJobs() 157 { 158 CheckResultsOperation *checkres = static_cast<CheckResultsOperation *>( 159 Commands.getByName("checkresults")); 160 const size_t doneJobs = checkres->getDoneJobs(); 161 const size_t presentJobs = checkres->getPresentJobs(); 162 LOG(1, "INFO: #" << presentJobs << " are waiting in the queue and #" << doneJobs << " jobs are calculated so far."); 163 } 164 165 /** Obtains results from done jobs from server. 166 * 167 * @param host address of server 168 * @param service port/service of server 169 */ 170 void FragmentController::receiveResults( 171 const std::string &host, 172 const std::string &service) 173 { 174 ReceiveResultsOperation *receiveres = static_cast<ReceiveResultsOperation *>( 175 Commands.getByName("receiveresults")); 176 (*receiveres)(host, service); 177 } 178 179 /** Getter for received results. 180 * 181 * @return vector with all received results 182 */ 183 std::vector<FragmentResult::ptr> FragmentController::getReceivedResults() 184 { 185 ReceiveResultsOperation *receiveres = static_cast<ReceiveResultsOperation *>( 186 Commands.getByName("receiveresults")); 187 return receiveres->getResults(); 188 } 189 190 /** Sends shutdown signal to server 191 * 192 * @param host address of server 193 * @param service port/service of server 194 */ 195 void FragmentController::shutdown( 196 const std::string &host, 197 const std::string &service) 198 { 199 ShutdownOperation *shutdown = static_cast<ShutdownOperation *>( 200 Commands.getByName("shutdown")); 201 (*shutdown)(host, service); 202 } 203 -
src/Fragmentation/Automation/FragmentController.hpp
re032b4 r4dd16e 19 19 20 20 #include "Connection.hpp" 21 #include "JobId.hpp" 21 22 #include "Jobs/FragmentJob.hpp" 22 23 #include "Results/FragmentResult.hpp" … … 42 43 size_t getExitflag() const; 43 44 45 void requestId(const std::string &host, const std::string &service); 46 JobId_t getAvailableId(); 47 void addJobs(std::vector<FragmentJob::ptr> &jobs); 48 void sendJobs(const std::string &host, const std::string &service); 49 void checkResults(const std::string &host, const std::string &service); 50 void printDoneJobs(); 51 void receiveResults(const std::string &host, const std::string &service); 52 std::vector<FragmentResult::ptr> getReceivedResults(); 53 void shutdown(const std::string &host, const std::string &service); 54 44 55 protected: 45 56 /// The Connection to the server. -
src/Fragmentation/Automation/controller.cpp
re032b4 r4dd16e 40 40 #include "CodePatterns/Log.hpp" 41 41 #include "FragmentController.hpp" 42 #include "Operations/Controllers/CheckResultsOperation.hpp"43 #include "Operations/Controllers/GetNextJobIdOperation.hpp"44 #include "Operations/Controllers/ReceiveResultsOperation.hpp"45 #include "Operations/Controllers/SendJobsOperation.hpp"46 #include "Operations/Controllers/ShutdownOperation.hpp"47 42 #include "Jobs/MPQCCommandJob.hpp" 48 #include "Jobs/MPQCCommandJob_MPQCData.hpp"49 43 #include "Jobs/SystemCommandJob.hpp" 50 44 #include "Results/FragmentResult.hpp" … … 60 54 }; 61 55 62 /** Requests an available id from server 63 * 64 * @param controller FragmentController with CommandRegistry 65 * @param host address of server 66 * @param service port/service of server 67 */ 68 void requestid( 69 FragmentController &controller, 70 const std::string &host, 71 const std::string &service) 72 { 73 GetNextJobIdOperation *getnextid = static_cast<GetNextJobIdOperation *>( 74 controller.Commands.getByName("getnextjobid")); 75 (*getnextid)(host,service); 76 } 77 78 /** Returns another available id from a finished GetNextJobIdOperation. 79 * 80 * @param controller FragmentController with CommandRegistry 81 * @return next available id 82 */ 83 JobId_t getavailableid(FragmentController &controller) 84 { 85 GetNextJobIdOperation *getnextid = static_cast<GetNextJobIdOperation *>( 86 controller.Commands.getByName("getnextjobid")); 87 const JobId_t nextid = getnextid->getNextId(); 88 LOG(1, "INFO: Next available id is " << nextid << "."); 89 return nextid; 90 } 91 56 57 /** Creates a SystemCommandJob out of give \a command with \a argument. 58 * 59 * @param jobs created job is added to this vector 60 * @param command command to execute for SystemCommandJob 61 * @param argument argument for command to execute 62 * @param nextid id for this job 63 */ 92 64 void createjobs( 93 65 std::vector<FragmentJob::ptr> &jobs, … … 96 68 const JobId_t nextid) 97 69 { 70 98 71 FragmentJob::ptr testJob( new SystemCommandJob(command, argument, nextid) ); 99 72 jobs.push_back(testJob); … … 123 96 } 124 97 125 /** Adds a vector of jobs to the send operation.126 *127 * @param controller FragmentController with CommandRegistry128 * @param jobs jobs to add129 */130 void addjobs(131 FragmentController &controller,132 std::vector<FragmentJob::ptr> &jobs)133 {134 SendJobsOperation *sendjobs = static_cast<SendJobsOperation *>(135 controller.Commands.getByName("sendjobs"));136 sendjobs->addJobs(jobs);137 const size_t presentJobs = sendjobs->getPresentJobs();138 LOG(1, "INFO: #" << presentJobs << " jobs are now waiting to be transmitted.");139 }140 141 /** Sends contained jobs in operation to server142 *143 * @param controller FragmentController with CommandRegistry144 * @param host address of server145 * @param service port/service of server146 */147 void sendjobs(148 FragmentController &controller,149 const std::string &host,150 const std::string &service)151 {152 SendJobsOperation *sendjobs = static_cast<SendJobsOperation *>(153 controller.Commands.getByName("sendjobs"));154 const size_t presentJobs = sendjobs->getPresentJobs();155 LOG(1, "INFO: #" << presentJobs << " jobs are being sent to the server.");156 (*sendjobs)(host, service);157 }158 159 /** Obtains scheduled and done jobs from server160 *161 * @param controller FragmentController with CommandRegistry162 * @param host address of server163 * @param service port/service of server164 */165 void checkresults(166 FragmentController &controller,167 const std::string &host,168 const std::string &service)169 {170 CheckResultsOperation *checkres = static_cast<CheckResultsOperation *>(171 controller.Commands.getByName("checkresults"));172 (*checkres)(host, service);173 }174 175 /** Prints scheduled and done jobs.176 *177 * @param controller FragmentController with CommandRegistry178 */179 void printdonejobs(FragmentController &controller)180 {181 CheckResultsOperation *checkres = static_cast<CheckResultsOperation *>(182 controller.Commands.getByName("checkresults"));183 const size_t doneJobs = checkres->getDoneJobs();184 const size_t presentJobs = checkres->getPresentJobs();185 LOG(1, "INFO: #" << presentJobs << " are waiting in the queue and #" << doneJobs << " jobs are calculated so far.");186 }187 188 /** Obtains results from done jobs from server.189 *190 * @param controller FragmentController with CommandRegistry191 * @param host address of server192 * @param service port/service of server193 */194 void receiveresults(195 FragmentController &controller,196 const std::string &host,197 const std::string &service)198 {199 ReceiveResultsOperation *receiveres = static_cast<ReceiveResultsOperation *>(200 controller.Commands.getByName("receiveresults"));201 (*receiveres)(host, service);202 }203 204 98 /** Print received results. 205 99 * 206 * @param controller FragmentController with CommandRegistry 207 */ 208 void printreceivedresults(FragmentController &controller) 209 { 210 ReceiveResultsOperation *receiveres = static_cast<ReceiveResultsOperation *>( 211 controller.Commands.getByName("receiveresults")); 212 std::vector<FragmentResult::ptr> results = receiveres->getResults(); 100 * @param results received results to print 101 */ 102 void printReceivedResults(std::vector<FragmentResult::ptr> &results) 103 { 213 104 for (std::vector<FragmentResult::ptr>::const_iterator iter = results.begin(); 214 105 iter != results.end(); ++iter) … … 218 109 /** Print received results. 219 110 * 220 * @param controller FragmentController with CommandRegistry 221 */ 222 void printreceivedmpqcresults(FragmentController &controller, const std::string &KeySetFilename) 223 { 224 ReceiveResultsOperation *receiveres = static_cast<ReceiveResultsOperation *>( 225 controller.Commands.getByName("receiveresults")); 226 std::vector<FragmentResult::ptr> results = receiveres->getResults(); 227 111 * @param results vector of all received FragmentResult's 112 * @param KeySetFilename filename containing keysets 113 */ 114 void printreceivedmpqcresults(std::vector<FragmentResult::ptr> &results, const std::string &KeySetFilename) 115 { 228 116 // parse in KeySetfile 229 117 // const size_t MAXBUFFER = 256; … … 249 137 LOG(1, "INFO: extracted data is " << extractedData << "."); 250 138 } 251 }252 253 /** Sends shutdown signal to server254 *255 * @param controller FragmentController with CommandRegistry256 * @param host address of server257 * @param service port/service of server258 */259 void shutdown(260 FragmentController &controller,261 const std::string &host,262 const std::string &service)263 {264 ShutdownOperation *shutdown = static_cast<ShutdownOperation *>(265 controller.Commands.getByName("shutdown"));266 (*shutdown)(host, service);267 139 } 268 140 … … 327 199 // get an id for every filename 328 200 for (int argcount = 4; argcount < argc; ++argcount) { 329 requestid(controller,argv[1], argv[2]);201 controller.requestId(argv[1], argv[2]); 330 202 } 331 203 } … … 338 210 ELOG(1, "'createjobs' requires two options: [command] [argument]."); 339 211 } else { 340 requestid(controller,argv[1], argv[2]);212 controller.requestId(argv[1], argv[2]); 341 213 } 342 214 break; … … 372 244 } else { 373 245 for (int argcount = 4; argcount < argc; ++argcount) { 374 const JobId_t next_id = getavailableid(controller);246 const JobId_t next_id = controller.getAvailableId(); 375 247 const std::string filename(argv[argcount]); 376 248 LOG(1, "INFO: Creating MPQCCommandJob with filename'" … … 378 250 parsejob(jobs, filename, next_id); 379 251 } 380 addjobs(controller,jobs);381 sendjobs(controller,argv[1], argv[2]);252 controller.addJobs(jobs); 253 controller.sendJobs(argv[1], argv[2]); 382 254 } 383 255 break; … … 387 259 std::vector<FragmentJob::ptr> jobs; 388 260 if (argc < 6) { 389 ELOG(1, "'createjobs' requires two options: [command] [argument]."); 390 } else { 391 const JobId_t next_id = getavailableid(controller); 392 const std::string command(argv[4]); 393 const std::string argument(argv[5]); 394 LOG(1, "INFO: Creating SystemCommandJob with command '" 395 +command+"', argument '"+argument+"', and id "+toString(next_id)+"."); 396 createjobs(jobs, command, argument, next_id); 397 } 398 addjobs(controller, jobs); 399 sendjobs(controller, argv[1], argv[2]); 261 ELOG(1, "'createjobs' requires two options: [command] [argument]."); 262 } else { 263 const JobId_t next_id = controller.getAvailableId(); 264 createjobs(jobs, argv[4], argv[5], next_id); 265 controller.addJobs(jobs); 266 controller.sendJobs(argv[1], argv[2]); 267 } 400 268 break; 401 269 } 402 270 case CheckResultsIndex: 403 271 { 404 c heckresults(controller,argv[1], argv[2]);272 controller.checkResults(argv[1], argv[2]); 405 273 break; 406 274 } 407 275 case ReceiveResultsIndex: 408 276 { 409 receiveresults(controller,argv[1], argv[2]);277 controller.receiveResults(argv[1], argv[2]); 410 278 break; 411 279 } 412 280 case ReceiveMPQCIndex: 413 281 { 414 receiveresults(controller,argv[1], argv[2]);282 controller.receiveResults(argv[1], argv[2]); 415 283 break; 416 284 } 417 285 case ShutdownIndex: 418 286 { 419 shutdown(controller,argv[1], argv[2]);287 controller.shutdown(argv[1], argv[2]); 420 288 break; 421 289 } … … 440 308 case CheckResultsIndex: 441 309 { 442 printdonejobs(controller);310 controller.printDoneJobs(); 443 311 break; 444 312 } 445 313 case ReceiveResultsIndex: 446 314 { 447 printreceivedresults(controller); 315 std::vector<FragmentResult::ptr> results = controller.getReceivedResults(); 316 printReceivedResults(results); 448 317 break; 449 318 } … … 455 324 const std::string KeySetFilename = argv[4]; 456 325 LOG(1, "INFO: Parsing id associations from " << KeySetFilename << "."); 457 printreceivedmpqcresults(controller, KeySetFilename); 326 std::vector<FragmentResult::ptr> results = controller.getReceivedResults(); 327 printreceivedmpqcresults(results, KeySetFilename); 458 328 } 459 329 break; … … 475 345 return Exitflag; 476 346 } 347
Note:
See TracChangeset
for help on using the changeset viewer.