Samchon Framework for CPP
1.0.0
|
A network driver for a parallel system. More...
#include <ParallelSystem.hpp>
Public Member Functions | |
ParallelSystem () | |
Default Constructor. More... | |
virtual void | construct (std::shared_ptr< library::XML >) override |
Construct data of the Entity from an XML object. More... | |
virtual auto | toXML () const -> std::shared_ptr< library::XML > override |
Get an XML object represents the EntityGroup. More... | |
![]() | |
ExternalSystem () | |
Default Constructor. More... | |
virtual void | start ()=0 |
Start interaction. More... | |
virtual auto | key () const -> std::string override |
Get a key that can identify the Entity uniquely. More... | |
virtual void | replyData (std::shared_ptr< Invoke >) override |
Handling replied message from an external system. More... | |
virtual auto | TAG () const -> std::string override |
A tag name when represented by XML. More... | |
virtual auto | CHILD_TAG () const -> std::string override |
A tag name of children. More... | |
![]() | |
EntityGroup () | |
Default Constructor. More... | |
auto | has (const std::string &key) const -> bool |
Indicates whether a container has an object having the specified identifier. More... | |
auto | get (const std::string &key) -> value_type & |
Access the element by specified identifier(key). More... | |
auto | get (const std::string &key) const -> const value_type & |
Access the const element by specified identifier(key). More... | |
![]() | |
Entity () | |
Default Constructor. More... | |
![]() | |
IEntityGroup () | |
Default Constructor. More... | |
![]() | |
IClient () | |
Default Constructor. More... | |
virtual void | listen () |
Listens message from a related system. More... | |
virtual void | sendData (std::shared_ptr< Invoke >) |
Sends message to a related system. More... | |
![]() | |
IProtocol () | |
Default Constructor. More... | |
Protected Member Functions | |
virtual auto | createChild (std::shared_ptr< library::XML >) -> ExternalSystemRole *override |
Factory method of a child Entity. More... | |
virtual void | _replyData (std::shared_ptr< Invoke >) override |
A method for pre-processing replied Invoke message. More... | |
![]() | |
virtual auto | BUFFER_SIZE () const -> size_t |
Buffer size of network I/O. More... | |
Protected Attributes | |
ParallelSystemArray * | systemArray |
A master that the system is belonged to. More... | |
PRInvokeHistoryArray * | historyArray |
A list of history log for reported Invoke messages. More... | |
PRInvokeHistoryArray * | progressArray |
A list of invoke messages on progress. More... | |
double | performance |
A performance index. More... | |
![]() | |
std::string | name |
A name can identify an external system. More... | |
std::string | ip |
An ip address of an external system. More... | |
int | port |
A port number of an external system. More... | |
![]() | |
Socket * | socket |
Socket for network I/O. More... | |
std::mutex * | sendMtx |
A mutex for sending message. More... | |
Private Member Functions | |
void | sendPieceData (PRMasterHistory *, std::shared_ptr< Invoke >, size_t, size_t) |
Send a message with segmentation index. More... | |
A network driver for a parallel system.
ParallelSystem class is an ExternalSystem having performance index and history logs of handled Invoke messages with those elapsed times. Those performance index and history logs are used to determine how much segmentation to be allocated.
Each segmentation in requested process (Invoke message) is equivalent. Thus, role of ParallelSystem objects in a ParallelSystemArray are almost same and does not need to specify ExternalSystemRole on ParallelSystem.
Definition at line 41 of file ParallelSystem.hpp.
ParallelSystem::ParallelSystem | ( | ) |
Default Constructor.
Definition at line 18 of file ParallelSystem.cpp.
References historyArray, performance, progressArray, and systemArray.
|
overridevirtual |
Construct data of the Entity from an XML object.
Constructs the EntityGroup's own member variables only from the input XML object.
Do not consider about constructing children Entity objects' data in EntityGroup::construct(). Those children Entity objects' data will constructed by their own construct() method. Even insertion of XML objects representing children are done by abstract method of EntityGroup::toXML().
Constructs only data of EntityGroup's own.
Overrides the construct() method and fetch data of member variables from the XML.
By recommended guidance, data representing member variables are contained in properties of the put XML object.
xml | An xml used to construct data of entity |
Reimplemented from samchon::protocol::ExternalSystem.
Reimplemented in samchon::protocol::master::ParallelServer.
Definition at line 33 of file ParallelSystem.cpp.
References _replyData(), samchon::protocol::ExternalSystem::construct(), samchon::protocol::EntityGroup< _Container, _ETy, T >::construct(), samchon::protocol::InvokeHistory::construct(), createChild(), samchon::protocol::EntityGroup< _Container, _ETy, T >::get(), samchon::protocol::InvokeHistory::getUID(), samchon::protocol::EntityGroup< _Container, _ETy, T >::has(), historyArray, performance, progressArray, samchon::protocol::ExternalSystem::replyData(), sendPieceData(), and samchon::protocol::InvokeHistoryArray::TAG().
Referenced by samchon::protocol::master::ParallelServer::construct().
|
overrideprotectedvirtual |
Factory method of a child Entity.
EntityGroup::createChild() is a factory method creating a new child Entity which is belonged to the EntityGroup. This method is called by EntityGroup::construct(). The children construction methods Entity::construct() will be called by abstract method of the EntityGroup::construct().
Implements samchon::protocol::EntityGroup< _Container, _ETy, T >.
Referenced by construct().
|
overrideprotectedvirtual |
A method for pre-processing replied Invoke message.
You can realize a pre-processing about the replied Invoke message by overriding the IClient::_replyData().
Archiving a history log, filtering and truncating, let handling the message with a new thread, calculating performance by estimating elapsed time about the Invoke message, and so on. Anything you can define pre-processing works before IProtocol::replyData().
invoke | An invoke message to be pre-processed and shifted to IProtocol::replyData(). |
Reimplemented from samchon::protocol::IClient.
Referenced by construct().
|
private |
Send a message with segmentation index.
invoke | An invoke message requesting a process. |
startIndex | Starting index number of segmentation. |
size | Size of segmentation. |
Definition at line 75 of file ParallelSystem.cpp.
References samchon::protocol::IClient::sendData().
Referenced by construct().
|
overridevirtual |
Get an XML object represents the EntityGroup.
Archives the EntityGroup's own member variables only to the returned XML object.
Do not consider about archiving children Entity objects' data in EntityGroup::toXML(). Those children Entity objects will converted to XML object by their own toXML() method. The insertion of XML objects representing children are done by abstract method of EntityGroup::toXML().
Archives only data of EntityGroup's own.
Returns an XML object that can represents the Entity containing member variables into properties.
A member variable (not object, but atomic value like number, string or date) is categorized as a property within the framework of entity side. Thus, when overriding a toXML() method and archiving member variables to an XML object to return, puts each variable to be a property belongs to only an XML object.
Don't archive the member variable of atomic value to XML::value causing enormouse creation of XML objects to number of member variables. An Entity must be represented by only an XML instance (tag).
Standard Usage | Non-standard usage abusing value |
---|---|
<memberList> <member id='jhnam88' name='Jeongho+Nam' birthdate='1988-03-11' /> <member id='master' name='Administartor' birthdate='2011-07-28' /> </memberList> | <member> <id>jhnam88</id> <name>Jeongho+Nam</name> <birthdate>1988-03-11</birthdate> </member> |
Reimplemented from samchon::protocol::ExternalSystem.
Reimplemented in samchon::protocol::master::ParallelServer.
Definition at line 100 of file ParallelSystem.cpp.
References performance, and samchon::protocol::ExternalSystem::toXML().
Referenced by samchon::protocol::master::ParallelServer::toXML().
|
protected |
A master that the system is belonged to.
Definition at line 53 of file ParallelSystem.hpp.
Referenced by ParallelSystem().
|
protected |
A list of history log for reported Invoke messages.
Definition at line 58 of file ParallelSystem.hpp.
Referenced by construct(), and ParallelSystem().
|
protected |
A list of invoke messages on progress.
Definition at line 63 of file ParallelSystem.hpp.
Referenced by construct(), and ParallelSystem().
|
protected |
A performance index.
A performance index z is calculated by normalization calculating reverse number of
whole parallel system's average elapsed times and its z value between the normal distribution.
If a parallel system has no history of handling Invoke message, then set the performance index to 0 as default. The performance index will be re-calcuated whenever segmented process has sent (ParallelSystemArray::sendData(Invoke, size_t)).
Definition at line 79 of file ParallelSystem.hpp.
Referenced by construct(), samchon::protocol::master::ParallelSystemArray::notifyEnd(), ParallelSystem(), and toXML().