Ignore:
Timestamp:
May 4, 2012, 2:19:07 PM (14 years ago)
Author:
Frederik Heber <heber@…>
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, Candidate_v1.7.0, Candidate_v1.7.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)
Message:

Added Shutdown as choice to ControllerChoices.

  • new helper app Shutdowner that shuts down Server.
  • TESTFIX: Changed regression test Fragmentation/Automation where now Shutdowner is uses instead of Jobadder with 0 jobs to power down controller socket.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Automation/FragmentController.cpp

    re70b9d r0196c6  
    157157}
    158158
     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 */
     164void 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
    159191/** Callback function when operation has been completed.
    160192 *
     
    339371}
    340372
     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 */
     377void 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
    341391/** Internal function to disconnect connection_ correctly.
    342392 *
     
    403453}
    404454
     455/** Function to initiate shutdown of server.
     456 *
     457 */
     458void FragmentController::shutdown()
     459{
     460  // connect
     461  connect_shutdown();
     462  //disconnect
     463  disconnect();
     464}
     465
    405466/** Getter for doneJobs.
    406467 *
Note: See TracChangeset for help on using the changeset viewer.