Changeset aec098
- Timestamp:
- Jun 29, 2012, 1:23: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:
- e8f397
- Parents:
- 9a3f84
- git-author:
- Frederik Heber <heber@…> (03/04/12 16:12:28)
- git-committer:
- Frederik Heber <heber@…> (06/29/12 13:23:20)
- Location:
- src/Fragmentation/Automation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Automation/Pool/PoolWorker.cpp
r9a3f84 raec098 52 52 * We automatically connect to the given pool and enroll. 53 53 * 54 * @param io_service io service for creating connections54 * @param _io_service io service for creating connections 55 55 * @param _host host part of address of pool to connect to 56 56 * @param _service service part of address of pool to connect to … … 59 59 */ 60 60 PoolWorker::PoolWorker( 61 boost::asio::io_service& io_service,61 boost::asio::io_service& _io_service, 62 62 const std::string& _host, 63 63 const std::string& _service, 64 64 const std::string& listenhost, 65 65 const std::string& listenservice) : 66 connection_(io_service),67 PoolListener( io_service, boost::lexical_cast<unsigned short>(listenservice), *this),66 io_service(_io_service), 67 PoolListener(_io_service, boost::lexical_cast<unsigned short>(listenservice), *this), 68 68 address(listenhost, listenservice), 69 connection_(_io_service), 69 70 enrollOp(connection_, address), 70 71 submitOp(connection_, address), 71 72 submitresult(boost::bind(&AsyncOperation::operator(), 72 73 boost::ref(submitOp), 74 _host, _service)), 75 removeOp(connection_, address), 76 removeme(boost::bind(&Operation::operator(), 77 boost::ref(removeOp), 73 78 _host, _service)) 74 79 { … … 138 143 submitresult(); 139 144 } 145 146 /** Helper function to shutdown the worker properly. 147 * 148 * Note that we will use ShutdownWorkerOperation to unlist from server's pool. 149 * 150 */ 151 void PoolWorker::shutdown(int sig) 152 { 153 LOG(1, "INFO: Shutting down due to signal "+toString(sig)+"."); 154 155 // remove us from pool 156 removeme(); 157 158 // somehow stop listener 159 PoolListener.closeSocket(); 160 161 // finally, stop io_service 162 io_service.stop(); 163 } -
src/Fragmentation/Automation/Pool/PoolWorker.hpp
r9a3f84 raec098 23 23 #include "Jobs/FragmentJob.hpp" 24 24 #include "Controller/Commands/EnrollInPoolOperation.hpp" 25 #include "Controller/Commands/RemoveFromPoolOperation.hpp" 25 26 #include "Controller/Commands/SubmitResultOperation.hpp" 26 27 #include "Listener.hpp" … … 50 51 51 52 void WorkOnJob(FragmentJob::ptr &job); 53 void removeFromPool(); 54 void shutdown(int sig); 52 55 53 56 class PoolListener_t : public Listener … … 79 82 80 83 private: 81 //!> The Connection to the server.82 Connection connection_;84 //!> reference to io_service which we use for connections 85 boost::asio::io_service& io_service; 83 86 84 87 //!> The listener for the WorkerPool … … 87 90 //!> address of this worker 88 91 const WorkerAddress address; 92 93 //!> The Connection to the server for the stored operations 94 Connection connection_; 89 95 90 96 //!> operation that handles obtaining a job … … 96 102 //!> internally bound function such that host and service don't have to be stored, submits result 97 103 boost::function<void ()> submitresult; 104 105 //!> operation that handles removal from pool 106 RemoveFromPoolOperation removeOp; 107 108 //!> internally bound function such that host and service don't have to be stored, submits result 109 boost::function<void ()> removeme; 98 110 }; 99 111 -
src/Fragmentation/Automation/poolworker.cpp
r9a3f84 raec098 29 29 #include <iostream> 30 30 #include <boost/lexical_cast.hpp> 31 #include <signal.h> 31 32 32 33 #include "atexit.hpp" … … 35 36 #include "Pool/PoolWorker.hpp" 36 37 38 boost::function<void (int)> shutdownfunction; 39 40 void signalhandler(int sig) 41 { 42 if (shutdownfunction) 43 shutdownfunction(sig); 44 signal(SIGINT, NULL); 45 } 37 46 38 47 int main(int argc, char* argv[]) … … 56 65 boost::asio::io_service io_service; 57 66 PoolWorker client(io_service, argv[1], argv[2], argv[3], argv[4]); 67 68 // catch ctrl-c and shutdown worker properly 69 shutdownfunction = boost::bind(&PoolWorker::shutdown, boost::ref(client), _1); 70 // signal(SIGABRT, &signalhandler); 71 // signal(SIGTERM, &signalhandler); 72 signal(SIGINT, &signalhandler); 73 74 // process io requests 58 75 { 59 76 Info info("io_service");
Note:
See TracChangeset
for help on using the changeset viewer.