Changeset d57585


Ignore:
Timestamp:
Jul 2, 2012, 8:32:08 AM (13 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, 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:
bff93d
Parents:
9db22d
git-author:
Frederik Heber <heber@…> (05/11/12 19:42:43)
git-committer:
Frederik Heber <heber@…> (07/02/12 08:32:08)
Message:

Added ExitflagContainer that FragmentController and PoolWorker use.

Location:
src/Fragmentation/Automation
Files:
1 added
17 edited

Legend:

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

    r9db22d rd57585  
    4747FragmentController::FragmentController(
    4848    boost::asio::io_service& io_service) :
    49     connection_(io_service)
     49    connection_(io_service),
     50    failed(boost::bind(&ExitflagContainer::setExitflag, this, ExitflagContainer::ErrorFlag))
    5051{
    5152  Info info(__FUNCTION__);
    5253
    5354  // insert commands into registry
    54   Commands.registerInstance(new CheckResultsOperation(connection_, AsyncOperation::NoOpCallback));
    55   Commands.registerInstance(new GetNextJobIdOperation(connection_, AsyncOperation::NoOpCallback));
    56   Commands.registerInstance(new ReceiveResultsOperation(connection_, AsyncOperation::NoOpCallback));
     55  Commands.registerInstance(new CheckResultsOperation(connection_, AsyncOperation::NoOpCallback, failed));
     56  Commands.registerInstance(new GetNextJobIdOperation(connection_, AsyncOperation::NoOpCallback, failed));
     57  Commands.registerInstance(new ReceiveResultsOperation(connection_, AsyncOperation::NoOpCallback, failed));
    5758  Commands.registerInstance(new RemoveAllWorkerOperation(connection_));
    58   Commands.registerInstance(new SendJobsOperation(connection_, AsyncOperation::NoOpCallback));
     59  Commands.registerInstance(new SendJobsOperation(connection_, AsyncOperation::NoOpCallback, failed));
    5960  Commands.registerInstance(new ShutdownOperation(connection_));
    6061}
     
    6768  Commands.cleanup();
    6869}
    69 
    70 /** Getter for Exitflag of all any Operation.
    71  *
    72  * We simply go through all of them and check which failed.
    73  *
    74  * @return Combined Exitflag of all Operations in \a Commands.
    75  */
    76 size_t FragmentController::getExitflag() const
    77 {
    78   for (OperationRegistry::const_iterator iter = Commands.getBeginIter();
    79       iter != Commands.getEndIter(); ++iter)
    80     if ((iter->second)->getExitflag() != 0)
    81       return (iter->second)->getExitflag();
    82   return 0;
    83 }
    84 
    8570
    8671/** Requests an available id from server
  • src/Fragmentation/Automation/FragmentController.hpp

    r9db22d rd57585  
    1919
    2020#include "Connection.hpp"
     21#include "ExitflagContainer.hpp"
    2122#include "JobId.hpp"
    2223#include "Jobs/FragmentJob.hpp"
     
    3435 * of the fragments on distant computers.
    3536 */
    36 class FragmentController
     37class FragmentController : public ExitflagContainer
    3738{
    3839public:
    3940  FragmentController(boost::asio::io_service& io_service);
    4041  ~FragmentController();
    41 
    42   /// getter for operations exit flag.
    43   size_t getExitflag() const;
    4442
    4543  void requestIds(const std::string &host, const std::string &service, const size_t NumberIds);
     
    6159  //!> registry with all operations of this controller
    6260  OperationRegistry Commands;
     61
     62private:
     63  //!> internally bound function that sets the Exitflag to ErrorFlag
     64  boost::function<void ()> failed;
    6365};
    6466
  • src/Fragmentation/Automation/Makefile.am

    r9db22d rd57585  
    9393FRAGMENTATIONAUTOMATIONHELPERHEADER = \
    9494  atexit.hpp \
     95  ExitflagContainer.hpp \
    9596  GlobalJobId.hpp \
    9697  Listener.hpp \
  • src/Fragmentation/Automation/Operations/AsyncOperation.cpp

    r9db22d rd57585  
    5353  {
    5454    // An error occurred.
    55     Exitflag = ErrorFlag;
    5655    ELOG(1, e.message());
    5756    callback_on_failure();
  • src/Fragmentation/Automation/Operations/Controllers/CheckResultsOperation.cpp

    r9db22d rd57585  
    6060    // operation the io_service will run out of work to do and the client will
    6161    // exit.
    62     Exitflag = ErrorFlag;
    6362    ELOG(1, e.message());
     63    AsyncOperation::handle_FinishOperation(e);
    6464  }
    6565}
     
    8484  {
    8585    // An error occurred.
    86     Exitflag = ErrorFlag;
    8786    ELOG(1, e.message());
     87    AsyncOperation::handle_FinishOperation(e);
    8888  }
    8989}
  • src/Fragmentation/Automation/Operations/Controllers/GetNextJobIdOperation.cpp

    r9db22d rd57585  
    6262    // exit.
    6363    ELOG(1, e.message());
     64    AsyncOperation::handle_FinishOperation(e);
    6465  }
    6566}
     
    8586    // An error occurred.
    8687    ELOG(1, e.message());
     88    AsyncOperation::handle_FinishOperation(e);
    8789  }
    8890}
     
    108110    // An error occurred.
    109111    ELOG(1, e.message());
     112    AsyncOperation::handle_FinishOperation(e);
    110113  }
    111114}
  • src/Fragmentation/Automation/Operations/Controllers/ReceiveResultsOperation.cpp

    r9db22d rd57585  
    6262    // operation the io_service will run out of work to do and the client will
    6363    // exit.
    64     Exitflag = ErrorFlag;
    6564    ELOG(1, e.message());
     65    AsyncOperation::handle_FinishOperation(e);
    6666  }
    6767}
     
    8686  {
    8787    // An error occurred.
    88     Exitflag = ErrorFlag;
    8988    ELOG(1, e.message());
     89    AsyncOperation::handle_FinishOperation(e);
    9090  }
    9191}
  • src/Fragmentation/Automation/Operations/Controllers/SendJobsOperation.cpp

    r9db22d rd57585  
    6363    // operation the io_service will run out of work to do and the client will
    6464    // exit.
    65     Exitflag = ErrorFlag;
    6665    ELOG(1, e.message());
     66    AsyncOperation::handle_FinishOperation(e);
    6767  }
    6868}
     
    8888  {
    8989    // An error occurred.
    90     Exitflag = ErrorFlag;
    9190    ELOG(1, e.message());
     91    AsyncOperation::handle_FinishOperation(e);
    9292  }
    9393
  • src/Fragmentation/Automation/Operations/Operation.hpp

    r9db22d rd57585  
    3434  Operation(const std::string &_name, Connection &_connection) :
    3535    connection_(_connection),
    36     Exitflag(OkFlag),
    3736    name(_name)
    3837  {}
     
    4948  virtual void operator()(const std::string& _host, const std::string& _service) = 0;
    5049
    51   enum Exitflag_t {
    52     OkFlag = 0,
    53     ErrorFlag = 255
    54   };
    55 
    56   /** Getter for Exitflag.
    57    *
    58    * @return Exitflag
    59    */
    60   size_t getExitflag() const
    61   {
    62     return Exitflag;
    63   }
    64 
    65   /** Getter for name.
     50 /** Getter for name.
    6651   *
    6752   * @return const reference to Operation::name.
     
    7560  Connection &connection_;
    7661
    77   // exit flag of this operation, derived classes may change it
    78   enum Exitflag_t Exitflag;
    79 
    8062private:
    8163  /// Name of this AsyncOperation (required for Registry pattern)
  • src/Fragmentation/Automation/Operations/Servers/SendJobToWorkerOperation.cpp

    r9db22d rd57585  
    5959    // operation the io_service will run out of work to do and the client will
    6060    // exit.
    61     Exitflag = ErrorFlag;
    6261    ELOG(1, e.message());
     62    AsyncOperation::handle_FinishOperation(e);
    6363  }
    6464}
  • src/Fragmentation/Automation/Operations/Servers/ShutdownWorkerOperation.cpp

    r9db22d rd57585  
    6262    // operation the io_service will run out of work to do and the client will
    6363    // exit.
    64     Exitflag = ErrorFlag;
    6564    ELOG(1, e.message());
     65    AsyncOperation::handle_FinishOperation(e);
    6666  }
    6767}
  • src/Fragmentation/Automation/Operations/Workers/EnrollInPoolOperation.cpp

    r9db22d rd57585  
    5757    // exit.
    5858    ELOG(1, e.message());
     59    AsyncOperation::handle_FinishOperation(e);
    5960  }
    6061}
     
    8081    // exit.
    8182    ELOG(1, e.message());
     83    AsyncOperation::handle_FinishOperation(e);
    8284  }
    8385}
     
    101103    // exit.
    102104    ELOG(1, e.message());
     105    AsyncOperation::handle_FinishOperation(e);
    103106  }
    104107}
  • src/Fragmentation/Automation/Operations/Workers/ObtainJobOperation.cpp

    r9db22d rd57585  
    5757    // exit.
    5858    ELOG(1, e.message());
     59    AsyncOperation::handle_FinishOperation(e);
    5960  }
    6061}
  • src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.cpp

    r9db22d rd57585  
    5757    // operation the io_service will run out of work to do and the client will
    5858    // exit.
    59     exitflag = ErrorFlag;
    6059    ELOG(1, e.message());
     60    AsyncOperation::handle_FinishOperation(e);
    6161  }
    6262}
     
    7979    // operation the io_service will run out of work to do and the client will
    8080    // exit.
    81     exitflag = ErrorFlag;
    8281    ELOG(1, e.message());
     82    AsyncOperation::handle_FinishOperation(e);
    8383  }
    8484}
     
    101101    // operation the io_service will run out of work to do and the client will
    102102    // exit.
    103     exitflag = ErrorFlag;
    104103    ELOG(1, e.message());
     104    AsyncOperation::handle_FinishOperation(e);
    105105  }
    106106}
  • src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.hpp

    r9db22d rd57585  
    3434    AsyncOperation(std::string("submitresult"),_connection, _callback_on_success, _callback_on_failure),
    3535    result( new FragmentResult(JobId::NoJob, std::string("EmptyResult")) ),
    36     address(_address),
    37     exitflag(OkFlag)
     36    address(_address)
    3837  {}
    3938  /// Destructor for class SubmitResultOperation
     
    4847    result.reset();
    4948    result = _result;
    50   }
    51 
    52 public:
    53   enum {
    54     OkFlag = 0,
    55     ErrorFlag = 1
    56   };
    57 
    58   /** Returns the flag of the handled operation.
    59    *
    60    */
    61   size_t getFlag() const
    62   {
    63     return exitflag;
    6449  }
    6550
     
    8469  //!> address for listener
    8570  WorkerAddress address;
    86 
    87   /// exit flag
    88   size_t exitflag;
    8971};
    9072
  • src/Fragmentation/Automation/Pool/PoolWorker.cpp

    r9db22d rd57585  
    6868  address(listenhost, listenservice),
    6969  connection_(_io_service),
    70   enrollOp(connection_, address, AsyncOperation::NoOpCallback, AsyncOperation::NoOpCallback),
    71   submitOp(connection_, address, AsyncOperation::NoOpCallback, AsyncOperation::NoOpCallback),
     70  failed(boost::bind(&ExitflagContainer::setExitflag, this, ExitflagContainer::ErrorFlag)),
     71  enrollOp(connection_, address, AsyncOperation::NoOpCallback, failed),
     72  submitOp(connection_, address, AsyncOperation::NoOpCallback, failed),
    7273  submitresult(boost::bind(&AsyncOperation::operator(),
    7374      boost::ref(submitOp),
  • src/Fragmentation/Automation/Pool/PoolWorker.hpp

    r9db22d rd57585  
    2121#include <vector>
    2222#include "Connection.hpp"
     23#include "ExitflagContainer.hpp"
    2324#include "Jobs/FragmentJob.hpp"
    2425#include "Operations/Workers/EnrollInPoolOperation.hpp"
     
    3132 *
    3233 */
    33 class PoolWorker
     34class PoolWorker : public ExitflagContainer
    3435{
    3536public:
     
    4748  size_t getFlag() const
    4849  {
    49     return submitOp.getFlag() + PoolListener.getExitflag();
     50    if (PoolListener.getExitflag())
     51      return PoolListener.getExitflag();
     52    if (getExitflag())
     53      return getExitflag();
     54    return 0;
    5055  }
    5156
     
    95100  Connection connection_;
    96101
     102  //!> internally bound function that sets the Exitflag to ErrorFlag
     103  boost::function<void ()> failed;
     104
    97105  //!> operation that handles obtaining a job
    98106  EnrollInPoolOperation enrollOp;
Note: See TracChangeset for help on using the changeset viewer.