16.4. Configure a basic cluster with NSAPI

Task: Configure a Basic Cluster with NSAPI

Complete this task to configure a basic cluster, where requests for particular paths are forwarded to particular worker nodes. The procedure specifies that worker02 serves the /nc path, while worker01 serves /status and all other paths defined in the first part of the obj.conf file.

Prerequisites

  1. Define the paths to serve via NSAPI

    Edit the SJWS/PROFILE/config/obj.conf file. Define paths that should be served via NSAPI at the end of the default Object definition, as shown:
    <Object name="default">
          [...]
       NameTrans fn="assign-name" from="/status" name="jknsapi"
       NameTrans fn="assign-name" from="/images(|/*)" name="jknsapi"
       NameTrans fn="assign-name" from="/css(|/*)" name="jknsapi"
       NameTrans fn="assign-name" from="/nc(|/*)" name="jknsapi"
       NameTrans fn="assign-name" from="/jmx-console(|/*)" name="jknsapi"
    </Object>
    You can map the path of any application deployed on your JBoss Enterprise Platform instance in this obj.conf file. In the example code, the /nc path is mapped to an application deployed under the name nc.
  2. Define the worker that serves each path

    Edit the SJWS/PROFILE/config/obj.conf file and add the following jknsapi Object definition after the default Object definition.
    <Object name="jknsapi">
       ObjectType fn=force-type type=text/plain
       Service fn="jk_service" worker="worker01" path="/status"
       Service fn="jk_service" worker="worker02" path="/nc(/*)"
       Service fn="jk_service" worker="worker01"
    </Object>
    This jknsapi Object defines the worker nodes used to serve each path that was assigned to name="jknsapi" in the default Object.
    In the example code, the third Service definition does not specify a path value, so the worker node defined (worker01) serves all of the paths assigned to jknsapi by default. In this case, the first Service definition in the example code, which assigns the /status path to worker01, is superfluous.
  3. Define the workers and their attributes

    Create a workers.properties file in the location you defined in Step 2.
    Define the list of worker nodes and each worker node's properties in this file:
    # An entry that lists all the workers defined
    worker.list=worker01, worker02
    
    # Entries that define the host and port associated with these workers
    worker.worker01.host=127.0.0.1
    worker.worker01.port=8009
    worker.worker01.type=ajp13
    
    worker.worker02.host=127.0.0.100
    worker.worker02.port=8009
    worker.worker02.type=ajp13
  4. Restart the server

    Once your Sun Java System Web Server instance is configured, restart it so that your changes take effect.
    For Sun Java System Web Server 6.1:
    SJWS/PROFILE/stop
    SJWS/PROFILE/start
    For Sun Java System Web Server 7.0:
    SJWS/PROFILE/bin/stopserv
    SJWS/PROFILE/bin/startserv