bluemix hands-on workshop - meetupfiles.meetup.com/14755122/ibm bluemix workshop - lab f... ·...

16
BlueMix Han Lab F - Java EE Clo BlueMix Version : 3.0 Last modification date : 05/ Owner : IBM nds-On Workshop oud Trader Benchmark Applic 00 /12/2014 M Ecosystem Development cation on

Upload: others

Post on 27-Mar-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

BlueMix HandsLab F - Java EE Cloud Trader Benchmark Application onBlueMix

Version : 3.00Last modification date : 05/Owner : IBM

BlueMix Hands-On WorkshopJava EE Cloud Trader Benchmark Application on

.00/12/2014

IBM Ecosystem Development

Java EE Cloud Trader Benchmark Application on

Copyright IBM Corporation 2013-2014. All rights reserved. 3

Table of Contents

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix................................................................ 5

1. Starting Eclipse ................................................................................................................................. 5

2. Importing the code for this section from GitHub................................................................................ 5

3. Define the BlueMix Server ................................................................................................................ 7

4. Push the application from Eclipse ..................................................................................................... 8

5. Running the application...................................................................................................................10

6. View the application's database......................................................................................................12

7. Add the Monitoring and Analytics service to the application...........................................................14

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 5

Lab F: Java EE Cloud Trader Benchmark Application onBlueMix

Lab Objectives: In this lab you'll learn how to create a Java EE benchmark application that runs on IBM BlueMix

and makes use of the SQLDB BlueMix service. Once you create and use the application you’ll also be able to use

performance analysis capabilities provided as services on BlueMix.

CloudTrader is a Java EE application which simulates an online stock trading system. This application allows users to

login, view their portfolio, lookup stock quotes, and buy or sell stock shares. It is built primarily with Java Servlets,

JSPs and JavaBeans. To showcase migrating existing applications to BlueMix and revitalizing them with services,

CloudTrader was created with minor changes on top of a ten year old DayTrader Java EE benchmark sample.

Lab Duration : 40 minutes

1. Starting Eclipse

In this section you’ll start Eclipse and load the workspace that will be used for this lab.

Step 1 Open Windows Explorer and launch the program \BlueMixLabs\eclipse\eclipse.exe where\BlueMixLabs is the root folder of the files provided to you by the instructor.

Step 2 Select the workspace \BlueMixLabs\workspaces\LabF when prompted and click OK

2. Importing the code for this section from GitHub

In this section you’ll use the built in Eclipse tools to import the code for this section from a Git repository.This is demonstrates how a typical BlueMix developer would work with version controlled code.

Step 1 Select File->Import from the Eclipse menu and select Git_>Projects from Git in the resultingdialog. Click Next.

Figure 1 Importing from GitHub

Step 2 Select GitHub as the source and click Next

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 6

Figure 2 Select GitHub as the source

Step 3 Enter the string bluemix-days-cloud in the Search field and click Search

Figure 3 Finding GitHub Repository

Step 4 Select the ibmecod Repository shown in Figure 3 and click Next.

Step 5 Repeat clicking Next to accept the defaults until the Finish button becomes active .

Step 6 Click Finish to complete the importing of the code.

Step 7 Wait until the project is built by monitoring the build status at the bottom right of the Eclipse UIuntil there is no activity reported

Figure 4 Build status

Step 8 Verify that there are no errors (ie red X's) in the Project Explorer pane following the build.

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 7

Figure 5 Project Explorer following import

3. Define the BlueMix Server

In this section you'll define the BlueMix server so you can automatically push your Eclipse code out toBlueMix when needed

Step 1 Click on the Servers tab at the bottom of the Eclipse UI as shown in Figure 24.

Figure 6 Eclipse Servers tab

Step 2 Click the link labeled ...Click this link to create a new server.

Step 3 Expand the IBM category and select IBM BlueMix. Click Next.

Figure 7 BlueMix as Server type

Step 4 In the next dialog enter your BlueMix credentials and click on Validate Account

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 8

Figure 8 Validate your BlueMix account

Step 5 Verify that the dialog reports that your account is valid and then click Finish.

Step 6 Your server definition should now appear in the Servers tab

Figure 9 Your server definition

4. Push the application from Eclipse

In this section you'll push, create services and start your app all from within the same UI in Eclipse .

Step 1 Go back to Eclipse and from the Servers tab select your server, right click and select Add andRemove from the context menu

Figure 10 Add project to server

Step 2 Select the CloudTrader application and click Add .

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 9

Figure 11 Add project to BlueMix

Step 3 Click Finish. Click Next in the resulting dialog

Step 4 Append a unique string to the Subdomain (eg your first initial + last name ) since this has to beunique systemwide. See Figure 16 for an example. Click Next

Figure 12 Specify unique Subdomain for app

Step 5 Click the icon to add a new service

Figure 13 Add new service

Step 6 Name the service TraderDataSource and select SQLDB as the Type. Click Finish

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 10

Figure 14 Name and type of service

Step 7 Click Finish to push and start your application.

Step 8 Messages should start appearing on the console. Wait for the message that says The serverdefaultServer is ready to run a smarter planet.

Figure 15 Console messages

5. Running the application

Now that the application has been deployed and started, you can run it from inside Eclipse

Step 1 From the Eclipse menu select Window>Web Browser and then select one of your installedWeb browsers (eg Firefox)

Figure 16 Select an external browser

Step 2 In the Project Explorer select your project, right click and then select Run As->Run on

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 11

Server from the context menu.

Figure 17 Launch application

Step 3 Click on Finish in the resulting dialog. .The browser you selected in Step 1 should launch withthe application

Figure 18 CloudTrader Initial Page

Step 4 Click on the Configuration tab and click “(Re)-populate Database” to populate your DB2database with initial users and stocks. Verify that you see a message that says

Trade Database Built - 50 users created

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 12

Figure 19 Populate database

Step 5 Click on the Trading & Portfolio tab and login to start buying and selling stocks.

Figure 20 Trading and Portfolio tab

Step 6 Click on Account to view account details, Portfolio to view your holdings and Quotes/Tradeto buy or sell holdings.

Step 7 Click the FAQ tab to see notes on the underlying “Trade” application design includingmessage driven beans, caching, performance benchmarking and application primitives

6. View the application's database

Now that the application has been deployed and started, you can look at the SQLDB database fromBlueMix

Step 1 In your browser go to the BlueMix url https://ace.ng.bluemix.net and login if necessary

Step 2 From your Dashboard scroll down to the Services section

Step 3 Click on the icon for the TradeDataSource service

Step 4 Click Launch the Console

Step 5 Select Database Viewer and then select Schemas

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 13

Figure 21 Schemas in Database Viewer

Step 6 Schemas are present for the system database tables and one for user tables, select the onefor user tables (last one in the list)

Step 7 You should be presented with the tables our Cloud Trader application is using, there are tablesfor the various entities used in the application such as Accounts, stock transaction Orders andQuotes.

Figure 22 CloudTrader Tables

Step 8 Select a table to inspect its columns:

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 14

Figure 23 Table Inspector

Step 9 Select Sample Data (on the left) to see some of the data in the selected table

Figure 24 Sample the Table's Data

7. Add the Monitoring and Analytics service to the application

Performance and availability monitoring is a critical capability and the Monitoring and Analytics service isa tool that can be easily added to check performance bottlenecks anywhere in the application andavailability issues.

What the Monitoring and Analytics service provides:

Built-in to the development environment so you see instant results Insight into how your code may affect the performance of the application Easy to use dashboards and integrated analytics-powered search capability help you find the root

cause line of code quickly and easily

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 15

Step 1 With your browser open the Blue Mix url https://ace.ng.bluemix.net and login if necessary

Step 2 Scroll down to Services section and click the Add new Service button.

Step 3 Click on the icon for the Monitoring and Analytics service in the DevOps section

Step 4 Click on CREATE AND ADD APP

Step 5 Select CloudTrader under Add to: and click Create.

Step 6 Click OK when prompted about restarting CloudTrader

Step 7 Go back to Eclipse and select CloudTrader in the Servers tab, right click and select Updateand Restart for the context menu

Step 8 Select CloudTrader in the Project Explorer, right click and select Run as->Run on Server tobring up CloudTrader in your browser

Step 9 Append /stress.jsp to the CloudTrader application's main page URL and reload. Let theresulting stress test run for about 30 seconds and then close the browser tab

Figure 25 CloudTrader Stress Test

Step 10 With your browser open the Blue Mix url https://ace.ng.bluemix.net and login if necessary

Step 11 Scroll down to Services section and click the icon for the running Monitoring and Analyticsservice

Step 12 Explore the Availability and Performance Monitoring tabs (using the notes after Figure 26 as aguide)

Lab F: Java EE Cloud Trader Benchmark Application on BlueMix

Copyright IBM Corporation 2013-2014. All rights reserved. 16

Figure 26 Monitoring and Analytics UI

Notes:

The Availability tab provides basic "ping" information about your BlueMix application URL. The resultsfrom recent hours are displayed so that you can answer the following questions:

• Has my BlueMix application been consistently reachable and responsive?

• Were there time periods when application response times were unusually slow?

• Were there time periods when my application was down, as signified by 404 or other non-200status codes?

The Performance Monitoring tab provides resource metrics about your BlueMix Liberty application.Recent data is displayed so that you can answer the following questions:

• Have there been any unusual spikes in CPU usage?

• How much heap memory has my application been using and is it within acceptable limits?

• What is my application's thread pool usage, and is it what I expected?

• How frequently and for what duration has garbage collection run and might that impactperformance?

Congratulations! You’ve successfully completed Lab F where you've deployed a legacy JEE applicationand used the Monitoring and Analytics Service