1 | /*
|
---|
2 | * CheckAliveWorkerOperation.hpp
|
---|
3 | *
|
---|
4 | * Created on: Sep 05, 2012
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef FRAGMENTCONTROLLER_CHECKALIVEWORKEROPERATION_HPP_
|
---|
9 | #define FRAGMENTCONTROLLER_CHECKALIVEWORKEROPERATION_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 "JobMarket/Connection.hpp"
|
---|
21 |
|
---|
22 | #include "JobMarket/Jobs/FragmentJob.hpp"
|
---|
23 | #include "JobMarket/Jobs/SystemCommandJob.hpp"
|
---|
24 | #include "JobMarket/Operations/AsyncOperation.hpp"
|
---|
25 | #include "JobMarket/WorkerAddress.hpp"
|
---|
26 |
|
---|
27 | class CheckAliveWorkerOperation : public AsyncOperation {
|
---|
28 | public:
|
---|
29 | /** Constructor for class CheckAliveWorkerOperation.
|
---|
30 | *
|
---|
31 | * @param _connection connection for operation
|
---|
32 | */
|
---|
33 | CheckAliveWorkerOperation(Connection &_connection,
|
---|
34 | const boost::function<void (const WorkerAddress )> _checkAddress,
|
---|
35 | const boost::function<void ()> _callback_on_success = NoOpCallback,
|
---|
36 | const boost::function<void ()> _callback_on_failure = NoOpCallback) :
|
---|
37 | AsyncOperation(std::string("checkaliveworker"),_connection, _callback_on_success, _callback_on_failure),
|
---|
38 | address("127.0.0.1", "0"),
|
---|
39 | checkAddress(_checkAddress)
|
---|
40 | {}
|
---|
41 | // /** Constructor for class CheckAliveWorkerOperation.
|
---|
42 | // *
|
---|
43 | // * @param _connection connection for operation
|
---|
44 | // * @param _job job to send to worker
|
---|
45 | // */
|
---|
46 | // CheckAliveWorkerOperation(Connection &_connection) :
|
---|
47 | // AsyncOperation(std::string("checkaliveworker"),_connection),
|
---|
48 | // address("127.0.0.1", "0")
|
---|
49 | // {}
|
---|
50 | /// Destructor for class CheckAliveWorkerOperation
|
---|
51 | ~CheckAliveWorkerOperation() {}
|
---|
52 |
|
---|
53 | public:
|
---|
54 | // virtual function pointer to the connection handler
|
---|
55 | virtual void handle_connect(const boost::system::error_code& e,
|
---|
56 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
|
---|
57 |
|
---|
58 | // handler function when after sending choice to receive alive signal
|
---|
59 | void handle_ReceiveAddress(const boost::system::error_code& e);
|
---|
60 |
|
---|
61 | // handler function when after having received worker's address
|
---|
62 | void handle_CheckAddress(const boost::system::error_code& e);
|
---|
63 |
|
---|
64 | private:
|
---|
65 | //!> address of worker as its alive signal
|
---|
66 | WorkerAddress address;
|
---|
67 |
|
---|
68 | //!> callback function to check address
|
---|
69 | boost::function<void (const WorkerAddress )> checkAddress;
|
---|
70 | };
|
---|
71 |
|
---|
72 | #endif /* FRAGMENTCONTROLLER_CHECKALIVEWORKEROPERATION_HPP_ */
|
---|