Skip to content

Instantly share code, notes, and snippets.

@miguno
miguno / gist:548cd72eaec017c475448cb9b2ced258
Last active April 7, 2023 19:24
Taking Java JVM memory snapshots with gdb and jmap (for YourKit)

Notes

  • Good: very quick snapshotting even for large heap spaces (e.g. works if your JVM process would otherwise timeout and die)
  • Bad: such a memory snapshot contains significantly less useful information than YourKit's "enhanced" memory snapshots.

Usage

# 1. Find the relevant JVM pid on the target machine
$ ps ...
@miguno
miguno / docker.sh
Created June 18, 2018 09:01
Quick tip: Running a Java or Scala application with Docker (e.g., a Java/Scala app using Apache Kafka's Streams API), assuming the application is packaged as a fat jar / uber jar
$ docker container run --rm \
--net streams_streams-net \
-v /docker/host/path/to/app.jar:/docker/container/path/to/app.jar \
openjdk:8-jre java -jar /docker/container/path/to/app.jar
@miguno
miguno / define-a-struct.sql
Last active June 27, 2018 07:58
Creating a stream with a STRUCT column
CREATE STREAM orders (orderid VARCHAR, itemid VARCHAR, address STRUCT<city VARCHAR, state VARCHAR, zicode BIGINT>)
WITH (kafka_topic = 'orders_topic', value_format = 'JSON', key = 'orderId');
@miguno
miguno / udaf.java
Created June 29, 2018 08:12
UDAF example
package com.myorg.ksql.udaf;
import io.confluent.ksql.function.udaf.UdafFactory;
import io.confluent.ksql.function.udf.UdfDescription;
@UdfDescription(name = "totalStringLength", author = "Confluent", version = "1.0")
public class TotalStringLength {
@UdafFactory(description = "sums the length of strings")
public static Udaf<String, Long> createSumLengthString() {
@miguno
miguno / hll.py
Last active November 9, 2022 14:58
HyperLogLog (HLL) experiments: register bits, register counts, estimation error, error bounds
# Runs HLL experiments, using randomly generated strings as input data.
#
# Requirements
# ============
#
# # https://github.com/ascv/HyperLogLog
# $ pip install HLL
#
#
# How to use
@miguno
miguno / interactive-queries_list-app-instances.md
Last active May 14, 2021 15:37 — forked from enothereska/interactive-queries_list-app-instances.md
List all running instances of this application
# List all running instances of this application
$ http://localhost:7070/kafka-music/instances
[
	{
		"host": "localhost",
 "port": 7070,
@miguno
miguno / interactive-queries_app-instances-for-a-store.md
Created October 31, 2018 16:27 — forked from enothereska/interactive-queries_app-instances-for-a-store.md
List running app instances that currently manage (parts of) state store "top-five-songs"
# List running app instances that currently manage (parts of) state store "top-five-songs"
$ http://localhost:7070/kafka-music/instances/top-five-songs
[
	{
		"host": "localhost",
 "port": 7070,
# Get all the top-5 charts across all instances
$ http://localhost:7070/kafka-music/charts/top-five
[
  {
    "artist":"Hilltop Hoods",
 "album":"The Calling",
# Get all the top-5 charts across all instances
$ http://localhost:7070/kafka-music/charts/genre/punk
[
  {
    "artist":"Wheres The Pope?",
 "album":"PSI",
@miguno
miguno / interactive-queries_song-id.md
Created October 31, 2018 16:27 — forked from enothereska/interactive-queries_song-id.md
Get details for a particular song
# Get all the top-5 charts across all instances
$ http://localhost:7070/kafka-music/song/9
{
  "artist":"N.W.A",
  "album":"Straight Outta Compton",
 "name":"Gangsta Gangsta"