Skip to content

Commit f4448b9

Browse files
committed
[FAB-2439] Add sample genesis profile for Kafka
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 <[email protected]>
1 parent 6daec3f commit f4448b9

File tree

6 files changed

+48
-45
lines changed

6 files changed

+48
-45
lines changed

bddtests/environments/orderer-1-kafka-1/docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ services:
77
image: hyperledger/fabric-testenv-orderer
88
environment:
99
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
10-
- ORDERER_GENESIS_ORDERERTYPE=kafka
11-
- ORDERER_KAFKA_BROKERS=[kafka0:9092]
10+
- ORDERER_GENERAL_GENESISPROFILE=SampleInsecureKafka
11+
- CONFIGTX_ORDERER_KAFKA_BROKERS=[kafka0:9092]
1212
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
1313
command: orderer
1414
ports:

bddtests/environments/orderer-1-kafka-3/docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ services:
77
image: hyperledger/fabric-testenv-orderer
88
environment:
99
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
10-
- ORDERER_GENESIS_ORDERERTYPE=kafka
11-
- ORDERER_KAFKA_BROKERS=[kafka0:9092,kafka1:9092,kafka2:9092]
10+
- ORDERER_GENERAL_GENESISPROFILE=SampleInsecureKafka
11+
- CONFIGTX_ORDERER_KAFKA_BROKERS=[kafka0:9092,kafka1:9092,kafka2:9092]
1212
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
1313
command: orderer
1414
ports:

bddtests/environments/orderer-n-kafka-n/docker-compose.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ services:
66
orderer:
77
image: hyperledger/fabric-testenv-orderer
88
environment:
9-
- ORDERER_GENERAL_QUEUESIZE=1000
109
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
11-
- ORDERER_GENESIS_ORDERERTYPE=kafka
10+
- ORDERER_GENERAL_GENESISPROFILE=SampleInsecureKafka
1211
ports:
1312
- '7050'
1413
depends_on:

bddtests/environments/orderer/docker-compose.yml

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ services:
44
build: .
55
image: hyperledger/fabric-testenv-orderer
66
environment:
7-
- ORDERER_GENERAL_QUEUESIZE=1000
87
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
9-
- ORDERER_GENESIS_ORDERERTYPE=solo
108
ports:
119
- '7050'
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,44 @@
11
#!/usr/bin/env bash
22

3-
# This script will either start the kafka server, or run the user
3+
# This script will either start the Kafka server, or run the user
44
# specified command.
55

6-
# Exit immediately if a pipeline returns a non-zero status.
6+
# exit immediately if a pipeline returns a non-zero status
77
set -e
88

99
ORDERER_EXE=orderer
10+
KAFKA_GENESIS_PROFILES=(SampleInsecureKafka)
1011

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

16-
# handle default (i.e. no custom options or commands)
17+
# check if the Kafka-based orderer is invoked
1718
if [ "$1" = "${ORDERER_EXE}" ]; then
18-
19-
case "$ORDERER_GENESIS_ORDERERTYPE" in
20-
solo)
21-
;;
22-
kafka)
23-
# make sure at least one broker has started.
24-
# get the broker list from zookeeper
25-
if [ -z "$ORDERER_KAFKA_BROKERS" ] ; then
26-
if [ -z "$ZOOKEEPER_CONNECT" ] ; then
27-
export ZOOKEEPER_CONNECT="zookeeper:2181"
19+
for PROFILE in "${KAFKA_GENESIS_PROFILES[@]}"; do
20+
if [ "$ORDERER_GENERAL_GENESISPROFILE" == "$PROFILE" ] ; then
21+
# make sure at least one broker has started
22+
# get the broker list from ZooKeeper
23+
if [ -z "$CONFIGTX_ORDERER_KAFKA_BROKERS" ] ; then
24+
if [ -z "$ZOOKEEPER_CONNECT" ] ; then
25+
export ZOOKEEPER_CONNECT="zookeeper:2181"
26+
fi
27+
ZK_CLI_EXE="/usr/share/zookeeper/bin/zkCli.sh -server ${ZOOKEEPER_CONNECT}"
28+
until [ -n "$($ZK_CLI_EXE ls /brokers/ids | grep '^\[')" ] ; do
29+
echo "No Kafka brokers registered in ZooKeeper. Will try again in 1 second."
30+
sleep 1
31+
done
32+
CONFIGTX_ORDERER_KAFKA_BROKERS="["
33+
CONFIGTX_ORDERER_KAFKA_BROKERS_SEP=""
34+
for BROKER_ID in $($ZK_CLI_EXE ls /brokers/ids | grep '^\[' | sed 's/[][,]/ /g'); do
35+
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')
36+
CONFIGTX_ORDERER_KAFKA_BROKERS_SEP=","
37+
done
38+
export CONFIGTX_ORDERER_KAFKA_BROKERS="${CONFIGTX_ORDERER_KAFKA_BROKERS}]"
2839
fi
29-
ZK_CLI_EXE="/usr/share/zookeeper/bin/zkCli.sh -server ${ZOOKEEPER_CONNECT}"
30-
until [ -n "$($ZK_CLI_EXE ls /brokers/ids | grep '^\[')" ] ; do
31-
echo "No Kafka brokers registered in ZooKeeper. Will try again in 1 second."
32-
sleep 1
33-
done
34-
ORDERER_KAFKA_BROKERS="["
35-
ORDERER_KAFKA_BROKERS_SEP=""
36-
for BROKER_ID in $($ZK_CLI_EXE ls /brokers/ids | grep '^\[' | sed 's/[][,]/ /g'); do
37-
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')
38-
ORDERER_KAFKA_BROKERS_SEP=","
39-
done
40-
export ORDERER_KAFKA_BROKERS="${ORDERER_KAFKA_BROKERS}]"
4140
fi
42-
;;
43-
sbft)
44-
;;
45-
esac
46-
41+
done
4742
fi
4843

4944
exec "$@"

common/configtx/tool/configtx.yaml

+18-7
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,26 @@
99
################################################################################
1010
Profiles:
1111

12-
# SampleInsecureSol defines a configuration which contains no MSP definitions
13-
# and allows all transactions and channel creation requests
12+
# SampleInsecureSolo defines a configuration which uses the Solo orderer,
13+
# contains no MSP definitions, and allows all transactions and channel
14+
# creation requests
1415
SampleInsecureSolo:
1516
Orderer:
1617
<<: *OrdererDefaults
17-
Application:
18+
Application:
19+
<<: *ApplicationDefaults
20+
21+
# SampleInsecureKafka defines a configuration that differs from the
22+
# SampleInsecureSolo one only in that is uses the Kafka-based orderer.
23+
SampleInsecureKafka:
24+
Orderer:
25+
<<: *OrdererDefaults
26+
OrdererType: kafka
27+
Application:
1828
<<: *ApplicationDefaults
1929

20-
# SampleSingleMSPSolo defines a configuration which contains a single MSP
21-
# definition (the MSP sampleconfig).
30+
# SampleSingleMSPSolo defines a configuration which uses the Solo orderer,
31+
# and contains a single MSP definition (the MSP sampleconfig).
2232
SampleSingleMSPSolo:
2333
Orderer:
2434
<<: *OrdererDefaults
@@ -102,8 +112,9 @@ Orderer: &OrdererDefaults
102112
AbsoluteMaxBytes: 99 MB
103113

104114
# Preferred Max Bytes: The preferred maximum number of bytes allowed for
105-
# the serialized messages in a batch. A message larger than the preferred
106-
# max bytes will result in a batch larger than preferred max bytes.
115+
# the serialized messages in a batch. A message larger than the
116+
# preferred max bytes will result in a batch larger than preferred max
117+
# bytes.
107118
PreferredMaxBytes: 512 KB
108119

109120
Kafka:

0 commit comments

Comments
 (0)