GlassFish v2.1 clustering GlassFish v3 new features

Document Sample
GlassFish v2.1 clustering GlassFish v3 new features Powered By Docstoc
					GlassFish v2.1 clustering
GlassFish v3 new features

Alexis Moussine-Pouchkine
GlassFish Team
Sun Microsystems
                            1
 Timeline of Project GlassFish




Tomcat
 Jasper                                     v3                  v3
 Catalina
                                         “Prelude”          (Java EE 6)
  JSTL                     v1
  Struts      GlassFish
    Crimson
               Launch             v2               v2.1
    XSLTC
     Xalan
    Xerces


  JAXB          June      May    Sept.   Oct/Nov     Dec    Fall-2009
JAX-RPC
   JSF          2005      2006   2007     2008       2008
                                                     (you are here)
GlassFish community
Real users
GlassFish around you
Some vocabulary
• Cluster – a group a homogenous GlassFish instances
 administered as a whole


• Load-Balancing – a strategy and implementation to
 balance HTTP, IIOP, and other incoming requests.
 Enough to provide service continuity


• High-Availability (HA) – replication of stateful data to
 survive instance crash. All about session continuity
Dynamic Clustering with Project Shoal

• GMS with Project Shoal
  > http://shoal.dev.java.net
  > Dynamic clusters implemented with JXTA by default
  > Ease of use in cluster setup
  > Differentiates between a member that leaves the group
    because of failure or for administrative reason
  > Configurable
     >Failure timeout detection
     ># of retries for failed member
     >Heartbeat timeouts
In-Memory Replication

• What?
 >   HTTP session state
 >   Stateful EJB session state
 >   Single Sign-On state
 >   Container state (timers, …)

• How?
 > Default is In-Memory replication with JXTA for application state
 > Can also use HADB for 99.999% uptime
Clustering in GlassFish v2




             JMX = Java Management Extensions
Memory Replication
Typical cluster topology




                Instance 1   Instance 2




                Instance 3   Instance 4




                Machine 1    Machine 2
Memory Replication
Typical cluster topology         Example: Maximize
                                 Availability on 4 node
                                 cluster on 2 machines




                Instance 1   Instance 2




                Instance 3   Instance 4




                Machine 1    Machine 2
Memory Replication
 Typical failover scenario

• Location transparency
  > fail over request can go to any instance in the cluster
• 2 Cases: Failover request lands on
  > Case 1: instance with replica data:
    ownership taken, processing continues
  > Case 2: instance without replica data
     > instance sends broadcast request
     > instance with replica data transfers data back to requester and deletes
       its copy after an acknowledge
     > JXTA makes this easy (propagation communication channels are
       scoped within the “group” (i.e. the cluster members)
HTTP Session State Failover


                    Servlet                    Servlet
                (HTTP Session)             (HTTP Session)


                   replicas                   replicas

 W    Load         instance 1                 instance 2
 S   Balancer




                    Servlet                    Servlet
                (HTTP Session)             (HTTP Session)


                   replicas                   replicas

                   instance 4    Cluster      instance 3
HTTP Session State Failover


                       Servlet                    Servlet
                   (HTTP Session)             (HTTP Session)


                      replicas                   replicas

  W      Load         instance 1                 instance 2
  S     Balancer


 Case 1:
 Instance has          Servlet                    Servlet
 replica data      (HTTP Session)             (HTTP Session)


                      replicas                   replicas

                      instance 4    Cluster      instance 3
HTTP Session State Failover


                         Servlet                    Servlet
                     (HTTP Session)             (HTTP Session)


                        replicas                   replicas

  W      Load           instance 1                 instance 2
  S     Balancer


 Case 2:
 Instance does not       Servlet                    Servlet
 have replica data   (HTTP Session)             (HTTP Session)


 Broadcast…
                        replicas                   replicas

                        instance 4    Cluster      instance 3
HTTP Session State Failover


                         Servlet                    Servlet
                     (HTTP Session)             (HTTP Session)


                        replicas                   replicas

  W      Load           instance 1                 instance 2
  S     Balancer


 Case 2:
 Instance does not       Servlet                    Servlet
 have replica data   (HTTP Session)             (HTTP Session)


 and ownership
                        replicas                   replicas
 transfer…
                        instance 4    Cluster      instance 3
Cluster Dynamic Shape Change


                         Servlet                    Servlet
                     (HTTP Session)             (HTTP Session)


                        replicas                   replicas

  W        Load         instance 1                 instance 2
  S       Balancer


 Shape Change
 instance1 fails         Servlet                    Servlet
                     (HTTP Session)             (HTTP Session)


                        replicas                   replicas

                        instance 4    Cluster      instance 3
Cluster Dynamic Shape Change


                         Servlet                    Servlet
                     (HTTP Session)             (HTTP Session)
                                      X
                        replicas                   replicas

  W        Load         instance 1                 instance 2
  S       Balancer
                                      X
 Shape Change
 instance1 fails         Servlet                    Servlet
 Instance2 and 4     (HTTP Session)             (HTTP Session)
 see the failure

                        replicas                   replicas

                        instance 4    Cluster      instance 3
Cluster Dynamic Shape Change


                              Servlet                                  Servlet
                          (HTTP Session)                           (HTTP Session)


                              replicas                                 replicas

  W        Load               instance 1                              instance 2
  S       Balancer


 Shape Change
 instance1 fails              Servlet                                  Servlet
                          (HTTP Session)                           (HTTP Session)
 Instance2 and 4
 see the failure

 Instance4 selects            replicas                                 replicas
 Instance2 as new
 partner—new                  instance 4           Cluster            instance 3
 connections
 established
                     the reverse happens when an instance joins or re-joins the cluster
Memory Replication Configuration
 Our hope was to say…

• “This page left intentionally blank” ;-)
  > Meaning “zero configuration required”
• We came close to that goal…
Memory Replication Configuration
 Out of the box…

• Create a domain
  > Use the ‘cluster’ profile – defaults for replication are handled
     > Enables GMS—heartbeat enabled
     > persistence-type = "replicated"
• Create a cluster and instances
• Deploy your application with availability-
  enabled=true
• That’s it
Memory Replication Configuration
 Making your app distributable

• <distributable/> element
  > Required in web.xml
     > Indicates you believe your application is ready to run in a cluster
• Serializable objects required
  > HTTP Session state
  > EJB technology Stateful Session Bean state
Configuring the availability service
     What is a
“lightweight”
Application Server ?
Tomcat ?
Fast startup ?
Load on-demand ?
Introducing
GlassFish v3 Prelude
Admin Console
Modular and Dynamic

• Modular : Apache Felix (OSGi)
• Extensible : HK2
• Yet very Fast !                            Security     Config
                    Grails JRuby/Rails
                          Web                Naming     Injection

                                dispatch
                                  GlassFish Kernel
                browser
                             Grizzly                           requests
                                           HK2 Services
                    Bundles repositories   OSGi Runtime
                                                               services
   Demo
     Startup
Compile on Save
Deploy on Change
Preserve Session
Painless Java EE development !

• Java EE development doesn't have to be painful :)
• Incremental compile of all Java EE artifacts
• Auto-deploy of all Java EE and static artifacts
Session Retention

Deployment option to maintain stateful sessions across re-
 deployments

$ asadmin redeploy --properties
 keepSessions=true myapp.war

Greatly simplifies the
 development paradigm.

Integrated in NetBeans 6.5 :
Yes, Eclipse too !




GlassFish (v2/v3) + Eclipse 3.4 Tools Bundle: http://download.java.net/glassfish/eclipse/
Update Center
Prelude to Java EE 6
(via GlassFish Update Center)


• JSF 2.0 Preview               • EJB 3.1 Preview
  > Integrated Facelets          > WAR packaging
  > First-class Ajax             > Singleton
    support                      > No Interface View
  > Pub/Sub Events               > TimerService
  > Composite                    > Asynchronous
    components                     operations
  > Better resource              > ...
    handling
                                • Servlet 3.0 soon
  > Groovy integration
JAX-RS (JSR 311) with Jersey

• Making it easy to build RESTful Web services
• Production-quality Reference Implementation
@javax.ws.rs.Path("/users/{id}")
public class UserResource {
    @javax.ws.rs.GET
    @javax.ws.rs.Produces("text/xml")
    public String getUser( @PathParam("id")
      String userName) {
        ...
    }
}

• Final and supported v1.0
• Fine client API too
Servlet 3.0

• POJO
  > @WebServlet
  > @ServletFilter
  > @WebServletContextListener
• web.xml now optional and supports fragments
• Support for asynchrony
  > @WebServlet(asyncSupported=true)
  > New APIs for Servlet request and response for suspend,
    resume
EJB 3.1 Sample

import javax.ejb.Singleton;            import javax.servlet.WebServlet;

@Singleton                             @WebServlet(urlMapping={"/Counter"})
                                       public class SimpleServlet {
public class CounterBean {
                                           @EJB     CounterBean counterBean;
    private int hitCount;                  void processRequest(...) {

    public synchronized int                     try {
         incrementAndGetHitCount() {                 ...

        return hitCount++;                           counterBean.incrementAndGetHitCount());

    }                                                ...

                                                } finally {

                                                      out.close();
}
                                                }
                                            }
                                       }
 Demo
simple ejb 3.1
war packaging
GlassFish Embedded



   AppServer glassfish = new AppServer(8080);
   glassfish.deployWar(warFile);
GlassFish Embedded

public class Main {
  public static void main (String[] args) {
    AppServer glassfish = new AppServer(8080);
    glassfish.deployWar(warFile);
  }
}
GlassFish Embedded

 @BeforeClass
 public static void setUpClass () {
   AppServer glassfish = new AppServer(8080);
   glassfish.deployWar(warFile);
 }

 @Test
 public void pingApplication () {
   ...
 }
A lot more ...

•   Dynamic languages : Rails, Grails, Django, ...
•   Comet, Cometd/Bayeux
•   Full support for mod_jk, WebDAV, CGI, SSI
•   Web Services Metro 1.4 (.Net 3.5)
•   IPS/pkg(5)                                         console user
                      domain.xml
                                  Central Config
•   RESTful admin                                Admin Console
•   Monitoring               Container       C
                                             o
                             Runtime               GUI Parts
•   Extensible                               n
                                             f
    > Engine              Grizzly Adapter       i
                                                g      Admin commands
    > Admin console
    > Config file                             Kernel
                             client/browser              admin invocation
GlassFish v3 Prelude – Practical

• Get it from http://glassfish.org
• Download size: 26MB
  > Graphical Installer
  > Zip version
  > Community-contributed IzPack installer
• Choice
  > Eclipse or NetBeans
  > Runs on Java 5 and Java 6 (Java EE 6 will mandate Java 6)
  > Felix or Equinox
• Questions and feedback to :
  USERS@glassfish.dev.java.net or GlassFish forum.
• Supported product, subscriptions available
GlassFish v3 Roadmap

• V3 Prelude
  > Today!

• V3 Final aligned with Java EE 6
  > Starting a series of Milestone releases
  > Targeted for Fall 2009
  > Clustering, central admin likely on the update center

• V3.1 full clustering
  > Likely 6 to 9 months after V3
Questions ?
alexis.mp@sun.com
http://blogs.sun.com/alexismp
                                47

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:41
posted:11/10/2011
language:English
pages:47