theLink 10.0
Loading...
Searching...
No Matches
MqContextC_SlaveApi_Slave_CC_API

MqContextC - create and manage a slave context … More...

+ Collaboration diagram for MqContextC_SlaveApi_Slave_CC_API:

Functions

MqContextCccmqmsgque::MqContextC::SlaveGetMaster ()
  C++: MqContextC* ctx.SlaveGetMaster() C-API
opposite function of MqSlaveGetFilter
 
MqContextCccmqmsgque::MqContextC::SlaveGet (MQ_SLAVE_ID id)
  C++: MqContextC* ctx.SlaveGet(MQ_SLAVE_ID id) C-API
get the slave-context from a master-context
 
MqContextCccmqmsgque::MqContextC::SlaveGetFilter ()
  C++: MqContextC* ctx.SlaveGetFilter() C-API
get the filter-ctx or the master-ctx
 
MqContextCccmqmsgque::MqContextC::SlaveGetProxy (MQ_SLAVE_ID id)
  C++: MqContextC* ctx.SlaveGetProxy(MQ_SLAVE_ID id) C-API
on slave return the master and on master return the slave identified by id.
 
MK_BOOL ccmqmsgque::MqContextC::SlaveCheck (MQ_SLAVE_ID id) const
  C++: MK_BOOL ctx.SlaveCheck(MQ_SLAVE_ID id) C-API
check if slave-id is valid
 
void ccmqmsgque::MqContextC::SlaveCreate (MQ_SLAVE_ID id, MqContextC *slave)
  C++: ctx.SlaveCreate(MQ_SLAVE_ID id, MqContextC* slave) C-API
create a master/slave link between the master-parent-context and the slave-parent-context …
 
void ccmqmsgque::MqContextC::SlaveCreate (MQ_SLAVE_ID id, const MqContextC &slave)
  C++: ctx.SlaveCreate(MQ_SLAVE_ID id, MqContextC* slave) C-API
create a master/slave link between the master-parent-context and the slave-parent-context …
 
void ccmqmsgque::MqContextC::SlaveDelete (MQ_SLAVE_ID id)
  C++: ctx.SlaveDelete(MQ_SLAVE_ID id) C-API
Delete a slave object from a master/slave link identified by id. …
 
MK_BOOL ccmqmsgque::MqContextC::SlaveIs () const
  C++: MK_BOOL ctx.SlaveIs() C-API
is the context a slave-context ? …
 
void ccmqmsgque::MqContextC::SlaveWorker (MQ_SLAVE_ID id, MK_STRN fct="WORKER", MkBufferListC *args=NULL)
  C++: ctx.SlaveWorker(MQ_SLAVE_ID id, MK_STRN fct = "WORKER", MkBufferListC* args = NULL) C-API
create a master/slave link using the image of the ctx object self. …
 
void ccmqmsgque::MqContextC::SlaveWorker (MK_NUM id, MK_STRN factory, const MkBufferListC &args)
  C++: ctx.SlaveWorker(MQ_SLAVE_ID id, MK_STRN fct = "WORKER", MkBufferListC* args = NULL) C-API
create a master/slave link using the image of the ctx object self. …
 

Detailed Description

MqContextC - create and manage a slave context …

The master-slave-link is used to create a mesh of nodes defined by different parent-context. The master control the slave.

The master-slave-link is used to perform the following tasks:

In difference to the client-server-link the master-slave-link connect two independent parent-context in the same process or thread (e.g. node). This leads to the restriction that only the master-context can be a server-context because only one server-context per node is possible.

   node-0   |           node-1/2        |   node-3/4/5
===================================================================

| <- client/server link -> | <- client/server link -> |

             | <-- master/slave link --> |

                           |- client1-0 -|- server3 ...
             |-  server1  -|
             |             |- client1-1 -|- server4 ...
  client0-0 -|
             |-  server2  -|- client1-2 -|- server5 ...

Definition of the "master-context"

Definition of the "slave-context"

Definition of the "worker-context"

Definition of the "slave-id"

Definition of the "LOOPBACK" (0) slave

Performance analyse

The performance-test is created with:
  • pipe
    • Nhi1Exec perfclient.c --parent --wrk ? @ perfserver.c
  • spawn, fork, thread
    • Nhi1Exec -r=uds perfserver.c --spawn|fork|thread
    • Nhi1Exec -r=uds perfclient.c --parent --wrk ?
  • the number of workers are set with the –wrk option
  • the cpu is a xeon with 4/8
  • the performance is calculated as worker-context-created / time-in-sec with a ~2sec (default) measurement period.
performance-test code:
  • The test-setup is done as:
      perfclient                                worker                            perfserver
      ==========                                ======                            ==========
      |
      |- loop --wrk x
        |- MqSlaveWorker(...)               ->  worker[1] 
        |- MqSend(worker[1],"E","STR0..")   ->  PerfWorker_I160(...)
                                                |- loop endless
                                                  |- MqContextCreate(...)
                                                  |- MqLinkCreate(...)      <->   MqContextCreate(...)
                                                  |- MqContextDelete(...)   <->   MqContextDelete(...)
      |- sleep x sec
      |- loop --wrk x
        |- MqSend(worker[1],"C"..,"END0")   ->  PerfWorker_END0(...)
        |                                       |- stop loop
        |- "callback" - add number to all   <-  |- return #context 
performance-test results:
  • results generated using the debug environment
    setup –wrk # worker-context performance info
    pipe 1 2500 1000 the pipe start a new worker-context with spawn
    spawn 1 2500 <1000 same as pipe but use network-protocoll
    fork 1 3800 4000 the fork is faster than spawn
    thread 1 16500 9000 the thread is faster than fork
    pipe 4 8000 4500 the worker scale linear up to number of processors
    spawn 4 7600 <4500 -
    fork 4 23200 11500 -
    thread 4 55500 27500 -
    pipe 8 10000 5500 the additional scaling up to the max hyper-threading does not really help
    spawn 8 9100 <5500 -
    fork 8 23200 11500 -
    thread 8 55500 27500 -

The master-slave-link is used to create a mesh of nodes defined by different parent-context. The master control the slave.

The master-slave-link is used to perform the following tasks:

In difference to the client-server-link the master-slave-link connect two independent parent-context in the same process or thread (e.g. node). This leads to the restriction that only the master-context can be a server-context because only one server-context per node is possible.

   node-0   |           node-1/2        |   node-3/4/5
===================================================================

| <- client/server link -> | <- client/server link -> |

             | <-- master/slave link --> |

                           |- client1-0 -|- server3 ...
             |-  server1  -|
             |             |- client1-1 -|- server4 ...
  client0-0 -|
             |-  server2  -|- client1-2 -|- server5 ...

Definition of the "master-context"

Definition of the "slave-context"

Definition of the "worker-context"

Definition of the "slave-id"

Definition of the "LOOPBACK" (0) slave

Performance analyse

The performance-test is created with:
  • pipe
    • Nhi1Exec perfclient.c --parent --wrk ? @ perfserver.c
  • spawn, fork, thread
    • Nhi1Exec -r=uds perfserver.c --spawn|fork|thread
    • Nhi1Exec -r=uds perfclient.c --parent --wrk ?
  • the number of workers are set with the –wrk option
  • the cpu is a xeon with 4/8
  • the performance is calculated as worker-context-created / time-in-sec with a ~2sec (default) measurement period.
performance-test code:
  • The test-setup is done as:
      perfclient                                worker                            perfserver
      ==========                                ======                            ==========
      |
      |- loop --wrk x
        |- MqSlaveWorker(...)               ->  worker[1] 
        |- MqSend(worker[1],"E","STR0..")   ->  PerfWorker_I160(...)
                                                |- loop endless
                                                  |- MqContextCreate(...)
                                                  |- MqLinkCreate(...)      <->   MqContextCreate(...)
                                                  |- MqContextDelete(...)   <->   MqContextDelete(...)
      |- sleep x sec
      |- loop --wrk x
        |- MqSend(worker[1],"C"..,"END0")   ->  PerfWorker_END0(...)
        |                                       |- stop loop
        |- "callback" - add number to all   <-  |- return #context 
performance-test results:
  • results generated using the debug environment
    setup –wrk # worker-context performance info
    pipe 1 2500 1000 the pipe start a new worker-context with spawn
    spawn 1 2500 <1000 same as pipe but use network-protocoll
    fork 1 3800 4000 the fork is faster than spawn
    thread 1 16500 9000 the thread is faster than fork
    pipe 4 8000 4500 the worker scale linear up to number of processors
    spawn 4 7600 <4500 -
    fork 4 23200 11500 -
    thread 4 55500 27500 -
    pipe 8 10000 5500 the additional scaling up to the max hyper-threading does not really help
    spawn 8 9100 <5500 -
    fork 8 23200 11500 -
    thread 8 55500 27500 -

Function Documentation

◆ SlaveCheck()

MK_BOOL ccmqmsgque::MqContextC::SlaveCheck ( MQ_SLAVE_ID id) const
inline

C++: MK_BOOL ctx.SlaveCheck(MQ_SLAVE_ID id) C-API
check if slave-id is valid

Definition at line 2168 of file MqContextC_inline_cc.hh.

2168 {
2169 MK_UNUSED auto ctx = getCTXN();
2170 MK_BOOL __retVal__L = MqSlaveCheck(ctx, id);
2171 return __retVal__L;
2172 }
#define MK_UNUSED
MQ_CTXN getCTXN() const
(const) return the LibMsgqueObject from current MqContextC instance
static bool MqSlaveCheck(MQ_CTXN const ctx, MQ_SLAVE_ID const id)
check if slave-id is valid

◆ SlaveCreate() [1/2]

void ccmqmsgque::MqContextC::SlaveCreate ( MQ_SLAVE_ID id,
const MqContextC & slave )
inline

C++: ctx.SlaveCreate(MQ_SLAVE_ID id, MqContextC* slave) C-API
create a master/slave link between the master-parent-context and the slave-parent-context …

Definition at line 2183 of file MqContextC_inline_cc.hh.

2183 {
2184 MK_UNUSED auto ctx = getCTX();
2185 const MQ_CTX slave_hdl = MqContextC::getCTX(slave);
2186 enum MkErrorE errVal = MqSlaveCreate(ctx, id, slave_hdl);
2187 MkErrorC_Check(ctx, errVal);
2188 }
MQ_CTX getCTX() const
return the LibMsgqueObject from current MqContextC instance
struct MqContextS * MQ_CTX
class-shortcut for struct MqContextS *, all shortcut using the XX_YYY syntax (only for public API) …
#define MqSlaveCreate(...)

◆ SlaveCreate() [2/2]

void ccmqmsgque::MqContextC::SlaveCreate ( MQ_SLAVE_ID id,
MqContextC * slave )
inline

C++: ctx.SlaveCreate(MQ_SLAVE_ID id, MqContextC* slave) C-API
create a master/slave link between the master-parent-context and the slave-parent-context …

Definition at line 2175 of file MqContextC_inline_cc.hh.

2175 {
2176 MK_UNUSED auto ctx = getCTX();
2177 MQ_CTX slave_hdl = MqContextC::getCTX(slave);
2178 enum MkErrorE errVal = MqSlaveCreate(ctx, id, slave_hdl);
2179 MkErrorC_Check(ctx, errVal);
2180 }

◆ SlaveDelete()

void ccmqmsgque::MqContextC::SlaveDelete ( MQ_SLAVE_ID id)
inline

C++: ctx.SlaveDelete(MQ_SLAVE_ID id) C-API
Delete a slave object from a master/slave link identified by id. …

Definition at line 2191 of file MqContextC_inline_cc.hh.

2191 {
2192 MK_UNUSED auto ctx = getCTX();
2193 enum MkErrorE errVal = MqSlaveDelete(ctx, id);
2194 MkErrorC_Check(ctx, errVal);
2195 }
#define MqSlaveDelete(...)

◆ SlaveGet()

MqContextC * ccmqmsgque::MqContextC::SlaveGet ( MQ_SLAVE_ID id)
inline

C++: MqContextC* ctx.SlaveGet(MQ_SLAVE_ID id) C-API
get the slave-context from a master-context

Definition at line 2139 of file MqContextC_inline_cc.hh.

2139 {
2140 MK_UNUSED auto ctx = getCTX();
2141 MQ_CTX ctx_out;
2142 enum MkErrorE errVal = MqSlaveGet(ctx, id, &ctx_out);
2143 MkErrorC_Check(ctx, errVal);
2145 }
#define MK_RT_CALL
static MqContextC * MqContextC_ObjNew(MK_RT_ARGS MQ_CTX hdl)
return MqContextC from LibMsgqueObject
#define MqSlaveGet(...)

◆ SlaveGetFilter()

MqContextC * ccmqmsgque::MqContextC::SlaveGetFilter ( )
inline

C++: MqContextC* ctx.SlaveGetFilter() C-API
get the filter-ctx or the master-ctx

Definition at line 2148 of file MqContextC_inline_cc.hh.

2148 {
2149 MK_UNUSED auto ctx = getCTX();
2150 MQ_CTX ctx_out;
2151 enum MkErrorE errVal = MqSlaveGetFilter(ctx, &ctx_out);
2152 MkErrorC_Check(ctx, errVal);
2154 }
#define MqSlaveGetFilter(...)
+ Here is the caller graph for this function:

◆ SlaveGetMaster()

MqContextC * ccmqmsgque::MqContextC::SlaveGetMaster ( )
inline

C++: MqContextC* ctx.SlaveGetMaster() C-API
opposite function of MqSlaveGetFilter

Definition at line 2130 of file MqContextC_inline_cc.hh.

2130 {
2131 MK_UNUSED auto ctx = getCTX();
2132 MQ_CTX __retVal__L = MqSlaveGetMaster(ctx);
2133 return MqContextC::MqContextC_ObjNew(MK_RT_CALL __retVal__L);
2134 }
static MQ_CTX MqSlaveGetMaster(MQ_CTX const ctx)
opposite function of MqSlaveGetFilter
+ Here is the caller graph for this function:

◆ SlaveGetProxy()

MqContextC * ccmqmsgque::MqContextC::SlaveGetProxy ( MQ_SLAVE_ID id)
inline

C++: MqContextC* ctx.SlaveGetProxy(MQ_SLAVE_ID id) C-API
on slave return the master and on master return the slave identified by id.

Definition at line 2157 of file MqContextC_inline_cc.hh.

2157 {
2158 MK_UNUSED auto ctx = getCTX();
2159 MQ_CTX ctx_out;
2160 enum MkErrorE errVal = MqSlaveGetProxy(ctx, id, &ctx_out);
2161 MkErrorC_Check(ctx, errVal);
2163 }
#define MqSlaveGetProxy(...)

◆ SlaveIs()

MK_BOOL ccmqmsgque::MqContextC::SlaveIs ( ) const
inline

C++: MK_BOOL ctx.SlaveIs() C-API
is the context a slave-context ? …

Definition at line 2198 of file MqContextC_inline_cc.hh.

2198 {
2199 MK_UNUSED auto ctx = getCTXN();
2200 MK_BOOL __retVal__L = MqSlaveIs(ctx);
2201 return __retVal__L;
2202 }
static bool MqSlaveIs(MQ_CTXN const ctx)
is the context a slave-context ? …

◆ SlaveWorker() [1/2]

void ccmqmsgque::MqContextC::SlaveWorker ( MK_NUM id,
MK_STRN factory,
const MkBufferListC & args )
inline

C++: ctx.SlaveWorker(MQ_SLAVE_ID id, MK_STRN fct = "WORKER", MkBufferListC* args = NULL) C-API
create a master/slave link using the image of the ctx object self. …

Definition at line 21 of file MqContextC_inline_cc.hh.

21 {
22 MK_BAC args_hdl = MkBufferListC::getBFL(args);
23 MkRtSetup_XN(args_hdl);
24 enum MkErrorE errVal = MqSlaveWorker (reinterpret_cast<MQ_CTX>(hdl), id, fct, args_hdl);
25 ErrorCheck(errVal);
26 }
struct MkBufferListS * MK_BAC
void ErrorCheck(enum MkErrorE err, MK_STRN const caller=__builtin_FUNCTION(), MK_I32 const line=__builtin_LINE()) const
#define MkRtSetup_XN(x)
#define MqSlaveWorker(...)

◆ SlaveWorker() [2/2]

void ccmqmsgque::MqContextC::SlaveWorker ( MQ_SLAVE_ID id,
MK_STRN fct = "WORKER",
MkBufferListC * args = NULL )
inline

C++: ctx.SlaveWorker(MQ_SLAVE_ID id, MK_STRN fct = "WORKER", MkBufferListC* args = NULL) C-API
create a master/slave link using the image of the ctx object self. …

Definition at line 2205 of file MqContextC_inline_cc.hh.

2205 {
2206 MK_UNUSED auto ctx = getCTX();
2208 enum MkErrorE errVal = MqSlaveWorker(ctx, id, fct, args_hdl);
2209 MkErrorC_Check(ctx, errVal);
2210 }
MK_BFL getBFL__null_allow() const