Skip to main content

Architecting on demand solutions, Part 22: Define and deploy WebSphere clusters using Rational Software Architect WebSphere Cluster Creation Pattern

Ron Doyle (rdoyle@us.ibm.com), Senior Technical Staff Member, IBM, Software Group
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 (ngawor@us.ibm.com), Advisory Software Engineer, IBM, Software Group
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.

Summary:  In this installment of the Architecting on demand solutions series, you use the WebSphere Cluster Creation Pattern to quickly create Jython or Java™ Command Language (JACL) scripts to instantiate WebSphere® clusters on WebSphere Application Server (Versions 5.x and 6.x) using IBM Rational® Software Architect. Using Rational Software Architect to model cluster components in Unified Modeling Language (UML) lets you visualize component interactions. With this pattern you can generate deployment scripts from the UML models to accurately manage deployed assets. Discover how to use the pattern and a model-driven approach to produce deployment artifacts quickly and reliably.

View more content in this series

Date:  18 Jul 2006
Level:  Intermediate
Activity:  1508 views
Comments:  

Introduction

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.

Installation

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
dW 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
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
Apply 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
Package creation

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:

NameValue
CellWebSphere cell that will contain the cluster (must already exist)
ClusterCluster that will be created
J2EEApp(s)Application or applications that will be deployed into the newly created cluster
HttpServerWeb 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
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
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
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
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
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
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.


Summary

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.


Resources

Learn

Get products and technologies

Discuss

About the authors

Ron Doyle

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

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.

Comments



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Sample IT projects, WebSphere, Rational, Architecture
ArticleID=146886
ArticleTitle=Architecting on demand solutions, Part 22: Define and deploy WebSphere clusters using Rational Software Architect WebSphere Cluster Creation Pattern
publish-date=07182006
author1-email=rdoyle@us.ibm.com
author1-email-cc=
author2-email=ngawor@us.ibm.com
author2-email-cc=ngawor@us.ibm.com

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).