Designing and deploying a reusable database pattern
JayAllen 120000G6WH Comment (1) Visits (5610)
In this blog entry, we’ll highlight how to design and deploy an application to the cloud using the Database Pattern provided as one of the patterns within IBM Work Load Manager.
Here are two acronyms used in this blog entry
Why you might need a database pattern
Before we dive into building and implementing a database pattern, it is worth spending some time to explain why you might need a database pattern,. Most enterprise applications will consist of, at the least, an application EAR(enterprise archive) or WAR(web application archive) file and a database.
You can easily create a virtual application pattern(VAP) with both these elements and deploy it on the cloud; however, the database is tied to the instance , When that's the case, if you delete the VAP instance, the database instance is also deleted.
In real-world usage, databases are managed independently of any application. To more closely model this paradigm, a database pattern was created. By deploying an independent database pattern, deleting a virtual application has no impact on the deployed database.
We will now look at how to create a reusable database component (DB2) using IWDs Data
We've split this blog entry into three parts:
Design and deploy database pattern
As shown in Figure 1 go to Patterns tab in the IWD; you will see a pull-down menu. Select the Database Patterns.
Figure 1. Select Database Patterns
After the Database Patterns option is selected, this will lead to a screen which lists the database patterns in the system. Click the green add icon to create a new pattern as shown in Figure 2.
Figure 2. Adding a new pattern
In the next screen (Figure 3), specify the options for the new database pattern. Enter the database pattern name and also include the path to the schema file as shown. Then enter Save to proceed to next step.
Please note the schema file should contain the DDL to create the tables and any data you want to prepopulate. The schema file used in this example is attached as part of this blog entry.
Figure 3. Specify the options for the database pattern
Now the left panel in IWD will show the recently created database pattern; in this example it will be IpasdemoDB. Click on the pattern and the panel on the right will display the details as shown in Figure 4.
Figure 4. Display the new pattern details
As highlighted in Figure 4, click on the Deploy button to deploy the pattern on the cloud. This will pop up a dialog box as shown in Figure 5.
Figure 5. Fill in this dialog box
Enter the database name and description that needs to be created. In this example, We use mydb as the name. This essentially creates an instance of the database. IWD will install the operating system and then install the database. For test purpose we are using db2 9.7 on Linux.
Click the OK button. IWD then deploys the database pattern to the cloud.
Next, IWD will then present a link to go to the instance being deployed. Click on it and you will be taken to the Instance tab. Here IWD will provide real-time information about the deployment.
After the deployment is completed, IWD will show all green as seen in Figure 6.
Figure 6. All green means your deployment is complete
A few notes on what’s shown in Figure 6:
Make the deployed database instance a reusable virtual component
Now we’ll highlight how to make the database instance you’ve created into a reusable virtual component.
Navigate to the Catalog tab on the IWD interface and select the Reusable Components option as seen in Figure 7.
Figure 7. Reusable Components option
From the Reusable Components page, select the Add icon in green as shown in Figure 8.
Figure 8. Add the component
After selecting the Add icon, a new Create dialog box will open. Select WebApp Pattern Type 1.0 as the pattern type. For the component type, select the Existing Database (DB2) option. Now the dialog should look like Figure 9.
Figure 9. Selecting the pattern and component types
Click the Next button. As shown in Figure 10, fill in the fields for the reusable components to correspond to the database deployed earlier.
Figure 10. Make sure the reusable component data matches the earlier-deployed database info
Make sure the existing database name matches the name created earlier, IP address, port number, user name, and password. Please refer to back to Figure 6 to get all of this information.
Click Done. You should now have a reusable component that can be used in the VAP.
Use the reusable database component to design and deploy a VAP
Now we move on to the final task in this blog entry -- to create a virtual application pattern which includes a WebSphere Application Server and the earlier created database component.
From IWD, select the Patterns tab and select the Virtual Applications option as seen in Figure 11.
Figure 11. The Virtual Applications option
After selecting Virtual Applications, click the Add icon in green which will take you to a Create application dialog box as seen in Figure 12.
Figure 12. The Create application dialog
Select WebApp Pattern Type 1.0, choose the Blank application option, and click on the Start Building button. This will then lead us to the VAP creation screen as seen in Figure 13.
Figure 13. Starting VAP creation
In Figure 13, the left panel lists all the components that can be dragged and used in a VAP; select the Enterprise Application component and drag it to the right side panel. Click the just dragged component and the extreme right panel will refresh as shown.
The next step is to upload the EAR file to the VAP; this can be done by clicking the Browse button as shown in Figure 13. The name of the EAR file I used is ipasdemoEAR.
You can obtain the EAR file by following this link. After performing this step, the warning link highlighted in Figure 13 will disappear.
Now you can proceed to add the database instance pattern you created in the previous steps. First expand the Database Components from the left panel and select Existing Database and then you’ll see a twisty. Click on the twisty to see the database you created earlier. Select and drag the component to the right panel as shown in Figure 14.
Figure 14. Adding the database instance pattern
Now select the just dragged box and you will see properties of the database are all pre-filled because you are using the component you customized in the earlier steps. This can be seen in Figure 15.
Figure 15. Pre-filled in database component descriptions
In order for the Enterprise Application to use the database, we need to link the two components. Hover over the Enterprise Application and drag the yellow dot over to the existing database, it will turn into a line with an arrow (Figure 16).
Figure 16. Linking the Enterprise Application and database components
On the extreme right side panel enter the JNDI Name the application will use; in the example I use jdbc/mydb as the resource name. Apply the resource name to the respective WAR by clicking on the select drop-down; leave the rest as default. The application deployment topology has been completely designed.
Save the application by clicking on the Save As tab on the top left area. This will bring up a dialog as shown in Figure 17; in the example We have named it ipasDemoapp.
Figure 17. Saving the application
Click the OK button; this will lead you to Figure 18.
Figure 18. Back to Virtual Application Patterns screen
As you can see, the left panel lists the VAPs in IWD. Highlight ipasDemoapp (the name of the application) and the right panel will refresh with the pattern details. Click on the Deploy button to deploy the pattern. This is very similar to steps described in Figures 4 and 5.
After the pattern is deployed, go the instance view for VAP (Figure 19); the pattern instance will be available on the left pane.
Figure 19. VAP instance view
This step may take a bit of time; the cloud order of deployment is:
After these automated operations are completed, you need to verify that the deployment was successful. Just look for all green arrows (Figure 20).
Figure 20. All green arrows means deployment is successful
Notice the Endpoint hyperlink circled in red in Figure 20; IWD provides a way to invoke and test your application. Click on the link and a new window will open that will show the endpoint for the application (as shown in Figure 21).
Figure 21. Testing application endpoints
Click on the hyperlink presented in the dialog; this will take you to the application in a new browser window (as in Figure 22).
Figure 22. Testing your database connection status
As you can see, the application deployment was successful -- the page interacts with the backed application which reads the database and displays the users from the DEMO_USERS table.
We’ve shown you how to successfully design a database using the IWD’s Data