Giter VIP home page Giter VIP logo

kafkageodemo's Introduction

KafkaGeoDemo

This repo has a demonstration of the KSQLGeo UDF. The data presently in this demo come from WMATA but can easily be adapated from other data like from Chicago Transit Authority (CTA). This demonstration provides a node.js script that queries the REST API WMATA provides (and one for CTA) and publishes it into Kafka. That data will then be pre-processed in KSQL to transform it slightly and enrich with a geo hash. One of the transformations is to speed the timeline up 10X to make the routes draw more rapidly so its more interesting. The geo hash is calculated using the geo_geohash() UDF function.

This data is then served up to a webapp built using the javascript mapping library Leaflet through an event rest service that sits in front of Kafka (KafkaEventService https://github.com/wlaforest/KafkaEventService). The KafkaEventService is a vert.x web app and allows you to serve up static content. In this case the static content is the webb app. The web app interface allows one to define shapes on the map that represent geo fences. Those geo fences are sent to the KafkaEventService which publishes them into a Kafka topic. The geo_fence topic is joined with the cta bus data topic to find instances when buses have entered the fences.

The map also displays bus densities based off a KSQL aggregated on the geo hashes.

Requirements

  • Confluent Platform 6.0
  • Java 11 or higher
  • Node.js (optional if you want to load your own data)

Steps To Run Demo.

This demo assumes that you have Confluent Platform running on your local machine with the default ports. If not you can download it and find installation instructions at https://www.confluent.io/download/

Install the geospatial UDF

From the root directory of the project

Assuming the Confluent Platform is installed as a tarball and that CONFLUENT_HOME is set you can run the following command bin/install-geo-udf.sh. This two line command assumes you have not set the ksql.extension.dir variable in your ksql-server.properties. If you have then you can manually install jars/ksqlgeo-1.3.1.jar.

Run the demo

From the root directory of the project

  1. run start.sh
  2. In a web browser goto localhost:8080/home.html

The start script prepares the topics, load the data, and creats the ksqlDB processing pipeline. One can kill the launched service when you are done with ^c

It is more instructive to create the ksqlDB pipeline manually. This can be done with the following steps:

  1. run bin/prepTopics.sh
  2. run each of the KSQL commands in the same order seen in bin/prepKsql.sh. This can be done on the command line with a command like ksql < ksql/createGeoFence.sql or you can copy and past the contents into the ksql console confluent control center at http://localhost:9021/ or by executing ksql from the command line and going interactive mode.
  3. run java -jar jars/KafkaEventService-1.0.1-fat.jar -conf conf/kesConfig.json

After you are done you can clean all the demo state by running bin/clean.sh

Optional Steps

If you with to run the data loader yourself you will need to install node.js and then run the following

  1. npm init --yes
  2. npm install request --save
  3. npm install kafkajs

kafkageodemo's People

Contributors

wlaforest avatar wmcred avatar

Stargazers

Manu Sharma avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.