You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/03/15 22:08:09 UTC

[GitHub] jiazhai commented on a change in pull request #1263: Issue 881: use initialize insteadof format in docker image

jiazhai commented on a change in pull request #1263: Issue 881: use initialize insteadof format in docker image
URL: https://github.com/apache/bookkeeper/pull/1263#discussion_r174947695
 
 

 ##########
 File path: docker/scripts/entrypoint.sh
 ##########
 @@ -61,11 +63,50 @@ until /opt/bookkeeper/bin/bookkeeper org.apache.zookeeper.ZooKeeperMain -server
 echo "create the zk root dir for bookkeeper"
 /opt/bookkeeper/bin/bookkeeper org.apache.zookeeper.ZooKeeperMain -server ${BK_zkServers} create ${BK_CLUSTER_ROOT_PATH}
 
-echo "format zk metadata"
-echo "please ignore the failure, if it has already been formatted, "
 export BOOKIE_CONF=/opt/bookkeeper/conf/bk_server.conf
 export SERVICE_PORT=$PORT0
-/opt/bookkeeper/bin/bookkeeper shell metaformat -n || true
+
+# Init the cluster if required znodes not exist in Zookeeper.
+# Use ephemeral zk node as lock to keep initialize atomic.
+/opt/bookkeeper/bin/bookkeeper org.apache.zookeeper.ZooKeeperMain -server ${BK_zkServers} stat ${BK_zkLedgersRootPath}/available/readonly
+if [ $? -eq 0 ]; then
+    echo "Metadata of cluster already exists, no need format"
+else
+    # create ephemeral zk node bkInitLock, initiator who this node, then do init; other initiators will wait.
+    /opt/bookkeeper/bin/bookkeeper org.apache.zookeeper.ZooKeeperMain -server ${BK_zkServers} create -e ${BK_CLUSTER_ROOT_PATH}/bkInitLock
 
 Review comment:
   Thanks, the second will wait the first.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services