An assignment that implements fail-over mechanism using Apache Zookeeper.
- Java 1.7
- Maven with Tomcat plugin
- Zookeeper
- Redis
- Jar package of https://github.com/hunghoang/masterslave
Redis connection, key name and the number of items accounted for in the statistics services are configurable
at /orderservice/src/main/resources/config.properties
- Build https://github.com/hunghoang/masterslave in order to have the required jar available in the local maven repository
- Without tests:
mvn clean install -DskipTests
- With unit tests:
mvn clean install
(a Redis server with proper config is required)
- Start zookeeper on the local machine that listens on port
2181
- Start redis as configured
- Run
mvn tomcat:run -Dmaven.tomcat.port=<port>
Without the -Dmaven.tomcat.port
parameter, the web app will be binded to port 8080 by default
The web app is then available at http://localhost:<port>/orderservice/
- Run several server instances at different ports simultaneously in order to test fail-over mechanism
/orderservice/test.html
could be used to testPOST
order services
POST http://localhost:<port>/orderservice/api/order/placeOrder
POST
parameters:
- account: string
- symbol: string
- price: float
- volume: integer
- type: string
POST http://localhost:<port>/orderservice/api/order/replaceOrder
POST
parameters:
- id: string
- account: string
- symbol: string
- price: float
- volume: integer
- type: string
POST http://localhost:<port>/orderservice/api/order/cancelOrder
POST
parameters:
- id: string
- account: string
- symbol: string
- price: float
- volume: integer
- type: string
GET http://localhost:<port>/orderservice/api/stats/topOrders
GET http://localhost:<port>/orderservice/api/stats/topAccounts