Commit fb267bd5 authored by hengwen's avatar hengwen
Browse files

Add README

parent d2d4d615
This module serve as a coordinator of the distributed montisim. It provide a set of RESTful endpoints
for users to control the simulation process.
This is the simulation server module. It provide a set of RESTful APIs for setting up, running simulation and also
retrieving the results.
## Endpoints
## Install
Install using maven:
```
$ mvn clean install -settings=../settings.xml
```
Run the server:
```
$ java -jar ./target/restful-1.0.0-SNAPSHOT.jar
```
It is also fine to start the server using your IDE, the main class is located at `src/main/java/server/restful/Server.java`.
## Simulation
To start a simulation, the following services must be started at first:
- ZooKeeper
- RMIModelServer
- rpc server
The following instructions enables the server to run a simulation task
with arbitrary maps and scenarios.
### ZooKeeper
Checkout the installation guide [here](https://zookeeper.apache.org/doc/r3.1.2/zookeeperStarted.html#ch_GettingStarted).
After installation, start the ZooKeeper server, it should be listening on **localhost:2181** by default.
### RMIModelServer
Please refer to [RMIModelServer](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/RMIModelServer) for installation guide.
After installation, start at least one rmiserver, by default it should be listening on **localhost:10101**.
### RPC Server
Go to the rpc module for installation guid.
Start at least one RPC server on **localhost:6000**
## Docker
Since the server depends on multiple services, it is a good choice to run them all in docker
containers. We can start all dependencies with docker at once:
```
$ docker-compose -f dev.yml up --scale rmi-server=2 --scale rpc-server=2
```
To scale specific services:
```
$ docker-compose -f dev.yml up --scale rmi-server=10 rmi-server
$ docker-compose -f dev.yml up --scale rpc-server=3 rpc-server
```
To build the docker image, first build the jar with maven and then:
```
$ ./build.sh
```
## Development
For the local development of restful module with simple scenario(1 vehicle, arbitrary map and sectors), make sure that:
- A RMIModelServer is available at **localhost:10101**
- A RPC Server is available at **localhost:6000**
- A ZooKeeper is available at **localhost:2181**
If multiple vehicles are involved, we need more than one RMIModelServer.
In this case, we must use docker containers.
`dev.yml` configures the restful server to run in debug mode, the JVM listens for debugging request
at **localhost:8787**.
To debug restful server, simply configure a remote debugger in the IDE and start debugging.
So the workflow should be:
1. code
2. compile
3. use `dev.yml` to start and scale necessary services
4. start a remote debugger to debug the server
5. goto 1
If you need to debug rpc server, add a new service into `dev.yml`:
```yaml
rpc-server-debugger:
image: rpc-server
depends_on:
- zoo1
ports:
- 8788:8787
restart: always
environment:
ZOO_SERVERS: zoo1:2181
entrypoint:
- java
- -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787
- -cp
- "simulator-rpc.jar:."
- server.rpc.RpcServer
- "6000"
```
It starts a rpc server that listen on port **8788** for debugging.
## Test
```
$ ./run_test.sh
```
## Endpoints
The restful endpoints are defined in the `openapi.yml`.
### Map
#### `POST /map`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment