Skip to content

Instantly share code, notes, and snippets.

View emrantalukder's full-sized avatar

Emran Talukder emrantalukder

View GitHub Profile
@emrantalukder
emrantalukder / avro-producer.sh
Created August 18, 2023 18:50
Produce AVRO Messages with RecordNameStrategy and Sink to MongoDB
kafka-avro-console-producer \
--bootstrap-server $BOOTSTRAP_SERVER \
--producer.config client.config \
--topic orders-avro \
--property value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy \
--property auto.register.schemas=true \
--property schema.registry.url=$SR_URL \
--property basic.auth.credentials.source=USER_INFO \
--property basic.auth.user.info=SR_KEY:SR_SECERT \
--property value.schema.file=orders-avro-schema.json < sample-data.json
@emrantalukder
emrantalukder / deploy-replicator.sh
Created August 14, 2023 21:36
Script used to deploy connectors
#!/bin/bash
curl -X POST http://localhost:8083/connectors \
-H 'Content-Type: application/json' \
-d @- << EOF
{
"name": "replicator",
"config": {
"connector.class": "io.confluent.connect.replicator.ReplicatorSourceConnector",
"topic.whitelist": "demo-topic-1",
@emrantalukder
emrantalukder / confluent-kafka-mqtt-install.sh
Created July 31, 2023 19:29
confluent-kafka-mqtt install for ubuntu
wget -qO - https://packages.confluent.io/deb/7.4/archive.key | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.confluent.io/deb/7.4 stable main"
sudo add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"
sudo apt-get update
sudo apt-get install confluent-kafka-mqtt
@emrantalukder
emrantalukder / ansible-benchmarks.md
Created June 26, 2023 19:35 — forked from cjmatta/ansible-benchmarks.md
A method for orchestrating distributed Kafka benchmarks using Ansible

A method for orchestrating distributed Kafka benchmarks using Ansible

Kafka benchmarks are typically run using a single producer and consumer against a single topic, and the producer and consumer are run at close to maximum write/read speeds. In the real world, a Kafka cluster is more often serving many lower throughput producers and consumers. Ansible allows for a benchmarking method that sets up any number of topics and many producers and consumers.

Ansible playbooks allow us to run a number of tasks against a distributed set of clients both synchronously and asynchronously.

Topic setup

Before we can run tests we need topics to test against. This play sets up a number of topics with various partition configurations:

- name : Setup
@emrantalukder
emrantalukder / JsonSRProducer.java
Created January 19, 2023 19:45
Json Schema Serializer with JsonNode and JsonSchema objects
package io.confluent.developer;
import java.util.Properties;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import random
from pprint import pprint
n = 100
event = 10
data = []
seen_events = 0
for i in range(n):
@emrantalukder
emrantalukder / k8_pod_hostnames.sh
Created April 2, 2020 23:52
Get K8 Pod Hostnames and generate YAML... but just use discovery instead.
#!/usr/bin/env bash
NAMESPACE=$1
# fetch hostnames
cnfl_hosts=$(kubectl get pods -n $NAMESPACE --selector clusterId=operator -o=json | jq '.items[].spec.hostname')
# output yaml string
YAML_OUTPUT="cnfl_hosts:"
CUSTOM_TAB=' '
@emrantalukder
emrantalukder / d3.sankey.js
Created December 4, 2019 21:16 — forked from emeeks/d3.sankey.js
Sankey Particles IV
d3.sankey = function() {
var sankey = {},
nodeWidth = 24,
nodePadding = 8,
size = [1, 1],
nodes = [],
links = [];
sankey.nodeWidth = function(_) {
if (!arguments.length) return nodeWidth;
@emrantalukder
emrantalukder / AWSSdkSample.scala
Created September 18, 2019 18:12
AWS Samples in Scala
import com.amazonaws.services.s3.AmazonS3Client
import com.amazonaws.services.s3.transfer.TransferManager
/** upload directory after ETL job completes */
def uploadDirectory(bucketName: String, bucketPath: String, path: String) = {
val s3client = new AmazonS3Client()
val transferManager = new TransferManager(s3client)
transferManager.uploadDirectory(bucketName, bucketPath, Paths.get(path).toFile, true)
}
@emrantalukder
emrantalukder / postgres-table-locking.sql
Created September 13, 2019 02:45
Postgres Table Locking
-- show locks
SELECT *
FROM pg_locks l
JOIN pg_class t ON l.relation = t.oid AND t.relkind = 'r';
-- kill pid
SELECT pg_terminate_backend('the_pid');