Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/Distributed"

m (Technology Summary)
m (Analysis)
Line 36: Line 36:
  
 
=Analysis=
 
=Analysis=
 +
 +
==AI2: Synchronous or Asynchronous access to session beans from clients==
 +
*We have the choice of getting a reference to a remote session bean and holding that reference for the duration of the client work packet until we return results to the server.  Or, we can perform separate calls to separate references to get and put the work unit.  It will depend on the length of time to process the unit, the bean lifetime and how many beans are in the server pool.
  
 
=Use Cases=
 
=Use Cases=

Revision as of 15:25, 9 February 2011

Distributed Enterprise App using JEE6 API - JPA 2.0, JSF 2.0, JAX-RS 1.1 and EJB 3.1

  • This tutorial describes the analysis, design, implementation and deployment of a distributed JEE6 application that makes use of the EJB 3.1, JPA 2.0, JSF 2.0, Servlet 3.0 and JAX-RS API implemented as part of the Oracle GlassFish Server 3.1 distribution. The Java IDE used for this tutorial is the tightly integrated SUN NetBeans 7.0 release that will be in beta until April 2011 but we are also able to use Eclipse Helios 3.6 as well.
  • Why distributed? We need to investigate the concurrent behavior and exception handling of a near-real-world hammering of a server based JPA application from multiple clients. Specifically I am interested in how we implement 2-phase commit, handle OptimisticLockExceptions and design for a mix of transaction types involving REQUIRES(default)|REQUIRES_NEW|NOT_REQUIRED. We may also integrate different isolation levels.
  • We will be concentrating on how to leverage the features of JPA 2.0 that are implemented by EclipseLink 2.x. These features should include con

Technology Summary

  • Normally we do not decide on what APIs will be in use before we analyse the requirements. However, here is the list of technologies we are using - as we finalize the implementation.
    • JPA 2.0 : All database interaction will be on the main server via a container managed @PersistenceContext on EJB session beans. The clients will modify detached entities and return them to the server for merging/persistence.
    • JTA : We will continue to use container managed transactions via the dependency injected proxy so we do not have to manage transaction events ourselves
    • EJB 3.1 : We will be using @Stateless @Remote beans but may be using @Singleton and/or container-managed JTA persistence units in the WAR for @Local beans
    • JSF 2.0 : We will use the existing @ManagedBean and new .XHTML controller/view separation pattern
    • JAX-RS 1.1 :
    • JMS :
    • JNI :(possible optimization via C++ using either IA32/64, SSE or even CUDA) - where the Java client is just the wrapper around the computation engine.
  • We will not be using an L2 cache such as Coherence, ehCache or Terracotta at this point - we will be communicating using standard EJB beans such as session or message-driven beans.

Problem

  • Instead of the usual Employee demo or even the simple entity/jsp format of previous JPA tutorials - we will attempt at providing a usefull distributed java application that could be deployed to a live server that would be hosted outside our firewall.
  • Our problem is how can we help prove the Collatz conjecture (or all integer paths lead to 1).
  • The Collatz conjecture or (3n + 1) problem has not been proven yet. There have been attempts at verifying collatz up to 2^61 - however, massive amounts of scalar processing power is required to do this because the problem is non-linear and therefore must be brute force simulated even with optimizations.
  • The algorithm is as follows for the set of positive integers to infinity.

odd numbers are transformed by 3n + 1 even numbers are divided by 2

  • If you think in base 2, we see that for odd numbers we shift bits to the left, add the number to the result and set bit 0. For even numbers we shift bits to the right. We therefore have a simplified algorithm as follows.
odd: next binary = number << 1 + number + 1 
even: next binary = number >> 1 
  • 'Observation 1: the maximum value remains at or around 2x the number of bits in the start number - at least so far in my own simulations up to 640 billion.
  • We stop iteration and record the max path and max value when the sequence enters the 4-2-1 loop after the first 1 is reached. This sequence must be simulated for all positive integers up to the limit of the software being used. Fortunately, in Java (and .NET3) we can use BigInteger which supports unlimited length integers - as we would quickly overflow using a 64 bit long as soon as we started iterating numbers over 32 bits.
  • Observation 2: I have determined - via a week of simulation distributed among 16 different machines in parallel - that we will need native computation.

Requirements

R1: Local Client Access

R2: Remote RMI Client Access Inside Firewall

R3: Remote WebService Client Access Outside Firewall

Analysis

AI2: Synchronous or Asynchronous access to session beans from clients

  • We have the choice of getting a reference to a remote session bean and holding that reference for the duration of the client work packet until we return results to the server. Or, we can perform separate calls to separate references to get and put the work unit. It will depend on the length of time to process the unit, the bean lifetime and how many beans are in the server pool.

Use Cases

Design

Design Issue 1: Remote RMI/EJB communication

Remote Session Beans on WebLogic 10.3.4.0

Remote Session Beans on GlassFish 3.1

Data Model

  • The following UML class diagram details the data model for the business objects. We will be using JPA entities and mappedsuperclass artifacts.

Collatz uml class.jpg

Implementation

Testing

GlassFish 3.1 Server Logs

  • The EE server is the same for all test cases below

Server Logs

INFO: GlassFish Server Open Source Edition 3.1-b41 (41) startup time : Felix (7,984ms), startup services(750ms), total(8,734ms)
INFO: EclipseLink, version: Eclipse Persistence Services - 2.2.0.v20110202-r8913
CONFIG: Connected: jdbc:derby://localhost:1527/collatz2
INFO: file:/C:/_Netbeans691Projects/CollatzGF/dist/gfdeploy/CollatzGF/CollatzGF-ejb_jar/_CollatzGF-ejbPU login successful
INFO: Portable JNDI names for EJB CollatzFacade : [java:global/CollatzGF/CollatzGF-ejb/CollatzFacade, java:global/CollatzGF/CollatzGF-ejb/CollatzFacade!org.dataparallel.collatz.business.CollatzFacadeRemote]
INFO: Glassfish-specific (Non-portable) JNDI names for EJB CollatzFacade : [ejb/CollatzFacade, ejb/CollatzFacade#org.dataparallel.collatz.business.CollatzFacadeRemote]

TC1: Remote Session Bean Lookup on GlassFish 3.1 from SE Client on Same JVM

SE Client Logs


TC2:Remote Session Bean Lookup on GlassFish 3.1 from SE Client on Different JVM - Local Machine

SE Client Logs


TC3:Remote Session Bean Lookup on GlassFish 3.1 from SE Client on Different JVM - Remote Machine

SE Client Logs


Results

EclipseLink 2.2 on GlassFish 3.1 within the same JVM in NetBeans 6.9.1

Status

References

Back to the top