- Timestamp:
- May 4, 2012, 2:19:07 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:
- dba6d1
- Parents:
- e70b9d
- git-author:
- Frederik Heber <heber@…> (12/09/11 20:11:50)
- git-committer:
- Frederik Heber <heber@…> (05/04/12 14:19:07)
- Location:
- src/Fragmentation/Automation
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Automation/ControllerChoices.hpp
re70b9d r0196c6 20 20 ReceiveJobs, 21 21 CheckState, 22 SendResults 22 SendResults, 23 Shutdown 23 24 }; 24 25 -
src/Fragmentation/Automation/FragmentController.cpp
re70b9d r0196c6 157 157 } 158 158 159 /** Handle completion of a connect operation. 160 * 161 * \param e error code if something went wrong 162 * \param endpoint_iterator endpoint of the connection 163 */ 164 void FragmentController::handle_connect_shutdown(const boost::system::error_code& e, 165 boost::asio::ip::tcp::resolver::iterator endpoint_iterator) 166 { 167 Info info(__FUNCTION__); 168 if (!e) 169 { 170 // Successfully established connection. Give choice. 171 enum ControllerChoices choice = Shutdown; 172 connection_.async_write(choice, 173 boost::bind(&FragmentController::handle_FinishOperation, this, 174 boost::asio::placeholders::error)); 175 } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) { 176 // Try the next endpoint. 177 connection_.socket().close(); 178 boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator; 179 connection_.socket().async_connect(endpoint, 180 boost::bind(&FragmentController::handle_connect_calc, this, 181 boost::asio::placeholders::error, ++endpoint_iterator)); 182 } else { 183 // An error occurred. Log it and return. Since we are not starting a new 184 // operation the io_service will run out of work to do and the client will 185 // exit. 186 Exitflag = ErrorFlag; 187 ELOG(1, e.message()); 188 } 189 } 190 159 191 /** Callback function when operation has been completed. 160 192 * … … 339 371 } 340 372 373 /** Internal function to connect to the endpoint of the server asynchronuously. 374 * 375 * We require internal connetion_ and host and service to be set up for this. 376 */ 377 void FragmentController::connect_shutdown() 378 { 379 Info info(__FUNCTION__); 380 // Resolve the host name into an IP address. 381 boost::asio::ip::tcp::resolver::iterator endpoint_iterator = getEndpointIterator(); 382 boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator; 383 384 // Start an asynchronous connect operation. 385 std::cout << "Connecting to endpoint " << endpoint << " to get results " << std::endl; 386 connection_.socket().async_connect(endpoint, 387 boost::bind(&FragmentController::handle_connect_shutdown, this, 388 boost::asio::placeholders::error, ++endpoint_iterator)); 389 } 390 341 391 /** Internal function to disconnect connection_ correctly. 342 392 * … … 403 453 } 404 454 455 /** Function to initiate shutdown of server. 456 * 457 */ 458 void FragmentController::shutdown() 459 { 460 // connect 461 connect_shutdown(); 462 //disconnect 463 disconnect(); 464 } 465 405 466 /** Getter for doneJobs. 406 467 * -
src/Fragmentation/Automation/FragmentController.hpp
re70b9d r0196c6 49 49 boost::asio::ip::tcp::resolver::iterator endpoint_iterator); 50 50 51 /// Handle completion of a Shutdown operation. 52 void handle_connect_shutdown(const boost::system::error_code& e, 53 boost::asio::ip::tcp::resolver::iterator endpoint_iterator); 54 51 55 /// Handle completion of an operation. 52 56 void handle_FinishOperation(const boost::system::error_code& e); … … 84 88 void obtainResults(); 85 89 90 /// prepares the server's shutdown 91 void shutdown(); 92 86 93 /// get the results for the current jobs 87 94 std::vector<FragmentResult> getResults(); … … 105 112 /// internal function to connect to server and receive calculated results 106 113 void connect_get(); 114 115 /// internal function to connect to server and receive calculated results 116 void connect_shutdown(); 107 117 108 118 /// internal function to disconnect from server -
src/Fragmentation/Automation/FragmentScheduler.cpp
re70b9d r0196c6 228 228 if (!e) 229 229 { 230 bool LaunchNewAcceptor = true; 230 231 // switch over the desired choice read previously 231 232 switch(choice) { … … 254 255 boost::bind(&FragmentScheduler::handle_CheckResultState, this, 255 256 boost::asio::placeholders::error, conn)); 256 257 initiateControllerSocket();258 257 break; 259 258 } … … 266 265 boost::bind(&FragmentScheduler::handle_SendResults, this, 267 266 boost::asio::placeholders::error, conn)); 268 269 initiateControllerSocket(); 267 break; 268 } 269 case Shutdown: 270 { 271 LaunchNewAcceptor = false; 270 272 break; 271 273 } … … 278 280 choice = NoOperation; 279 281 282 if (LaunchNewAcceptor) { 283 LOG(1, "Launching new acceptor on socket."); 284 // Start an accept operation for a new Connection. 285 connection_ptr new_conn(new Connection(controller_acceptor_.get_io_service())); 286 controller_acceptor_.async_accept(new_conn->socket(), 287 boost::bind(&FragmentScheduler::handle_AcceptController, this, 288 boost::asio::placeholders::error, new_conn)); 289 } 280 290 } 281 291 else … … 310 320 if (initiateSocket) 311 321 initiateWorkerSocket(); 312 // launch new acceptor of queue has been filled/is full313 initiateControllerSocket();314 } else {315 LOG(1, "INFO: Shutting down controller socket.");316 322 } 317 323 -
src/Fragmentation/Automation/Makefile.am
re70b9d r0196c6 45 45 AM_CPPFLAGS = ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS} 46 46 47 bin_PROGRAMS += JobAdder ResultChecker ResultGetter Server Worker47 bin_PROGRAMS += JobAdder ResultChecker ResultGetter Server Shutdowner Worker 48 48 49 49 CONTROLLERSOURCE = \ … … 119 119 ${CodePatterns_LIBS} 120 120 121 Shutdowner_SOURCES = $(CONTROLLERSOURCE) $(CONTROLLERHEADER) Shutdowner.cpp 122 Shutdowner_LDFLAGS = $(AM_LDFLAGS) $(BOOST_ASIO_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_THREAD_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS) 123 Shutdowner_CXXFLAGS = $(AM_CPPFLAGS) 124 Shutdowner_LDADD = \ 125 libMolecuilderFragmentJobs.la \ 126 libMolecuilderFragmentationAutomation.la \ 127 $(BOOST_ASIO_LIBS) \ 128 $(BOOST_SERIALIZATION_LIBS) \ 129 $(BOOST_THREAD_LIBS) \ 130 $(BOOST_SYSTEM_LIBS) \ 131 ${CodePatterns_LIBS} 132 121 133 Worker_SOURCES = $(WORKERSOURCE) $(WORKERHEADER) 122 134 Worker_LDFLAGS = $(AM_LDFLAGS) $(BOOST_ASIO_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_THREAD_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS)
Note:
See TracChangeset
for help on using the changeset viewer.