kafka-utils

kafka utils

License

License

GroupId

GroupId

sc.ala
ArtifactId

ArtifactId

kafka-utils_2.11
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

kafka-utils
kafka utils
Project URL

Project URL

https://github.com/maiha/kafka-utils
Project Organization

Project Organization

sc.ala
Source Code Management

Source Code Management

https://github.com/maiha/kafka-utils

Download kafka-utils_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/sc.ala/kafka-utils_2.11/ -->
<dependency>
    <groupId>sc.ala</groupId>
    <artifactId>kafka-utils_2.11</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/sc.ala/kafka-utils_2.11/
implementation 'sc.ala:kafka-utils_2.11:0.2.0'
// https://jarcasting.com/artifacts/sc.ala/kafka-utils_2.11/
implementation ("sc.ala:kafka-utils_2.11:0.2.0")
'sc.ala:kafka-utils_2.11:jar:0.2.0'
<dependency org="sc.ala" name="kafka-utils_2.11" rev="0.2.0">
  <artifact name="kafka-utils_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='sc.ala', module='kafka-utils_2.11', version='0.2.0')
)
libraryDependencies += "sc.ala" % "kafka-utils_2.11" % "0.2.0"
[sc.ala/kafka-utils_2.11 "0.2.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.7
org.apache.kafka : kafka_2.11 jar 0.9.0.0
org.apache.kafka : kafka-clients jar 0.9.0.0
sc.ala : rubyist_2.11 jar 0.2.6
pl.project13.scala : rainbow_2.11 jar 0.2

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 2.2.4

Project Modules

There are no modules declared in this project.

Build Status

KafkaUtils

Simple Kafka Utils in Scala

Features

  • simple api
    • see sc.ala.kafka.utils.Api

Usage

prepare

import sc.ala.kafka.utils._
val utils = KafkaUtils("localhost:2181")  // set zkConnect

1 hop api (just type one word)

get broker list

utils.brokers
// Seq[kafka.cluster.Broker] = ArrayBuffer(id:1,host:ubuntu,port:9092)

get topic names

utils.topics
// Seq[String] = ArrayBuffer(topic1, test)

about topic

create topic

utils.create("topic1", 1, 3)

leader broker ids for the topic

utils.leaders("topic1")
// Map[Int,Option[Int]] = Map(2 -> Some(1), 1 -> Some(1), 0 -> Some(1))

partitions for the topic

utils.partitions("topic1")
// Seq[Int] = ArrayBuffer(2, 1, 0)

delete topic

utils.delete("topic1")

count messages

utils.count("topic1")
// Long = 5

utils.counts("topic1")
// Map(2 -> 0, 1 -> 5, 0 -> 0)

list topics and counts

utils.topics.sorted.foreach{ t => println(s"${utils.count(t)}\t$t") }
// 1       t1
// 1534339 t2
// 0       t3

offset

utils.offset("topic1")
// Long = 5

utils.offsets("topic1")
// Map[Int,Long] = Map(2 -> 0, 1 -> 0, 0 -> 3)

teardown

utils.close

TODO

  • write tests
  • consumers

Tested

  • kafka-0.9.0
  • kafka-0.8.2

Versions

Version
0.2.0
0.1.1
0.1.0