SuhasHebbar / TransportScheduler

concurrent implementation of CSA algorithm using cell model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TS

Build Status Coverage Status Code Climate

TransportScheduler application dependencies:
GenStateMachine for station FSM and GenServer for IPC.
Maru for RESTful API implementation.
Edeliver using Distillery for building releases and deployment.

Other packages used:
ExCoveralls for test coverage.
ExProf for profiling.
Credo for code quality.

Usage

Setup

Run the following commands to compile:

cd TransportScheduler
mix deps.get
mix compile
mix test

Run the following command to build a release, and copy data directory into build path:

mix release
cp -r data/ _build/dev/rel/ts

Run the following command to run the application interactively:

_build/dev/rel/ts/bin/ts console

Issue the following cURL command (in a separate terminal) for initialisation of the network:

curl http://localhost:8880/api

Other cURL commands to query the network (as mentioned in 'Testing') can now be issued.

To stop the Erlang runtime and exit the TS console:

System.halt

Testing

For testing the API, following cURL commands are issued to:

  1. Obtain Schedule of a Station:
curl -X GET 'http://localhost:8880/api/station/schedule?station_code=%STATION_CODE%&date=%DATE%'

where %STATION_CODE% is a positive integer indicating the station code of the source and %DATE% is the date of travel in the format 'dd-mm-yyyy'.

  1. Obtain State of a Station:
curl -X GET 'http://localhost:8880/api/station/state?station_code=%STATION_CODE%'

where %STATION_CODE% is a positive integer indicating the required station code.

  1. Obtain Travel Itinerary:
curl -X GET 'http://localhost:8880/api/search?source=%SOURCE%&destination=%DESTINATION%&start_time=%START_TIME%&end_time=%END_TIME%&date=%DATE%'

where %SOURCE% and %DESTINATION% are positive integers indicating the station codes of the source and destination respectively, %START_TIME% and %END_TIME% are non-negative integers indicating start and end times of the itinerary in seconds from 12 am, and %DATE% is the date of travel in the format 'dd-mm-yyyy'.

Deployment

Run the following commands to deploy (currently server and user are localhost): UNTESTED

mix edeliver build release
mix edeliver deploy release

Run the following command to start application: UNTESTED

mix edeliver start
cp -r data/ /home/$USER/test/ts

Benchmark Tests

For running the respective benchmarks (async/synchronous), use

mix sync_benchmark
mix async_benchmark

A shell script for running the synchronous benchmark multiple times is:

for i in $(seq 1 $n); do mix benchmark [2>/dev/null | grep -C 2 "^Start time: "]; done [> ~/file.out]

where $n is the number of random queries over which the benchmark must be run. file.out is the file that will store the log thus generated by the benchmark. The portion of the command in [square brackets] is optional.

Automatically, three files async_test.csv, sync_test.csv and times.csv are created in the data/ directory.

About

concurrent implementation of CSA algorithm using cell model

License:GNU General Public License v3.0


Languages

Language:Elixir 93.4%Language:Shell 6.6%