users@glassfish.java.net

Standalone java client and er-request-load-balancing. package-appclient not

From: <forums_at_java.net>
Date: Tue, 10 May 2011 06:03:14 -0500 (CDT)

Oracle Glassfish 3.1, Java 1.6.0_25-b06, Windows Server 2008 SP2 32bit.

This post contains 3 questions;

1/ Does per-request-load-balancing work?

2/ Does it work for a java stanalone client which does not use the ACC?

3/ Does package-appclient work with domains which are not found under
domain1?

4/ From the context of a web application, for example a servlet, is there
ever a case in a homogenous cluster which does not use explicit machine names
in ejb references in which invoking an EJB will 'load balance' to a different
box, or even thread?

I have defined a cluster across 3 boxes;

Machine A has the DAS which is created as a Domain called CentralDAS. Its
config is found under C:\glassfish3\glassfish\domains\CentralDAS. 

On it I have defined a cluster, 'cluster1' as follows;

Machine B has one clustered instance 'instance1' under 'node1'

Machine C has the other clustered instance 'instance2' under 'node2'

 

I am investigating RMI-IIOP load balancing as defined
in http://download.oracle.com/docs/cd/E18930_01/html/821-2426/gknqo.html#abdbd
[1].

I have deployed an EAR with an SLSB implemented in a class named 'SLSB1'.

/** * Session Bean implementation class SLSB1 */ @Stateless(mappedName =
"SLSB1") @LocalBean public class SLSB1 implements SLSB1Remote {
@PersistenceContext(name="Experiment5jndiPU") EntityManager emInj;
@EJB(mappedName="SLSB2") private SLSB2Remote bean2r; @Override public
Invocation doTest(Invocation model) { model.testInvocation(emInj,
Component.WEB_TIER_BEAN, true); Invocation result = null;
if(model.lookupBeans()) { try { SLSB2Remote bean2lc = (SLSB2Remote) new
InitialContext().lookup("SLSB2"); result =
bean2lc.doTest(model.cloneForOnwardCall()); } catch (NamingException e) {
throw new TestException("Cannot find SLSB2 from SLSB1 using InitialContext",
e); } } else { result = bean2r.doTest(model.cloneForOnwardCall()); }
model.mergeState(result); model.testInvocation(emInj,
Component.WEB_TIER_BEAN, false); return model; } @Override public Invocation
beginTestInEJB(DeploymentScenario scenario) { Invocation model = new
Invocation(UUID.randomUUID().toString(), scenario);
model.testInvocation(emInj, Component.WEB_APP, true); Invocation result =
doTest(model.cloneForOnwardCall()); model.mergeState(result);
model.testInvocation(emInj, Component.WEB_TIER_BEAN, false); return model; }
In the EAR I have added the glassfish deployment descriptor with a
 per-request-load-balancing element;

<!DOCTYPE glassfish-ejb-jar PUBLIC "-//GlassFish.org//DTD GlassFish
Application Server 3.1 EJB 3.1//EN"
"http://glassfish.org/dtds/glassfish-ejb-jar_3_1.dtd"> <glassfish-ejb-jar>
<enterprise-beans> <ejb> <ejb-name>SLSB1</ejb-name>
<per-request-load-balancing>true</per-request-load-balancing>
I know this is being read because I have set logging on to FINEST for
everything and in the server.log file I can see the
element per-request-load-balancing being read. HOWEVER I cannot see the
message 'Setting per-request-load-balancing policyfor EJB ...' in server.log
as described in the docs
(http://download.oracle.com/docs/cd/E18930_01/html/821-2426/gknpv.html#gksgo
[2]). What is the CORBA log ... where can I find it?

SLSB1 simply records which machines and threads it has been used on and
prints this out.

Under Eclipse I create a simple standalone Java client WITHOUT using the ACC.
I run this on a client machine ClientMachine.

public static final boolean NewIContextEachRequest = true; /** * @param args
*/ public static void main(String[] args) { try { Properties props = new
Properties(); //Comment this out to make this work! and pass
-Dcom.sun.appserv.iiop.endpoints=martinsson:23700,svedberg:23700
props.setProperty("org.omg.CORBA.ORBInitialHost", "machineA");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700"); InitialContext
context; if (!NewIContextEachRequest) { context = new InitialContext(props);
} for (int i = 0; i < 10; i++) { if (NewIContextEachRequest) { context = new
InitialContext(props); } Object ref = context.lookup("SLSB1NoInj");
SLSB1Remote bean = (SLSB1Remote) ref; System.out.println("New LOOKUP
========================="); for (int j = 0; j < 10; j++) { Invocation result
= bean .beginTestInEJB(DeploymentScenario.SINGLE_CLUSTER_NO_FRILLS);
System.out.println("Result is " + result.printOut()); for (String report :
result.getReports()) { System.out.println("\t" + report); } for (String trace
: result.getTraces()) { System.out.println("\t" + trace); } } } } catch
(NamingException e) { // TODO Auto-generated catch block e.printStackTrace();
} }
 I run this with gf-client.jar on the path from Eclipse and it does not run
as the EAR is not found. I remove the org.omg.CORBA.* properties and having
found out the ports on node1 and node2 where the IIOP listener is I attempt
to re-run it and pass the following args to the JVM 
-Dcom.sun.appserv.iiop.endpoints=machine1:23700,machine2:23700

This does make it run. I see output of the form 

Result is Invocation:

id: a8da8103-5b11-4f37-8af0-35532f6f935e

scenario: SINGLE_CLUSTER_NO_FRILLS

OK

No reports

 

machineB, 650, Outward bound on WEB_APP for scenario SINGLE_CLUSTER_NO_FRILLS

machineB, 650, Outward bound on WEB_TIER_BEAN for scenario
SINGLE_CLUSTER_NO_FRILLS

machineB, 650, Outward bound on BEAN_2 for scenario SINGLE_CLUSTER_NO_FRILLS

machineB, 650, Return leg on BEAN_2 for scenario SINGLE_CLUSTER_NO_FRILLS

machineB, 650, Return leg on WEB_TIER_BEAN for scenario
SINGLE_CLUSTER_NO_FRILLS

machineB, 650, Return leg on WEB_TIER_BEAN for scenario
SINGLE_CLUSTER_NO_FRILLS

New LOOKUP =========================

Result is Invocation:

id: 1e2717cc-97bf-4a59-8d20-fc0f97166fda

scenario: SINGLE_CLUSTER_NO_FRILLS

OK

No reports

 

machineB, 650, Outward bound on WEB_APP for scenario SINGLE_CLUSTER_NO_FRILLS

machineB, 650, Outward bound on WEB_TIER_BEAN for scenario
SINGLE_CLUSTER_NO_FRILLS

machineB, 650, Outward bound on BEAN_2 for scenario SINGLE_CLUSTER_NO_FRILLS

machineB, 650, Return leg on BEAN_2 for scenario SINGLE_CLUSTER_NO_FRILLS

machineB, 650, Return leg on WEB_TIER_BEAN for scenario
SINGLE_CLUSTER_NO_FRILLS

 

 

This means that everything  on SLSB1 ran fine on machineB  on thread 650.
This means in turn that I did not get any per-request-load-balancing as
everything ran on the same instance.

If I change NewIContextEachRequest to true and re-run the tests then the
requests pass between each box;

 Result is Invocation:

id: 8987ae9d-f8c7-4022-bab4-855c78f3d0a8

scenario: SINGLE_CLUSTER_NO_FRILLS

OK

No reports

 

machineA, 742, Outward bound on WEB_APP for scenario SINGLE_CLUSTER_NO_FRILLS

machineA, 742, Outward bound on WEB_TIER_BEAN for scenario
SINGLE_CLUSTER_NO_FRILLS

machineA, 742, Outward bound on BEAN_2 for scenario SINGLE_CLUSTER_NO_FRILLS

machineA, 742, Return leg on BEAN_2 for scenario SINGLE_CLUSTER_NO_FRILLS

machineA, 742, Return leg on WEB_TIER_BEAN for scenario
SINGLE_CLUSTER_NO_FRILLS

machineA, 742, Return leg on WEB_TIER_BEAN for scenario
SINGLE_CLUSTER_NO_FRILLS

New LOOKUP =========================

Result is Invocation:

id: 17395dee-5363-432e-ad69-643cccd322de

scenario: SINGLE_CLUSTER_NO_FRILLS

OK

No reports

 

machineB, 789, Outward bound on WEB_APP for scenario SINGLE_CLUSTER_NO_FRILLS

machineB, 789, Outward bound on WEB_TIER_BEAN for scenario
SINGLE_CLUSTER_NO_FRILLS

machineB, 789, Outward bound on BEAN_2 for scenario SINGLE_CLUSTER_NO_FRILLS

machineB, 789, Return leg on BEAN_2 for scenario SINGLE_CLUSTER_NO_FRILLS

machineB, 789, Return leg on WEB_TIER_BEAN for scenario
SINGLE_CLUSTER_NO_FRILLS

 However I am still not seeing the requests pass between boxes everytime I
invoked the SLSB.

My first question is 

1/ What am I doing wrong - does per-request-load-balancing  work outside
the ACC?

 

Okay so lets do exactly what the docs described and use the ACC...

I attempt to run package-appclient from C:\glassfish3\glassfish\bin on
MachineA. This provides the following feedback;

C:\glassfish3\glassfish\bin>package-appclient Replacing
C:\glassfish3\glassfish\lib\appclient.jar The XML configuration file
C:\glassfish3\glassfish\domains\domain1\config\sun-acc.xml does not exist;
continuing but out
 

 If I attempt to use the generate appclient.jar I cannot extract anything
with java -jar appclient.jar, and it does not contain asenv.bat file or a
config directory.

2/ How can I run package-appclient if I don't have a domain 'domain1' ?

My last question...

In http://download.oracle.com/docs/cd/E18930_01/html/821-2426/toc.html
[3] the emphasis is on clients; the browser and the ACC.

Is there any sense in which load balancing or fail over occur once my Servlet
has been invoked inside Glassfish?

As part of my EAR I have  a web-app and servlet which calls my SLSB, SLSB1.
This in turn calls another SLSB in another EAR ( Experiment5-WebTier
servlet  TestMainServlet calls SLSB1 which calls SLSB2 in Experiment5-DomA
). Is there any possibility that glassfish can be configured so that one SLSB
( or indeed a Servlet ) calling another will result in a corss process call -
or indeed to a different thread - IFF the remote naming ejb ref format is not
being used ( I mean corbaname:iiop:MachineB:23700#BeanY type format)??

The attached jars ( really just renamed ears !) contain the two EARS which
define the EJBS for the app server and contain sources...

Thanks

 

 


[1]
http://download.oracle.com/docs/cd/E18930_01/html/821-2426/gknqo.html#abdbd
[2]
http://download.oracle.com/docs/cd/E18930_01/html/821-2426/gknpv.html#gksgo
[3] http://download.oracle.com/docs/cd/E18930_01/html/821-2426/toc.html

--
[Message sent by forum member 'JFK9']
View Post: http://forums.java.net/node/800472