Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
fuvidani committed Jun 13, 2018
2 parents 7ff55f8 + 9b8d0df commit d6015d1
Show file tree
Hide file tree
Showing 236 changed files with 24,091 additions and 9,456 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ classes/*
## Plugin-specific files:

# IntelliJ
/out/
*/out/

# mpeltonen/sbt-idea plugin
.idea_modules/
Expand Down
21 changes: 18 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
language: java
jdk:
- oraclejdk8
matrix:
include:
- language: java
jdk: oraclejdk8
- language: node_js
node_js: 8.9.3
install:
- npm i -g npm5
before_script:
- cd store-front
- npm install
script:
- npm run eslint
- npm run test
cache:
directories:
- node_modules

notifications:
email:
recipients:
Expand Down
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@

Data processing of autonomous vehicles in a fault-tolerant, resilient and asynchronous microservice environment. Featuring Kotlin, Spring Boot, Spring 5, MongoDB, RabbitMQ, Docker, Kubernetes.

# Useful shortcuts

* data-processor 9000
* data-simulator 10000
* gateway 4000
* notification 7000
* statistic 8000
* tracker 6000
* vehicle 5000
* rabbit-mq 15672 | 5672
* frontend 8069
* docker build -t eu.gcr.io/dse-group-05/***
* gcloud docker -- push eu.gcr.io/dse-group-05/***
* gcloud container clusters get-credentials dse-cluster --zone europe-west1-d --project dse-group-05


# Development

### Start Mongo (Docker)
Expand All @@ -17,12 +33,19 @@ And run:

Additionally, you can test the connection to the different databases through
the mongo shell:
- `mongo YOUR_LOCAL_IP:27017/vehicleDatabase -u 'vehicleService' -p 'vehicleDatabasePassword'`
- `mongo YOUR_LOCAL_IP:27017/trackerDatabase -u 'trackerService' -p 'trackerDatabasePassword'`
- `mongo YOUR_LOCAL_IP:27017/statisticsDatabase -u 'statisticsService' -p 'statisticsDatabasePassword'`
- `mongo YOUR_LOCAL_IP:27017/notificationDatabase -u 'notificationService' -p 'notificationDatabasePassword'`
- `mongo YOUR_LOCAL_IP:27017/vehicleDatabase -u "vehicleService" -p "vehicleDatabasePassword"`
- `mongo YOUR_LOCAL_IP:27017/trackerDatabase -u "trackerService" -p "trackerDatabasePassword"`
- `mongo YOUR_LOCAL_IP:27017/statisticsDatabase -u "statisticsService" -p "statisticsDatabasePassword"`
- `mongo YOUR_LOCAL_IP:27017/notificationDatabase -u "notificationService" -p "notificationDatabasePassword"`

### Start RabbitMQ (Docker)
`docker run -p 5672:5672 --hostname localhost rabbitmq:3` (change `localhost` accordingly)
`docker run -p 5672:5672 -p 15672:15672 --hostname localhost rabbitmq:3-management` (change `localhost` accordingly)


### Some useful JSONs
Sample `VehicleDataRecord`:
```json
{"id":null,"timestamp":1526126033768,"metaData":{"identificationNumber":"JH4DB8590SS001561","model":"1995 Acura Integra"},"sensorInformation":{"location":{"lat":0.0,"lon":0.0},"proximityInformation":{"distanceToVehicleFrontInCm":0.0,"distanceToVehicleBehindInCm":0.0},"passengers":4,"speed":50.0},"eventInformation":"NONE"}
```


1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ subprojects {
jcenter()
maven {
url = 'https://repo.spring.io/libs-milestone'
url = 'https://repo.spring.io/milestone'
}
}

Expand Down
6 changes: 6 additions & 0 deletions data-processor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM java:8-jre

ADD ./build/libs/data-processor-0.1.0.jar app.jar
CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-Xmx2048m", "-jar", "/app.jar"]

EXPOSE 9000
22 changes: 22 additions & 0 deletions data-processor/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id 'com.sourcemuse.mongo' version '1.0.6'
}

dependencies {
compile 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive'
compile 'com.squareup.retrofit2:retrofit:2.4.0'
compile 'com.squareup.retrofit2:converter-gson:2.4.0'
testCompile 'de.flapdoodle.embed:de.flapdoodle.embed.mongo:2.0.3'
testCompile group: 'org.mockito', name: 'mockito-inline', version: '2.15.0'
testImplementation "io.mockk:mockk:1.8.3"

}

test {
runWithMongoDb = true
}

mongo {
port = 'RANDOM'
logging = 'console'
}
36 changes: 36 additions & 0 deletions data-processor/resource-manifests/data-processor-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: data-processor
spec:
replicas: 1
minReadySeconds: 15
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
app: data-processor
spec:
containers:
- image: data-processor:1
imagePullPolicy: Never
name: data-processor
env:
- name: SPRING_RABBITMQ_HOST
value: "rabbitmq"
- name: SPRING_RABBITMQ_PORT
value: "5672"
- name: SPRING_DATA_MONGODB_HOST
value: "dse-mongo-db"
- name: SPRING_DATA_MONGODB_PORT
value: "27017"
- name: VEHICLE_SERVICE_HOST
value: "gateway-service"
- name: VEHICLE_SERVICE_PORT
value: "4000"
ports:
- containerPort: 9000
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package at.ac.tuwien.dse.ss18.group05

import at.ac.tuwien.dse.ss18.group05.service.client.VehicleService
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker
import org.springframework.context.annotation.Bean
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

/**
* <h4>About this class</h4>
*
* <p>Description</p>
*
* @author Daniel Fuevesi
* @version 1.0.0
* @since 1.0.0
*/
@SpringBootApplication
@EnableAutoConfiguration
@EnableCircuitBreaker
class DataProcessorApplication {

companion object {
@JvmStatic
fun main(args: Array<String>) {
SpringApplication.run(DataProcessorApplication::class.java, *args)
}
}

@Bean
fun vehicleService(
@Value("\${vehicle.service.host}") host: String,
@Value("\${vehicle.service.port}") port: String
): VehicleService {
val retrofit = Retrofit.Builder()
.baseUrl("http://$host:$port/vehicle/")
.addConverterFactory(GsonConverterFactory.create())
.build()
return retrofit.create(VehicleService::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package at.ac.tuwien.dse.ss18.group05.config

/* ktlint-disable no-wildcard-imports */
import org.springframework.amqp.core.*
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

/**
* <h4>About this class</h4>
*
* <p>Description</p>
*
* @author Daniel Fuevesi
* @version 1.0.0
* @since 1.0.0
*/
@Configuration
class RabbitConfig {

private val topicExchangeName = "vehicle-data-exchange-2"

@Bean
fun vehicleMovementQueue(): Queue {
return Queue("vehicleQueueProcessing", false)
}

@Bean
fun emsNotificationQueue(): Queue {
return Queue("emsQueueProcessing", false)
}

@Bean
fun exchange(): TopicExchange {
return TopicExchange(topicExchangeName)
}

@Bean
fun vehicleBinding(vehicleMovementQueue: Queue, exchange: TopicExchange): Binding {
return BindingBuilder.bind(vehicleMovementQueue).to(exchange).with("vehicle.data.#")
}

@Bean
fun emsBinding(emsNotificationQueue: Queue, exchange: TopicExchange): Binding {
return BindingBuilder.bind(emsNotificationQueue).to(exchange).with("ems.notification")
}
}
Loading

0 comments on commit d6015d1

Please sign in to comment.