| 1 | /*
|
|---|
| 2 | * FragmentController.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Nov 27, 2011
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef FRAGMENTCONTROLLER_HPP_
|
|---|
| 9 | #define FRAGMENTCONTROLLER_HPP_
|
|---|
| 10 |
|
|---|
| 11 | // include config.h
|
|---|
| 12 | #ifdef HAVE_CONFIG_H
|
|---|
| 13 | #include <config.h>
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | #include <boost/asio.hpp>
|
|---|
| 17 | #include <string>
|
|---|
| 18 | #include <vector>
|
|---|
| 19 |
|
|---|
| 20 | #include "Connection.hpp"
|
|---|
| 21 | #include "FragmentJob.hpp"
|
|---|
| 22 | #include "FragmentResult.hpp"
|
|---|
| 23 |
|
|---|
| 24 | #include "Controller/Commands/Operation.hpp"
|
|---|
| 25 | #include "Controller/Commands/CheckResultsOperation.hpp"
|
|---|
| 26 | #include "Controller/Commands/ReceiveJobsOperation.hpp"
|
|---|
| 27 | #include "Controller/Commands/SendResultsOperation.hpp"
|
|---|
| 28 | #include "Controller/Commands/ShutdownOperation.hpp"
|
|---|
| 29 |
|
|---|
| 30 | /** The FragmentController sends bunches of jobs to a FragmentScheduler,
|
|---|
| 31 | * waits for their calculation and is called when they are done. Then,
|
|---|
| 32 | * he loads the bunch of results from the Scheduler.
|
|---|
| 33 | *
|
|---|
| 34 | * While the FragmentScheduler and FragmentWorker rather act on their own
|
|---|
| 35 | * this is the piece to implant into the user software to allow for
|
|---|
| 36 | * communication with the Server/Worker duo to perform the calculation
|
|---|
| 37 | * of the fragments on distant computers.
|
|---|
| 38 | */
|
|---|
| 39 | class FragmentController
|
|---|
| 40 | {
|
|---|
| 41 | public:
|
|---|
| 42 | FragmentController(boost::asio::io_service& io_service);
|
|---|
| 43 | ~FragmentController();
|
|---|
| 44 |
|
|---|
| 45 | protected:
|
|---|
| 46 | /// The Connection to the server.
|
|---|
| 47 | Connection connection_;
|
|---|
| 48 |
|
|---|
| 49 | public:
|
|---|
| 50 |
|
|---|
| 51 | ReceiveJobsOperation recjobs;
|
|---|
| 52 | CheckResultsOperation checkres;
|
|---|
| 53 | SendResultsOperation sendres;
|
|---|
| 54 | ShutdownOperation shutdown;
|
|---|
| 55 |
|
|---|
| 56 | // get the exit flag of the last operations
|
|---|
| 57 | size_t getExitflag() const
|
|---|
| 58 | {
|
|---|
| 59 | if (recjobs.getExitflag() != 0)
|
|---|
| 60 | return recjobs.getExitflag();
|
|---|
| 61 | if (checkres.getExitflag() != 0)
|
|---|
| 62 | return checkres.getExitflag();
|
|---|
| 63 | if (sendres.getExitflag() != 0)
|
|---|
| 64 | return sendres.getExitflag();
|
|---|
| 65 | if (shutdown.getExitflag() != 0)
|
|---|
| 66 | return shutdown.getExitflag();
|
|---|
| 67 | return 0;
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | };
|
|---|
| 71 |
|
|---|
| 72 | #endif /* FRAGMENTCONTROLLER_HPP_ */
|
|---|