Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Getting Started Guide

Jared Gordon edited this page Aug 12, 2015 · 7 revisions
# Prerequisite Software The following software is required to build, deploy and run the SpringTrader application. ### To Build * Git 1.7.10 or later * Java 1.7

To deploy

Optional Software

  • vFabric RabbitMQ Management Plug-in (to view channel/queue stats)
  • MySQL client (to view database records)

Clone springtrader repo

Clone SpringTrader github repo under your home directory. It should create the ~/springtrader-cf folder.

git clone git@github.com:cf-platform-eng/springtrader-cf.git

Note: Please see github help for generating ssh keys: https://help.github.com/articles/generating-ssh-keys

As an alternative you can use the https method: https://github.com/cf-platform-eng/springtrader-cf.git

Build springtrader

First you need to set some environment variables for Gradle:

export GRADLE_OPTS='-Xmx1024m -Xms256m -XX:MaxPermSize=512m'

If you are behind proxy, add proxy to GRADLE_OPTS

export GRADLE_OPTS=$GRADLE_OPTS" -Dhttp.proxyHost=http://proxy.vmware.com -Dhttp.proxyPort=3128"

Run gradle build

cd ~/springtrader-cf
./gradlew clean build release

To compile without the tests you can execute the following command:

cd ~/springtrader-cf
./gradlew clean build release -x test

This should generate following files under dist folder

ls dist
spring-nanotrader-asynch-services-1.0.1.BUILD-SNAPSHOT.war
spring-nanotrader-services-1.0.1.BUILD-SNAPSHOT.war
spring-nanotrader-web-1.0.1.BUILD-SNAPSHOT.war
spring-nanotrader-web-1.0.1.BUILD-SNAPSHOT.tgz
DataGenerator.zip
## Create Service Instances
cf create-service cleardb spark tradersql
cf create-service cloudamqp lemur tradermessaging
## Push Application Components

An earlier instantiation of this project used a manifest to deploy the application and the first step was to make some minor edits to that manifest before pushing the app. In this version the manifest is no longer used. This is due to the fact that we are deploying an application to Cloud Foundry that is then also used as a service, via user provided service instance, with another pushed application binding to it. The manifest does not support the creation of user provided service instances so (begrudginly) we've had to move over to this imperative script.

The script is structured as follows: The first few lines assign names to the three application instances that will be pushed. Also assigned is the domain to which the apps will be pushed, as well as the names of existing service instances - one mysql database and one rabbitmq instance. These are the names you will need to change; I already own the routes traderweb.cfapps.io, traderfront.cfapps.io and traderback.cfapps.io, so if you try to deploy to run.pivotal.io without editing this script it will fail. Two more notes: 1) you should not have to change anything other than the names at the top of the script and 2) we are still assuming you created the service instances before running this script.

Your deployment script might look like this after edit:

#!/bin/sh

frontName=myveryowntraderfront
webName=myveryowntraderweb
backName=myveryowntraderback
domain=cfapps.io
sqlName=stsql
messagingName=stmessaging

date

echo Deploying front end services tier
cf push -p dist/spring-nanotrader-services-1.0.1.BUILD-SNAPSHOT.war -m 1G -t 180 -d $domain -n $frontName --no-start $frontName
cf bind-service $frontName $sqlName
cf bind-service $frontName $messagingName
cf push -p dist/spring-nanotrader-services-1.0.1.BUILD-SNAPSHOT.war -m 1G -t 180 -d $domain -n $frontName $frontName

echo Making this app available as a service instance
cf cups $frontName -p '{"uri":"http://'$frontName'.'$domain'/api/"}'

echo Deploying the web tier
cf push -p dist/spring-nanotrader-web-1.0.1.BUILD-SNAPSHOT.war -m 1G -t 180 -d $domain -n $webName --no-start $webName
cf bind-service $webName $frontName
cf push -p dist/spring-nanotrader-web-1.0.1.BUILD-SNAPSHOT.war -m 1G -t 180 -d $domain -n $webName $webName

echo Deploying back end services tier
cf push -p dist/spring-nanotrader-asynch-services-1.0.1.BUILD-SNAPSHOT.war -m 1G -t 180 -d $domain -n $backName --no-start $backName
cf bind-service $backName $sqlName
cf bind-service $backName $messagingName
cf push -p dist/spring-nanotrader-asynch-services-1.0.1.BUILD-SNAPSHOT.war -m 1G -t 180 -d $domain -n $backName $backName

date

Deploy the Application

After saving the deployment script you can simply push the entire application (the three war files), with service bindings, by issuing the following command:

./deployApp.sh
## Run SpringTrader Application

This is already done - your application is running at the URL reported in the output of the push command. Look for the URL of the traderfront application and try that in your browser.

The current application configuration includes the loading of quote data - that is, a set of tickers and prices associated. If this loads correctly on startup and you access the application you should see something like this:

Spring Trader Startscreen

If the ticker data is not shown across the top and you see only the username and password fields then the quote data was likely not loaded; you can use whatever MySQL client you'd like to have a look into the database. You will probably have the tables but the quote table is likely empty. To troubleshoot this:

In ...spring-nanotrader-services/src/main/resources/log4j.xml change these lines:

<logger name="org.hibernate">
   <level value="error" />
</logger>

to these:

<logger name="org.hibernate">
   <level value="debug" />
</logger>

Start streaming logs for your app with

cf logs <traderfrontappname>

and re-push the app. Inspect the logs.

Generate Sample Data

After the "springtrader" tc Server instance is running, you can optionally load sample data into the database.

... coming soon.