<commit_before>#!/bin/bash
#    Copyright 2015 Google, Inc.
#
#    Licensed 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.
set -x -e

function update_apt_get() {
  for ((i = 0; i < 10; i++)); do
    if apt-get update; then
      return 0
    fi
    sleep 5
  done
  return 1
}

# Variables for this script
ROLE=$(/usr/share/google/get_metadata_value attributes/dataproc-role)
CLUSTER_NAME=$(hostname | sed -r 's/(.*)-[w|m](-[0-9]+)?$/\1/')

# Download and extract ZooKeeper
update_apt_get
apt-get install -y zookeeper
mkdir -p /var/lib/zookeeper

# Configure ZooKeeper node ID
NODE_NUMBER=1
if [[ "${ROLE}" == 'Worker' ]]; then
	NODE_NUMBER=$((`hostname | sed 's/.*-w-\([0-9]\)*.*/\1/g'`+2))
fi
echo ${NODE_NUMBER} >| /var/lib/zookeeper/myid

# Write ZooKeeper configuration file
cat > /etc/zookeeper/conf/zoo.cfg <<EOF
tickTime=2000
dataDir=/var/lib/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=${CLUSTER_NAME}-m:2888:3888
server.2=${CLUSTER_NAME}-w-0:2888:3888
server.3=${CLUSTER_NAME}-w-1:2888:3888
EOF

# Start ZooKeeper
ZOO_LOG_DIR=/var/log/zookeeper /usr/lib/zookeeper/bin/zkServer.sh start<commit_msg>Install zookeeper-server instead of just zookeeper (#280)<commit_after>#!/bin/bash
#    Copyright 2015 Google, Inc.
#
#    Licensed 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.
set -o errexit
set -o xtrace

function update_apt_get() {
  for ((i = 0; i < 10; i++)); do
    if apt-get update; then
      return 0
    fi
    sleep 5
  done
  return 1
}

# Variables for this script
ROLE=$(/usr/share/google/get_metadata_value attributes/dataproc-role)
CLUSTER_NAME=$(hostname | sed -r 's/(.*)-[w|m](-[0-9]+)?$/\1/')

# Download and extract ZooKeeper Server
update_apt_get
apt-get install -y zookeeper-server
mkdir -p /var/lib/zookeeper

# Configure ZooKeeper node ID
NODE_NUMBER=1
if [[ "${ROLE}" == 'Worker' ]]; then
	NODE_NUMBER=$((`hostname | sed 's/.*-w-\([0-9]\)*.*/\1/g'`+2))
fi
echo ${NODE_NUMBER} >| /var/lib/zookeeper/myid

# Write ZooKeeper configuration file
cat > /etc/zookeeper/conf/zoo.cfg <<EOF
tickTime=2000
dataDir=/var/lib/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=${CLUSTER_NAME}-m:2888:3888
server.2=${CLUSTER_NAME}-w-0:2888:3888
server.3=${CLUSTER_NAME}-w-1:2888:3888
EOF

# Restart ZooKeeper
systemctl restart zookeeper-server
{'fraction_non_alphanumeric': 0.132486388384755, 'fraction_numerical': 0.03781004234724743, 'mean_word_length': 3.8560939794419973, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1270551', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1143, 'n_words': 341}