ReCodEx - Task Broker
ReCodEx is complex programmer testing solution, primary targeted to technical universities. It's highly customizable and based on modern technologies.
worker Class Reference

#include <worker.h>

Public Types

typedef std::shared_ptr< requestrequest_ptr
 

Public Member Functions

 worker (const std::string &id, const std::string &hwgroup, const std::multimap< std::string, std::string > &headers)
 
virtual ~worker ()
 
bool headers_equal (const std::multimap< std::string, std::string > &other)
 
virtual bool check_header (const std::string &header, const std::string &value)
 
virtual void enqueue_request (request_ptr request)
 
virtual void complete_request ()
 
virtual request_ptr cancel_request ()
 
virtual bool next_request ()
 
virtual std::shared_ptr< const requestget_current_request () const
 
virtual std::shared_ptr< std::vector< request_ptr > > terminate ()
 
std::string get_description () const
 

Public Attributes

const std::string identity
 
std::string description = ""
 
const std::string hwgroup
 
size_t liveness
 

Detailed Description

Contains information about a worker machine.

Definition at line 147 of file worker.h.

Member Typedef Documentation

§ request_ptr

typedef std::shared_ptr<request> worker::request_ptr

Pointer to evauate request type.

Definition at line 151 of file worker.h.

Constructor & Destructor Documentation

§ worker()

worker::worker ( const std::string &  id,
const std::string &  hwgroup,
const std::multimap< std::string, std::string > &  headers 
)
Parameters
idWorker unique identifier.
hwgroupWorker handrware group identifier.
headersHeaders describing worker capabilities.

Definition at line 89 of file worker.cpp.

§ ~worker()

worker::~worker ( )
virtual

Stated for completion.

Definition at line 106 of file worker.cpp.

Member Function Documentation

§ cancel_request()

worker::request_ptr worker::cancel_request ( )
virtual

Consider the current request failed. Called when the worker machine fails to process the request. The machine is then considered free.

Returns
a pointer to the cancelled request

Definition at line 121 of file worker.cpp.

§ check_header()

bool worker::check_header ( const std::string &  header,
const std::string &  value 
)
virtual

Check if the worker satisfies given header.

Parameters
headerName of the header.
valueValue to be checked against the header.

Definition at line 170 of file worker.cpp.

§ complete_request()

void worker::complete_request ( )
virtual

Consider the current request complete. Called when the actual worker machine successfully processes the request.

Definition at line 115 of file worker.cpp.

§ enqueue_request()

void worker::enqueue_request ( request_ptr  request)
virtual

Insert a request into the workers queue.

Parameters
requestA pointer to the request.

Definition at line 110 of file worker.cpp.

§ get_current_request()

std::shared_ptr< const request > worker::get_current_request ( ) const
virtual

Get the request that is now being processed.

Returns
Pointer to currently processed request or nullptr.

Definition at line 146 of file worker.cpp.

§ get_description()

std::string worker::get_description ( ) const

Get a textual description of the worker

Returns
textual description of the worker

Definition at line 191 of file worker.cpp.

§ headers_equal()

bool worker::headers_equal ( const std::multimap< std::string, std::string > &  other)

Check if the worker's headers are equal to given set of headers

Parameters
otherThe set of headers to check

Definition at line 186 of file worker.cpp.

§ next_request()

bool worker::next_request ( )
virtual

If possible, take a request from the queue and start processing it.

Returns
true if and only if the worker started processing a new request.

Definition at line 133 of file worker.cpp.

§ terminate()

std::shared_ptr< std::vector< worker::request_ptr > > worker::terminate ( )
virtual

Forget all requests (currently processed and queued). Called when the worker is considered dead.

Returns
Current request and all requests from waiting queue.

Definition at line 151 of file worker.cpp.

Member Data Documentation

§ description

std::string worker::description = ""

An optional human readable description

Definition at line 174 of file worker.h.

§ hwgroup

const std::string worker::hwgroup

A hardware group identifier.

Definition at line 177 of file worker.h.

§ identity

const std::string worker::identity

A unique identifier of the worker.

Definition at line 171 of file worker.h.

§ liveness

size_t worker::liveness

The amount of pings the worker can miss before it's considered dead.

Definition at line 180 of file worker.h.


The documentation for this class was generated from the following files: