DataStax Enterprise 3.0 Documentation

About Portfolio Manager demo application

Your DataStax Enterprise (DSE) installation contains a demo application that shows a sample mixed workload on a DSE cluster. The use case is a financial application where users can actively create and manage a portfolio of stocks.

On the Cassandra OLTP (online transaction processing) side, each portfolio contains a list of stocks, the number of shares purchased, and the purchase price. The demo's pricer utility simulates real-time stock data where each portfolio updates based on its overall value and the percentage of gain or loss compared to the purchase price. This utility also generates 100 days of historical market data (the end-of-day price) for each stock.

On the DSE OLAP (online analytical processing) side, a Hive MapReduce job calculates 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 guage their potential losses.

Prerequisites

  • A single-node or multiple node instance of DataStax Enterprise is installed.
  • Your cluster is configured and running with one analytics node:

Running the demo

To run the demo:

  1. On the analytics node, verify that DataStax Enterprise is running in analytics mode:

    • Binary install: <install_location>/bin/nodetool ring -h localhost
    • Package install: nodetool ring -h localhost

    ../../_images/dse_demo_analytics.png
  2. Go to the portfolio manager demo directory.

    • Binary install: cd <install_location>/demos/portfolio_manager
    • Packaged install: cd /usr/share/dse-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.

  3. Run the bin/pricer utility to generate stock data for the application:

    • To see all of the available options for this utility:

      bin/pricer --help
      
    • 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
      

    The pricer utility takes several minutes to run.

  4. Start the web service:

    cd website
    ./start
    
  5. Open a browser and go to http://localhost:8983/portfolio to see the real-time Portfolio Manager demo application.


    ../../_images/portfolio_demo1.png
  6. Open another terminal.

  7. Start Hive and run the MapReduce job for the demo in Hive.

    • Binary install: <install_location>/bin/dse hive -f <install_location>/demos/portfolio_manager/10_day_loss.q
    • Packaged install: dse hive -f /usr/share/dse-demos/portfolio_manager/10_day_loss.q

    The MapReduce job takes several minutes to run.

  8. Open the URL http://localhost:50030/jobtracker.jsp in a browser to watch the progress in the job tracker.

  9. After the job completes, refresh the Portfolio Manager web page to see the results of the Largest Historical 10 day Loss for each portfolio.


    ../../_images/historical-loss.png