Documentation of the perfserver tool used for example.test
.
The perfserver tool is used server-part of the performance-test
To perform the test the perfclient send various service request to the perfserver. The perfclient is written in C and finally create a report.
All context created, are connected using the libmqmsgque protocoll and build together a flat-like structure.
The GOAL for this setup is:
client → server → client
round-trip./** * @file NHI1/example/c/perfserver.c * @brief perfserver.c - 25 Aug 2024 - aotto1968 * @copyright (C) NHI - #1 - Project - Group * This software has NO permissions to copy, * please contact AUTHOR for additional information * @version c3b28928437a81158df1f3cafe23fbded7b34813 * @date Sun Aug 25 22:59:57 2024 +0200 * @author aotto1968 <aotto1968@t-online.de> */ /* LABEL-START */ #define META_FILE_NAME "perfserver.c" /* LABEL-END */ #include "common.h" static enum MkErrorE Ot_ECOU ( MQ_SERVICE_CALL_ARGS ) { MqSendSTART_E (mqctx); MqSendBUF_E (mqctx, MqReadBUF_e(mqctx)); error: return MqSendRETURN (mqctx); } static enum MkErrorE Ot_ECOI ( MQ_SERVICE_CALL_ARGS ) { MqSendSTART_E (mqctx); MqSendI32_E (mqctx, MqReadI32_e(mqctx)); error: return MqSendRETURN (mqctx); } static enum MkErrorE Ot_ECUL ( MQ_SERVICE_CALL_ARGS ) { MqSendSTART_E (mqctx); MqSendI8_E (mqctx, MqReadI8_e (mqctx)); MqSendI16_E (mqctx, MqReadI16_e (mqctx)); MqSendI32_E (mqctx, MqReadI32_e (mqctx)); MqSendDBL_E (mqctx, MqReadDBL_e (mqctx)); MqProxyItem_E (mqctx, mqctx); error: return MqSendRETURN (mqctx); } // [BufferStream-Create-TLS] static enum MkErrorE Ot_BUST ( MQ_SERVICE_CALL_ARGS ) { MK_BUS bus = MkBufferStreamCreateTLS_1( "perfserver-BUST" ); while (MqReadItemExists(mqctx)) { MkBufferStreamWriteBUF(bus,MqReadBUF_e(mqctx)); } MkBufferStreamPosToStart(bus); MqSendSTART_E (mqctx); while (MkBufferStreamReadItemExists(bus)) { MqSendBUF_E (mqctx, MkBufferStreamReadBUF_e (bus)); } error: return MqSendRETURN (mqctx); } // [BufferStream-Create-TLS] // [BufferList-Create-TLS] static enum MkErrorE Ot_BFLT ( MQ_SERVICE_CALL_ARGS ) { MK_BFL bfl = MkBufferListCreateTLS_1( "perfserver-BFLT" ); while (MqReadItemExists(mqctx)) { MkBufferListAppendBUF(bfl,MqReadBUF_e(mqctx)); } MqSendSTART_E (mqctx); for (int i=0; i<bfl->cursize; i++) { MqSendBUF_E (mqctx, MkBufferListIndexGet_e (bfl,i)); } error: return MqSendRETURN (mqctx); } // [BufferList-Create-TLS] static enum MkErrorE Ot_RDUL ( MQ_SERVICE_CALL_ARGS ) { MqReadI8_e (mqctx); MqReadI16_e (mqctx); MqReadI32_e (mqctx); MqReadDBL_e (mqctx); MqReadBUF_e (mqctx); error: return MK_OK; } static enum MkErrorE Ot_RDUC ( MQ_SERVICE_CALL_ARGS ) { MqReadSTR_e (mqctx); MqReadSTR_e (mqctx); MqReadSTR_e (mqctx); MqReadSTR_e (mqctx); MqReadSTR_e (mqctx); error: return MK_OK; } static enum MkErrorE Ot_STDB ( MQ_SERVICE_CALL_ARGS ) { MqSendSTART_E (mqctx); MqStorageOpen_E (mqctx, MqReadSTR_e (mqctx)); error: return MqSendRETURN (mqctx); } static enum MkErrorE Ot_STDC ( MQ_SERVICE_CALL_ARGS ) { MqSendSTART_E (mqctx); MqStorageClose_E (mqctx); error: return MqSendRETURN (mqctx); } static enum MkErrorE Ot_BINT ( MQ_SERVICE_CALL_ARGS ) { MkBinaryR bin = {0}; MqReadBIN_E (mqctx, &bin); error: return MK_OK; } static enum MkErrorE Ot_STRT ( MQ_SERVICE_CALL_ARGS ) { MK_STRN str = NULL; MqReadSTR_E (mqctx, &str); error: return MK_OK; } static enum MkErrorE Ot_NTHT ( MQ_SERVICE_CALL_ARGS ) { return MK_OK; } static enum MkErrorE Ot_MARK ( MQ_SERVICE_CALL_ARGS ) { mk_debug_color(MK_COLOR_BLUE,"%s",MqReadSTR_e(mqctx)); error: return MqSendRETURN(mqctx); } static enum MkErrorE ServerSetup ( MQ_SERVICE_CALL_ARGS ) { MqServiceCreate_E(mqctx,"ECOU", Ot_ECOU, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"ECOI", Ot_ECOI, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"ECUL", Ot_ECUL, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"RDUL", Ot_RDUL, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"RDUC", Ot_RDUC, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"STDB", Ot_STDB, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"STDC", Ot_STDC, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"BUST", Ot_BUST, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"BFLT", Ot_BFLT, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"BINT", Ot_BINT, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"STRT", Ot_STRT, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"NTHT", Ot_NTHT, NULL, NULL, NULL); MqServiceCreate_E(mqctx,"MARK", Ot_MARK, NULL, NULL, NULL); error: return MqSendRETURN(mqctx); } enum MkErrorE PerfServerFactory ( MQ_CALLBACK_FACTORY_CTOR_ARGS ) { MqContextSetup(NULL,tmpl,contextP); MqConfigSetServerSetup (*contextP, ServerSetup, NULL, NULL, NULL); return MK_OK; } int main (int argc, MK_STRN argv[]) { AllRtSetup_NULL; // setup commandline arguments for later use MK_BFL largv = MkBufferListCreateVC(argc, argv); struct MqContextS ctxS = {0}; MQ_CTX ctx = &ctxS; // [factory-item] // create "PerfServer" factory… and make it to the default. MqFactoryDefault( MqFactoryAdd_2(PerfServerFactory, "perfserver")); // [factory-item] // inspect commandline-argument for the "factory" to choose… and create a object MkErrorCheck(MqFactoryNew (MqFactoryGetCalledL(largv), NULL, &ctx)); // start listen for incoming call's MqLinkCreate_E (ctx, largv); MqCheckForLeftOverArguments_E (ctx, largv); MqProcessEvent_E (ctx,MQ_WAIT_FOREVER,MK_TIMEOUT_DEFAULT); error: MkBufferListDelete(largv); MqExit_1(ctx); }