je.rep.quote (Oracle - Berkeley DB Java Edition Examples)
Date: 2014-12-16

# Package je.rep.quote

JE Replication Stock Quote example.

See: Description

- Interface Summary
  Interface | Description
  --- | ---
  StockQuotesRMIForwarding.WriteServices |

- Class Summary
  Class | Description
  --- | ---
  HARouter | This example illustrates use of an HA aware Router used to forward high level requests to replication nodes implemented by `RouterDrivenStockQuotes`.
  RouterDrivenStockQuotes | This class is based on `StockQuotes` and illustrates use of an HA-aware router (implemented by `HARouter`), in conjunction with the `Monitor` class, to direct application requests, based upon the type of request (read or write) and the state (Master or Replica) of a node in the replication group.
  RunTransaction | Utility class to begin and commit/abort a transaction and handle exceptions according to this application's policies.
  SimpleRouter | This example illustrates the use of a simple HA-unaware router that is used in conjunction with `UpdateForwardingStockQuotes`.
  StockQuotes | The most basic demonstration of a replicated application.
  StockQuotesRMIForwarding | This example is a small variation on the basic `StockQuotes` example.
  UpdateForwardingStockQuotes | This class is based on `RouterDrivenStockQuotes` and illustrates use of an HA unaware router (implemented by `SimpleRouter`), that load balances requests (both read and write) across all the nodes in a replication group.

## Package je.rep.quote Description

JE Replication Stock Quote example.

## Example Overview

This example is a simple but complete demonstration of a replicated application. The application is a mock stock ticker which stores stock values in a replicated JE environment. The following commands are accepted:

- <stock> <number> : enter this stock price into the database
- print : print all the stocks and current prices held in the database
- quit : shut down

There are three versions of the example which illustrate different application designs and aspects of JE functionality. Please be sure to walk through the three examples in the order listed below, since the information in one example builds on the one before it. The javadoc description for each class describes the example and explains how to run it. More detailed information is found in the example source code.

1. `StockQuotes`: This example is the most basic demonstration of a replicated application. It's intended to help gain an understanding of basic HA concepts and demonstrate use of the HA APIs to create a replicated environment and issue read and write transactions.
2. `RouterDrivenStockQuotes` and `HARouter`: This example is based on `StockQuotes` and illustrates use of an HA-aware router (implemented by `HARouter`), in conjunction with the `Monitor` class, to direct application requests, based upon the type of request (read or write) and the state (Master or Replica) of a node in the replication group. This example is meant to illustrate how a software load balancer might be integrated with JE HA, where `HARouter` plays the role of the load balancer for purposes of the example.
3. `UpdateForwardingStockQuotes` and `SimpleRouter`: This example is based on `RouterDrivenStockQuotes` and illustrates use of an HA unaware router (implemented by `SimpleRouter`), that load balances requests (both read and write) across all the nodes in a replication group. This example is meant to illustrate how a load balancer appliance might fit into the JE HA architecture, where `SimpleRouter` plays the role of the load balancer appliance for purposes of the example.

Disclaimer: This example is intended to be illustrative. The example is single threaded, while actual applications may be multithreaded. The example forwards requests as text and receives responses in text form, while actual applications may for example, forward HTTP requests, or use some other application level network protocol to forward such requests. The example opens and closes a socket to send each request, while actual applications will typically use a connection management facility.

The example `StockQuotesRMIForwarding`, a minor variation to the basic `StockQuotes` example is also included in this package. It's intended to help illustrate how RMI could be used to forward write requests from a Replica to the Master.

Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved.