- Timestamp:
- Jul 6, 2012, 10:18:45 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:
- cbcbbd
- Parents:
- 865a218
- git-author:
- Frederik Heber <heber@…> (06/01/12 18:30:13)
- git-committer:
- Frederik Heber <heber@…> (07/06/12 10:18:45)
- Location:
- src
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r865a218 ree61ce 381 381 Fragmentation/Automation/Pool/WorkerPool.hpp 382 382 383 Controller_SOURCES = $(CONTROLLERSOURCE) $(CONTROLLERHEADER) controller.cpp DefaultOptions.cpp DefaultOptions.hpp ControllerOptions.cpp ControllerOptions.hpp ControllerOptions_MPQCCommandJob.cpp ControllerOptions_MPQCCommandJob.hpp ControllerOptions_SystemCommandJob.cpp ControllerOptions_SystemCommandJob.hpp383 Controller_SOURCES = $(CONTROLLERSOURCE) $(CONTROLLERHEADER) controller.cpp ControllerCommand.hpp ControllerCommandRegistry.cpp ControllerCommandRegistry.hpp DefaultOptions.cpp DefaultOptions.hpp ControllerOptions.cpp ControllerOptions.hpp ControllerOptions_MPQCCommandJob.cpp ControllerOptions_MPQCCommandJob.hpp ControllerOptions_SystemCommandJob.cpp ControllerOptions_SystemCommandJob.hpp 384 384 Controller_LDFLAGS = $(AM_LDFLAGS) $(BOOST_PROGRAM__OPTIONS_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_THREAD_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS) 385 385 Controller_CXXFLAGS = $(AM_CPPFLAGS) -
src/controller.cpp
r865a218 ree61ce 50 50 #include "Fragmentation/Automation/Results/FragmentResult.hpp" 51 51 #include "ControllerOptions_MPQCCommandJob.hpp" 52 #include "ControllerOptions_SystemCommandJob.hpp" 53 #include "ControllerCommandRegistry.hpp" 52 54 53 55 /** Print the status of scheduled and done jobs. … … 320 322 boost::program_options::variables_map vm; 321 323 322 typedef boost::function<void ()> ControllerCommand; 323 typedef std::map<std::string, std::deque<ControllerCommand> > CommandsMap_t; 324 CommandsMap_t CommandsMap; 325 326 // prepare the command queues for each ControllerCommand 327 // note: we need "< ControllerCommand >" because parseExecutable(),... return int 324 // prepare ControllerCommand 325 // note: we need "< ControllerCommand::commands_t >" because parseExecutable(),... return int 328 326 // in contrast to other functions that return void 329 std::deque<ControllerCommand> addjobsQueue = boost::assign::list_of< ControllerCommand > 327 ControllerCommandRegistry ControllerCommands; 328 ControllerCommands.registerInstance(new ControllerCommand("addjobs", 329 boost::assign::list_of< ControllerCommand::commands_t > 330 330 (boost::bind(&FragmentController::requestIds, 331 331 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport), 332 332 boost::bind(&std::vector<std::string>::size, boost::cref(ControllerInfo.jobfiles)))) 333 333 (boost::bind(&AddJobs, boost::ref(controller), boost::cref(ControllerInfo))) 334 ; 335 std::deque<ControllerCommand> createjobsQueue = boost::assign::list_of< ControllerCommand > 336 (boost::bind(&FragmentController::requestIds, 337 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport), 1)) 338 (boost::bind(&createJobs, boost::ref(controller), boost::cref(ControllerInfo))) 339 ; 340 std::deque<ControllerCommand> checkresultsQueue = boost::assign::list_of< ControllerCommand > 341 (boost::bind(&FragmentController::checkResults, 342 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport))) 343 (boost::bind(&printJobStatus, 344 boost::bind(&FragmentController::getJobStatus, boost::ref(controller)))) 345 ; 346 std::deque<ControllerCommand> receiveresultsQueue = boost::assign::list_of< ControllerCommand > 347 (boost::bind(&FragmentController::receiveResults, 348 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport))) 349 (boost::bind(&printReceivedResults, 350 boost::bind(&FragmentController::getReceivedResults, boost::ref(controller)))) 351 ; 352 std::deque<ControllerCommand> receivempqcresultsQueue = boost::assign::list_of< ControllerCommand > 353 (boost::bind(&FragmentController::receiveResults, 354 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport))) 355 (boost::bind(&printReceivedMPQCResults, 356 boost::bind(&FragmentController::getReceivedResults, boost::ref(controller)), 357 boost::cref(ControllerInfo.fragmentpath), 358 boost::bind(&getNoAtomsFromAdjacencyFile, boost::cref(ControllerInfo.fragmentpath)))) 359 ; 360 std::deque<ControllerCommand> removeallQueue = boost::assign::list_of< ControllerCommand > 361 (boost::bind(&FragmentController::removeall, 362 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport))) 363 ; 364 std::deque<ControllerCommand> shutdownQueue = boost::assign::list_of< ControllerCommand > 365 (boost::bind(&FragmentController::shutdown, 366 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport))) 367 ; 368 CommandsMap.insert( std::make_pair("addjobs", addjobsQueue) ); 369 CommandsMap.insert( std::make_pair("createjobs", createjobsQueue) ); 370 CommandsMap.insert( std::make_pair("checkresults", checkresultsQueue) ); 371 CommandsMap.insert( std::make_pair("receiveresults", receiveresultsQueue) ); 372 CommandsMap.insert( std::make_pair("receivempqc", receivempqcresultsQueue) ); 373 CommandsMap.insert( std::make_pair("removeall", removeallQueue) ); 374 CommandsMap.insert( std::make_pair("shutdown", shutdownQueue) ); 334 )); 335 ControllerCommands.registerInstance(new ControllerCommand("createjobs", 336 boost::assign::list_of< ControllerCommand::commands_t > 337 (boost::bind(&FragmentController::requestIds, 338 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport), 1)) 339 (boost::bind(&createJobs, boost::ref(controller), boost::cref(ControllerInfo))) 340 )); 341 ControllerCommands.registerInstance(new ControllerCommand("checkresults", 342 boost::assign::list_of< ControllerCommand::commands_t > 343 (boost::bind(&FragmentController::checkResults, 344 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport))) 345 (boost::bind(&printJobStatus, 346 boost::bind(&FragmentController::getJobStatus, boost::ref(controller)))) 347 )); 348 ControllerCommands.registerInstance(new ControllerCommand("receiveresults", 349 boost::assign::list_of< ControllerCommand::commands_t > 350 (boost::bind(&FragmentController::receiveResults, 351 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport))) 352 (boost::bind(&printReceivedResults, 353 boost::bind(&FragmentController::getReceivedResults, boost::ref(controller)))) 354 )); 355 ControllerCommands.registerInstance(new ControllerCommand("receivempqc", 356 boost::assign::list_of< ControllerCommand::commands_t > 357 (boost::bind(&FragmentController::receiveResults, 358 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport))) 359 (boost::bind(&printReceivedMPQCResults, 360 boost::bind(&FragmentController::getReceivedResults, boost::ref(controller)), 361 boost::cref(ControllerInfo.fragmentpath), 362 boost::bind(&getNoAtomsFromAdjacencyFile, boost::cref(ControllerInfo.fragmentpath)))) 363 )); 364 ControllerCommands.registerInstance(new ControllerCommand("removeall", 365 boost::assign::list_of< ControllerCommand::commands_t > 366 (boost::bind(&FragmentController::removeall, 367 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport))) 368 )); 369 ControllerCommands.registerInstance(new ControllerCommand("shutdown", 370 boost::assign::list_of< ControllerCommand::commands_t > 371 (boost::bind(&FragmentController::shutdown, 372 boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport))) 373 )); 375 374 std::vector<std::string> Commands; 376 for (CommandsMap_t::const_iterator iter = CommandsMap.begin(); iter != CommandsMap.end(); ++iter) 375 for (ControllerCommandRegistry::const_iterator iter = ControllerCommands.getBeginIter(); 376 iter != ControllerCommands.getEndIter(); ++iter) 377 377 Commands.push_back(iter->first); 378 378 … … 416 416 417 417 // parse given ControllerCommand 418 if( CommandsMap.count(ControllerInfo.command) == 0) {418 if(!ControllerCommands.isPresentByName(ControllerInfo.command)) { 419 419 ELOG(1, "Unrecognized command '"+toString(ControllerInfo.command)+"'."); 420 420 return 255; 421 421 } 422 std::deque<ControllerCommand> &commands = CommandsMap[ControllerInfo.command];422 const ControllerCommand *commands = ControllerCommands.getByName(ControllerInfo.command); 423 423 try 424 424 { 425 425 // execute each command in the queue synchronously 426 426 size_t phase = 1; 427 while (!commands.empty()) { 428 ControllerCommand command = commands.front(); 429 commands.pop_front(); 430 command(); 427 for (ControllerCommand::const_iterator iter = commands->begin(); 428 iter != commands->end(); ++iter, ++phase) { 429 (*iter)(); 431 430 { 432 431 io_service.reset();
Note:
See TracChangeset
for help on using the changeset viewer.