Getting Started

Running the Portfolio Manager demo

Shows a mixed workload sample on a DataStax Enterprise 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 gauge their potential losses.


Before running the demo, make sure the following items have been completed:

  • A single-node or multiple node instance of DataStax Enterprise is installed.
  • A cluster is configured and running.


To run the demo:

  1. Check which mode DataStax Enterprise is running in:
    1. Run the following command:
      • Packaged installs: $ nodetool status
      • Tarball installs: $ bin/nodetool status

    2. If the Datacenter is not Analytics, stop the node:
      • Packaged installs: $ sudo service dse stop
      • Tarball installs: From the install location:
        $ install_location/bin/dse cassandra-stop  ## Use sudo if necessary

        In the unlikely event that the cassandra-stop command fails because it cannot find the process DataStax Enterprise Java process ID (PID), the output instructs you to find the DataStax Enterprise Java process ID (PID) manually, and stop the process using its PID number.

        $ ps auwx | grep dse
        $ bin/dse cassandra-stop -p PID
    3. Start DataStax Enterprise as an analytics node:
      • Packaged installs: Edit the /etc/default/dse file, and change HADOOP_ENABLED=0 to HADOOP_ENABLED=1 and then start DataStax Enterprise:
        $ sudo service dse start
      • Tarball installs: install_location/bin/dse cassandra -t

  2. Create a directory for running your DataStax Enterprise demos:
    • Packaged installs: $
    • Tarball installs: $ install_location/bin/

    This script creates a directory called dse-demos where you can run the demos without using root or sudo permissions. It also tells you where the dse-demos directory is placed.

  3. Go to the portfolio manager demo directory:
    • Packaged installs: $ cd ~/dse-demos/portfolio_manager
    • Tarball installs: : $ cd install_location/dse-demos/portfolio_manager
  4. 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.
  5. Start the web service:
    $ cd website
    $ ./start
  6. Open a browser and go to http://localhost:8983/portfolio.

    The real-time Portfolio Manager demo application is displayed.

  7. Open another terminal.
  8. Start Hive and run the MapReduce job for the demo in Hive.
    • Packaged installs: $ dse hive -f /usr/share/dse-demos/portfolio_manager/10_day_loss.q
    • Tarball installs: $ install_location/bin/dse hive -f install_location/demos/portfolio_manager/10_day_loss.q

    The MapReduce job takes several minutes to run.

  9. To watch the progress in the job tracker, open the following URL in a browser.


  10. After the job completes, refresh the Portfolio Manager web page.

    The results of the Largest Historical 10 day Loss for each portfolio are displayed.

What's next