Skip to content
This repository has been archived by the owner on Mar 25, 2019. It is now read-only.

Provide a first implementation of this microservice, which will link Km4City's API with Kafka #1 #8

Merged
merged 43 commits into from Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f931956
To pull request
aletundo Oct 8, 2017
be3e7b5
Added missing .gitignore
aletundo Oct 8, 2017
c68ee83
Deleted wrong target folder due to a missing .gitignore file
aletundo Oct 8, 2017
ad10746
Fix Markdown link to km4city-to-kafka.md in README.md
ma82 Oct 8, 2017
b327242
Fixing inner link in km4city-to-kafka.md
ma82 Oct 8, 2017
b6786ff
Added org.json to pom.xml
ma82 Oct 8, 2017
a69c9b2
Fixed minor typo
ma82 Oct 8, 2017
22bc8fa
Excluded conflict dependency. Fixed ParkingConvertImpl.
aletundo Oct 10, 2017
2e03418
Gitignored application properties/yml files
aletundo Oct 26, 2017
856fb07
Updated and improved test configuration yml file. Provived applicatio…
aletundo Oct 26, 2017
d462d90
Changed and fixed generate-configuration.sh script in order to reflec…
aletundo Oct 26, 2017
87529a2
Added configurations for Async and Scheduling threads pool
aletundo Oct 26, 2017
7320974
Added services to perform cron scheduled and api triggered ingestion
aletundo Oct 26, 2017
0650ad0
Added receiver and avro deserializer for test purpoes
aletundo Oct 26, 2017
917efa0
Modified unit tests and other minor fixes to related classes
aletundo Oct 26, 2017
d8c0043
Added rest controller to accept api ingestion. Other related fixes an…
aletundo Oct 26, 2017
e7f7fa9
Added Swagger2 and Swagger UI. Other minor config fixes
aletundo Oct 26, 2017
8ef2e44
Added Dockerfile and docker maven plugin
aletundo Oct 26, 2017
864e4d4
Added super basic travis configuration yaml file
aletundo Oct 29, 2017
f988840
Added build status to README.md
aletundo Oct 29, 2017
85fcce2
Personalized travis file in order to not use maven wrapper
aletundo Oct 29, 2017
85a1c1f
Added cobertura maven plugin for code coverage. Added travis instruct…
aletundo Oct 29, 2017
46d741e
Added code converage status button to readme
aletundo Oct 29, 2017
a197dd6
generate_configuration.sh now only supports Car_park
ma82 Oct 26, 2017
e6cc16f
Updated km4city-to-kafka.md, mainly to reflect new config format.
ma82 Oct 26, 2017
d388a59
Merge pull request #2 from ma82/only-car-park
aletundo Oct 29, 2017
d78908c
Maven now produces an executable jar.
ma82 Oct 29, 2017
13f5a13
Updated TODOs
ma82 Oct 29, 2017
8cf95bc
Added section 'Building the container' and updated TODOs
ma82 Oct 29, 2017
3be06ed
Merge pull request #1 from ma82/executable-jar
aletundo Oct 29, 2017
9923160
Returned back to hardcoded service type converter, generalization wil…
aletundo Oct 30, 2017
bf976f3
Changed Event attributes field with an empty map due to serialization…
aletundo Oct 30, 2017
a220128
Removing tac tac
ma82 Oct 30, 2017
606fc49
Added docker-compose.yml
ma82 Oct 29, 2017
ae64065
Added docker rm{i} to the 'By hand' workflow
ma82 Oct 30, 2017
279d961
Merge pull request #3 from ma82/docker-compose
aletundo Oct 30, 2017
ef06956
s/disit.org/km4city.org
ma82 Oct 30, 2017
0cad6b8
As Ale noticed, version 2 of docker-compose is enough
ma82 Oct 30, 2017
61f59cf
Added Spring Retry in order to be more resilient
aletundo Oct 30, 2017
3210152
Merge branch 'master' of github.com:aletundo/daf-replicate-ingestion
aletundo Oct 30, 2017
ba9a07b
Revised km4city-to-kafka.md
ma82 Oct 30, 2017
f9a2544
Added ApiController test
aletundo Oct 30, 2017
129f166
More km4city-to-kafka.md revisions
ma82 Oct 30, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 59 additions & 0 deletions .gitignore
@@ -0,0 +1,59 @@
target/
!.mvn/wrapper/maven-wrapper.jar
src/main/resources/*.properties
src/main/resources/*.yml

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/

### Eclipse ###

.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# sbteclipse plugin
.target

# Code Recommenders
.recommenders/

### Eclipse Patch ###
# Eclipse Core
.project

# JDT-specific (Eclipse Java Development Tools)
.classpath
11 changes: 11 additions & 0 deletions .travis.yml
@@ -0,0 +1,11 @@
language: java
jdk:
- oraclejdk8
sudo: false
install:
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
script:
- mvn test
- mvn cobertura:cobertura
after_success:
- bash <(curl -s https://codecov.io/bash)
8 changes: 8 additions & 0 deletions Dockerfile
@@ -0,0 +1,8 @@
FROM openjdk:8-jdk-alpine
MAINTAINER TeamDigitale <teamdigitale@example.com>

VOLUME /tmp
ARG JAR_FILE
ADD target/${JAR_FILE} app.jar
ENV JAVA_OPTS=""
ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar
2 changes: 1 addition & 1 deletion LICENSE
Expand Up @@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
9 changes: 9 additions & 0 deletions README.md
@@ -0,0 +1,9 @@
# DAF Replicate Ingestion

[![Build Status](https://travis-ci.org/aletundo/daf-replicate-ingestion.svg?branch=master)](https://travis-ci.org/aletundo/daf-replicate-ingestion)
[![codecov](https://codecov.io/gh/aletundo/daf-replicate-ingestion/branch/master/graph/badge.svg)](https://codecov.io/gh/aletundo/daf-replicate-ingestion)

Microservices that ingest data from Replicate and push it into DAF

- [Km4City to Kafka](km4city-to-kafka.md)

28 changes: 28 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,28 @@
version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
build:
context: kafka
dockerfile: Dockerfile
ports:
- "9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_CREATE_TOPICS: "km4city:1:1"
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock
k42k:
build:
context: .
args:
JAR_FILE: daf-replicate-ingestion-0.0.1-SNAPSHOT.jar
dockerfile: Dockerfile
ports:
- "8080:8080"
# TODO Is this actually ignored?
# command: --spring.kafka.bootstrap-servers="kafka:9092"
50 changes: 50 additions & 0 deletions generate-configuration.sh
@@ -0,0 +1,50 @@
#!/bin/bash

CONFIGURATION_FILE=src/main/resources/application.yml
BASE_URL=http://servicemap.km4city.org/WebAppGrafo/api/v1/
KAFKA=kafka:9092
CRON_EXPRESSION="0/30 * * * * ?"

echo -n >${CONFIGURATION_FILE}

cat <<EOF >${CONFIGURATION_FILE}
spring:
profiles:
active: prod
kafka:
bootstrap-servers: $KAFKA
kafka:
topic:
km4city: km4city
km4city:
base_url: $BASE_URL
ingestion_cron: $CRON_EXPRESSION
EOF

echo "[1] Default application.yml written"

if [ "$#" -ne 3 ]; then
echo "Usage: ./generate-configuration.sh <category> <coordinates> <max-distance> in order to add a list of services to ingest"
exit 1
fi

CATEGORY=$1
COORDINATES=$2
MAX_DISTANCE=$3
SERVICES="?selection=$COORDINATES&categories=$CATEGORY&maxResults=0&maxDists=$MAX_DISTANCE&lang=it&format=json"i

SERVICE_URIS=`curl $BASE_URL/$SERVICES | jq '.[] | ."features" | .[] | ."properties" | ."serviceUri" '`

echo " services:" >> $CONFIGURATION_FILE

if [ $CATEGORY == "Car_park" ]; then
echo " parkings:" >> $CONFIGURATION_FILE
for i in $SERVICE_URIS; do
echo " - " $i >> $CONFIGURATION_FILE
done

echo "[2] Added service URIs from $BASE_URL, if any"
exit 0
else
echo "We only support category Car_park at the moment."
fi
26 changes: 26 additions & 0 deletions kafka/Dockerfile
@@ -0,0 +1,26 @@
FROM anapsix/alpine-java

ARG kafka_version=0.10.1.1
ARG scala_version=2.11

MAINTAINER wurstmeister

RUN apk add --update unzip wget curl docker jq coreutils

ENV KAFKA_VERSION=$kafka_version SCALA_VERSION=$scala_version
ADD download-kafka.sh /tmp/download-kafka.sh
RUN chmod a+x /tmp/download-kafka.sh && sync && /tmp/download-kafka.sh && tar xfz /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz -C /opt && rm /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz && ln -s /opt/kafka_${SCALA_VERSION}-${KAFKA_VERSION} /opt/kafka

VOLUME ["/kafka"]

ENV KAFKA_HOME /opt/kafka
ENV PATH ${PATH}:${KAFKA_HOME}/bin
ADD start-kafka.sh /usr/bin/start-kafka.sh
ADD broker-list.sh /usr/bin/broker-list.sh
ADD create-topics.sh /usr/bin/create-topics.sh
# The scripts need to have executable permission
RUN chmod a+x /usr/bin/start-kafka.sh && \
chmod a+x /usr/bin/broker-list.sh && \
chmod a+x /usr/bin/create-topics.sh
# Use "exec" form so that it runs as PID 1 (useful for graceful shutdown)
CMD ["start-kafka.sh"]