Skip to content

Instantly share code, notes, and snippets.

@miguno
miguno / queryable-state_list-app-instances.md
Last active September 2, 2016 14:22
List all running instances of this application
# List all running instances of this application
$ http://localhost:7070/state/instances
[
	{
		"host": "localhost",
 "port": 7070,
@miguno
miguno / queryable-state_app-instances-for-a-store.md
Last active September 2, 2016 14:22
List running app instances that currently manage (parts of) state store "word-count"
# List running app instances that currently manage (parts of) state store "word-count"
$ http://localhost:7070/state/instances/word-count
[
	{
		"host": "localhost",
 "port": 7070,
@miguno
miguno / queryable-state_all-records.md
Last active September 2, 2016 14:23
Get all key-value records of state store "word-count" across all instances
# Get all key-value records of state store "word-count" across all instances
$ http://localhost:7070/state/keyvalues/word-count/all 
[
	{
		"key": "a",
 "value": 147
@miguno
miguno / queryable-state_latest-value-for-key.md
Last active September 2, 2016 14:25
Get the latest value for key "jolly" in state store "word-count"
# Get the latest value for key "jolly" in state store "word-count"
$ http://localhost:7070/state/keyvalue/word-count/jolly
{
	"key": "jolly",
	"value": 55
}
@miguno
miguno / queryable-state_range-query.md
Last active September 2, 2016 14:24
Get all key-value records of state store "word-count" that have keys within a (key) range
# Get all key-value records of state store "word-count" that have keys within the range from "hat" to "kafka"
$ http://localhost:7070/state/keyvalues/word-count/range/hat/kafka
[
	{
		"key": "hat",
 "value": 65
@miguno
miguno / queryable-state_app-instance-for-a-key.md
Last active September 2, 2016 14:24
Find the app instance that contains key "jolly" (if it exists) for the state store "word-count"
# Find the app instance that contains key "jolly" (if it exists) for the state store "word-count"
$ http://localhost:7070/state/instance/word-count/jolly
{
	"host": "localhost",
	"port": 7070,
	"storeNames": [
@miguno
miguno / WordCountLambdaExample.java
Created September 7, 2016 10:53
Kafka Streams WordCount example (0.10.0.x)
public static void main(String[] args) throws Exception {
Properties streamsConfiguration = new Properties();
streamsConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, "wordcount-lambda-example");
streamsConfiguration.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
streamsConfiguration.put(StreamsConfig.ZOOKEEPER_CONNECT_CONFIG, "localhost:2181");
streamsConfiguration.put(StreamsConfig.KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName());
streamsConfiguration.put(StreamsConfig.VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName());
final Serde<String> stringSerde = Serdes.String();
final Serde<Long> longSerde = Serdes.Long();
@miguno
miguno / WordCountApp.scala
Last active November 29, 2017 20:10
WordCount algorithm implemented via a standard Scala application that uses Kafka's Streams API (Kafka 0.10.2)
import java.lang.Long
import java.util.Properties
import java.util.concurrent.TimeUnit
import org.apache.kafka.common.serialization._
import org.apache.kafka.streams._
import org.apache.kafka.streams.kstream.{KStream, KStreamBuilder, KTable}
import scala.collection.JavaConverters.asJavaIterableConverter
@miguno
miguno / KAFKA_STREAMS_AND_CONTAINERIZED_KAFKA.md
Last active April 3, 2017 13:02
Running Confluent's Kafka Streams demo applications against a containerized Kafka cluster
@miguno
miguno / docker_machine.sh
Last active May 1, 2017 13:22
Mac users only: Create and configure the Docker Machine
# MAC USERS ONLY!
#
# If you haven't done so, create a VM with 6GB of memory as your Docker Machine
# and name it `confluent`. If you already created the `confluent` machine earlier,
# ensure that it is running (`status`) and `start` it if need be.
$ docker-machine create --driver virtualbox --virtualbox-memory 6000 confluent
# Next, configure your terminal window to attach it to your new Docker Machine.
$ eval $(docker-machine env confluent)