Sun Java System Reference Configuration Series: Portal Service on Application Server Cluster

Implementing Portlet Session Failover

The following procedures use of an example portlet(PortletSessionCounter) to demonstrate how to set up and test portlet session failover. PortletSessionCounter is a portlet that stores session state information. In particular, it counts the number of times a user interacts with the portlet by accessing the developer desktop.

To implement portlet session failover, you first enable high availability for the Application Server cluster in which your Portal Server instances are running. You then deploy and set up high availability for the portlet. As a result, session state information that is created by the portlet will be saved in the Application Server's High Availability Session Store (HADB). If a Portal Server instance fails, the session state information is made available to a failover Portal Server instance.

This section consists of the following procedures.

ProcedureTo Configure the Availability Service for pscluster

To implement portlet session failover, you must first create an HADB cluster and configure Application Server availability service settings for pscluster, as described in this procedure.

  1. Create an HADB cluster and add it to your Application Server cluster.

    Run the following command on either ps1 or ps2:

    # /opt/SUNWappserver/sbin/asadmin configure-ha-cluster --user admin --hosts ps1.pstest.com,ps2.pstest.com pscluster

    When prompted, type the app-server-admin-password.

  2. Start the Application Server Admin Console.

    1. Start a browser.

    2. Go to the following URL:

      https://ps1.pstest.com/4849

      The Application Server Admin Console login page opens.

    3. Log in to the Application Server Admin Console by typing the following values and clicking Login.

      Input Field 

      Value 

      User ID 

      admin

      Password 

      app-server-admin-password?

      The Application Server Admin Console opens.

  3. Modify Availability Service settings.

    1. Click on the small triangle next to Configurations in the left pane under Common Tasks.

      The configurations are expanded.

    2. Click on the small triangle next to pscluster-config.

      The pscluster configuration is expanded.

    3. Click on the Availability Service.

      The Availability Service settings are displayed in the right pane.

    4. Type the Availability Service settings shown in the following table.

      Input Field 

      Value 

      Availability Service 

      Enabled

      Store Pool Name 

      pscluster-hadb-pool

      Ha-agent-hosts 

      10.0.2.3, 10.0.2.4

      Ha-agent-ports 

      1862

      Ha-db-name 

      pscluster

    5. Click Save.

  4. Close the Console.

  5. Verify that HADB is working and that ps1 and ps2 are part of the HADB cluster.

    1. Check the HADB status.

      # /opt/SUNWhadb/4.4.3-5/bin/hadbm status pscluster

      When prompted, type the app-server-admin-password.

      The status of the pscluster high availability database should be FaultTolerant.


      Database  Status 
      pscluster FaultTolerant
    2. Check that ps1 and ps2 are part of the HADB cluster.

      # /opt/SUNWhadb/4.4.3-5/bin/hadbm status --nodes pscluster

      When prompted, type the app-server-admin-password.

      When prompted, type the app-server-master-password.

      All Application Server nodes should be in the running state.


       NodeNo HostName       Port  NodeRole NodeState MirrorNode 
       0      ps1.pstest.com 15200 active   running   1
       1      ps2.pstest.com 15220 active   running   0

ProcedureTo Set Up Session Failover for a Portlet

This procedure uses an example Session Counter portlet to demonstrate how to set up portlet session failover. Using this example, the procedure describes how to deploy a portlet into the pstestPortlet portal, enable high availability for the portlet, and create a desktop channel for the portlet.

  1. Download the Session Counter portlet from the Open Portal Portlet Repository site:

    https://portlet-repository.dev.java.net/public/Download.html

    The sessioncounter.war file is downloaded.

  2. Deploy the Session Counter portlet to DeveloperSample in the pstestPortal portal.

    # /opt/SUNWportal/bin/psadmin deploy-portlet -u amadmin -d o=DeveloperSample,dc=pstest,dc=com -p pstestPortal sessioncounter.war

    When prompted, type the access-manager-admin-password.

  3. Enable high availability for the Session Counter portlet.

    # /opt/SUNWappserver/sbin/asadmin set --user admin "domain.applications.web-module.sessioncounter.availability-enabled=true"

    When prompted, type the app-server-admin-password.

  4. Enable high availability for the Portal web application.

    # /opt/SUNWappserver/sbin/asadmin set --user admin "domain.applications.web-module.portal.availability-enabled=true"

    When prompted, type the app-server-admin-password.

  5. Create a channel for the Session Counter portlet.

    1. Create a display profile for the Session Counter portlet.

      Save the display profile document in Example Display Profile: Session Counter Portlet to /tmp/developer-dp.xml.

    2. Add the display profile to the developer user.

      # /opt/SUNWportal/bin/psadmin add-display-profile -u amadmin -d uid=developer,ou=People,o=DeveloperSample,dc=pstest,dc=com -p pstestPortal /tmp/developer-dp.xml

      When prompted, type the access-manager-admin-password.

ProcedureTo Verify Portlet Session Failover

In this procedure, you exercise the Session Counter portlet by successively reloading the developer desktop page in a browser. You first exercise the portlet while the Portal Server instance on ps2 is shut down, noting the session counter value. You then restart the Portal Server instance on ps2 and simulate a failure of the Portal Server instance on ps1so that the portal service fails over to the instance on ps2.

You then continue to refresh the browser and note the session counter value. If portlet session failover is working properly, the session counter value should continue to increase from its value before the failover occurred. If the session counter value is reset to 1, then session failover is not working.

  1. Make sure that ps-inst-ps1 on ps1 is running and that ps-inst-ps2 on ps2 is shut down.

    1. Start ps-inst-ps1 by starting the Application Server instance on ps1 in which it is deployed.

      # /opt/SUNWappserver/sbin/asadmin start-instance --user admin as-cluster-inst-ps1

      When prompted, type the app-server-admin-password.

    2. Shut down ps-inst-ps2 by shutting down the Application Server instance on ps2 in which it is deployed.

      # /opt/SUNWappserver/sbin/asadmin stop-instance --user admin as-cluster-inst-ps2

      When prompted, type the app-server-admin-password.

  2. Create a portlet session on ps1.

    You create a session by accessing the Session Counter portlet on the Developer Sample desktop, as follows:

    1. Open the portal service in a browser:

      http://ps.pstest.com/portal

    2. On the Samples box, click on the DeveloperSample.

      The anonymous desktop for the DeveloperSample should be displayed.

    3. Log in by typing the following values and clicking Login.

      Input Field 

      Value 

      User ID 

      developer 

      Password 

      developer 

      The DeveloperSample desktop is displayed.

    4. Click the Portlet Samples tab.

    5. Look at the Session Counter channel.

      The channel should show (in addition to other information):

      Counter Value in Session is 1.

  3. Click Reload in your browser.

    Now the Session Counter channel should show:

    Counter Value in Session is 2.

    Every time you reload the desktop page, the counter value will increase.

  4. Start ps-inst-ps2.

    # /opt/SUNWappserver/sbin/asadmin start-instance --user admin as-cluster-inst-ps2

  5. Simulate a failure of ps-inst-ps1.

    In the configuration interface for your load balancer (ps.pstest.com), remove the real server instance, ps-inst-ps1, from the service group.

  6. Click Reload in your browser.

    Now the Session Counter channel should show:

    Counter Value in Session is N.

    Where the value of N is one integer greater than the last value in Step 3.

    If session failover is not working, then the channel would show:

    Counter Value in Session is 1.

  7. Recover the simulated failure of the ps-inst-ps1 instance.

    Return to the configuration interface for your load balancer, and re-enable the instance.