zookeeper.sh 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#!/usr/bin/env bash
################################################################################
#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

# Start/stop a ZooKeeper quorum peer.
USAGE="Usage: zookeeper.sh (start peer-id|stop|stop-all)"

STARTSTOP=$1
PEER_ID=$2

bin=`dirname "$0"`
bin=`cd "$bin"; pwd`

. "$bin"/config.sh

ZK_CONF=$FLINK_CONF_DIR/zoo.cfg
if [ ! -f $ZK_CONF ]; then
    echo "[ERROR] No ZooKeeper configuration file found in '$ZK_CONF'."
    exit 1
fi

if [[ $STARTSTOP == "start" ]]; then
    if [ -z $PEER_ID ]; then
        echo "[ERROR] Missing peer id argument. $USAGE."
        exit 1
    fi

    if [[ ! ${ZK_HEAP} =~ ${IS_NUMBER} ]]; then
        echo "[ERROR] Configured ZooKeeper JVM heap size is not a number. Please set '$KEY_ZK_HEAP_MB' in $FLINK_CONF_FILE."
        exit 1
    fi

    if [ "$ZK_HEAP" -gt 0 ]; then
        export JVM_ARGS="$JVM_ARGS -Xms"$ZK_HEAP"m -Xmx"$ZK_HEAP"m"
    fi

    # Startup parameters
    args="--zkConfigFile $ZK_CONF --peerId $PEER_ID"
fi

56
${FLINK_BIN_DIR}/flink-daemon.sh $STARTSTOP zookeeper "${args}"