Skip to content

Spycsh/runspec

Repository files navigation

RunSpec

specialize your running

Sihan Chen sihanc@kth.se
Yuehao Sui yuehao@kth.se
Zidi Chen zidi@kth.se

architecture

Workflow

android (open app)

⇨ adviser (weather and air information, hot spots)

⇨ android (display weather and air information)

⇨ android (start running)

⇨ producer (kafka collects data)

⇨ processor (process data: how hot the predefined spots are) [display in statisticsboard]

⇨ android (display steps, length and checklist of predefined spots)

API:

One tripId for one run.

  1. http://localhost:8082/adviser/info

    • POST

    • two parameters(not JSON): longitude, latitude

    • in adviser module

    • return a JSON string with weather and air information

    for example, in postman POST http://localhost:8082/adviser/info?longitude=18.0722299999&latitude=59.34706999999

  2. http://localhost:8182/producer/runningData

    • POST

    • JSON string: "longitude", "latitude", "tripId", "userId"

  3. http://localhost:8182/producer/returnTripData

    • POST

    • JSON string: "userId", "tripId"

    • return POIs (with latitude, name, pOIId, radius, longitude) which current user passes by in the current trip in JSON

  4. http://localhost:8182/producer/hotSpot

    • POST

    no param: we still use post here because we might need to post latitude and longitude to check the city for searching hottest spots in the future.

    • return 5 top hottest POIs in JSON (with latitude, name, pOIId, radius, longitude, count)
  5. http://localhost:8182/producer/returnHistoryTripData

    • POST

    • JSON string: "userId"

    • return POIs which the user passed in all the trips, no duplicates.

Note: There are two ways to run this project, from scratch or from docker

To run from scratch

This project is compatible with Java 11 and above.

  1. start Kafka

On EC2

$ bin/zookeeper-server-start.sh config/zookeeper.properties
$ bin/kafka-server-start.sh config/server.properties

For Windows (local mode) one terminal:

C:\kafka\bin\windows>zookeeper-server-start.bat ..\..\config\zookeeper.properties

another terminal:

C:\kafka\bin\windows>kafka-server-start.bat ..\..\config\server.properties
  1. start mongodb
C:\MongoDB\bin>mongod --dbpath=C:\MongoDB\data\db 
  1. run the project
  • adviser:
cd ./adviser
nohup ./mvnw org.springframework.boot:spring-boot-maven-plugin:run > myout.file 2>&1 &
  • statisticsboard:
cd ./statisticsboard
nohup ./mvnw org.springframework.boot:spring-boot-maven-plugin:run > myout.file 2>&1 &
  • processor:
cd ./processor
./mvnq exec:java
  • producer:
cd ./producer
./mvnw exec:java

Please install mvn tool firstly.

  • adviser:
cd ./adviser
mvn spring-boot:run
  • statisticsboard:
cd ./statisticsboard
mvn spring-boot:run
  • processor:
cd ./processor
mvn exec:java
  • producer:
cd ./producer
mvn exec:java

Test API in PostMan

POST http://13.53.101.158:8082/adviser/info?longitude=18.0722299999&latitude=59.34706999999

POST http://13.53.101.158:8182/producer/runningData

{
    "longitude": 18.0722299999,
    "latitude":59.34706999999,
    "userId":34,
    "tripId":8073
}

JMeter Load test

Here we can use JMeter to test the concurrency performance. For example, we set the default location to be KTH Kista as our testing POI data as follows:

{
	"longitude": 17.94948, 
	"latitude": 59.40498, 
	"tripId": ${__Random(100,900,tripId)}, 
	"userId": ${__Random(1000,90000,userId)}
}

In JMeter, create a ThreadGroup with 200 threads (users) in 1 loop. In the HTTP Request enter the above json in the request body. Meanwhile, in the HTTP Header Manager, specify the header Content-Type to be application/json;charset=UTF-8.

To do

  • basic infrastructure, producer+processor (maven), adviser+statisticsboard (maven springboot), android (gradle)
  • runner data REST api with reslet
  • connect Kafka producer, processor, specify json (de)serializer
  • spark filter/store runner data stream into mongo
  • POI points popularity measurement with POI id, user id and trip id
  • backend statistics board, subscribe messages with stomp.js, map display with leaflet.js
  • change packages dependencies to adapt to Java 11
  • add api for weather and air
  • add api for top five spots
  • add api to return the pois which the users passed by
  • android get data from backend
  • android UI demo
  • upgrade EC2
  • deployment on cluster

Demo of the very simple UI so far

  • statistic board records runner POI data via stomp.js board

  • Android dashboard tab records steps, distances, time and the hot spot that runner has passed by during the last run. Android home tab records location of users, weather & air quality got from backend and top 5 running POI. In Android setting tab you can enter the ip address and name to test the app. home