- Timestamp:
- May 17, 2012, 3:21:12 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:
- 1dc209
- Parents:
- fb2324
- git-author:
- Frederik Heber <heber@…> (12/10/11 15:17:06)
- git-committer:
- Frederik Heber <heber@…> (05/17/12 15:21:12)
- Location:
- src/Fragmentation/Automation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Automation/FragmentController.cpp
rfb2324 r5adb84 50 50 host(_host), 51 51 service(_service), 52 Exitflag(OkFlag) 52 recjobs(connection_, _host, _service), 53 checkres(connection_, _host, _service), 54 sendres(connection_, _host, _service), 55 shutdown(connection_, _host, _service) 53 56 { 54 57 Info info(__FUNCTION__); … … 61 64 {} 62 65 63 /** Handle completion of a connect operation. 66 /** Constructor for class Operation. 67 * 68 * \param _connection connection to operate on 69 */ 70 FragmentController::Operation::Operation(Connection &_connection, const std::string& _host, const std::string& _service) : 71 connection_(_connection), 72 host(_host), 73 service(_service), 74 Exitflag(OkFlag) 75 {} 76 77 /** Destructor for class Operation. 78 * 79 */ 80 FragmentController::Operation::~Operation() 81 {} 82 83 /** Handle connect operation to receive jobs from controller 64 84 * 65 85 * \param e error code if something went wrong 66 86 * \param endpoint_iterator endpoint of the connection 67 87 */ 68 void FragmentController:: handle_connect_calc(const boost::system::error_code& e,88 void FragmentController::ReceiveJobsOperation::handle_connect_calc(const boost::system::error_code& e, 69 89 boost::asio::ip::tcp::resolver::iterator endpoint_iterator) 70 90 { … … 75 95 enum ControllerChoices choice = ReceiveJobs; 76 96 connection_.async_write(choice, 77 boost::bind(&FragmentController:: handle_SendJobs, this,97 boost::bind(&FragmentController::ReceiveJobsOperation::handle_SendJobs, this, 78 98 boost::asio::placeholders::error)); 79 99 } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) { … … 82 102 boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator; 83 103 connection_.socket().async_connect(endpoint, 84 boost::bind(&FragmentController:: handle_connect_calc, this,104 boost::bind(&FragmentController::ReceiveJobsOperation::handle_connect_calc, this, 85 105 boost::asio::placeholders::error, ++endpoint_iterator)); 86 106 } else { … … 93 113 } 94 114 95 /** Handle completion of a connect operation. 115 /** Callback function when an operation has been completed. 116 * 117 * \param e error code if something went wrong 118 */ 119 void FragmentController::ReceiveJobsOperation::handle_FinishOperation(const boost::system::error_code& e) 120 { 121 Info info(__FUNCTION__); 122 123 LOG(1, "INFO: Jobs have been sent. Clearing."); 124 jobs.clear(); 125 126 Operation::handle_FinishOperation(e); 127 } 128 129 130 /** Handle connect operation to send number of done jobs. 96 131 * 97 132 * \param e error code if something went wrong 98 133 * \param endpoint_iterator endpoint of the connection 99 134 */ 100 void FragmentController:: handle_connect_check(const boost::system::error_code& e,135 void FragmentController::CheckResultsOperation::handle_connect_check(const boost::system::error_code& e, 101 136 boost::asio::ip::tcp::resolver::iterator endpoint_iterator) 102 137 { … … 107 142 enum ControllerChoices choice = CheckState; 108 143 connection_.async_write(choice, 109 boost::bind(&FragmentController:: handle_ReceiveDoneJobs, this,144 boost::bind(&FragmentController::CheckResultsOperation::handle_ReceiveDoneJobs, this, 110 145 boost::asio::placeholders::error)); 111 146 } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) { … … 114 149 boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator; 115 150 connection_.socket().async_connect(endpoint, 116 boost::bind(&FragmentController:: handle_connect_check, this,151 boost::bind(&FragmentController::CheckResultsOperation::handle_connect_check, this, 117 152 boost::asio::placeholders::error, ++endpoint_iterator)); 118 153 } else { … … 125 160 } 126 161 127 /** Handle co mpletion of a connect operation.162 /** Handle connect operation to send results. 128 163 * 129 164 * \param e error code if something went wrong 130 165 * \param endpoint_iterator endpoint of the connection 131 166 */ 132 void FragmentController:: handle_connect_get(const boost::system::error_code& e,167 void FragmentController::SendResultsOperation::handle_connect_get(const boost::system::error_code& e, 133 168 boost::asio::ip::tcp::resolver::iterator endpoint_iterator) 134 169 { … … 139 174 enum ControllerChoices choice = SendResults; 140 175 connection_.async_write(choice, 141 boost::bind(&FragmentController:: handle_ReceivingResults, this,176 boost::bind(&FragmentController::SendResultsOperation::handle_ReceivingResults, this, 142 177 boost::asio::placeholders::error)); 143 178 } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) { … … 146 181 boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator; 147 182 connection_.socket().async_connect(endpoint, 148 boost::bind(&FragmentController:: handle_connect_check, this,183 boost::bind(&FragmentController::SendResultsOperation::handle_connect_get, this, 149 184 boost::asio::placeholders::error, ++endpoint_iterator)); 150 185 } else { … … 157 192 } 158 193 159 /** Handle co mpletion of a connect operation.194 /** Handle connect operation to shutdown scheduler. 160 195 * 161 196 * \param e error code if something went wrong 162 197 * \param endpoint_iterator endpoint of the connection 163 198 */ 164 void FragmentController:: handle_connect_shutdown(const boost::system::error_code& e,199 void FragmentController::ShutdownOperation::handle_connect_shutdown(const boost::system::error_code& e, 165 200 boost::asio::ip::tcp::resolver::iterator endpoint_iterator) 166 201 { … … 171 206 enum ControllerChoices choice = Shutdown; 172 207 connection_.async_write(choice, 173 boost::bind(&FragmentController:: handle_FinishOperation, this,208 boost::bind(&FragmentController::ShutdownOperation::handle_FinishOperation, this, 174 209 boost::asio::placeholders::error)); 175 210 } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) { … … 178 213 boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator; 179 214 connection_.socket().async_connect(endpoint, 180 boost::bind(&FragmentController:: handle_connect_calc, this,215 boost::bind(&FragmentController::ShutdownOperation::handle_connect_shutdown, this, 181 216 boost::asio::placeholders::error, ++endpoint_iterator)); 182 217 } else { … … 189 224 } 190 225 191 /** Callback function when operation has been completed.192 * 193 * \param e error code if something went wrong 194 */ 195 void FragmentController:: handle_FinishOperation(const boost::system::error_code& e)226 /** Callback function when an operation has been completed. 227 * 228 * \param e error code if something went wrong 229 */ 230 void FragmentController::Operation::handle_FinishOperation(const boost::system::error_code& e) 196 231 { 197 232 Info info(__FUNCTION__); … … 215 250 * \param e error code if something went wrong 216 251 */ 217 void FragmentController:: handle_SendJobs(const boost::system::error_code& e)252 void FragmentController::ReceiveJobsOperation::handle_SendJobs(const boost::system::error_code& e) 218 253 { 219 254 Info info(__FUNCTION__); … … 225 260 LOG(1, "INFO: Sending "+toString(jobs.size())+" jobs ..."); 226 261 connection_.async_write(jobs, 227 boost::bind(&FragmentController:: handle_FinishOperation, this,262 boost::bind(&FragmentController::ReceiveJobsOperation::handle_FinishOperation, this, 228 263 boost::asio::placeholders::error)); 229 264 } … … 243 278 * \param e error code if something went wrong 244 279 */ 245 void FragmentController:: handle_ReceivingResults(const boost::system::error_code& e)280 void FragmentController::SendResultsOperation::handle_ReceivingResults(const boost::system::error_code& e) 246 281 { 247 282 Info info(__FUNCTION__); … … 251 286 // decode the data that is written to the underlying socket. 252 287 connection_.async_read(results, 253 boost::bind(&FragmentController:: handle_ReceivedResults, this,288 boost::bind(&FragmentController::SendResultsOperation::handle_ReceivedResults, this, 254 289 boost::asio::placeholders::error)); 255 290 } … … 269 304 * \param e error code if something went wrong 270 305 */ 271 void FragmentController:: handle_ReceivedResults(const boost::system::error_code& e)306 void FragmentController::SendResultsOperation::handle_ReceivedResults(const boost::system::error_code& e) 272 307 { 273 308 Info info(__FUNCTION__); … … 282 317 * \param e error code if something went wrong 283 318 */ 284 void FragmentController:: handle_ReceiveDoneJobs(const boost::system::error_code& e)319 void FragmentController::CheckResultsOperation::handle_ReceiveDoneJobs(const boost::system::error_code& e) 285 320 { 286 321 Info info(__FUNCTION__); … … 291 326 LOG(1, "INFO: Checking number of done jobs ..."); 292 327 connection_.async_read(doneJobs, 293 boost::bind(&FragmentController:: handle_FinishOperation, this,328 boost::bind(&FragmentController::Operation::handle_FinishOperation, this, 294 329 boost::asio::placeholders::error)); 295 330 } … … 306 341 * \return endpoint iterator of connection 307 342 */ 308 boost::asio::ip::tcp::resolver::iterator FragmentController:: getEndpointIterator()343 boost::asio::ip::tcp::resolver::iterator FragmentController::Operation::getEndpointIterator() 309 344 { 310 345 // Resolve the host name into an IP address. … … 321 356 * We require internal connetion_ and host and service to be set up for this. 322 357 */ 323 void FragmentController:: connect_calc()358 void FragmentController::ReceiveJobsOperation::connect_calc() 324 359 { 325 360 Info info(__FUNCTION__); … … 331 366 std::cout << "Connecting to endpoint " << endpoint << " to calc " << std::endl; 332 367 connection_.socket().async_connect(endpoint, 333 boost::bind(&FragmentController:: handle_connect_calc, this,368 boost::bind(&FragmentController::ReceiveJobsOperation::handle_connect_calc, this, 334 369 boost::asio::placeholders::error, ++endpoint_iterator)); 335 370 } … … 339 374 * We require internal connetion_ and host and service to be set up for this. 340 375 */ 341 void FragmentController:: connect_check()376 void FragmentController::CheckResultsOperation::connect_check() 342 377 { 343 378 Info info(__FUNCTION__); … … 349 384 std::cout << "Connecting to endpoint " << endpoint << " to check " << std::endl; 350 385 connection_.socket().async_connect(endpoint, 351 boost::bind(&FragmentController:: handle_connect_check, this,386 boost::bind(&FragmentController::CheckResultsOperation::handle_connect_check, this, 352 387 boost::asio::placeholders::error, ++endpoint_iterator)); 353 388 } … … 357 392 * We require internal connetion_ and host and service to be set up for this. 358 393 */ 359 void FragmentController:: connect_get()394 void FragmentController::SendResultsOperation::connect_get() 360 395 { 361 396 Info info(__FUNCTION__); … … 367 402 std::cout << "Connecting to endpoint " << endpoint << " to get results " << std::endl; 368 403 connection_.socket().async_connect(endpoint, 369 boost::bind(&FragmentController:: handle_connect_get, this,404 boost::bind(&FragmentController::SendResultsOperation::handle_connect_get, this, 370 405 boost::asio::placeholders::error, ++endpoint_iterator)); 371 406 } … … 375 410 * We require internal connetion_ and host and service to be set up for this. 376 411 */ 377 void FragmentController:: connect_shutdown()412 void FragmentController::ShutdownOperation::connect_shutdown() 378 413 { 379 414 Info info(__FUNCTION__); … … 385 420 std::cout << "Connecting to endpoint " << endpoint << " to get results " << std::endl; 386 421 connection_.socket().async_connect(endpoint, 387 boost::bind(&FragmentController:: handle_connect_shutdown, this,422 boost::bind(&FragmentController::ShutdownOperation::handle_connect_shutdown, this, 388 423 boost::asio::placeholders::error, ++endpoint_iterator)); 389 424 } … … 392 427 * 393 428 */ 394 void FragmentController:: disconnect()429 void FragmentController::Operation::disconnect() 395 430 { 396 431 //connection_.socket().close(); … … 401 436 * \param _jobs jobs to add 402 437 */ 403 void FragmentController:: addJobs(const std::vector<FragmentJob> &_jobs)438 void FragmentController::ReceiveJobsOperation::addJobs(const std::vector<FragmentJob> &_jobs) 404 439 { 405 440 jobs.reserve(jobs.size()+_jobs.size()); … … 411 446 /** Prepares the calculation of the results for the current jobs. 412 447 */ 413 void FragmentController:: calculateResults()448 void FragmentController::ReceiveJobsOperation::operator()() 414 449 { 415 450 Info info(__FUNCTION__); … … 422 457 /** Prepares the calculation of the results for the current jobs. 423 458 */ 424 void FragmentController:: checkResults()459 void FragmentController::CheckResultsOperation::operator()() 425 460 { 426 461 Info info(__FUNCTION__); … … 433 468 /** Getter for results. 434 469 * 435 * \sa calculateResults()436 470 * \return vector of results for the added jobs (\sa addJobs()). 437 471 */ 438 std::vector<FragmentResult> FragmentController:: getResults()472 std::vector<FragmentResult> FragmentController::SendResultsOperation::getResults() 439 473 { 440 474 Info info(__FUNCTION__); … … 445 479 * 446 480 */ 447 void FragmentController:: obtainResults()481 void FragmentController::SendResultsOperation::operator()() 448 482 { 449 483 // connect … … 456 490 * 457 491 */ 458 void FragmentController:: shutdown()492 void FragmentController::ShutdownOperation::operator()() 459 493 { 460 494 // connect … … 469 503 * \param doneJobs 470 504 */ 471 size_t FragmentController:: getDoneJobs() const505 size_t FragmentController::CheckResultsOperation::getDoneJobs() const 472 506 { 473 507 return doneJobs; … … 478 512 * \return jobs.size() 479 513 */ 480 size_t FragmentController:: getPresentJobs() const514 size_t FragmentController::ReceiveJobsOperation::getPresentJobs() const 481 515 { 482 516 return jobs.size(); -
src/Fragmentation/Automation/FragmentController.hpp
rfb2324 r5adb84 34 34 { 35 35 public: 36 FragmentController(boost::asio::io_service& io_service, const std::string& host, const std::string&service);36 FragmentController(boost::asio::io_service& io_service, const std::string& _host, const std::string& _service); 37 37 ~FragmentController(); 38 38 39 /// Handle completion of a calculate operation. 40 void handle_connect_calc(const boost::system::error_code& e, 41 boost::asio::ip::tcp::resolver::iterator endpoint_iterator); 42 43 /// Handle completion of a CheckResults operation. 44 void handle_connect_check(const boost::system::error_code& e, 45 boost::asio::ip::tcp::resolver::iterator endpoint_iterator); 46 47 /// Handle completion of a GetResults operation. 48 void handle_connect_get(const boost::system::error_code& e, 49 boost::asio::ip::tcp::resolver::iterator endpoint_iterator); 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 55 /// Handle completion of an operation. 56 void handle_FinishOperation(const boost::system::error_code& e); 57 58 /// Callback function when bunch of jobs have been sent. 59 void handle_SendJobs(const boost::system::error_code& e); 60 61 /// Callback function when doneJobs have been received. 62 void handle_ReceiveDoneJobs(const boost::system::error_code& e); 63 64 /// Callback function when results are about to be received. 65 void handle_ReceivingResults(const boost::system::error_code& e); 66 67 /// Callback function when results have been received. 68 void handle_ReceivedResults(const boost::system::error_code& e); 69 70 /// place number of jobs into this controller 71 void addJobs(const std::vector<FragmentJob> &jobs); 72 73 /// prepares the calculation of the results 74 void calculateResults(); 75 76 enum Exitflag_t { 77 OkFlag = 0, 78 ErrorFlag = 255 79 }; 39 class Operation { 40 public: 41 Operation(Connection &_connection, const std::string& _host, const std::string& _service); 42 virtual ~Operation(); 43 public: 44 /// The Connection to the server. 45 Connection &connection_; 46 47 // virtual function pointer to the operation to do 48 virtual void operator()() = 0; 49 50 /// Handle completion of an operation. 51 void handle_FinishOperation(const boost::system::error_code& e); 52 53 enum Exitflag_t { 54 OkFlag = 0, 55 ErrorFlag = 255 56 }; 57 58 // get the exit flag of the last operations 59 size_t getExitflag() const 60 { 61 return Exitflag; 62 } 63 64 protected: 65 /// internal function to resolve host name and ip address 66 boost::asio::ip::tcp::resolver::iterator getEndpointIterator(); 67 68 /// internal function to disconnect from server 69 void disconnect(); 70 71 protected: 72 /// host name of server 73 const std::string host; 74 75 // service to connect to to 76 const std::string service; 77 78 /// flag of operation to give on program exit 79 enum Exitflag_t Exitflag; 80 }; 81 82 class ReceiveJobsOperation : public Operation { 83 public: 84 /// Constructor for class ReceiveJobsOperation. 85 ReceiveJobsOperation(Connection &_connection, const std::string& _host, const std::string& _service) : 86 Operation(_connection, _host, _service) {} 87 /// Destructor for class ReceiveJobsOperation 88 ~ReceiveJobsOperation() {} 89 90 public: 91 /// Placing receive jobs operations into an io_service 92 virtual void operator()(); 93 94 /// Handle completion of a calculate operation. 95 void handle_connect_calc(const boost::system::error_code& e, 96 boost::asio::ip::tcp::resolver::iterator endpoint_iterator); 97 98 /// Callback function when bunch of jobs have been sent. 99 void handle_SendJobs(const boost::system::error_code& e); 100 101 /// Handle completion of an operation. 102 void handle_FinishOperation(const boost::system::error_code& e); 103 104 /// internal function to connect to server and send jobs for calculation 105 void connect_calc(); 106 107 /// Setter for jobs 108 void addJobs(const std::vector<FragmentJob> &jobs); 109 110 /// Getter for number of size of jobs 111 size_t getPresentJobs() const; 112 113 protected: 114 /// bunch of jobs 115 std::vector<FragmentJob> jobs; 116 }; 117 118 struct CheckResultsOperation : public Operation { 119 public: 120 /// Constructor for class CheckResultsOperation. 121 CheckResultsOperation(Connection &_connection, const std::string& _host, const std::string& _service) : 122 Operation(_connection, _host, _service), 123 doneJobs(0) 124 {} 125 /// Destructor for class CheckResultsOperation 126 ~CheckResultsOperation() {} 127 128 public: 129 // placing receive jobs operations into an io_service 130 virtual void operator()(); 131 132 /// Handle completion of a CheckResults operation. 133 void handle_connect_check(const boost::system::error_code& e, 134 boost::asio::ip::tcp::resolver::iterator endpoint_iterator); 135 136 /// Callback function when doneJobs have been received. 137 void handle_ReceiveDoneJobs(const boost::system::error_code& e); 138 139 /// Handle completion of an operation. 140 void handle_FinishOperation(const boost::system::error_code& e); 141 142 /// internal function to connect to server and check done jobs 143 void connect_check(); 144 145 /// Getter for doneJobs 146 size_t getDoneJobs() const; 147 148 protected: 149 /// currently calculated results 150 size_t doneJobs; 151 }; 152 153 struct SendResultsOperation : public Operation { 154 public: 155 /// Constructor for class SendResultsOperation. 156 SendResultsOperation(Connection &_connection, const std::string& _host, const std::string& _service) : 157 Operation(_connection, _host, _service) {} 158 /// Destructor for class SendResultsOperation 159 ~SendResultsOperation() {} 160 161 public: 162 // placing receive jobs operations into an io_service 163 virtual void operator()(); 164 165 /// Handle completion of a GetResults operation. 166 void handle_connect_get(const boost::system::error_code& e, 167 boost::asio::ip::tcp::resolver::iterator endpoint_iterator); 168 169 /// Callback function when results are about to be received. 170 void handle_ReceivingResults(const boost::system::error_code& e); 171 172 /// Callback function when results have been received. 173 void handle_ReceivedResults(const boost::system::error_code& e); 174 175 /// internal function to connect to server and receive calculated results 176 void connect_get(); 177 178 /// Getter for results 179 std::vector<FragmentResult> getResults(); 180 181 protected: 182 /// bunch of results 183 std::vector<FragmentResult> results; 184 }; 185 186 struct ShutdownOperation : public Operation { 187 public: 188 /// Constructor for class ShutdownOperation. 189 ShutdownOperation(Connection &_connection, const std::string& _host, const std::string& _service) : 190 Operation(_connection, _host, _service) {} 191 /// Destructor for class ShutdownOperation 192 ~ShutdownOperation() {} 193 194 public: 195 // placing receive jobs operations into an io_service 196 virtual void operator()(); 197 198 /// Handle completion of a Shutdown operation. 199 void handle_connect_shutdown(const boost::system::error_code& e, 200 boost::asio::ip::tcp::resolver::iterator endpoint_iterator); 201 202 /// internal function to connect to server and receive calculated results 203 void connect_shutdown(); 204 205 }; 206 207 protected: 208 /// The Connection to the server. 209 Connection connection_; 210 211 public: 212 213 ReceiveJobsOperation recjobs; 214 CheckResultsOperation checkres; 215 SendResultsOperation sendres; 216 ShutdownOperation shutdown; 80 217 81 218 // get the exit flag of the last operations 82 219 size_t getExitflag() const 83 220 { 84 return Exitflag; 85 } 86 87 /// prepares the receival of the results 88 void obtainResults(); 89 90 /// prepares the server's shutdown 91 void shutdown(); 221 if (recjobs.getExitflag() != 0) 222 return recjobs.getExitflag(); 223 if (checkres.getExitflag() != 0) 224 return checkres.getExitflag(); 225 if (sendres.getExitflag() != 0) 226 return sendres.getExitflag(); 227 if (shutdown.getExitflag() != 0) 228 return shutdown.getExitflag(); 229 return 0; 230 } 231 232 /// place number of jobs into this controller 233 void addJobs(const std::vector<FragmentJob> &jobs) 234 { 235 recjobs.addJobs(jobs); 236 } 92 237 93 238 /// get the results for the current jobs 94 std::vector<FragmentResult> getResults() ;95 96 /// get the number of finished results for the current jobs97 void checkResults();239 std::vector<FragmentResult> getResults() 240 { 241 return sendres.getResults(); 242 } 98 243 99 244 /// Getter for doneJobs 100 size_t getDoneJobs() const; 245 size_t getDoneJobs() const 246 { 247 return checkres.getDoneJobs(); 248 } 101 249 102 250 /// Getter for number of jobs in the queue 103 size_t getPresentJobs() const; 251 size_t getPresentJobs() const 252 { 253 return recjobs.getPresentJobs(); 254 } 104 255 105 256 private: 106 /// internal function to resolve host name and ip address107 boost::asio::ip::tcp::resolver::iterator getEndpointIterator();108 109 /// internal function to connect to server and send jobs for calculation110 void connect_calc();111 112 /// internal function to connect to server and check done jobs113 void connect_check();114 115 /// internal function to connect to server and receive calculated results116 void connect_get();117 118 /// internal function to connect to server and receive calculated results119 void connect_shutdown();120 121 /// internal function to disconnect from server122 void disconnect();123 124 private:125 /// The Connection to the server.126 Connection connection_;127 128 257 /// host name of server 129 258 const std::string host; … … 131 260 // service to connect to to 132 261 const std::string service; 133 134 /// bunch of jobs135 std::vector<FragmentJob> jobs;136 137 /// flag to give on program exit138 enum Exitflag_t Exitflag;139 140 /// bunch of results141 std::vector<FragmentResult> results;142 143 /// currently calculated results144 size_t doneJobs;145 262 }; 146 263 -
src/Fragmentation/Automation/JobAdder.cpp
rfb2324 r5adb84 67 67 } 68 68 controller.addJobs(jobs); 69 controller. calculateResults();69 controller.recjobs(); 70 70 { 71 71 Info info("io_service"); -
src/Fragmentation/Automation/ResultChecker.cpp
rfb2324 r5adb84 59 59 FragmentController controller(io_service, argv[1], argv[2]); 60 60 61 controller.check Results();61 controller.checkres(); 62 62 { 63 63 Info info("io_service"); -
src/Fragmentation/Automation/ResultGetter.cpp
rfb2324 r5adb84 67 67 } 68 68 69 controller. obtainResults();69 controller.sendres(); 70 70 { 71 71 Info info("io_service");
Note:
See TracChangeset
for help on using the changeset viewer.