/* * FragmentController.hpp * * Created on: Nov 27, 2011 * Author: heber */ #ifndef FRAGMENTCONTROLLER_HPP_ #define FRAGMENTCONTROLLER_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "JobMarket/Connection.hpp" #include "JobMarket/ExitflagContainer.hpp" #include "JobMarket/JobId.hpp" #include "JobMarket/Jobs/FragmentJob.hpp" #include "JobMarket/Results/FragmentResult.hpp" #include "JobMarket/Operations/OperationRegistry.hpp" class FragmentController_JobIdProxy; /** The FragmentController sends bunches of jobs to a FragmentScheduler, * waits for their calculation and is called when they are done. Then, * he loads the bunch of results from the Scheduler. * * While the FragmentScheduler and FragmentWorker rather act on their own * this is the piece to implant into the user software to allow for * communication with the Server/Worker duo to perform the calculation * of the fragments on distant computers. */ class FragmentController : public ExitflagContainer { public: FragmentController(boost::asio::io_service& io_service); ~FragmentController(); void requestIds(const std::string &host, const std::string &service, const size_t NumberIds); JobId_t getAvailableId(); void addJobs(std::vector &jobs); void sendJobs(const std::string &host, const std::string &service); void checkResults(const std::string &host, const std::string &service); std::pair getJobStatus() const; void removeWaitingResults(const std::string &host, const std::string &service); void removeWaitingJobs(const std::string &host, const std::string &service); void removeall(const std::string &host, const std::string &service); void receiveResults(const std::string &host, const std::string &service); std::vector getReceivedResults(); void shutdown(const std::string &host, const std::string &service); protected: void changeJobId(FragmentJob::ptr &job, const JobId_t _newid) const; protected: /// The Connection to the server. Connection connection_; public: //!> registry with all operations of this controller OperationRegistry Commands; private: //!> internally bound function that sets the Exitflag to ErrorFlag boost::function failed; private: //!> grant this specifically made proxy access to jobids friend class FragmentController_JobIdProxy; //!> list of all job ids that the server currently has std::set jobids; }; #endif /* FRAGMENTCONTROLLER_HPP_ */