Your DataStax Enterprise (DSE) installation contains a demo portfolio manager application that showcases how you can run a mixed workload on a DSE cluster. The demo is located in /usr/share/dse-demos/portfolio_manager for packaged installations or $DSE_HOME/demos/portfolio_manager for binary installations.
The portfolio manager application demonstrates a hybrid workflow using DataStax Enterprise. The use case is a financial application where users can actively create and manage a portfolio of stocks.
On the Cassandra OLTP side, each portfolio contains a list of stocks, the number of shares purchased, and the price at which the shares were purchased. A live stream of data simulates an active stock market, and updates each portfolio based on its overall value and the percentage of gain or loss compared to the purchase price. Historical market data is tracked for each stock (the end-of-day price) going back in time.
In the demo, simulated real-time stock data is generated by the pricer utility. This utility generates portfolios, live stock prices, and historical market data.
On the DSE OLAP side, a Hive MapReduce job is used to calculate the greatest historical 10 day loss period for each portfolio, which is an indicator of the risk associated with a portfolio. This information is then fed back into the real-time application to allow customers to better gage their potential losses.
Before you begin, make sure you have installed, configured, and started DSE on either a single node or a cluster. If running the demo on a cluster, install and run the demo from the DSE Job Tracker (analytics seed) node.
Go to the portfolio manager demo directory.
cd /usr/share/dse-demos/portfolio_manager
or
cd $DSE_HOME/demos/portfolio_manager
Note
You must run the pricer utility from a directory where you have write permissions (such as your home directory), or else run it as root or using sudo.
Run the ./bin/pricer utility to generate stock data for the OLTP application. To see all of the available options for this utility:
./bin/pricer --help
The following examples will generate 100 days worth of historical data.
If running on a single node cluster on localhost:
./bin/pricer -o INSERT_PRICES
./bin/pricer -o UPDATE_PORTFOLIOS
./bin/pricer -o INSERT_HISTORICAL_PRICES -n 100
If running the demo on a cluster, you also need to supply the IP address of the DSE Analytics node from where you are running the demo. For the first command, also supply the replication strategy for the keyspace that gets created. For example:
./bin/pricer -o INSERT_PRICES -d 110.82.155.0 \
--replication-strategy="org.apache.cassandra.locator.NetworkTopologyStrategy" \
--strategy-properties="Analytics:1,Cassandra:1"
./bin/pricer -d 110.82.155.0 -o UPDATE_PORTFOLIOS
./bin/pricer -d 110.82.155.0 -o INSERT_HISTORICAL_PRICES -n 100
Start the web service.
cd website
java -jar start.jar &
Open a browser and go to http://localhost:8983/portfolio to see the real-time Portfolio Manager demo application.
Open another shell window.
Start Hive and run the MapReduce job for the demo in Hive.
dse hive -f /usr/share/dse-demos/portfolio_manager/10_day_loss.q
or for binary installations:
$DSE_HOME/bin/dse hive -f $DSE_HOME/demos/portfolio_manager/10_day_loss.q
The MapReduce job will take several minutes to run. Open the URL http://localhost:50030/jobtracker.jsp in a browser to watch the progress in the Job Tracker.
After the job completes, refresh the Portfolio Manager web page to see the results of Largest Historical 10day Loss for each portfolio.