pymqmsgque 9.0
Loading...
Searching...
No Matches
Example: perfserver

Documentation of the perfserver tool used for example.test.

INTRODUCTION

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 pymqmsgque protocoll and build together a flat-like structure.

The GOAL for this setup is:

CODE server

#+
#:   -*- coding: utf8 -*-
#:
#:   @file         example/python/perfserver.py
#:   @brief        perfserver.py - 03 May 2023 - aotto1968
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permissions to copy,
#:                 please contact AUTHOR for additional information
#:   @version      1c3a8f89f6bbd5c146252125f8a426400f6e1300
#:   @date         Wed May 3 12:28:13 2023 +0200
#:   @author       aotto1968 <aotto1968@t-online.de>
#:

import sys
from pymkkernel import *
from pymqmsgque import *

class perfserver(MqContextC):

  # factory startup
  def __init__(self, tmpl=None):
    self.ConfigSetServerSetup(self.ServerSetup)
    super().__init__()

  def ECOU(self):
    self.SendSTART()
    self.SendU(self.ReadU())
    self.SendRETURN()

  def ECOI(self):
    self.SendSTART()
    self.SendI(self.ReadI())
    self.SendRETURN()

  def ECUL(self):
    self.SendSTART()
    self.SendY(self.ReadY())
    self.SendS(self.ReadS())
    self.SendI(self.ReadI())
    self.SendD(self.ReadD())
    self.ProxyItem(self)
    self.SendRETURN()

  def RDUL(self):
    self.ReadY()
    self.ReadS()
    self.ReadI()
    self.ReadD()
    self.ReadU()

  def RDUC(self):
    self.ReadC()
    self.ReadC()
    self.ReadC()
    self.ReadC()
    self.ReadC()

  def STDB (self):
    self.SendSTART ()
    self.StorageOpen (self.ReadC())
    self.SendRETURN ()

  def STDC (self):
    self.SendSTART ()
    self.StorageClose ()
    self.SendRETURN ()

  # [BufferStream-Create-TLS]
  def BUST (self):
    bus = MkBufferStreamC.CreateTLS(0)
    while self.ReadItemExists():
      bus.WriteU(self.ReadU())
    bus.PosToStart()
    self.SendSTART()
    while bus.ReadItemExists():
      self.SendU(bus.ReadU())
    self.SendRETURN()
  # [BufferStream-Create-TLS]

  # [BufferList-Create-TLS]
  def BFLT (self):
    bfl = MkBufferListC.CreateTLS(0)
    while self.ReadItemExists():
      bfl.AppendU(self.ReadU())
    self.SendSTART()
    for i in range(bfl.Size()):
      self.SendU(bfl.IndexGet(i))
    self.SendRETURN()
  # [BufferList-Create-TLS]
  
  def BINT (self):
    self.ReadB ()
  
  def STRT (self):
    self.ReadC ()

  def ServerSetup(self):
    self.ServiceCreate("ECOU",perfserver.ECOU)
    self.ServiceCreate("ECOI",perfserver.ECOI)
    self.ServiceCreate("ECUL",perfserver.ECUL)
    self.ServiceCreate("RDUL",perfserver.RDUL)
    self.ServiceCreate("RDUC",perfserver.RDUC)
    self.ServiceCreate("STDB",perfserver.STDB)
    self.ServiceCreate("STDC",perfserver.STDC)
    self.ServiceCreate("BUST",perfserver.BUST)
    self.ServiceCreate("BFLT",perfserver.BFLT)
    self.ServiceCreate("BINT",perfserver.BINT)
    self.ServiceCreate("STRT",perfserver.STRT)

if __name__ == "__main__":

  # [factory-item]
  # create the "perfserver" factory… and the object
  srv = MqFactoryC.Add(perfserver).New()
  # [factory-item]

  try:
    srv.LinkCreate(sys.argv)
    srv.ProcessEvent(MqWaitOnEventE.FOREVER)
  except Exception as ex:
    srv.ErrorCatch(ex)
  finally:
    srv.Exit()