Performance Tester

Description:

Use special tests to simulate heavy business loads, in order to test the J-Integra® Espresso's Performance.

Goal:

Write an EJB for your J2EE server, create IDL files, generate .NET C# code and write the .NET client.

Source:

\DemoJ2EE\PerformanceTester


Example:

Step 1. Write an J2EE Server

Write an EJB with the following interfaces and implementation.
Create the jar/ear files and deploy it to your J2EE Server.

a.) Remote interface (ics\ejb\EjbValTester1.java):

 
  package ics.ejb;
  import ics.byval.OuterVal;
  import java.util.Hashtable;

  public interface EjbValTester1 extends javax.ejb.EJBObject
  {
    public void NOP() throws java.rmi.RemoteException;
    public String getAString(String val) throws java.rmi.RemoteException;
    public String[] getStrings(String[] vals) throws java.rmi.RemoteException;
    public OuterVal getAVal(OuterVal val) throws java.rmi.RemoteException;
    public OuterVal[] getVals(OuterVal[] vals) throws java.rmi.RemoteException;
    public Hashtable getSetHashtable(Hashtable ht) throws java.rmi.RemoteException;
    public Hashtable[] getSetHashtables(Hashtable[] ht) throws java.rmi.RemoteException;   
  }  

b.) The Bean (ics\ejb\EjbVal1Bean.java):

  package ics.ejb;
  import javax.ejb.*;
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import java.io.IOException;
  import java.net.InetAddress;
  import java.net.UnknownHostException;
  import java.util.Hashtable;
  import java.rmi.RemoteException;
  
  import ics.byval.OuterVal;
  import ics.byval.OuterVal;
  
  public class EjbVal1Bean implements javax.ejb.SessionBean {   

    private SessionContext ctx;

    public void setSessionContext(SessionContext ctx) {
      this.ctx = ctx;
    }

    public void ejbRemove() {
      System.out.println("ejbRemove()");
    }

    public void ejbActivate() {
      System.out.println("ejbActivate()");
    }

    public void ejbPassivate() {
      System.out.println("ejbPassivate()");
    }

    public void ejbCreate() { }

    public void NOP() { }

    public String getAString(String val) {
      String ret = val;
      return ret;
    }

    public String[] getStrings(String[] vals) {
      return vals;
    }

    public OuterVal getAVal(OuterVal val) {
      return val;
    }

    public OuterVal[] getVals(OuterVal[] vals) {
      return vals;
    }

    public Hashtable getSetHashtable(Hashtable ht) {
      return ht;
    }

    public Hashtable[] getSetHashtables(Hashtable[] ht) {
      return ht;
    }
}

c.) Home interface (ics\ejb\EjbVal1Home.java):

  package ics.ejb;
  public interface EjbVal1Home extends javax.ejb.EJBHome {
    EjbValTester1 create() throws java.rmi.RemoteException, javax.ejb.CreateException;  
  }

d.) Pass by value object (ics\byval\OuterVal.java):

  package ics.byval;
  import java.io.Serializable;
  
  public class OuterVal implements Serializable {   
    public String s_val_a;
    public String s_val_b;
    public int i_val_a;
    public int i_val_b;
    public double d_val_a;
}

Step 2. Generate the IDL files

IDL-Files: \DemoJ2EE\PerformanceTester\IDL

    
> set J2EE_PATH=C:\Sun\AppServer\lib\j2ee.jar
> BrewerCmd -cp java\EjbPerfTest.jar;%J2EE_PATH% -v -d .\IDL -g idl ics.ejb.EjbVal1Home;ics.ejb.EjbValTester1;ics.byval.OuterVal

Step 3. Generate the .NET code from the IDL files

Generated C#-Files: DemoJ2EE\PerformanceTester\DotNetClient\generated_cs\ics, \DemoJ2EE\PerformanceTester\DotNetClient\generated_cs\org

> BrewerCmd -v -d .\DotNetClient\generated_cs -g cs .\idl

Alternative Step 2 & 3. Generate the .NET code from the Java jar

Both Steps 2 & 3 can be completed in one call of the BrewerCmd. Please make sure you modify the path to J2EE.jar.

    
> set J2EE_PATH=%CLASSPATH%;C:\Sun\AppServer\lib\j2ee.jar
> BrewerCmd -cp java\EjbPerfTest.jar;%J2EE_PATH% -v -dcs .\DotNetClient\generated_cs -didl .\IDL -g source ics.ejb.EjbVal1Home;ics.ejb.EjbValTester1;ics.byval.OuterVal

Step 4. Write the .NET client

Implementation: DemoJ2EE\PerformanceTester\DotNetClient\Class1.cs

a.) Create a console application

b.) Add a reference to '$ESPRESSO_INSTALL_DIR$/bin/Jintegra.Espresso.dll'

c.) Add the generated files in directories: .\ics and .\org

d.) Write the client:

The client first connects to the J2EE Application Server, retrieves the remote object registered under the name 'PerfTester' (which is a ics.ejb.EjbVal1Home interface), generates a new server object from it, and eventually excecutes the following performance tests (each performance test runs 5000 times to test the system and simulate a heavy business load):

Step 5. Run the example

The example's EJB jar (EjbPerfTest.jar) already contains Application Server Configuration for JBoss and WebLogic. In this insturction, we use JBoss for demonstration only.

a.) Create the configuration file for the Client (refer User Guide for more information on Espresso Config file):

    <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
        
        <configSections>
          <section name="Jintegra" type="Ics.Config.JintegraConfigHandler, Jintegra.Espresso, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f1aa1bb10d3603d9"/>
        </configSections>
        
        <Jintegra>
          <!--
          Put your license here, if you haven't installed it in the registry
          -->
          <J2EEConfig>    
              <ApplicationServer>
              <!-- values: 
                        Weblogic
                        Websphere
                        JBoss
                        Sun_jdk_rmi_iiop
              -->
                <type>JBoss</type>
                <!-- <type>Weblogic</type> -->
                <!-- The ejb jar is ready for both JBoss and Weblogic -->
                <!-- Use only if NOT localhost -->                         
                <!-- <host>indigo01</host>  -->
                <!-- Only set port if NOT running on application server default port -->
                <!-- <port>1234</port>   -->    
              </ApplicationServer>
              
              <!--
                Uncomment for TLS/SSL access 
                -->
                <!-- <Security> -->
                <!-- other option is SSL (older) -->
	              <!-- <secureConnectionType>TLS</secureConnectionType> -->
	              <!-- only set to true if you have the app server's certificate installed -->
	              <!-- In the Windows Certificate store -->
                  <!-- <authenticateServer>false</authenticateServer> -->
                <!-- </Security>  -->
          		         
          </J2EEConfig>
        </Jintegra>
    </configuration>
          
          

b.) Start the JBoss Application Server:

    > run -c all    

c.) Deploy your bean
Copy EjbPerfTest.jar into the AppServers autodeploy directory ($JBOSS$\server\all\deploy).

d.) Start the client.