Last active
February 22, 2018 11:11
-
-
Save gphilipp/60f7447ce7039048f5c50f2726898494 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#kafka helper functions riped off from cddr: https://gist.github.com/cddr/65b03448d34bb34636c3b2738ff14e3e | |
export BROKER_LIST=kafka-4:9092 | |
export SCHEMA_REGISTRY_URL="https://schema-registry.fc-uat.us" | |
export ZOOKEEPER_ADDRESS="localhost:2181" | |
# just do that once | |
#sudo ifconfig en0 alias 192.168.4.1 broadcast 192.168.4.255 | |
#sudo ifconfig en0 alias 192.168.5.1 broadcast 192.168.5.255 | |
#sudo ifconfig en0 alias 192.168.6.1 broadcast 192.168.6.255 | |
function create-topic () { | |
$KAFKA_DIR/kafka-topics --zookeeper $ZOOKEEPER_ADDRESS \ | |
--create \ | |
--config retention.ms=2000 \ | |
--partitions 1 \ | |
--replication-factor 3 \ | |
--topic $1 | |
} | |
function delete-topic () { | |
$KAFKA_DIR/kafka-topics --zookeeper $ZOOKEEPER_ADDRESS \ | |
--delete \ | |
--topic $1 | |
} | |
function list-topics () { | |
$KAFKA_DIR/kafka-topics --zookeeper $ZOOKEEPER_ADDRESS \ | |
--list | |
} | |
function test-produce () { | |
$KAFKA_DIR/kafka-console-producer --broker-list $BROKER_LIST \ | |
--topic $1 | |
} | |
function test-produce () { | |
$KAFKA_DIR/kafka-avro-console-producer --broker-list $BROKER_LIST \ | |
--topic $1 | |
} | |
function remove-topic () { | |
$KAFKA_DIR/kafka-topics --zookeeper $ZOOKEEPER_ADDRESS \ | |
--delete \ | |
--topic $1 | |
} | |
function consume () { | |
$KAFKA_DIR/kafka-console-consumer --zookeeper $ZOOKEEPER_ADDRESS \ | |
--property print.key=true \ | |
--from-beginning \ | |
--topic $1 | |
} | |
function avro-consume () { | |
$KAFKA_DIR/kafka-avro-console-consumer \ | |
--bootstrap-server kafka-3:9092 \ | |
--property schema.registry.url=$SCHEMA_REGISTRY_URL \ | |
--from-beginning \ | |
--topic $1 | |
} | |
function describe () { | |
$KAFKA_DIR/kafka-topics --zookeeper $ZOOKEEPER_ADDRESS \ | |
--describe \ | |
--topic $1 | |
} | |
function create-uat-tunnel() { | |
ssh -f -N -T -M -A uat-tunnel | |
} | |
function destroy-uat-tunnel() { | |
ssh -T -O "exit" uat-tunnel | |
} | |
echo "Network aliases config:" | |
ifconfig en0 | grep 192.168 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by https://gist.github.com/fjsousa/4c37c0b1bd0bad0a8f6a3b6ece9bd9ab