public class Quote extends Object
Quotes are cached for 20 seconds. At that time the cached data is invalidated by GemFire and, if the symbol is queried again, the QuoteLoader will be invoked to read an updated quote from NASDAQ.
The program is run like this, assuming that you have followed the instructions for setting up your environment.
$ java flashcache.Quote Enter symbol: ORCL (QuoteLoader netSearching for ORCL) (QuoteLoader querying nasdaq for ORCL) ORCL: last sale=9.85 net change=-0.34 volume=26,526,419 Enter next symbol: AMZN (QuoteLoader netSearching for AMZN) (QuoteLoader querying nasdaq for AMZN) AMZN: last sale=36.37 net change=-0.19 volume=5,668,938 Enter next symbol:The main prompts for a NASDAQ stock symbol. Enter a symbol, such as SUNW, to request a quote. Enter no symbol to exit. The cached quotes are distributed to other GemFire caches connected to the same distributed system. Optimistic distribution is used, so there is no locking or acknowledgment of updates, and quotes are distributed asynchronously.
| Constructor and Description |
|---|
Quote() |
| Modifier and Type | Method and Description |
|---|---|
String |
getQuote(String symbol)
this method returns a cached quote
|
void |
initializeCache(com.gemstone.gemfire.cache.Cache cache,
com.gemstone.gemfire.cache.CacheListener<String,Object> aListener)
this method initializes the cache
|
void |
initializeDistSystem(String sysDir)
this method initializes the distributed system
|
static void |
main(String[] args) |
Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.