Coder Social home page Coder Social logo

sparkstreamingtohbase's Introduction

SparkStreamingHBase

This example program, is example how to create Kafka Producer, Kafka Consumer, and insert streaming data to HBase using Java and Spark.

  • Producer: reads hourly time series of humidity data (humidity.json) and sends to Kafka.
  • Consumer: consumes data from Kafka, transforms, and saves to HBase.


Details

Kafka

  • Kafka topic: test-v1
  • Kafka topic partitions: 3

HBase

  • HBase table name: test-table-1
  • HBase row id: city name (example: portland, san_francisco)
  • HBase column family name: humidity
  • HBase column qualifier name: datetime (example: 2017-11-29_23:00:00, 2017-11-30_00:00:00)
humidity
2017-11-29_23:00:00 2017-11-30_00:00:00 ... yyyy-MM-dd_HH:mm:dd
portland 50.0 60.5 ... 45.0
san_francisco 55.0 50.0 ... 40.0

Program Arguments

Producer

args[0]

{
  "kafka": {
    "broker": "host:port",
    "kafka_topic": "topic_name"
  }
}

args[1]: path to JSON file

Consumer

args[0]

{
  "hbase": {
    "output_table": "table_name",
    "master": "host",
    "quorum": "host",
    "hbaseZkPort":"port",
  },
  "kafka": {
    "broker": "host:port",
    "group_name": "group_name",
    "auto_offset_reset": "none/earliest/latest",
    "auto_commit": true/false,
    "kafka_topics": {
      "topic_name1": number_partitions,
      "topic_name2": number_partitions
    }
  }
}


How to compile

mvn install


Running the program

Producer

spark-submit --class com.reza.dev.learn.main.Main_Producer --master local[2] target/SparkStreamingHBase-1.0-SNAPSHOT-jar-with-dependencies.jar '{"kafka":{"broker":"datanode01:6667,datanode02:6667,datanode03:6667","kafka_topic":"test"}}' '/doc/data/humidity.json'

Consumer

spark-submit --class com.reza.dev.learn.main.Main_Consumer --master local[2] --conf spark.streaming.backpressure.enabled=true --conf spark.streaming.kafka.maxRatePerPartition=100 target/SparkStreamingHBase-1.0-SNAPSHOT-jar-with-dependencies.jar '{"hbase":{"output_table":"test-table-1","master":"namenode01,namenode02","quorum":"master,namenode01,namenode02","hbaseZkPort":"2181"},"kafka":{"broker":"datanode01:6667,datanode02:6667,datanode03:6667","group_name":"group-test","auto_offset_reset":"earliest","auto_commit":true,"kafka_topics":{"test-v1":3}}}'

sparkstreamingtohbase's People

Contributors

rezaadie avatar

Stargazers

 avatar

Watchers

 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.