Changeset 78ad7d for src/Fragmentation
- Timestamp:
- Jun 22, 2012, 3:21:25 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:
- f0834d
- Parents:
- 142ff5
- git-author:
- Frederik Heber <heber@…> (02/06/12 08:43:07)
- git-committer:
- Frederik Heber <heber@…> (06/22/12 15:21:25)
- Location:
- src/Fragmentation/Automation
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Automation/Controller/Commands/ReceiveJobsOperation.cpp
r142ff5 r78ad7d 114 114 * \param _jobs jobs to add 115 115 */ 116 void ReceiveJobsOperation::addJobs(const std::vector<FragmentJob > &_jobs)116 void ReceiveJobsOperation::addJobs(const std::vector<FragmentJob::ptr> &_jobs) 117 117 { 118 118 jobs.reserve(jobs.size()+_jobs.size()); 119 BOOST_FOREACH(FragmentJob job, _jobs) {119 BOOST_FOREACH(FragmentJob::ptr job, _jobs) { 120 120 jobs.push_back(job); 121 121 } -
src/Fragmentation/Automation/Controller/Commands/ReceiveJobsOperation.hpp
r142ff5 r78ad7d 40 40 41 41 /// Setter for jobs 42 void addJobs(const std::vector<FragmentJob > &jobs);42 void addJobs(const std::vector<FragmentJob::ptr> &jobs); 43 43 44 44 /** Getter for number of jobs present in the queue. … … 55 55 56 56 /// bunch of jobs 57 std::vector<FragmentJob > jobs;57 std::vector<FragmentJob::ptr> jobs; 58 58 }; 59 59 -
src/Fragmentation/Automation/FragmentJob.hpp
r142ff5 r78ad7d 16 16 #include <string> 17 17 18 #include "boost/serialization/array.hpp" 18 #include "boost/shared_ptr.hpp" 19 #include "boost/serialization/access.hpp" 20 #include "boost/serialization/shared_ptr.hpp" 19 21 20 22 #include "FragmentResult.hpp" … … 39 41 friend class FragmentJobTest; 40 42 public: 43 typedef boost::shared_ptr<FragmentJob> ptr; 44 41 45 FragmentJob(); 42 46 FragmentJob(const std::string &_command, const std::string &_outputfile, const JobId_t _JobId); -
src/Fragmentation/Automation/FragmentQueue.cpp
r142ff5 r78ad7d 38 38 */ 39 39 FragmentQueue::~FragmentQueue() 40 {} 40 { 41 jobs.clear(); 42 results.clear(); 43 } 41 44 42 45 /** Checks whether there are jobs in the queue at all. … … 54 57 * \param job job to enter into queue 55 58 */ 56 void FragmentQueue::pushJob(FragmentJob &job)57 { 58 ASSERT(job .getId() != JobId::IllegalJob,59 void FragmentQueue::pushJob(FragmentJob::ptr job) 60 { 61 ASSERT(job->getId() != JobId::IllegalJob, 59 62 "FragmentQueue::pushJob() - job to push has IllegalJob id."); 60 ASSERT(!results.count(job .getId()),61 "FragmentQueue::pushJob() - job id "+toString(job .getId())+" has already been used.");62 results.insert( std::make_pair(job .getId(), NoResult));63 ASSERT(!results.count(job->getId()), 64 "FragmentQueue::pushJob() - job id "+toString(job->getId())+" has already been used."); 65 results.insert( std::make_pair(job->getId(), NoResult)); 63 66 jobs.push_back(job); 64 67 } … … 72 75 * \param _jobs jobs to enter into queue 73 76 */ 74 void FragmentQueue::pushJobs(std::vector<FragmentJob > &_jobs)75 { 76 for (std::vector<FragmentJob >::iterator iter = _jobs.begin();77 void FragmentQueue::pushJobs(std::vector<FragmentJob::ptr> &_jobs) 78 { 79 for (std::vector<FragmentJob::ptr>::iterator iter = _jobs.begin(); 77 80 iter != _jobs.end(); ++iter) 78 81 pushJob(*iter); … … 85 88 * \return job topmost job from queue 86 89 */ 87 FragmentJob FragmentQueue::popJob()90 FragmentJob::ptr FragmentQueue::popJob() 88 91 { 89 92 ASSERT(jobs.size(), 90 93 "FragmentQueue::popJob() - there are no jobs on the queue."); 91 FragmentJob job = jobs.front();92 ResultMap::iterator iter = results.find(job .getId());94 FragmentJob::ptr job = jobs.front(); 95 ResultMap::iterator iter = results.find(job->getId()); 93 96 ASSERT(iter != results.end(), 94 "FragmentQueue::popJob() - for job "+toString(job .getId())+" no result place has been stored.");97 "FragmentQueue::popJob() - for job "+toString(job->getId())+" no result place has been stored."); 95 98 iter->second = NoResultQueued; 96 99 jobs.pop_front(); -
src/Fragmentation/Automation/FragmentQueue.hpp
r142ff5 r78ad7d 36 36 37 37 // entering jobs into queue 38 void pushJob(FragmentJob &job);39 void pushJobs(std::vector<FragmentJob > &_jobs);40 FragmentJob popJob();38 void pushJob(FragmentJob::ptr job); 39 void pushJobs(std::vector<FragmentJob::ptr> &_jobs); 40 FragmentJob::ptr popJob(); 41 41 bool isJobPresent() const; 42 42 … … 59 59 static FragmentResult ResultDelivered; 60 60 61 typedef std::deque<FragmentJob > JobQueue;61 typedef std::deque<FragmentJob::ptr> JobQueue; 62 62 typedef std::map<JobId_t, FragmentResult> ResultMap; 63 63 -
src/Fragmentation/Automation/FragmentScheduler.cpp
r142ff5 r78ad7d 39 39 #include "FragmentScheduler.hpp" 40 40 41 FragmentJob FragmentScheduler::NoJob(std::string("/bin/false"), std::string("NoJob"), JobId::NoJob);41 FragmentJob::ptr FragmentScheduler::NoJob(new FragmentJob(std::string("/bin/false"), std::string("NoJob"), JobId::NoJob)); 42 42 43 43 /** Constructor of class FragmentScheduler. … … 115 115 if (JobsQueue.isJobPresent()) { 116 116 // pop a job and send it to the client. 117 FragmentJob job(JobsQueue.popJob());117 FragmentJob::ptr job(JobsQueue.popJob()); 118 118 // The connection::async_write() function will automatically 119 119 // serialize the data structure for us. 120 LOG(1, "INFO: Sending job #" << job .getId() << ".");120 LOG(1, "INFO: Sending job #" << job->getId() << "."); 121 121 conn->async_write(job, 122 122 boost::bind(&FragmentScheduler::handle_SendJobtoWorker, this, -
src/Fragmentation/Automation/FragmentScheduler.hpp
r142ff5 r78ad7d 94 94 95 95 /// bunch of jobs received from controller before placed in JobsQueue 96 std::vector<FragmentJob > jobs;96 std::vector<FragmentJob::ptr> jobs; 97 97 98 98 /// number of jobs that are calculated, required for returning status … … 106 106 107 107 // static entity to indicate to clients that the queue is empty. 108 static FragmentJob NoJob;108 static FragmentJob::ptr NoJob; 109 109 110 110 // Exit flag on program exit -
src/Fragmentation/Automation/FragmentWorker.cpp
r142ff5 r78ad7d 99 99 if (!e) 100 100 { 101 LOG(1, "INFO: Received job #" << job .getId() << ".");102 if (job .getId() != JobId::NoJob) {101 LOG(1, "INFO: Received job #" << job->getId() << "."); 102 if (job->getId() != JobId::NoJob) { 103 103 // Print out the data that was received. 104 std::cout << "Job output: " << job .outputfile << "\n";105 std::cout << "Job id: " << job .getId() << "\n";104 std::cout << "Job output: " << job->outputfile << "\n"; 105 std::cout << "Job id: " << job->getId() << "\n"; 106 106 107 107 // do something .. right now: wait 108 LOG(1, "INFO: Calculating job #" << job .getId() << " ...");109 FragmentResult result(job .Work());108 LOG(1, "INFO: Calculating job #" << job->getId() << " ..."); 109 FragmentResult result(job->Work()); 110 110 111 111 // write the result to the server 112 LOG(1, "INFO: Sending result for job #" << job .getId() << " ...");112 LOG(1, "INFO: Sending result for job #" << job->getId() << " ..."); 113 113 connection_.async_write(result, 114 114 boost::bind(&FragmentWorker::handle_SendResult, this, … … 141 141 Info info(__FUNCTION__); 142 142 // Nothing to do. 143 LOG(1, "INFO: Job #" << job .getId() << " calculated and sent.");143 LOG(1, "INFO: Job #" << job->getId() << " calculated and sent."); 144 144 // erase job 145 job = FragmentJob ();145 job = FragmentJob::ptr(new FragmentJob()); 146 146 } 147 147 -
src/Fragmentation/Automation/FragmentWorker.hpp
r142ff5 r78ad7d 62 62 63 63 /// The data received from the server. 64 FragmentJob job;64 FragmentJob::ptr job; 65 65 66 66 /// The result created to be sent to the server. -
src/Fragmentation/Automation/controller.cpp
r142ff5 r78ad7d 50 50 }; 51 51 52 void createjobs(std::vector<FragmentJob > &jobs)53 { 54 FragmentJob testJob(std::string("cat"), std::string("Nothing"), 1);55 FragmentJob othertestJob(std::string("cat"), std::string("Nothing"), 2);52 void createjobs(std::vector<FragmentJob::ptr> &jobs) 53 { 54 FragmentJob::ptr testJob( new FragmentJob( std::string("cat"), std::string("Nothing"), 1) ); 55 FragmentJob::ptr othertestJob( new FragmentJob( std::string("cat"), std::string("Nothing"), 2) ); 56 56 jobs.push_back(testJob); 57 57 jobs.push_back(othertestJob); 58 58 } 59 59 60 void addjobs(FragmentController &controller, std::vector<FragmentJob > &jobs)60 void addjobs(FragmentController &controller, std::vector<FragmentJob::ptr> &jobs) 61 61 { 62 62 ReceiveJobsOperation *recjobs = static_cast<ReceiveJobsOperation *>( … … 156 156 case SendJobsIndex: 157 157 { 158 std::vector<FragmentJob > jobs;158 std::vector<FragmentJob::ptr> jobs; 159 159 createjobs(jobs); 160 160 addjobs(controller, jobs); -
src/Fragmentation/Automation/unittests/FragmentJobUnitTest.cpp
r142ff5 r78ad7d 62 62 void FragmentJobTest::equalityTest() 63 63 { 64 FragmentJob testJob(command, outputfile, 1);65 FragmentJob sameIdJob(command, outputfile, 1);66 FragmentJob otherIdJob(command, outputfile, 2);67 FragmentJob copiedJob(testJob);68 FragmentJob copiedchangedJob(testJob);69 copiedchangedJob .setId(3);64 FragmentJob::ptr testJob(new FragmentJob(command, outputfile, 1)); 65 FragmentJob::ptr sameIdJob(new FragmentJob(command, outputfile, 1)); 66 FragmentJob::ptr otherIdJob(new FragmentJob(command, outputfile, 2)); 67 FragmentJob::ptr copiedJob(new FragmentJob(*testJob)); 68 FragmentJob::ptr copiedchangedJob(new FragmentJob(*testJob)); 69 copiedchangedJob->setId(3); 70 70 71 CPPUNIT_ASSERT( testJob ==sameIdJob );72 CPPUNIT_ASSERT( testJob !=otherIdJob );73 CPPUNIT_ASSERT( testJob ==copiedJob );74 CPPUNIT_ASSERT( testJob !=copiedchangedJob );71 CPPUNIT_ASSERT( *testJob == *sameIdJob ); 72 CPPUNIT_ASSERT( *testJob != *otherIdJob ); 73 CPPUNIT_ASSERT( *testJob == *copiedJob ); 74 CPPUNIT_ASSERT( *testJob != *copiedchangedJob ); 75 75 } 76 76 … … 79 79 void FragmentJobTest::WorkTest() 80 80 { 81 FragmentJob testJob(command, outputfile, 1);82 FragmentJob othertestJob(command, outputfile, 2);81 FragmentJob::ptr testJob(new FragmentJob(command, outputfile, 1)); 82 FragmentJob::ptr othertestJob(new FragmentJob(command, outputfile, 2)); 83 83 84 FragmentResult testResult(testJob .Work());85 FragmentResult othertestResult(othertestJob .Work());84 FragmentResult testResult(testJob->Work()); 85 FragmentResult othertestResult(othertestJob->Work()); 86 86 87 87 CPPUNIT_ASSERT_EQUAL( (JobId_t)1, testResult.getId() ); … … 93 93 void FragmentJobTest::serializationTest() 94 94 { 95 FragmentJob testJob(command, outputfile, 1);95 FragmentJob::ptr testJob(new FragmentJob(command, outputfile, 1)); 96 96 // write element to stream 97 97 std::stringstream stream; … … 104 104 boost::archive::text_iarchive ia(stream); 105 105 // read class state from archive 106 FragmentJob otherJob;106 FragmentJob::ptr otherJob; 107 107 108 108 ia >> otherJob; 109 109 110 CPPUNIT_ASSERT ( testJob ==otherJob);110 CPPUNIT_ASSERT (*testJob == *otherJob); 111 111 } 112 112 -
src/Fragmentation/Automation/unittests/FragmentQueueUnitTest.cpp
r142ff5 r78ad7d 58 58 void FragmentQueueTest::JobTest() 59 59 { 60 FragmentJob testJob;60 FragmentJob::ptr testJob(new FragmentJob); 61 61 /// check for illegal id 62 62 #ifndef NDEBUG … … 65 65 #endif 66 66 // set to valid id 67 testJob .setId(1);68 testJob .outputfile = std::string("do something");67 testJob->setId(1); 68 testJob->outputfile = std::string("do something"); 69 69 70 70 CPPUNIT_ASSERT_EQUAL(false, queue->isJobPresent() ); … … 94 94 CPPUNIT_ASSERT_EQUAL((size_t)1, queue->results.size()); 95 95 96 FragmentJob poppedJob;96 FragmentJob::ptr poppedJob; 97 97 #ifndef NDEBUG 98 98 CPPUNIT_ASSERT_NO_THROW( poppedJob = queue->popJob() ); … … 122 122 { 123 123 // prepare some jobs 124 FragmentJob testJob;125 testJob .setId((JobId_t)1);126 testJob .outputfile = std::string("do something");127 FragmentJob anothertestJob;128 anothertestJob .setId((JobId_t)2);129 anothertestJob .outputfile = std::string("do something else");124 FragmentJob::ptr testJob(new FragmentJob); 125 testJob->setId((JobId_t)1); 126 testJob->outputfile = std::string("do something"); 127 FragmentJob::ptr anothertestJob(new FragmentJob); 128 anothertestJob->setId((JobId_t)2); 129 anothertestJob->outputfile = std::string("do something else"); 130 130 131 131 // prepare a vector of them 132 std::vector<FragmentJob > testjobs;132 std::vector<FragmentJob::ptr> testjobs; 133 133 testjobs.push_back(testJob); 134 134 testjobs.push_back(anothertestJob); 135 135 136 136 // prepare another vector of them 137 std::vector<FragmentJob > sametestjobs;137 std::vector<FragmentJob::ptr> sametestjobs; 138 138 sametestjobs.push_back(testJob); 139 139 sametestjobs.push_back(anothertestJob); … … 173 173 { 174 174 // prepare a job 175 FragmentJob testJob;176 testJob .setId(1);177 testJob .outputfile = std::string("do something");175 FragmentJob::ptr testJob(new FragmentJob); 176 testJob->setId(1); 177 testJob->outputfile = std::string("do something"); 178 178 #ifndef NDEBUG 179 179 CPPUNIT_ASSERT_NO_THROW( queue->pushJob(testJob) ); … … 240 240 { 241 241 // prepare a job 242 FragmentJob testJob;243 testJob .setId(1);244 testJob .outputfile = std::string("do something");245 FragmentJob anothertestJob;246 anothertestJob .setId(2);247 anothertestJob .outputfile = std::string("do something else");242 FragmentJob::ptr testJob( new FragmentJob ); 243 testJob->setId(1); 244 testJob->outputfile = std::string("do something"); 245 FragmentJob::ptr anothertestJob( new FragmentJob ); 246 anothertestJob->setId(2); 247 anothertestJob->outputfile = std::string("do something else"); 248 248 249 249 #ifndef NDEBUG
Note:
See TracChangeset
for help on using the changeset viewer.