Real-world applications require predictable availability and response time. One way to assure availability and consistent response time is to define clusters of servers to handle web and enterprise applications. A cluster is a set of servers that provide a single system image, and manage application load and server load across the servers that participate in the cluster. Managing load across a cluster involves the following facets:
JRun supports the following types of clustering:
The sections "Connector-based clustering" and in "Object clustering" describe additional considerations for load balancing and failover.
You use the JMC to define JRun server clusters. For more information on defining a cluster of JRun servers, see the JMC online Help.
Note: Do not add the admin JRun server to a cluster.
When you start a JRun server that belongs to a cluster, the cluster manager uses multicast to register itself with all other nearby clustered JRun servers (that is, JRun servers in the same cluster and on the same subnet). You can also name specific cluster members with the cluster manager unicastPeer attribute in the jrun.xml file. Specifying a unicast peer lets you cluster JRun servers that do not run on the same subnet.
JRun lets you automatically deploy enterprise applications, web applications, EJBs, and JCA connector to all servers in the cluster. Thus, you can ensure a consistent image across all JRun servers in a cluster.
JRun session persistence functionality ensures that user sessions for JSPs, servlets, and stateful session beans are maintained when a server shuts down. In a nonclustered environment, the sessions are restored the next time JRun starts. In a clustered environment, however, you want session information to be immediately available to other servers in the cluster. This section describes JRun session persistence options and how they apply to clustering.
Note: When executing a stateful session bean or a web application that uses sessions, JRun uses session affinity to route requests to the appropriate server. JRun can handle sessions based on cookies (the default), URL parameters, and form variables.
To get the from your clustered environment, you must understand session management options and how JRun handles session management. For web applications, JRun persists sessions using one of the following mechanisms:
Optionally, you can use settings in the jrun-web.xml file to persist sessions while JRun is running. File-based session persistence does not support clustered session management.
For stateful session beans, JRun uses in-memory replication only. When an EJB method completes, JRun automatically passivates session state to a buddy server in the cluster.
This is the only method that supports web server load balancing through ClusterCATS. For more information, see "Web server clustering".
You configure file, JDBC, and custom session persistence through elements in the jrun-web.xml file, as follows:
The following sections provide examples of these elements.
File-based session persistence is the default. In most cases you do not change any settings. However, you can modify settings, such as such as session-swapping and session-swap-interval.
In addition, file-based session persistence takes the following init-param:
The following example shows file-based session persistence in the jrun-web.xml file:
...
<session-config> ��<persistence-config> ����<active>true</active> ����<persistence-type>file</persistence-type> ����<persistence-synchronized>true</persistence-synchronized> ����<class-change-option>reload</class-change-option> ����<session-swapping>true</session-swapping> ����<session-swap-interval>5</session-swap-interval> ����<session-max-resident>500</session-max-resident> ��</persistence-config> ...
When using file-based session persistence, you can pass a path attribute as an init-param, which specifies the directory to which JRun writes session information.
For more information on these settings, see the online descriptor documentation accessed from the JRun online documentation home page.
JDBC-based session management allows multiple JRun servers to share a persistence store.
persistence-type to JDBC and specifying init-param elements for the following items:The following example illustrates JDBC-based session persistence in the jrun-web.xml file:
...
<session-config> ��<persistence-config> ����<active>true</active> ����<persistence-type>jdbc</persistence-type> ����<persistence-synchronized>true</persistence-synchronized> ����<class-change-option>reload</class-change-option> ����<session-swapping>true</session-swapping> ����<session-swap-interval>5</session-swap-interval> ����<session-max-resident>500</session-max-resident> ����<init-param> ������<param-name>JDBCConnection</param-name> ������<param-value>samples</param-value> ����</init-param> ����<init-param> ������<param-name>JDBCSessionTable</param-name> ������<param-value>sessions</param-value> ����</init-param> ����<init-param> ������<param-name>JDBCSessionIDColumn</param-name> ������<param-value>sessionid</param-value> ����</init-param> ����<init-param> ������<param-name>JDBCSessionDataColumn</param-name> ������<param-value>sessiondata</param-value> ����</init-param> ��</persistence-config> ...
For more information on these settings, see the online descriptor documentation accessed from the JRun online documentation home page.
To use session replication for web applications, update the session-config element in jrun-web.xml file for all web applications that use in-memory session management. To replicate to all servers in a cluster, specify replication-config elements, as follows:
...
<replication-config> ��<active>true</active> ��<buddy-list>*</buddy-list> </replication-config> ...
Tip: To implement this change for all web applications in a JRun server, code the replication-config settings in the SERVER-INF/default-web.xml file.
To replicate to one or more specific servers in a cluster, specify replication-config elements, as follows:
...
replication-config> ��<active>true</active> ��<buddy-list>jrunserver2</buddy-list> ��<buddy-list>jrunserver3</buddy-list> ��<buddy-list>jrunserver4</buddy-list> </replication-config> ...
Tip: You can specify * to replicate across all servers in the cluster.
Restart all JRun servers after making these changes.
JRun 3.x let you persist session information to a database. JRun 4 replaces this functionality with an interface that you can implement to persist session information to a site-specific session store, which could be a database or some other destination.
jrun.servlet.session.SessionStorage.... public class DBMSSessionStorage implements SessionStorage ...
jrun.servlet.session.SessionStorage
java.io.InputStreamjava.util.Listjava.util.Propertiesinit-param properties passed to the init method.String dataSource; String table; String idColumn; String dataColumn;
init method. For example a DBMS-based custom session storage manager might use the following initialization parameters:public void init(Properties props) throws Exception {
��dataSource = props.getProperty("dataSource");
��if (dataSource == null) {
����dataSource = "defaultDataSource";
��}
��table = props.getProperty("table");
��if (table == null) {
����table = "sessions";
��}
��idColumn = props.getProperty("idColumn");
��if (idColumn == null) {
����idColumn = "sessionid";
��}
��dataColumn = props.getProperty("dataColumn");
��if (dataColumn == null) {
����dataColumn = "sessioninfo";
��}
} // end init
store method, which stores a session in the custom persistence mechanism. The store method has the following signature:public void store(String id, InputStream in, int len) throws Exception
retrieve method, which access a session from the custom persistence mechanism. The retrieve method has the following signature:public InputStream retrieve(String id) throws Exception
remove method, which deletes a session from the custom persistence mechanism. The remove method has the following signature:public void remove(String id) throws Exception
destroy method, which performs any clean up required when shutting down the service. The destroy method has the following signature:public void destroy()
For complete examples, see the SERVER-INF/lib/jrun/samples/session directory in the samples server.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/jrun/4/JRun_Administrators_Guide/clustering2.htm
Comments
ben pinnick said on Oct 28, 2003 at 2:42 AM :