Samchon Framework for CPP  1.0.0
samchon::protocol::master::ParallelSystem Class Reference

A network driver for a parallel system. More...

#include <ParallelSystem.hpp>

Collaboration diagram for samchon::protocol::master::ParallelSystem:

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...
 
- Public Member Functions inherited from samchon::protocol::ExternalSystem
 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...
 
- Public Member Functions inherited from samchon::protocol::EntityGroup< _Container, _ETy, T >
 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...
 
- Public Member Functions inherited from samchon::protocol::Entity
 Entity ()
 Default Constructor. More...
 
- Public Member Functions inherited from samchon::protocol::IEntityGroup
 IEntityGroup ()
 Default Constructor. More...
 
- Public Member Functions inherited from samchon::protocol::IClient
 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...
 
- Public Member Functions inherited from samchon::protocol::IProtocol
 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...
 
- Protected Member Functions inherited from samchon::protocol::IClient
virtual auto BUFFER_SIZE () const -> size_t
 Buffer size of network I/O. More...
 

Protected Attributes

ParallelSystemArraysystemArray
 A master that the system is belonged to. More...
 
PRInvokeHistoryArrayhistoryArray
 A list of history log for reported Invoke messages. More...
 
PRInvokeHistoryArrayprogressArray
 A list of invoke messages on progress. More...
 
double performance
 A performance index. More...
 
- Protected Attributes inherited from samchon::protocol::ExternalSystem
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...
 
- Protected Attributes inherited from samchon::protocol::IClient
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...
 

Detailed Description

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.

protocol_master_parallel_system.png
[Inherited]

Definition at line 41 of file ParallelSystem.hpp.

Constructor & Destructor Documentation

ParallelSystem::ParallelSystem ( )

Default Constructor.

Definition at line 18 of file ParallelSystem.cpp.

References historyArray, performance, progressArray, and systemArray.

Member Function Documentation

void ParallelSystem::construct ( std::shared_ptr< library::XML xml)
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.

[Inherited]
Construct data of the Entity from an XML object.

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.

Parameters
xmlAn 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().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual auto samchon::protocol::master::ParallelSystem::createChild ( std::shared_ptr< library::XML ) -> ExternalSystemRole *override
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().

Returns
A new child Entity belongs to EntityGroup.

Implements samchon::protocol::EntityGroup< _Container, _ETy, T >.

Referenced by construct().

Here is the caller graph for this function:

virtual void samchon::protocol::master::ParallelSystem::_replyData ( std::shared_ptr< Invoke )
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().

  • Archive history log -> cloud service
  • Estimating performance -> distributed and parallel processing system
Parameters
invokeAn invoke message to be pre-processed and shifted to IProtocol::replyData().

Reimplemented from samchon::protocol::IClient.

Referenced by construct().

Here is the caller graph for this function:

void ParallelSystem::sendPieceData ( PRMasterHistory ,
std::shared_ptr< Invoke ,
size_t  ,
size_t   
)
private

Send a message with segmentation index.

Parameters
invokeAn invoke message requesting a process.
startIndexStarting index number of segmentation.
sizeSize of segmentation.

Definition at line 75 of file ParallelSystem.cpp.

References samchon::protocol::IClient::sendData().

Referenced by construct().

Here is the call graph for this function:

Here is the caller graph for this function:

auto ParallelSystem::toXML ( ) const -> std::shared_ptr<library::XML>
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.

[Inherited]
Get an XML object represents the Entity.

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>
Returns
An XML object representing the Entity.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

ParallelSystemArray* samchon::protocol::master::ParallelSystem::systemArray
protected

A master that the system is belonged to.

Definition at line 53 of file ParallelSystem.hpp.

Referenced by ParallelSystem().

PRInvokeHistoryArray* samchon::protocol::master::ParallelSystem::historyArray
protected

A list of history log for reported Invoke messages.

Definition at line 58 of file ParallelSystem.hpp.

Referenced by construct(), and ParallelSystem().

PRInvokeHistoryArray* samchon::protocol::master::ParallelSystem::progressArray
protected

A list of invoke messages on progress.

Definition at line 63 of file ParallelSystem.hpp.

Referenced by construct(), and ParallelSystem().

double samchon::protocol::master::ParallelSystem::performance
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.

  • X = (¥ì + z¥ò)

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().


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