Skip to content

Commit

Permalink
[FAB-2439] Add sample genesis profile for Kafka
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-2439

This changeset:

1. Introduces a bare-minimum genesis profile for Kafka
2. Updates the Kafka-related Docker environments under `bddtests`

Change-Id: I02c106f181afb38ab2262410baaf05427aa4bb20
Signed-off-by: Kostas Christidis <kostas@christidis.io>
  • Loading branch information
kchristidis committed Feb 25, 2017
1 parent 6daec3f commit f4448b9
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 45 deletions.
4 changes: 2 additions & 2 deletions bddtests/environments/orderer-1-kafka-1/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ services:
image: hyperledger/fabric-testenv-orderer
environment:
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENESIS_ORDERERTYPE=kafka
- ORDERER_KAFKA_BROKERS=[kafka0:9092]
- ORDERER_GENERAL_GENESISPROFILE=SampleInsecureKafka
- CONFIGTX_ORDERER_KAFKA_BROKERS=[kafka0:9092]
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
command: orderer
ports:
Expand Down
4 changes: 2 additions & 2 deletions bddtests/environments/orderer-1-kafka-3/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ services:
image: hyperledger/fabric-testenv-orderer
environment:
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENESIS_ORDERERTYPE=kafka
- ORDERER_KAFKA_BROKERS=[kafka0:9092,kafka1:9092,kafka2:9092]
- ORDERER_GENERAL_GENESISPROFILE=SampleInsecureKafka
- CONFIGTX_ORDERER_KAFKA_BROKERS=[kafka0:9092,kafka1:9092,kafka2:9092]
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
command: orderer
ports:
Expand Down
3 changes: 1 addition & 2 deletions bddtests/environments/orderer-n-kafka-n/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ services:
orderer:
image: hyperledger/fabric-testenv-orderer
environment:
- ORDERER_GENERAL_QUEUESIZE=1000
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENESIS_ORDERERTYPE=kafka
- ORDERER_GENERAL_GENESISPROFILE=SampleInsecureKafka
ports:
- '7050'
depends_on:
Expand Down
2 changes: 0 additions & 2 deletions bddtests/environments/orderer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ services:
build: .
image: hyperledger/fabric-testenv-orderer
environment:
- ORDERER_GENERAL_QUEUESIZE=1000
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENESIS_ORDERERTYPE=solo
ports:
- '7050'
55 changes: 25 additions & 30 deletions bddtests/environments/orderer/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,44 @@
#!/usr/bin/env bash

# This script will either start the kafka server, or run the user
# This script will either start the Kafka server, or run the user
# specified command.

# Exit immediately if a pipeline returns a non-zero status.
# exit immediately if a pipeline returns a non-zero status
set -e

ORDERER_EXE=orderer
KAFKA_GENESIS_PROFILES=(SampleInsecureKafka)

# handle starting the orderer with an option
if [ "${1:0:1}" = '-' ]; then
set -- ${ORDERER_EXE} "$@"
fi

# handle default (i.e. no custom options or commands)
# check if the Kafka-based orderer is invoked
if [ "$1" = "${ORDERER_EXE}" ]; then

case "$ORDERER_GENESIS_ORDERERTYPE" in
solo)
;;
kafka)
# make sure at least one broker has started.
# get the broker list from zookeeper
if [ -z "$ORDERER_KAFKA_BROKERS" ] ; then
if [ -z "$ZOOKEEPER_CONNECT" ] ; then
export ZOOKEEPER_CONNECT="zookeeper:2181"
for PROFILE in "${KAFKA_GENESIS_PROFILES[@]}"; do
if [ "$ORDERER_GENERAL_GENESISPROFILE" == "$PROFILE" ] ; then
# make sure at least one broker has started
# get the broker list from ZooKeeper
if [ -z "$CONFIGTX_ORDERER_KAFKA_BROKERS" ] ; then
if [ -z "$ZOOKEEPER_CONNECT" ] ; then
export ZOOKEEPER_CONNECT="zookeeper:2181"
fi
ZK_CLI_EXE="/usr/share/zookeeper/bin/zkCli.sh -server ${ZOOKEEPER_CONNECT}"
until [ -n "$($ZK_CLI_EXE ls /brokers/ids | grep '^\[')" ] ; do
echo "No Kafka brokers registered in ZooKeeper. Will try again in 1 second."
sleep 1
done
CONFIGTX_ORDERER_KAFKA_BROKERS="["
CONFIGTX_ORDERER_KAFKA_BROKERS_SEP=""
for BROKER_ID in $($ZK_CLI_EXE ls /brokers/ids | grep '^\[' | sed 's/[][,]/ /g'); do
CONFIGTX_ORDERER_KAFKA_BROKERS=${CONFIGTX_ORDERER_KAFKA_BROKERS}${ORDERER_KAFKA_BROKERS_SEP}$($ZK_CLI_EXE get /brokers/ids/$BROKER_ID 2>&1 | grep '^{' | jq -j '. | .host,":",.port')
CONFIGTX_ORDERER_KAFKA_BROKERS_SEP=","
done
export CONFIGTX_ORDERER_KAFKA_BROKERS="${CONFIGTX_ORDERER_KAFKA_BROKERS}]"
fi
ZK_CLI_EXE="/usr/share/zookeeper/bin/zkCli.sh -server ${ZOOKEEPER_CONNECT}"
until [ -n "$($ZK_CLI_EXE ls /brokers/ids | grep '^\[')" ] ; do
echo "No Kafka brokers registered in ZooKeeper. Will try again in 1 second."
sleep 1
done
ORDERER_KAFKA_BROKERS="["
ORDERER_KAFKA_BROKERS_SEP=""
for BROKER_ID in $($ZK_CLI_EXE ls /brokers/ids | grep '^\[' | sed 's/[][,]/ /g'); do
ORDERER_KAFKA_BROKERS=${ORDERER_KAFKA_BROKERS}${ORDERER_KAFKA_BROKERS_SEP}$($ZK_CLI_EXE get /brokers/ids/$BROKER_ID 2>&1 | grep '^{' | jq -j '. | .host,":",.port')
ORDERER_KAFKA_BROKERS_SEP=","
done
export ORDERER_KAFKA_BROKERS="${ORDERER_KAFKA_BROKERS}]"
fi
;;
sbft)
;;
esac

done
fi

exec "$@"
25 changes: 18 additions & 7 deletions common/configtx/tool/configtx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,26 @@
################################################################################
Profiles:

# SampleInsecureSol defines a configuration which contains no MSP definitions
# and allows all transactions and channel creation requests
# SampleInsecureSolo defines a configuration which uses the Solo orderer,
# contains no MSP definitions, and allows all transactions and channel
# creation requests
SampleInsecureSolo:
Orderer:
<<: *OrdererDefaults
Application:
Application:
<<: *ApplicationDefaults

# SampleInsecureKafka defines a configuration that differs from the
# SampleInsecureSolo one only in that is uses the Kafka-based orderer.
SampleInsecureKafka:
Orderer:
<<: *OrdererDefaults
OrdererType: kafka
Application:
<<: *ApplicationDefaults

# SampleSingleMSPSolo defines a configuration which contains a single MSP
# definition (the MSP sampleconfig).
# SampleSingleMSPSolo defines a configuration which uses the Solo orderer,
# and contains a single MSP definition (the MSP sampleconfig).
SampleSingleMSPSolo:
Orderer:
<<: *OrdererDefaults
Expand Down Expand Up @@ -102,8 +112,9 @@ Orderer: &OrdererDefaults
AbsoluteMaxBytes: 99 MB

# Preferred Max Bytes: The preferred maximum number of bytes allowed for
# the serialized messages in a batch. A message larger than the preferred
# max bytes will result in a batch larger than preferred max bytes.
# the serialized messages in a batch. A message larger than the
# preferred max bytes will result in a batch larger than preferred max
# bytes.
PreferredMaxBytes: 512 KB

Kafka:
Expand Down

0 comments on commit f4448b9

Please sign in to comment.