users@glassfish.java.net

Re: JEE newbie question (related to glassfish)

From: <glassfish_at_javadesktop.org>
Date: Thu, 11 Oct 2007 17:35:26 PDT

> First question, about the VM. Is a VM created per.
> web application, per. thread or per. server? If i was
> to create a static class, and dump it in the
> appropriate directory in a web application director,
> and the class had a property for counting or
> whatever, how would this static class be scoped?
> Would it be shared across all threads in the
> web-application? And, how would this work with the
> clustering feature of glassfish?

Each instance of the server is running in a single JVM. All of the applications deployed on that server share that JVM. Applications servers play numerous shenanigans with classloaders and classloader hierarchies. You can almost think that each application has it's own classloader, but each applications shares the root classloaders (it's more complicated than that, but you get the idea). So, if you have a static class loaded from a library that is deployed only with the application, and you have two applications using the same class, each application would see a different static class because the class is visible only within each respective application.

However, if the static class were loaded from a common library loaded by the container (for example, a JDBC driver is loaded by the container, not the individual applications), then any static class in that shared library would also be shared across the applications.

In a cluster, you have several instances of the server and therefore several instance of the JVM, and there's no real direct sharing between them (there's sharing for failover, but that's different).

> Next question, about the DAS node in a glassfish
> cluster, I am aware that the node isn't required to
> be "live" for the cluster to run. And that its "only"
> used for administration, however, is it possible to
> implement redundancy? This bit from the glassfish
> cluster overview wiki-page confuses me a bit:
>
> [i]"It must be possible to have a failover plan for
> the DAS for example if the node on which it is
> running fails. This will include the ability to
> backup the Central Repository and and restore it onto
> a newly created DAS."[/i]
>
> does that mean, it is possible? or that it will be,
> in the future :D

No idea.

> Second last question :D (sorry about all these
> questions :P)
> How "transparent" is the clustering seen from a
> webapplication developers perspective? Is it possible
> to set up a cluster, so the developer can use JEE5
> freely and and worry about the war being deployed on
> a cluster?

Clustering is never transparent. It may seem transparent, but it will always have costs. If you application is completely stateless, where everything is, say, loaded from the database for every single transaction, then it's almost transparent.

> Last question :P
> When the load balancers forward a request to a
> glassfish cluster, does it collect the response from
> the application server, and send this back to the
> client. Or does the node in the application cluster
> communicate directly with the client?

The load balancer is effectively a sophisticated proxy, so all of the traffic passes through it in both directions.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=239630