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

The GOAL for this setup is:

CODE server

#!/usr/bin/env atlsh
#+
#:   @file         NHI1/example/atl/perfserver.atl
#:   @brief        tag: nhi1-release-250425
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permission to copy,
#:                 please contact AUTHOR for additional information
#:

package require lib_85
package require atlmqmsgque

::myooX::ClassN ::perfserver {
  SuperI ::MqContextC

  proc Ot_ECOU { myNs } {
    SendSTART $myNs
    SendBUF $myNs [ReadBUF $myNs]
    SendRETURN $myNs
  }

  proc Ot_ECOI { myNs } {
    SendSTART $myNs
    SendI32 $myNs [ReadI32 $myNs]
    SendRETURN $myNs
  }

  proc Ot_ECUL { myNs } {
    SendSTART $myNs
    SendI8 $myNs [ReadI8 $myNs]
    SendI16 $myNs [ReadI16 $myNs]
    SendI32 $myNs [ReadI32 $myNs]
    SendDBL $myNs [ReadDBL $myNs]
    ProxyItem $myNs $myNs
    SendRETURN $myNs
  }

  proc Ot_RDUL { myNs } {
    ReadI8 $myNs
    ReadI16 $myNs
    ReadI32 $myNs
    ReadDBL $myNs
    ReadBUF $myNs
  }

  proc Ot_RDUC { myNs } {
    ReadSTR $myNs
    ReadSTR $myNs
    ReadSTR $myNs
    ReadSTR $myNs
    ReadSTR $myNs
  }

  proc Ot_STDB { myNs } {
    SendSTART $myNs
    StorageOpen $myNs [ReadSTR $myNs]
    SendRETURN $myNs
  }

  proc Ot_STDC { myNs } {
    SendSTART $myNs
    StorageClose $myNs
    SendRETURN $myNs
  }

  # [BufferStream-Create-TLS]
  proc Ot_BUST { myNs } {
    set bus [MkBufferStreamC::CreateTLS "perfserver-BUST" ]
    while {[ReadItemExists $myNs]} {
      MkBufferStreamC::WriteBUF $bus [ReadBUF $myNs]
    }
    MkBufferStreamC::PosToStart $bus
    SendSTART $myNs
    while {[MkBufferStreamC::ReadItemExists $bus]} {
      SendBUF $myNs [MkBufferStreamC::ReadBUF $bus]
    }
    SendRETURN $myNs
  }
  # [BufferStream-Create-TLS]

  # [BufferList-Create-TLS]
  proc Ot_BFLT { myNs } {
    set bfl [MkBufferListC::CreateTLS "perfserver-BFLT" ]
    while {[ReadItemExists $myNs]} {
      MkBufferListC::AppendBUF $bfl [ReadBUF $myNs]
    }
    SendSTART $myNs
    set size [MkBufferListC::Size $bfl]
    for {set i 0} {$i < $size} {incr i} {
      SendBUF $myNs [MkBufferListC::IndexGet $bfl $i]
    }
    SendRETURN $myNs
  }
  # [BufferList-Create-TLS]

  proc Ot_BINT { myNs } {
    ReadBIN $myNs
  }

  proc Ot_STRT { myNs } {
    ReadSTR $myNs
  }

  proc Ot_NTHT { myNs } { }

  proc serverSetup { myNs } {
    ServiceCreate $myNs ECOU Ot_ECOU
    ServiceCreate $myNs ECOI Ot_ECOI
    ServiceCreate $myNs ECUL Ot_ECUL
    ServiceCreate $myNs RDUL Ot_RDUL
    ServiceCreate $myNs RDUC Ot_RDUC
    ServiceCreate $myNs STDB Ot_STDB
    ServiceCreate $myNs STDC Ot_STDC
    ServiceCreate $myNs BUST Ot_BUST
    ServiceCreate $myNs BFLT Ot_BFLT
    ServiceCreate $myNs BINT Ot_BINT
    ServiceCreate $myNs STRT Ot_STRT
    ServiceCreate $myNs NTHT Ot_NTHT
  }

  # factory startup (constructor)
  proc perfserver {myNs {tmpl ""}} {
    MqContextC $myNs $tmpl
    ConfigSetServerSetup $myNs serverSetup
  }
} 

MqMsgque::Main {

  # setup commandline arguments for later use
  set largv   [MkBufferListC::CreateLA {*}$argv]

  # [factory-item]
  # create "perfserver" factory... and make it to the default.
  MqFactoryC::Default [MqFactoryC::Add ::perfserver]
  # [factory-item]

  # inspect commandline-argument for the "factory" to choose... and create a new instance
  set srv     [MqFactoryC::New [MqFactoryC::GetCalledL $largv]]

  try {
    MqContextC::LinkCreate $srv $largv
    MqContextC::ProcessEvent $srv MQ_WAIT_FOREVER
  } on error {} {
    MqContextC::ErrorCatch $srv
  } finally {
    MqContextC::Exit $srv
  }
}