Changeset 5ac92e
- Timestamp:
- Jul 2, 2012, 8:32:03 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:
- 012c98
- Parents:
- dc759c
- git-author:
- Frederik Heber <heber@…> (04/25/12 10:27:55)
- git-committer:
- Frederik Heber <heber@…> (07/02/12 08:32:03)
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Automation/Makefile.am
rdc759c r5ac92e 160 160 $(BOOST_ASIO_LIBS) \ 161 161 $(BOOST_SERIALIZATION_LIBS) \ 162 $(BOOST_PROGRAM_OPTIONS_LIBS) \ 162 163 $(BOOST_THREAD_LIBS) \ 163 164 $(BOOST_SYSTEM_LIBS) \ -
src/Fragmentation/Automation/poolworker.cpp
rdc759c r5ac92e 28 28 29 29 #include <iostream> 30 #include <boost/program_options.hpp> 30 31 #include <boost/lexical_cast.hpp> 31 32 #include <signal.h> 33 #include <vector> 32 34 33 35 #include "atexit.hpp" … … 36 38 #include "Pool/PoolWorker.hpp" 37 39 40 //!> global shutdown function 38 41 boost::function<void (int)> shutdownfunction; 42 //!> global signal vector for later releasing 43 std::vector<size_t> signals; 39 44 40 45 void signalhandler(int sig) 41 46 { 47 // shutdown if we have handler 42 48 if (shutdownfunction) 43 49 shutdownfunction(sig); 44 signal(SIGINT, NULL); 50 51 // release signal hook again 52 for (std::vector<size_t>::const_iterator iter = signals.begin(); 53 iter != signals.end(); ++iter) 54 signal(*iter, NULL); 45 55 } 46 56 … … 51 61 atexit(cleanUp); 52 62 53 setVerbosity(3); 63 // Declare the supported options. 64 boost::program_options::options_description desc("Allowed options"); 65 desc.add_options() 66 ("help,h", "produce help message") 67 ("verbosity,v", boost::program_options::value<size_t>(), "set verbosity level") 68 ("signal", boost::program_options::value< std::vector<size_t> >(), "set signal to catch (can be given multiple times)") 69 ("server", boost::program_options::value< std::string>(), "connect to server at this address (host:port)") 70 ("listen", boost::program_options::value< std::string >(), "listen on this port") 71 ("hostname", boost::program_options::value< std::string>(), "name of host on which this codes runs and which server can resolve") 72 ; 73 74 boost::program_options::variables_map vm; 75 boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); 76 boost::program_options::notify(vm); 77 78 if (vm.count("help")) { 79 std::cout << desc << "\n"; 80 return 1; 81 } 82 83 if (vm.count("verbosity")) { 84 LOG(0, "STATUS: Verbosity level was set to " << vm["verbosity"].as<size_t>() << "."); 85 setVerbosity(vm["verbosity"].as<size_t>()); 86 } else { 87 LOG(0, "STATUS: Verbosity level was not set, defaulting to 5."); 88 setVerbosity(5); 89 } 90 91 std::string server; 92 std::string serverport; 93 if (vm.count("server")) { 94 server = vm["server"].as< std::string >(); 95 serverport = server.substr(server.find_last_of(':')+1, std::string::npos); 96 server = server.substr(0, server.find_last_of(':')); 97 try { 98 boost::lexical_cast<size_t>(serverport); 99 } catch (boost::bad_lexical_cast) { 100 ELOG(1, "Could not interpret " << serverport << " as server:port."); 101 return 255; 102 } 103 LOG(1, "INFO: Using " << server << ":" << serverport << " as server's address."); 104 } else { 105 ELOG(1, "Requiring server's address (host:port) to connect to."); 106 return 255; 107 } 108 109 std::string hostname("localhost"); 110 if (vm.count("hostname")) { 111 hostname = vm["hostname"].as< std::string >(); 112 LOG(1, "INFO: Using " << hostname << " as host's name."); 113 } else { 114 ELOG(1, "Requiring port to listen on ."); 115 return 255; 116 } 117 118 std::string listenport; 119 if (vm.count("listen")) { 120 try { 121 listenport = vm["listen"].as< std::string >(); 122 } catch (boost::bad_lexical_cast) { 123 ELOG(1, "Could not read " << vm["listen"].as< std::string >() << " as digits."); 124 return 255; 125 } 126 LOG(1, "INFO: Using port " << listenport << " to listen to server connects."); 127 } else { 128 ELOG(1, "Requiring port to listen on ."); 129 return 255; 130 } 54 131 55 132 size_t exitflag = 0; 56 133 try 57 134 { 58 // Check command line arguments.59 if (argc != 5)60 {61 std::cerr << "Usage: " << argv[0] << " <host> <port> <listenhost> <listenport>" << std::endl;62 return 1;63 }64 65 135 boost::asio::io_service io_service; 66 PoolWorker client(io_service, argv[1], argv[2], argv[3], argv[4]);136 PoolWorker client(io_service, server, serverport, hostname, listenport); 67 137 68 138 // catch ctrl-c and shutdown worker properly 69 139 shutdownfunction = boost::bind(&PoolWorker::shutdown, boost::ref(client), _1); 70 // signal(SIGABRT, &signalhandler); 71 // signal(SIGTERM, &signalhandler); 72 signal(SIGINT, &signalhandler); 140 if (vm.count("signal")) { 141 signals = vm["signal"].as< std::vector<size_t> >(); 142 for (std::vector<size_t>::const_iterator iter = signals.begin(); 143 iter != signals.end(); ++iter) { 144 LOG(0, "STATUS: Catching signal " << *iter << " via signal handler."); 145 signal(*iter, &signalhandler); 146 } 147 } else { 148 LOG(0, "STATUS: No signals are caught."); 149 } 73 150 74 151 // process io requests -
tests/regression/Fragmentation/Automation/testsuite-fragmentation-automation-addingjobs.at
rdc759c r5ac92e 19 19 20 20 # enlist a worker to work on jobs 21 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker 127.0.0.1 $WORKERPORT 127.0.0.1$WORKERLISTENPORT &21 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker -v 5 --signal 2 --server 127.0.0.1:${WORKERPORT} --hostname 127.0.0.1 --listen $WORKERLISTENPORT & 22 22 worker_pid=$! 23 23 AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) -
tests/regression/Fragmentation/Automation/testsuite-fragmentation-automation-completerun.at
rdc759c r5ac92e 27 27 28 28 # enlist a worker to work on jobs 29 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker 127.0.0.1 $WORKERPORT 127.0.0.1$WORKERLISTENPORT &29 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker -v 5 --signal 2 --server 127.0.0.1:${WORKERPORT} --hostname 127.0.0.1 --listen $WORKERLISTENPORT & 30 30 worker_pid=$! 31 31 AT_CHECK([sleep 2], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) -
tests/regression/Fragmentation/Automation/testsuite-fragmentation-automation-enrollinpool.at
rdc759c r5ac92e 13 13 AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $server_pid]) 14 14 15 # check help of poolworker 16 AT_CHECK([${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker -h], 1, [ignore], [ignore], [kill $server_pid]) 17 15 18 # let worker enroll in pool 16 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker 127.0.0.1 $WORKERPORT 127.0.0.1$WORKERLISTENPORT &19 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker -v 5 --signal 2 --server 127.0.0.1:${WORKERPORT} --hostname 127.0.0.1 --listen $WORKERLISTENPORT & 17 20 worker_pid=$! 18 21 AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) 19 22 20 # send kill signal to worker such that it shuts down 21 AT_CHECK([kill - INT$worker_pid], 0, [stdout], [ignore], [kill $server_pid $worker_pid])23 # send kill signal to worker such that it shuts down properly 24 AT_CHECK([kill -2 $worker_pid], 0, [stdout], [ignore], [kill $server_pid $worker_pid]) 22 25 23 26 # shutdown server as well -
tests/regression/Fragmentation/Automation/testsuite-fragmentation-automation-mpqc-jobs.at
rdc759c r5ac92e 28 28 29 29 # enlist a worker to work on jobs 30 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker 127.0.0.1 $WORKERPORT 127.0.0.1$WORKERLISTENPORT &30 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker -v 5 --signal 2 --server 127.0.0.1:${WORKERPORT} --hostname 127.0.0.1 --listen $WORKERLISTENPORT & 31 31 worker_pid=$! 32 32 AT_CHECK([sleep 5], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) -
tests/regression/Fragmentation/Automation/testsuite-fragmentation-automation-resubmitjobs.at
rdc759c r5ac92e 19 19 20 20 # enlist a worker to work on jobs 21 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker 127.0.0.1 $WORKERPORT 127.0.0.1$WORKERLISTENPORT 2>workererr &21 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker -v 5 --signal 2 --server 127.0.0.1:${WORKERPORT} --hostname 127.0.0.1 --listen $WORKERLISTENPORT 2>workererr & 22 22 worker_pid=$! 23 23 AT_CHECK([sleep 2], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) -
tests/regression/Fragmentation/Automation/testsuite-fragmentation-automation-server-worker.at
rdc759c r5ac92e 18 18 19 19 # enlist a worker to work on jobs 20 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker 127.0.0.1 $WORKERPORT 127.0.0.1$WORKERLISTENPORT &20 ${AUTOTEST_PATH}/Fragmentation/Automation/PoolWorker -v 5 --signal 2 --server 127.0.0.1:${WORKERPORT} --hostname 127.0.0.1 --listen $WORKERLISTENPORT & 21 21 worker_pid=$! 22 22 AT_CHECK([sleep 2], 0, [ignore], [ignore], [kill $server_pid $worker_pid])
Note:
See TracChangeset
for help on using the changeset viewer.