4 # Copyright 2013 LinkedIn, Inc
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # This script generates a final cluster.xml and stores.xml after dropping a zone from the current
19 # cluster.xml and stores.xml, placing the output in output directory.
21 # Argument = -c <current_cluster.xml> -s <current_stores.xml> -d <drop_zoneid> -o <outputdir>
23 # This script steals partitions from other nodes in the zone that is being dropped
24 # and assigns them to the nodes in the surviving zones.
26 # This script uses getopts which means only single character switches are allowed.
27 # Using getopt would allow for multi character switch names but would come at a
28 # cost of not being cross compatible.
30 # Function to display usage
38 -c Current cluster that describes the cluster
39 -s Current stores.xml for the cluster
40 -d ZoneId that you want to drop
41 -o Output dir for final cluster.xml/stores.xml
46 # initialize variables to an empty string
52 # Figure out voldemort home directory
53 dir
="$( cd "$
( dirname "${BASH_SOURCE[0]}" )" && pwd )"
54 vold_home
="$(dirname "$dir")"
57 while getopts “hc
:s
:d
:o
:” OPTION
65 current_cluster
=$OPTARG
66 echo "[rebalance-zone-shrinkage] Will rebalance on the cluster described in '$current_cluster'."
69 current_stores
=$OPTARG
70 echo "[rebalance-zone-shrinkage] Will rebalance stores described in '$current_stores'."
74 echo "[rebalance-zone-shrinkage] Will get rid of servers in zone '$drop_zoneid'."
79 echo "[rebalance-zone-shrinkage] Using '$output_dir' for final files generated."
87 if [[ -z $current_cluster ]] ||
[[ -z $drop_zoneid ]] ||
[[ -z $output_dir ]] ||
[[ -z $current_stores ]]
90 echo "[rebalance-zone-shrinkage] Missing argument. Check again."
95 if [ ! -e $current_cluster ]; then
96 usage_and_exit
"File '$current_cluster' does not exist."
99 if [ ! -e $current_stores ]; then
100 usage_and_exit
"File '$current_stores' does not exist."
104 $vold_home/bin
/run-class.sh voldemort.tools.ZoneClipperCLI \
105 --current-cluster $current_cluster \
106 --current-stores $current_stores \
107 --drop-zoneid $drop_zoneid \
108 --output-dir $output_dir/