Your DataStax Community (DSC) installation can run the Portfolio Demo Sample Application. This demo showcases using Apache Cassandra in a real-time web application developed in Java and using the Cassandra Query Language (CQL) JDBC driver.
The demo application is located in:
The Portfolio demo is a financial application where users can actively create and manage a portfolio of stocks. Each portfolio contains a list of stocks, the number of shares purchased, and the price at which the shares were purchased. An overall value is maintained for each stock portfolio as well as the percentage of gain or loss compared to the original stock purchase prices for a portfolio.
The demo has a pricer utility that simulates an active feed of live stock market data. For each stock ticker symbol, the application tracks the current stock price and the historical market data (end-of-day price) for each stock for 100 days.
Prerequisites
You might need to configure the demo application to point to the correct Cassandra installation location. For example, if DataStax Community Edition is installed in a directory called datastax in your home directory:
$ sed -i -e "s,/usr/share/cassandra,~/datastax,"
~/datastax/demos/portfolio_manager/bin/pricer
If you copy the above text, be sure to delete any extra spaces.
Go to the Portfolio Manager demo directory.
Binary Installs: $ cd <install_location>/demos/portfolio_manager
Packaged Installs: $ 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.
Run the pricer utility to generate stock data for the application. To see the available options:
$ bin/pricer --help
To 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
Start the web service:
$ cd <install_location>/demos/portfolio_manager/website
$ java -jar start.jar &
Open a browser and go to:
This open` the Portfolio Manager demo web application home page.
The sample data for the demo application is contained in a Cassandra keyspace called PortfolioDemo.
In that keyspace are four column families:
The cassandra-cli program is a command-line interface for Cassandra, which you can use to explore the PortfolioDemo keyspace and data model.
$ cd <install_location> $ bin/cassandra-cli -h localhost
[default@unknown] USE PortfolioDemo;
[default@unknown] SHOW SCHEMA;
[default@unknown] GET Stocks[GCO];
[default@unknown] exit;