Saturday, February 5, 2011

JEE6 Tutorial for a Distributed Enterprise Application incorporating EJB 3.1, JPA 2.0, JSF 2.0, Servlet 3.0 and JAX-RS on Oracle GlassFish Server 3.1

20110209: This tutorial has widened in scope and is being developed at the following URL.
http://wiki.eclipse.org/EclipseLink/Examples/Distributed

    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.

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.

Problem:
    The Collatz conjecture or (3n + 1) problem is currently not proved.  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:

Analysis:

Use Cases:

Design:

Data Model:
    The following UML class diagram details the data model for the business objects.  We will be using JPA entities and mappedsuperclass artifacts.
Figure 1-1: UML Class Diagram - Data Model


Implementation:

Deployment:

References:


/ Michael O'Brien 20110205

No comments:

Total Pageviews

Followers