Changeset 0542e2 for ThirdParty/JobMarket/src
- Timestamp:
- Apr 5, 2018, 1:19:33 PM (7 years ago)
- Branches:
- AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
- Children:
- 456f19
- Parents:
- 1181a3
- git-author:
- Frederik Heber <frederik.heber@…> (04/05/18 12:24:11)
- git-committer:
- Frederik Heber <frederik.heber@…> (04/05/18 13:19:33)
- Location:
- ThirdParty/JobMarket/src/JobMarket
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
ThirdParty/JobMarket/src/JobMarket/Controller/FragmentController.cpp
r1181a3 r0542e2 31 31 #include "Operations/Controllers/CheckResultsOperation.hpp" 32 32 #include "Operations/Controllers/GetNextJobIdOperation.hpp" 33 #include "Operations/Controllers/GetNumberWorkersOperation.hpp" 33 34 #include "Operations/Controllers/ReceiveResultsOperation.hpp" 34 35 #include "Operations/Controllers/RemoveAllJobsOperation.hpp" … … 56 57 Commands.registerInstance(new CheckResultsOperation(connection_, AsyncOperation::NoOpCallback, failed)); 57 58 Commands.registerInstance(new GetNextJobIdOperation(connection_, AsyncOperation::NoOpCallback, failed)); 59 Commands.registerInstance(new GetNumberWorkersOperation(connection_, AsyncOperation::NoOpCallback, failed)); 58 60 Commands.registerInstance(new ReceiveResultsOperation(connection_, AsyncOperation::NoOpCallback, failed)); 59 61 Commands.registerInstance(new RemoveAllJobsOperation(connection_)); … … 162 164 } 163 165 166 /** Obtains number of workers enrolled at server 167 * 168 * @param host address of server 169 * @param service port/service of server 170 */ 171 void FragmentController::checkEnrolledWorkers( 172 const std::string &host, 173 const std::string &service) 174 { 175 GetNumberWorkersOperation *checkres = static_cast<GetNumberWorkersOperation *>( 176 Commands.getByName("numberworkers")); 177 (*checkres)(host, service); 178 } 179 164 180 /** Return scheduled and done jobs. 165 181 * … … 173 189 const size_t presentJobs = checkres->getPresentJobs(); 174 190 return make_pair(presentJobs, doneJobs); 191 } 192 193 /** Return scheduled and done jobs. 194 * 195 * @return number of workers in certain states enrolled in server 196 */ 197 std::vector<size_t> FragmentController::getNumberOfWorkers() 198 { 199 const GetNumberWorkersOperation * const checkres = static_cast<const GetNumberWorkersOperation *>( 200 Commands.getByName("numberworkers")); 201 return checkres->get(); 175 202 } 176 203 -
ThirdParty/JobMarket/src/JobMarket/Controller/FragmentController.hpp
r1181a3 r0542e2 49 49 void checkResults(const std::string &host, const std::string &service); 50 50 std::pair<size_t, size_t> getJobStatus() const; 51 void checkEnrolledWorkers(const std::string &host, const std::string &service); 52 std::vector<size_t> getNumberOfWorkers(); 51 53 void removeWaitingResults(const std::string &host, const std::string &service); 52 54 void removeWaitingJobs(const std::string &host, const std::string &service); -
ThirdParty/JobMarket/src/JobMarket/Controller/controller_main.cpp
r1181a3 r0542e2 57 57 } 58 58 59 /** Print the status of workers 60 * 61 * @param number_workers vector of workers in certain states (busy, idle, ...) 62 */ 63 void printNumberWorkers(const std::vector<size_t> &number_workers) 64 { 65 ASSERT(number_workers.size() == 2, 66 "printNumberWorkers() - vector of worker numbers is not of size 2."); 67 LOG(1, "INFO: " << number_workers[0] << " are busy and " 68 << number_workers[1] << " are idle."); 69 } 70 59 71 inline std::vector<std::string> getListOfCommands(const ControllerCommandRegistry &ControllerCommands) 60 72 { … … 96 108 (boost::bind(&printJobStatus, 97 109 boost::bind(&FragmentController::getJobStatus, boost::ref(controller)))) 110 )); 111 registrator(new ControllerCommand("numberworkers", 112 boost::assign::list_of< ControllerCommand::commands_t > 113 (boost::bind(&FragmentController::checkEnrolledWorkers, 114 boost::ref(controller), boost::cref(ControllerInfo->server), boost::cref(ControllerInfo->serverport))) 115 (boost::bind(&printNumberWorkers, 116 boost::bind(&FragmentController::getNumberOfWorkers, boost::ref(controller)))) 98 117 )); 99 118 registrator(new ControllerCommand("removeall", -
ThirdParty/JobMarket/src/JobMarket/ControllerChoices.hpp
r1181a3 r0542e2 24 24 EmptyJobQueue, 25 25 RemoveAll, 26 ShutdownControllerSocket 26 ShutdownControllerSocket, 27 NumberOfWorkers 27 28 }; 28 29 -
ThirdParty/JobMarket/src/JobMarket/FragmentScheduler.hpp
r1181a3 r0542e2 205 205 void handle_SendResults(const boost::system::error_code& e, connection_ptr conn); 206 206 207 /// Controller callback function when result are to be sent. 208 void handle_SendNumberWorkers(const boost::system::error_code& e, connection_ptr conn); 209 207 210 /// Controller callback function when results has been sent. 208 211 void handle_finishSendResults(const boost::system::error_code& e, connection_ptr conn); -
ThirdParty/JobMarket/src/JobMarket/FragmentScheduler_ControllerListener.cpp
r1181a3 r0542e2 25 25 26 26 #include <algorithm> 27 #include <boost/assign.hpp> 27 28 #include <boost/bind.hpp> 28 29 #include <sstream> … … 43 44 44 45 #include "JobMarket/FragmentScheduler.hpp" 46 47 using namespace boost::assign; 45 48 46 49 /** Handle a new controller connection. … … 138 141 { 139 142 removeallWorkers(); 143 break; 144 } 145 case NumberOfWorkers: 146 { 147 LOG(1, "INFO: Sending total number of workers to a controller ..."); 148 std::vector<size_t> number_workers; 149 number_workers += pool.getNoBusyWorkers(); 150 number_workers += pool.getNoIdleWorkers(); 151 conn->async_write(number_workers, 152 boost::bind(&FragmentScheduler::ControllerListener_t::handle_SendNumberWorkers, this, 153 boost::asio::placeholders::error, conn)); 140 154 break; 141 155 } … … 346 360 LOG(1, "INFO: Results have been sent."); 347 361 } 362 363 /** Controller callback function when number of workers has been sent. 364 * 365 * \param e error code if something went wrong 366 * \param conn reference with the connection 367 */ 368 void FragmentScheduler::ControllerListener_t::handle_SendNumberWorkers(const boost::system::error_code& e, connection_ptr conn) 369 { 370 DEBUG_FUNCTION_ENTRYEXIT 371 // do nothing 372 LOG(1, "INFO: Number of workers have been sent."); 373 } -
ThirdParty/JobMarket/src/JobMarket/Makefile.am
r1181a3 r0542e2 40 40 Operations/Controllers/CheckResultsOperation.cpp \ 41 41 Operations/Controllers/GetNextJobIdOperation.cpp \ 42 Operations/Controllers/GetNumberWorkersOperation.cpp \ 42 43 Operations/Controllers/ReceiveResultsOperation.cpp \ 43 44 Operations/Controllers/RemoveAllJobsOperation.cpp \ … … 63 64 Operations/Controllers/CheckResultsOperation.hpp \ 64 65 Operations/Controllers/GetNextJobIdOperation.hpp \ 66 Operations/Controllers/GetNumberWorkersOperation.hpp \ 65 67 Operations/Controllers/ReceiveResultsOperation.hpp \ 66 68 Operations/Controllers/RemoveAllJobsOperation.hpp \
Note:
See TracChangeset
for help on using the changeset viewer.