Skip to content

Commit 5f2fec6

Browse files
cawright-rhCameron Wrightdobrerazvan
authored
Adding SEED_PORT to have a port override alongside the existing SEED_NODE. (#31)
* adding SEED_PORT as a potential override to clientport for zookeeper management scripts * Make zu.jar run over ssl * updating zookeeperStart.sh * taking out debug echo's and fixing zookeeper readyness check to have ssl_options if 2182 is used * removing debug echos --------- Co-authored-by: Cameron Wright <[email protected]> Co-authored-by: Razvan Dobre <[email protected]>
1 parent b5af315 commit 5f2fec6

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

docker/bin/zookeeperFunctions.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ function zkConnectionString() {
2929
set -e
3030
echo "localhost:${CLIENT_PORT}"
3131
else
32+
if [ -z "${SEED_PORT}" ]; then
33+
PORT=${CLIENT_PORT}
34+
else
35+
PORT=${SEED_PORT}
36+
fi
3237
set -e
33-
echo "${CLIENT_HOST}:${CLIENT_PORT}"
38+
echo "${CLIENT_HOST}:${PORT}"
3439
fi
3540
}

docker/bin/zookeeperReady.sh

+9-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ OFFSET=${OFFSET:-1}
2727
# CLIENT_HOST is used in zkConnectionString function already to create zkURL
2828
CLIENT_HOST=${SEED_NODE:-$CLIENT_HOST}
2929

30-
3130
OK=$(echo ruok | socat stdio tcp:localhost:$CLIENT_PORT)
3231

3332
# Check to see if zookeeper service answers
@@ -88,12 +87,18 @@ if [[ "$OK" == "imok" ]]; then
8887
exit 0
8988
elif [[ "$ROLE" == "observer" ]]; then
9089
echo "Zookeeper service is ready to be upgraded from observer to participant."
91-
ROLE=participant
90+
SSL_OPTIONS="-Dzookeeper.clientCnxnSocket=org.apache.zookeeper.ClientCnxnSocketNetty -Dzookeeper.client.secure=true"
9291
ZKURL=$(zkConnectionString)
92+
ROLE=participant
9393
ZKCONFIG=$(zkConfig $OUTSIDE_NAME)
94-
java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar remove $ZKURL $MYID
94+
if [[ "$ZKURL" =~ :2182$ ]]; then
95+
ZK_OPTIONS="$SSL_OPTIONS"
96+
else
97+
ZK_OPTIONS=""
98+
fi
99+
java -Dlog4j.configuration=file:"$LOG4J_CONF" $ZK_OPTIONS -jar /opt/libs/zu.jar remove $ZKURL $MYID
95100
sleep 1
96-
java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar add $ZKURL $MYID $ZKCONFIG
101+
java -Dlog4j.configuration=file:"$LOG4J_CONF" $ZK_OPTIONS -jar /opt/libs/zu.jar add $ZKURL $MYID $ZKCONFIG
97102
exit 0
98103
else
99104
echo "Something has gone wrong. Unable to determine zookeeper role."

docker/bin/zookeeperStart.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ if [ -f $MYID_FILE ]; then
7373
fi
7474
fi
7575

76-
if [ -f $DYNCONFIG ]; then
76+
if [ -f $DYNCONFIG ] && [ -z $SEED_NODE ]; then
7777
ONDISK_DYN_CONFIG=true
7878
fi
7979

@@ -137,6 +137,7 @@ else
137137
fi
138138
fi
139139

140+
140141
if [[ "$WRITE_CONFIGURATION" == true ]]; then
141142
echo "Writing myid: $MYID to: $MYID_FILE."
142143
echo $MYID > $MYID_FILE
@@ -151,13 +152,20 @@ if [[ "$WRITE_CONFIGURATION" == true ]]; then
151152
fi
152153
fi
153154

155+
154156
if [[ "$REGISTER_NODE" == true ]]; then
155157
ROLE=observer
156158
ZKURL=$(zkConnectionString)
157159
ZKCONFIG=$(zkConfig $OUTSIDE_NAME)
158160
set -e
159161
echo Registering node and writing local configuration to disk.
160-
java -Dlog4j.configuration=file:"$LOG4J_CONF" -jar /opt/libs/zu.jar add $ZKURL $MYID $ZKCONFIG $DYNCONFIG
162+
SSL_OPTIONS="-Dzookeeper.clientCnxnSocket=org.apache.zookeeper.ClientCnxnSocketNetty -Dzookeeper.client.secure=true"
163+
if [[ "$ZKURL" =~ :2182$ ]]; then
164+
ZK_OPTIONS="$SSL_OPTIONS"
165+
else
166+
ZK_OPTIONS=""
167+
fi
168+
java -Dlog4j.configuration=file:"$LOG4J_CONF" $ZK_OPTIONS -jar /opt/libs/zu.jar add $ZKURL $MYID $ZKCONFIG $DYNCONFIG
161169
set +e
162170
fi
163171

docker/zu/src/main/java/io/pravega/zookeeper/Main.kt

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ fun runSync(args: Array<String>, suppressOutput: Boolean = false): String {
5050
if (! suppressOutput) {
5151
print(clusterSize)
5252
}
53+
zk.close()
5354
clusterSize
5455
} catch (e: Exception) {
5556
System.err.println("Error performing zookeeper sync operation:")
@@ -71,6 +72,7 @@ fun runGetAll(args: Array<String>, suppressOutput: Boolean = false): String {
7172
if (! suppressOutput) {
7273
print(zkCfg)
7374
}
75+
zk.close()
7476
zkCfg
7577
} catch (e: Exception) {
7678
System.err.println("Error getting server config")
@@ -129,6 +131,7 @@ fun reconfigure(zkUrl: String, joining: String?, leaving: String?, outputFile: S
129131
} else {
130132
File(outputFile).bufferedWriter().use {it.write(cfgStr + "\n")}
131133
}
134+
zk.close()
132135
} catch (e: Exception) {
133136
System.err.println("Error performing zookeeper reconfiguration:")
134137
e.printStackTrace(System.err)

0 commit comments

Comments
 (0)