- Timestamp:
- Jun 27, 2012, 4:07:20 PM (13 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:
- 554809
- Parents:
- 6f2bc7
- git-author:
- Frederik Heber <heber@…> (02/16/12 15:09:52)
- git-committer:
- Frederik Heber <heber@…> (06/27/12 16:07:20)
- Location:
- src/Fragmentation/Automation
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Automation/Controller/FragmentController.cpp
r6f2bc7 rd1dbfc 30 30 #include "Controller/Commands/Operation.hpp" 31 31 #include "Controller/Commands/CheckResultsOperation.hpp" 32 #include "Controller/Commands/GetNextJobIdOperation.hpp" 32 33 #include "Controller/Commands/ReceiveJobsOperation.hpp" 33 34 #include "Controller/Commands/SendResultsOperation.hpp" … … 48 49 // insert commands into registry 49 50 Commands.registerInstance(new CheckResultsOperation(connection_)); 51 Commands.registerInstance(new GetNextJobIdOperation(connection_)); 50 52 Commands.registerInstance(new ReceiveJobsOperation(connection_)); 51 53 Commands.registerInstance(new SendResultsOperation(connection_)); -
src/Fragmentation/Automation/ControllerChoices.hpp
r6f2bc7 rd1dbfc 18 18 enum ControllerChoices { 19 19 NoOperation, 20 GetNextJobId, 20 21 ReceiveJobs, 21 22 CheckState, -
src/Fragmentation/Automation/FragmentScheduler.cpp
r6f2bc7 rd1dbfc 68 68 jobInfo((size_t)2, 0), 69 69 choice(NoOperation), 70 globalId(0), 70 71 Exitflag(OkFlag) 71 72 { … … 240 241 { 241 242 bool LaunchNewAcceptor = true; 243 LOG(1, "INFO: Received request for operation " << choice << "."); 242 244 // switch over the desired choice read previously 243 245 switch(choice) { … … 247 249 break; 248 250 } 251 case GetNextJobId: 252 { 253 const JobId_t nextid = globalId.getNextId(); 254 LOG(1, "INFO: Sending next available job id " << nextid << " to controller ..."); 255 conn->async_write(nextid, 256 boost::bind(&FragmentScheduler::handle_GetNextJobIdState, this, 257 boost::asio::placeholders::error, conn)); 258 break; 259 } 249 260 case ReceiveJobs: 250 251 252 253 254 255 256 257 258 261 { 262 // The connection::async_write() function will automatically 263 // serialize the data structure for us. 264 LOG(1, "INFO: Receiving bunch of jobs from a controller ..."); 265 conn->async_read(jobs, 266 boost::bind(&FragmentScheduler::handle_ReceiveJobs, this, 267 boost::asio::placeholders::error, conn)); 268 break; 269 } 259 270 case CheckState: 260 271 { … … 350 361 } 351 362 363 /** Controller callback function when checking on state of results. 364 * 365 * \param e error code if something went wrong 366 * \param conn reference with the connection 367 */ 368 void FragmentScheduler::handle_GetNextJobIdState(const boost::system::error_code& e, connection_ptr conn) 369 { 370 Info info(__FUNCTION__); 371 // do nothing 372 LOG(1, "INFO: Sent next available job id."); 373 } 374 352 375 /** Controller callback function when result has been received. 353 376 * -
src/Fragmentation/Automation/FragmentScheduler.hpp
r6f2bc7 rd1dbfc 19 19 #include "Connection.hpp" 20 20 #include "ControllerChoices.hpp" 21 #include "ControllerChoices.hpp"22 21 #include "FragmentQueue.hpp" 22 #include "GlobalJobId.hpp" 23 23 #include "Jobs/FragmentJob.hpp" 24 24 #include "Results/FragmentResult.hpp" … … 75 75 void handle_CheckResultState(const boost::system::error_code& e, connection_ptr conn); 76 76 77 /// Controller callback function when checking on state of results. 78 void handle_GetNextJobIdState(const boost::system::error_code& e, connection_ptr conn); 79 77 80 /// Controller callback function when result has been received. 78 81 void handle_SendResults(const boost::system::error_code& e, connection_ptr conn); … … 109 112 static FragmentJob::ptr NoJob; 110 113 114 // TODO: replace this instance by a IdPool. 115 //!> global id to give next available job id 116 GlobalJobId globalId; 117 111 118 // Exit flag on program exit 112 119 enum Exitflag_t Exitflag; -
src/Fragmentation/Automation/GlobalJobId.cpp
r6f2bc7 rd1dbfc 22 22 #include "GlobalJobId.hpp" 23 23 24 GlobalJobId::GlobalJobId( ) :25 JobId( 0)24 GlobalJobId::GlobalJobId(const JobId_t _jobid) : 25 JobId(_jobid) 26 26 {} 27 27 … … 31 31 JobId_t GlobalJobId::getNextId() 32 32 { 33 setId(getId()+ 1);33 setId(getId()+(JobId_t)1); 34 34 return getId(); 35 35 } -
src/Fragmentation/Automation/GlobalJobId.hpp
r6f2bc7 rd1dbfc 19 19 { 20 20 public: 21 GlobalJobId();21 explicit GlobalJobId(const JobId_t _jobid); 22 22 ~GlobalJobId(); 23 23 -
src/Fragmentation/Automation/Makefile.am
r6f2bc7 rd1dbfc 47 47 Controller/FragmentController.cpp \ 48 48 Controller/Commands/CheckResultsOperation.cpp \ 49 Controller/Commands/GetNextJobIdOperation.cpp \ 49 50 Controller/Commands/Operation.cpp \ 50 51 Controller/Commands/ReceiveJobsOperation.cpp \ … … 60 61 Controller/FragmentController.hpp \ 61 62 Controller/Commands/CheckResultsOperation.hpp \ 63 Controller/Commands/GetNextJobIdOperation.hpp \ 62 64 Controller/Commands/Operation.hpp \ 63 65 Controller/Commands/ReceiveJobsOperation.hpp \ -
src/Fragmentation/Automation/controller.cpp
r6f2bc7 rd1dbfc 39 39 #include "Controller/FragmentController.hpp" 40 40 #include "Controller/Commands/CheckResultsOperation.hpp" 41 #include "Controller/Commands/GetNextJobIdOperation.hpp" 41 42 #include "Controller/Commands/ReceiveJobsOperation.hpp" 42 43 #include "Controller/Commands/SendResultsOperation.hpp" 43 44 #include "Controller/Commands/ShutdownOperation.hpp" 44 #include "GlobalJobId.hpp"45 45 #include "Jobs/MPQCCommandJob.hpp" 46 46 #include "Jobs/SystemCommandJob.hpp" … … 56 56 }; 57 57 58 // TODO: replace this instance by a IdPool owned by controller. 59 GlobalJobId globalId; 60 61 void createjobs(std::vector<FragmentJob::ptr> &jobs) 62 { 63 FragmentJob::ptr testJob( new SystemCommandJob( std::string("cat"), std::string("Nothing"), globalId.getNextId()) ); 64 FragmentJob::ptr othertestJob( new SystemCommandJob( std::string("cat"), std::string("Nothing"), globalId.getNextId()) ); 58 /** Requests an available id from server 59 * 60 * @param controller FragmentController with CommandRegistry 61 * @param host address of server 62 * @param service port/service of server 63 */ 64 void requestid( 65 FragmentController &controller, 66 const std::string &host, 67 const std::string &service) 68 { 69 GetNextJobIdOperation *getnextid = static_cast<GetNextJobIdOperation *>( 70 controller.Commands.getByName("getnextjobid")); 71 (*getnextid)(host,service); 72 } 73 74 /** Returns another available id from a finished GetNextJobIdOperation. 75 * 76 * @param controller FragmentController with CommandRegistry 77 * @return next available id 78 */ 79 JobId_t getavailableid(FragmentController &controller) 80 { 81 GetNextJobIdOperation *getnextid = static_cast<GetNextJobIdOperation *>( 82 controller.Commands.getByName("getnextjobid")); 83 const JobId_t nextid = getnextid->getNextId(); 84 LOG(1, "INFO: Next available id is " << nextid << "."); 85 return nextid; 86 } 87 88 void createjobs(std::vector<FragmentJob::ptr> &jobs, const JobId_t nextid) 89 { 90 FragmentJob::ptr testJob( new SystemCommandJob( std::string("cat"), std::string("Nothing"), nextid) ); 65 91 jobs.push_back(testJob); 66 jobs.push_back(othertestJob); 67 } 68 69 void parsejob(std::vector<FragmentJob::ptr> &jobs, const std::string &filename) 92 LOG(1, "INFO: Added one empty SystemCommandJob's."); 93 } 94 95 /** Creates a MPQCCommandJob with argument \a filename. 96 * 97 * @param jobs created job is added to this vector 98 * @param filename filename being argument to job 99 * @param nextid id for this job 100 */ 101 void parsejob( 102 std::vector<FragmentJob::ptr> &jobs, 103 const std::string &filename, 104 const JobId_t nextid) 70 105 { 71 106 std::ifstream file; … … 74 109 std::string output((std::istreambuf_iterator<char>(file)), 75 110 std::istreambuf_iterator<char>()); 76 FragmentJob::ptr testJob( new MPQCCommandJob(output, globalId.getNextId()) );111 FragmentJob::ptr testJob( new MPQCCommandJob(output, nextid) ); 77 112 jobs.push_back(testJob); 78 113 file.close(); … … 80 115 } 81 116 82 void addjobs(FragmentController &controller, std::vector<FragmentJob::ptr> &jobs) 117 /** Adds a vector of jobs to the send operation. 118 * 119 * @param controller FragmentController with CommandRegistry 120 * @param jobs jobs to add 121 */ 122 void addjobs( 123 FragmentController &controller, 124 std::vector<FragmentJob::ptr> &jobs) 83 125 { 84 126 ReceiveJobsOperation *recjobs = static_cast<ReceiveJobsOperation *>( … … 87 129 } 88 130 89 void sendjobs(FragmentController &controller, const std::string &host, const std::string &service) 131 /** Sends contained jobs in operation to server 132 * 133 * @param controller FragmentController with CommandRegistry 134 * @param host address of server 135 * @param service port/service of server 136 */ 137 void sendjobs( 138 FragmentController &controller, 139 const std::string &host, 140 const std::string &service) 90 141 { 91 142 ReceiveJobsOperation *recjobs = static_cast<ReceiveJobsOperation *>( … … 94 145 } 95 146 96 void checkresults(FragmentController &controller, const std::string &host, const std::string &service) 147 /** Obtains scheduled and done jobs from server 148 * 149 * @param controller FragmentController with CommandRegistry 150 * @param host address of server 151 * @param service port/service of server 152 */ 153 void checkresults( 154 FragmentController &controller, 155 const std::string &host, 156 const std::string &service) 97 157 { 98 158 CheckResultsOperation *checkres = static_cast<CheckResultsOperation *>( … … 101 161 } 102 162 163 /** Prints scheduled and done jobs. 164 * 165 * @param controller FragmentController with CommandRegistry 166 */ 103 167 void printdonejobs(FragmentController &controller) 104 168 { … … 110 174 } 111 175 112 void receiveresults(FragmentController &controller, const std::string &host, const std::string &service) 176 /** Obtains results from done jobs from server. 177 * 178 * @param controller FragmentController with CommandRegistry 179 * @param host address of server 180 * @param service port/service of server 181 */ 182 void receiveresults( 183 FragmentController &controller, 184 const std::string &host, 185 const std::string &service) 113 186 { 114 187 SendResultsOperation *sendres = static_cast<SendResultsOperation *>( … … 117 190 } 118 191 192 /** Print received results. 193 * 194 * @param controller FragmentController with CommandRegistry 195 */ 119 196 void printreceivedresults(FragmentController &controller) 120 197 { … … 127 204 } 128 205 129 void shutdown(FragmentController &controller, const std::string &host, const std::string &service) 206 /** Sends shutdown signal to server 207 * 208 * @param controller FragmentController with CommandRegistry 209 * @param host address of server 210 * @param service port/service of server 211 */ 212 void shutdown( 213 FragmentController &controller, 214 const std::string &host, 215 const std::string &service) 130 216 { 131 217 ShutdownOperation *shutdown = static_cast<ShutdownOperation *>( … … 183 269 FragmentController controller(io_service); 184 270 271 // Initial phase: information gathering from server 272 185 273 switch(getCommandIndex(CommandsMap, argv[3])) { 186 274 case AddJobsIndex: 187 275 { 276 if (argc < 5) { 277 ELOG(1, "Please add a filename for the MPQCCommandJob."); 278 } else { 279 // get an id for every filename 280 for (int argcount = 4; argcount < argc; ++argcount) { 281 requestid(controller, argv[1], argv[2]); 282 } 283 } 284 break; 285 } 286 case CreateJobsIndex: 287 { 288 requestid(controller, argv[1], argv[2]); 289 break; 290 } 291 case CheckResultsIndex: 292 break; 293 case ReceiveResultsIndex: 294 break; 295 case ShutdownIndex: 296 break; 297 case UnknownCommandIndex: 298 default: 299 ELOG(1, "Unrecognized command '"+toString(argv[3])+"'."); 300 break; 301 } 302 303 { 304 io_service.reset(); 305 Info info("io_service: Phase One"); 306 io_service.run(); 307 } 308 309 // Second phase: Building jobs and sending information to server 310 311 switch(getCommandIndex(CommandsMap, argv[3])) { 312 case AddJobsIndex: 313 { 188 314 std::vector<FragmentJob::ptr> jobs; 189 if (argc == 4) {315 if (argc < 5) { 190 316 ELOG(1, "Please add a filename for the MPQCCommandJob."); 191 317 } else { 192 318 for (int argcount = 4; argcount < argc; ++argcount) { 193 LOG(1, "INFO: Parsing job for file " << argv[argcount] << "."); 194 parsejob(jobs, argv[argcount]); 319 const JobId_t next_id = getavailableid(controller); 320 const std::string filename(argv[argcount]); 321 LOG(1, "INFO: Creating MPQCCommandJob with filename'" 322 +filename+"', and id "+toString(next_id)+"."); 323 parsejob(jobs, filename, next_id); 195 324 } 196 325 addjobs(controller, jobs); … … 202 331 { 203 332 std::vector<FragmentJob::ptr> jobs; 204 createjobs(jobs); 333 const JobId_t next_id = getavailableid(controller); 334 createjobs(jobs, next_id); 205 335 addjobs(controller, jobs); 206 336 sendjobs(controller, argv[1], argv[2]); … … 229 359 230 360 { 231 Info info("io_service"); 361 io_service.reset(); 362 Info info("io_service: Phase Two"); 232 363 io_service.run(); 233 364 } 365 366 // Final phase: Print result of command 234 367 235 368 switch(getCommandIndex(CommandsMap, argv[3])) {
Note:
See TracChangeset
for help on using the changeset viewer.