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 jvmqmsgque protocoll and build together a flat-like structure.
The GOAL for this setup is:
client → server → client
round-trip./** * @file NHI1/example/jv/perfserver.java * @brief perfserver.java - 19 Aug 2024 - aotto1968 * @copyright (C) NHI - #1 - Project - Group * This software has NO permissions to copy, * please contact AUTHOR for additional information * @version a5cb9f916df9a2d44f91871d69b296ab9a9d1e68 * @date Mon Aug 19 14:57:57 2024 +0200 * @author aotto1968 <aotto1968@t-online.de> */ package example; import java.util.stream.IntStream; import jvmsgque.mqmsgque.*; import jvmsgque.mkkernel.*; final class perfserver extends MqContextC implements IServerSetup { // Factory Constructor public perfserver(MqContextC tmpl) { super(tmpl); } class ECOU implements MqServiceIF { public void Callback(MqContextC ctx) { ctx.SendSTART(); ctx.SendBUF(ctx.ReadBUF()); ctx.SendRETURN(); } } class ECOI implements MqServiceIF { public void Callback(MqContextC ctx) { ctx.SendSTART(); int i = ctx.ReadI32(); ctx.SendI32(i); ctx.SendRETURN(); } } class ECUL implements MqServiceIF { public void Callback(MqContextC ctx) { ctx.SendSTART(); ctx.SendI8(ctx.ReadI8()); ctx.SendI16(ctx.ReadI16()); ctx.SendI32(ctx.ReadI32()); ctx.SendDBL(ctx.ReadDBL()); ctx.ProxyItem(ctx); ctx.SendRETURN(); } } class RDUL implements MqServiceIF { public void Callback(MqContextC ctx) { ctx.ReadI8(); ctx.ReadI16(); ctx.ReadI32(); ctx.ReadDBL(); ctx.ReadBUF(); } } class RDUC implements MqServiceIF { public void Callback(MqContextC ctx) { ctx.ReadSTR(); ctx.ReadSTR(); ctx.ReadSTR(); ctx.ReadSTR(); ctx.ReadSTR(); } } class STDB implements MqServiceIF { public void Callback(MqContextC ctx) { ctx.SendSTART(); ctx.StorageOpen(ReadSTR()); ctx.SendRETURN(); } } class STDC implements MqServiceIF { public void Callback(MqContextC ctx) { ctx.SendSTART(); ctx.StorageClose(); ctx.SendRETURN(); } } // [BufferStream-Create-TLS] class BUST implements MqServiceIF { public void Callback(MqContextC ctx) { MkBufferStreamC bus = MkBufferStreamC.CreateTLS("perfserver-BUST" ); while (ReadItemExists()) { bus.WriteBUF(ReadBUF()); } bus.PosToStart(); SendSTART(); while (bus.ReadItemExists()) { SendBUF(bus.ReadBUF()); } SendRETURN(); } } // [BufferStream-Create-TLS] // [BufferList-Create-TLS] class BFLT implements MqServiceIF { public void Callback(MqContextC ctx) { MkBufferListC bfl = MkBufferListC.CreateTLS("perfserver-BFLT" ); while (ReadItemExists()) { bfl.AppendBUF(ReadBUF()); } SendSTART(); IntStream.range(0, bfl.Size()).forEach( i -> { SendBUF(bfl.IndexGet(i)); } ); SendRETURN(); } } // [BufferList-Create-TLS] class BINT implements MqServiceIF { public void Callback(MqContextC ctx) { ctx.ReadBIN(); } } class STRT implements MqServiceIF { public void Callback(MqContextC ctx) { ctx.ReadSTR(); } } class NTHT implements MqServiceIF { public void Callback(MqContextC ctx) { } } public void ServerSetup() { ServiceCreate("ECOU", new ECOU()); ServiceCreate("ECOI", new ECOI()); ServiceCreate("ECUL", new ECUL()); ServiceCreate("RDUL", new RDUL()); ServiceCreate("RDUC", new RDUC()); ServiceCreate("STDB", new STDB()); ServiceCreate("STDC", new STDC()); ServiceCreate("BUST", new BUST()); ServiceCreate("BFLT", new BFLT()); ServiceCreate("BINT", new BINT()); ServiceCreate("STRT", new STRT()); ServiceCreate("NTHT", new NTHT()); } // ------------------------------------------------------------- public static void main(String[] argv) { // setup commandline arguments for later use MkBufferListC largs = new MkBufferListC(argv); // [factory-item] // create "perfserver" factory… and make it to the default. MqFactoryC.Add(perfserver.class).Default(); // [factory-item] // inspect commandline-argument for the "factory" to choose… and create a object MqContextC srv = MqFactoryC.GetCalled(largs).New(); try { srv.LinkCreate(largs); srv.ProcessEvent(MqWaitOnEventE.FOREVER); } catch (Throwable e) { srv.ErrorCatch(e); } srv.Exit(); } }