Samchon Framework for CPP  1.0.0
samchon::templates::distributed::DistributedProcess Class Referenceabstract

#include <DistributedProcess.hpp>

Collaboration diagram for samchon::templates::distributed::DistributedProcess:

Public Member Functions

 DistributedProcess (base::DistributedSystemArrayBase *systemArray)
 
virtual auto key () const -> std::string override
 
template<class SystemArray >
auto getSystemArray () const -> SystemArray *
 
auto getName () const -> std::string
 
auto getResource () const -> double
 
void setResource (double val)
 
void enforceResource (double val)
 
auto sendData (std::shared_ptr< protocol::Invoke > invoke) -> std::shared_ptr< DistributedSystem >
 
virtual auto sendData (std::shared_ptr< protocol::Invoke > invoke, double weight) -> std::shared_ptr< DistributedSystem > override
 
virtual void replyData (std::shared_ptr< protocol::Invoke >)=0
 

Protected Attributes

std::string name
 

Detailed Description

A role of Distributed Processing System.

The DistributedProcess is an abstract class who represents a process, SOMETHING TO DISTRIBUTE in a Distributed Processing System. Overrides the DistributedProcess and defines the SOMETHING TO DISTRIBUTE.

Relationship between DistributedSystem and DistributedProcess objects are M: N Associative. Unlike ExternalSystemRole, the DistributedProcess objects are not belonged to a specific DistributedSystem object. The DistributedProcess objects are belonged to the DistributedSystemArrayMediator directly.

When you need the distributed process, then call sendData(). The sendData will find the most idle slave system considering not only number of processes on progress, but also performance index of each DistributedSystem object and resource index of this DistributedProcess object. The Invoke message requesting the distributed process will be sent to the most idle slave system.

Those performance index and resource index are revaluated whenever the distributed process has completed basis on the execution time.

Class Diagram

Templates - Distributed System

Author
Jeongho Nam http://samchon.org

Definition at line 45 of file DistributedProcess.hpp.

Constructor & Destructor Documentation

samchon::templates::distributed::DistributedProcess::DistributedProcess ( base::DistributedSystemArrayBase *  systemArray)
inline

Constrct from parent DistributedSystemArray object.

Parameters
systemArrayThe parent DistributedSystemArray object.

Definition at line 73 of file DistributedProcess.hpp.

Member Function Documentation

virtual auto samchon::templates::distributed::DistributedProcess::key ( ) const -> std::string
inlineoverridevirtual

Identifier of ParallelProcess is its name.

Reimplemented from samchon::protocol::Entity< std::string >.

Definition at line 95 of file DistributedProcess.hpp.

References name.

template<class SystemArray >
auto samchon::templates::distributed::DistributedProcess::getSystemArray ( ) const -> SystemArray*
inline

Constrct from parent DistributedSystemArray object.

Parameters
systemArrayThe parent DistributedSystemArray object.

Definition at line 106 of file DistributedProcess.hpp.

Referenced by samchon::templates::distributed::DSInvokeHistory::DSInvokeHistory().

Here is the caller graph for this function:

auto samchon::templates::distributed::DistributedProcess::getName ( ) const -> std::string
inline

Get name, who represents and identifies this process.

Definition at line 114 of file DistributedProcess.hpp.

References name.

auto samchon::templates::distributed::DistributedProcess::getResource ( ) const -> double
inline

Get resource index.

Get resource index that indicates how much this role is heavy.

If this role does not have any Invoke message had handled, then the resource index will be 1.0, which means default and average value between all DistributedProcess instances (that are belonged to a same DistributedSystemArray object).

You can specify the resource index by yourself, but notice that, if the resource index is higher than other DistributedProcess objects, then this role will be ordered to handle less processes than other DistributedProcess objects. Otherwise, the resource index is lower than others, of course, much processes will be requested.

Unless enforceResource() is called, This resource index is revaluated whenever sendData() is called.

Returns
Resource index.

Definition at line 141 of file DistributedProcess.hpp.

Referenced by samchon::templates::distributed::DistributedSystemArray< MasterSystem >::construct().

Here is the caller graph for this function:

void samchon::templates::distributed::DistributedProcess::setResource ( double  val)
inline

Set resource index.

Set resource index that indicates how much this role is heavy. This resource index can be revaulated.

Note that, initial and average resource index of DistributedProcess objects are 1.0. If the resource index is higher than other DistributedProcess objects, then this DistributedProcess will be ordered to handle more processes than other DistributedProcess objects. Otherwise, the resource index is lower than others, of course, less processes will be requested.

Unlike enforceResource, configuring resource index by this setResource allows the revaluation. This revaluation prevents wrong valuation from user. For example, you mis-valuated the resource index. The role is much heavier than any other, but you estimated it to the lightest one. It looks like a terrible case that causes entire distributed processing system to be slower, however, don't mind. The role will the direct to the propriate resource index eventually with the revaluation.

  • The revaluation is caused by the sendData() method.
Parameters
valNew resource index, but can be revaluated.

Definition at line 169 of file DistributedProcess.hpp.

Referenced by samchon::templates::distributed::DistributedSystemArray< MasterSystem >::construct().

Here is the caller graph for this function:

void samchon::templates::distributed::DistributedProcess::enforceResource ( double  val)
inline

Enforce resource index.

Enforce resource index that indicates how much heavy the role is. The resource index will be fixed, never be revaluated.

Note that, initial and average resource index of DistributedProcess objects are 1.0. If the resource index is higher than other DistributedProcess objects, then this DistributedProcess will be ordered to handle more processes than other DistributedProcess objects. Otherwise, the resource index is lower than others, of course, less processes will be requested.

The difference between setResource and this enforceResource is allowing revaluation or not. This enforceResource does not allow the revaluation. The resource index is clearly fixed and never be changed by the revaluation. But you've to keep in mind that, you can't avoid the mis-valuation with this enforceResource.

For example, there's a role much heavier than any other, but you mis-estimated it to the lightest. In that case, there's no way. The entire distributed processing system will be slower by the mis-valuation. By the reason, using enforceResource, it's recommended only when you can clearly certain the resource index. If you can't certain the resource index but want to recommend, then use setResource instead.

Parameters
valNew resource index to be fixed.

Definition at line 200 of file DistributedProcess.hpp.

auto samchon::templates::distributed::DistributedProcess::sendData ( std::shared_ptr< protocol::Invoke invoke) -> std::shared_ptr<DistributedSystem>
inline

Send an Invoke message.

Sends an Invoke message requesting a distributed process. The Invoke message will be sent to the most idle DistributedSystem object, which represents a slave system, and the most idle DistributedSystem object will be returned.

When the distributed process has completed, then the DistributedSystemArray object will revaluate resource index and performance index of this DistributedSystem and the most idle DistributedSystem objects basis on the execution time.

Parameters
invokeAn Invoke message requesting distributed process.
Returns
The most idle DistributedSystem object who may send the Invoke message.

Definition at line 224 of file DistributedProcess.hpp.

virtual auto samchon::templates::distributed::DistributedProcess::sendData ( std::shared_ptr< protocol::Invoke invoke,
double  weight 
) -> std::shared_ptr<DistributedSystem>
inlineoverridevirtual

Send an Invoke message.

Sends an Invoke message requesting a distributed process. The Invoke message will be sent to the most idle DistributedSystem object, which represents a slave system, and the most idle DistributedSystem object will be returned.

When the distributed process has completed, then the DistributedSystemArray object will revaluate resource index and performance index of this DistributedSystem and the most idle DistributedSystem objects basis on the execution time.

Parameters
invokeAn Invoke message requesting distributed process.
weightWeight of resource which indicates how heavy this Invoke message is. Default is 1.
Returns
The most idle DistributedSystem object who may send the Invoke message.

Definition at line 245 of file DistributedProcess.hpp.

References replyData(), and samchon::library::UniqueReadLock::unlock().

Here is the call graph for this function:

virtual void samchon::templates::distributed::DistributedProcess::replyData ( std::shared_ptr< protocol::Invoke )
pure virtual

Referenced by sendData().

Here is the caller graph for this function:

Member Data Documentation

std::string samchon::templates::distributed::DistributedProcess::name
protected

A name, represents and identifies this process.

This name is an identifier represents this process. This name is used in DistributedSystemArray.getProcess and DistributedSystemArray.getProcess, as a key elements. Thus, this name should be unique in its parent DistributedSystemArray object.

Definition at line 62 of file DistributedProcess.hpp.

Referenced by getName(), and key().


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