In this article, discover how to use the newly released WebSphere Cluster Creation Pattern to build and deploy WebSphere clusters. First, you'll import the WebSphere Cluster Creation Pattern into Rational Software Architect. Next, you'll create a new UML model to which you can add this pattern, which encapsulates best practices for deploying WebSphere clusters. By applying a WebSphere profile to this model along with the pattern, your model will be able to define all of the components of a WebSphere cluster. After you've used the pattern to model the WebSphere cluster(s) you want to deploy, you'll be able to transform your model into JACL or Jython scripts that can be used to deploy the modeled clusters. By using scripts based on the pattern, you can be sure your deployed cluster will reflect best practices. This article walks you through the entire process, from importing the pattern to running the generated scripts.
Using the WebSphere Cluster Creation Pattern
The WebSphere Cluster Creation Pattern is packaged as a reusable asset that can be imported and installed into Rational Software Architect. You can design a complete WebSphere cluster topology, including applications and HTTP tier, using the UML modeling capabilities of Rational Software Architect.
This pattern lets you use the UML modeling functions of Rational Software Architect to model the elements of a WebSphere cluster. Modeled elements include the WebSphere cell, cluster, server instances, HTTP server, and Java Enterprise Edition (JEE) applications. Using the UML model with the necessary configuration parameters, this pattern provides the transformation of the model to runnable JACL or Jython scripts to instantiate the cluster in a live environment.
Installing the WebSphere Cluster Creation Pattern requires Rational Software Architect V6.0.0.1 or V6.0.1. To install the WebSphere Cluster Creation Pattern, launch the New Repository Connection wizard from the RAS (Reusable Assets) Perspective, and select DeveloperWorks Repository, as shown in Figure 1.
Figure 1. DeveloperWorks Repository connection

After successful connection, the WebSphere Cluster Creation Pattern is visible in the deploy_soa folder. Select Import, as shown in Figure 2.
Figure 2. Importing the WebSphere Cluster Creation Pattern Asset

After restarting the workspace, the WebSphere Cluster Creation Pattern appears in the Pattern Explorer, as shown Figure 3.
Figure 3. Viewing the WebSphere Cluster Creation Pattern in Pattern Explorer

Modeling a WebSphere cluster in UML
To visualize a cluster environment, you can start by creating a new UML model (for example, ABC Customer Cluster) and applying the WebSphere Cluster Creation Profile. The WebSphere Cluster Creation Profile provides stereotypes for annotating UML nodes and components representing cluster server members, network deployment nodes, HTTP servers, and Java EE applications. To apply the profile, simply select Profiles in the model properties and click Add Profile. Select WebSphere Cluster Creation Profile, as shown in Figure 4. Save the model before proceeding.
Figure 4. Applying WebSphere Cluster Creation Profile

See a larger version of this figure.
Next, you need to add a UML package to capture future artifacts. Select the model and choose Add UML > Package, as shown Figure 5.
Figure 5. Creating a package

Now you're ready to build a model to represent the WebSphere cluster. Begin by adding a new UML diagram by selecting Add Diagram > Freeform diagram.
Applying the WebSphere Cluster Creation Pattern
To apply the WebSphere Cluster Creation Pattern, select WebSphere Cluster Creation Pattern from the Pattern Explorer, and drop it into the free-form diagram you just created.
The WebSphere Cluster Creation Pattern has five parameters:
| Name | Value |
|---|---|
| Cell | WebSphere cell that will contain the cluster (must already exist) |
| Cluster | Cluster that will be created |
| J2EEApp(s) | Application or applications that will be deployed into the newly created cluster |
| HttpServer | Web server that sends traffic to the cluster |
| Node(s) | Node or nodes that will have cluster members created on them (must already exist) |
First, define the cell parameter. You can create a cell by dragging a UML component from the palette and applying the cell stereotype, but it is easier to use the pattern instance to create a cell for you. To create the cell with a default name that is added to the model, move your cursor to the cell parameter and select the component icon in the action bar, as shown in Figure 6.
Figure 6. Creating a new cell parameter

Highlight the cell parameter and rename it to reflect the name of the cell that will contain the cluster. The cell stereotype has three parameters associated with it that you will need to define in the Stereotypes tab of the Properties view, as shown in Figure 7:
- hostname: the deployment manager hostname
- port: the deployment manager port
- webspherePath: the location of the WebSphere installation directory on the deployment manager host
Figure 7. Cell stereotype properties

- Create a cluster by placing the cursor over the cluster parameter and selecting the component icon in the action bar. Highlight the cluster parameter and rename it to the name of the cluster you want to create. The cluster stereotype has no parameters.
- Create one or more Java EE applications by placing the cursor over the J2EEApp parameter and selecting the artifact icon in the action bar. If you do not want to deploy any Java EE applications to your cluster, you do not need to specify a value for this parameter. For each application that you want to deploy into the cluster, you will need to rename the application parameter to reflect the name of your application and specify the path property in the Stereotypes tab of the Properties view. The path is the location of the application file on the deployment manager machine. The slashes in the path should be UNIX™-style, or forward, slashes (for example, C:/pathToMyApp/A).
- Create an HTTP server by placing the cursor over the HTTPServer parameter and selecting the node icon in the action bar. The name of the HTTP server parameter is not important.
- Create one or more nodes by placing the cursor over the node parameter and selecting the node icon in the action bar. Rename each node to the name of the node that will be created as a new cluster member.
- After adding all the pattern parameters, be sure that you have saved all of the files to ensure everything is in a consistent state. To see a visual representation of the model you've just created and the relationship created between the various pattern parameters, drag each pattern parameter from the Model Explorer onto the free-form diagram. If you cannot see the abstractions between the model objects, right-click the diagram and select Filters > Show / Hide Relationships. Make sure the Abstraction checkbox is checked and select OK.
The model should look similar to the one in Figure 8.
Figure 8. WebSphere cluster model

The model is now complete and ready for transformation to a deployment script.
Running WebSphere Cluster Deployment transformation
The WebSphere Cluster Deployment transform is included in the WebSphere Cluster Creation Pattern asset. You can use this transform to generate JACL or Jython scripts to create the WebSphere cluster you modeled. From the Modeling perspective, highlight the package you created and select Transform > Run Transformation > WebSphere Cluster Deployment Transformation to invoke the transform, as shown in Figure 9.
Figure 9. Invoking the WebSphere Cluster Deployment Transform

Select the Output tab from the transformation wizard. If you want the transformation to output a Jython script instead of a JACL script, select the Output in Jython checkbox, as shown in Figure 10. JACL scripts can be used with WebSphere Application Server versions 5.x and 6.x, while Jython scripts will work with WebSphere Application Server 6.x and above.
Figure 10. Project selection

Select the project containing your model, such as Miscellaneous Models, in the transformation wizard, as shown in Figure 11. Select Run.
Figure 11. Selecting the WebSphere Cluster project

The script will be generated in the target you have specified (Miscellaneous Models project), but you may not be able to see it from the Modeling perspective. To view the script, switch to the Resources perspective, as shown in Figure 12.
Figure 12. Generated JACL script shown in the resources perspective

Listing 1 shows the generated JACL script created by transforming the model.
Listing 1.WebSphere Cluster Creation0.jacl
set clusterNameSearch "*/TestCluster*"
set clusterName "TestCluster"
set cell [$AdminConfig list Cell]
set preferLocalValue "false"
set clusterDesc "Cluster for WebSphere Cluster Creation0"
set oServerClusterList [$AdminConfig list ServerCluster]
set oI [lsearch -glob $oServerClusterList $clusterNameSearch ]
if { $oI < 0 } {
set attrs [list [list name $clusterName] [list preferLocal $preferLocalValue]
[list description $clusterDesc]]
set createCluster [$AdminConfig create ServerCluster $cell $attrs]
}
$AdminConfig save
puts 0;
set oServerClusterList [$AdminConfig list ServerCluster]
set oI [lsearch -glob $oServerClusterList "*/TestCluster*"]
if { $oI < 0 } {
exit 1;
}
set oAppList [$AdminApp list]
set oI [lsearch -glob $oAppList "TestApp"]
if { $oI < 0 } {
$AdminApp install "C:/pathToApp/testApp.ear" {-cluster TestCluster}
}
$AdminConfig save
set oServerClusterList [$AdminConfig list ServerCluster]
set oI [lsearch -glob $oServerClusterList "*/TestCluster*"]
if { $oI < 0 } {
exit 1;
}
set oNodeList [$AdminConfig list Node]
set oI [lsearch -glob $oNodeList "*/TestNode*"]
if { $oI < 0 } {
exit 1;
}
set oServList [$AdminConfig list Server]
set oI [lsearch -glob $oServList "*/TestNode_Server_0*"]
if { $oI < 0 } {
set cluster [$AdminConfig getid /ServerCluster:TestCluster/]
set servers [$AdminConfig list Server]
set node [$AdminConfig getid /Node:TestNode/]
$AdminConfig createClusterMember $cluster $node {{memberName TestNode_Server_0}}
}
$AdminConfig save
set Sync1 [$AdminControl completeObjectName node=TestNode,name=nodeSync,* ]
$AdminControl invoke $Sync1 sync
set pluginGen [$AdminControl completeObjectName type=PluginCfgGenerator,*]
$AdminControl invoke $pluginGen generate [list "C:/IBM/WebSphere/AppServer"
"C:/IBM/WebSphere/AppServer/config" TestCell null null "TestCell_plugin"]
# Save the configuration
$AdminConfig save
puts "Configuration saved."
|
This script will only install the application if it doesn't already exist. If the cluster being created already exists, it will exit with an error.
Executing the transform output
The scripts generated by the pattern transformation are used as input to the wsadmin command. The syntax
for the wsadmin command (on Windows) is shown in Listing 2.
Listing 2. Syntax for wsadmin command
wsadmin.bat -user username -password password -f "WebSphere Cluster Creation0.jacl" |
If you choose Jython as the output scripting language, you must include a -lang jython option on the command
line.
In this article you use the recently released Rational Software Architect WebSphere Cluster Creation Pattern to rapidly build and deploy WebSphere clusters. As more and more reusable patterns are captured in Rational Software Architect, more of the best practices can be automatically generated, reducing the development time and improving overall quality.
Learn
- Series overview: Link to more articles in this series and an overview of this project, which demonstrates to business analysts, solution designers, and architects how to design and implement on demand solutions using the thirteen capabilities of the IBM On Demand Operating Environment.
- Rational Software Architect: Learn more about Eclipse-based UML Modeling and Java Development.
-
Visit the developerWorks Rational Pattern Solutions zone to expand your patterns skills.
- Reusable Asset Specification documentation: Read more about reusable assets.
- Search for related books at Safari Bookshelf.
Get products and technologies
- Rational Software Architect: Download a free trial version of Rational Software Architect.
-
Build your next development project with IBM trial software, available for download directly from developerWorks.
Discuss
- Stay current with developerWorks technical events and webcasts.
- developerWorks blogs: Get involved in the developerWorks community.

Ron Doyle is a senior technical staff member in Software Group Strategy, working in the Advanced Design and Technology department in Research Triangle Park, NC. He is currently working on projects involving dynamic resource provisioning, software automation, and systems management. You can reach Ron at rdoyle@us.ibm.com.

Nell Gawor is an advisory software engineer for IBM in Research Triangle Park, North Carolina, in the Software Group Advanced Design and Technology Group. She received a Masters Degree in Computer Science from the University of Illinois at Urbana-Champaign. Contact Nell at ngawor@us.ibm.com.

