Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ormanli committed Apr 1, 2019
1 parent 9856846 commit de45a20
Show file tree
Hide file tree
Showing 46 changed files with 1,799 additions and 1 deletion.
261 changes: 261 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@

# Created by https://www.gitignore.io/api/macos,linux,windows,maven,jetbrains+all,eclipse,java
# Edit at https://www.gitignore.io/?templates=macos,linux,windows,maven,jetbrains+all,eclipse,java

### Eclipse ###

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

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

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

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Annotation Processing
.apt_generated

.sts4-cache/

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### JetBrains+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/macos,linux,windows,maven,jetbrains+all,eclipse,java
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
# kestane
# sepet

An example system simulating some thermometers sending temperature metrics. It is also possible to query these statistics for a given timespan.

![diagram](diagram.jpg)

Info
====
* Project contains two parts. Collector is responsible for collecting temperature metrics. Server is responsible for persisting and aggregating metrics. Spring Boot used for both of them.
* Collector collects readings and publishes readings to Redis. Collector collects reading with gRPC streaming.
* Server subscribes that topic and persists them to the database. TimescaleDB used for persistence. It is a time series database built on PostgreSQL.
* For querying temperature metrics Swagger UI is available at `localhost:8081/swagger-ui.html`. `localhost:8081/query` accepts time range and machine-ids and returns map of machine-id and statistics. `localhost:8081/query/machine-id` returns existing machine-ids in database.
* There is a simple simulator for thermometer data. It accepts parameters `-n -h -p`. n is the number of simulators, h is host and p is port of Collector. It uses sine function to generate temperature. Default configuration spans 50 simulators.
* There is no security or machine-id/reading validation implemented.

Requirements
====
* Docker > 18.0.0
* Docker Compose > 1.23.0

Used Technologies
====
* Docker
* Docker Compose
* Java 11
* Spring Boot 2
* Redis
* gRPC
* TimescaleDB

How To Run
====
Go to root folder and run build.sh. It compiles applications, creates docker images and runs.

What is sepet?
====
Turkish word for **basket**. Better than **gRPC-SpringBoot-RedisPubSub-TimescaleDB-Example**.
19 changes: 19 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

set -e

docker-compose down

MAVEN_DIR="${HOME}/.m2"

docker run \
--rm \
-v ${MAVEN_DIR}:/root/.m2 \
-v ${PWD}:/src \
--entrypoint="sh" \
maven:3.6.0-jdk-11-slim \
-c "mvn -f /src/pom.xml clean package"

docker-compose build

docker-compose up -d
7 changes: 7 additions & 0 deletions collector.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM openjdk:11-jre-slim

WORKDIR /collector

COPY ./collector/target/collector-*.jar /collector/collector.jar

CMD ["java", "-jar", "collector.jar"]
25 changes: 25 additions & 0 deletions collector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

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

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

0 comments on commit de45a20

Please sign in to comment.