-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcloud_optimize.sh
executable file
·56 lines (46 loc) · 1.62 KB
/
cloud_optimize.sh
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
56
#!/bin/bash
#
# Optimize a SolrCloud collection
#
# Deprecated (read: Never used)
###############################################################################
# CONFIG
###############################################################################
if [[ -s "cloud.conf" ]]; then
source "cloud.conf" # Local overrides
fi
pushd ${BASH_SOURCE%/*} > /dev/null
if [[ -s "cloud.conf" ]]; then
source "cloud.conf" # Project overrides
fi
source general.conf
: ${CLOUD:=`pwd`/cloud}
: ${MAX_SEGMENTS:=1}
popd > /dev/null
# curl -s "http://localhost:9010/solr/admin/cores?action=STATUS&wt=json" | jq '.status | ..[] | .cloud.replica' 2> /dev/null
: ${RETRIES:=6} # default number of retries on start probe before giving up
function usage() {
echo "Usage: ./cloud_optimize.sh"
exit $1
}
################################################################################
# FUNCTIONS
################################################################################
CORES=""
SOLR_PORT=$SOLR_BASE_PORT
for S in $(seq 1 $SOLRS); do
SOLR="http://${HOST}:${SOLR_PORT}/solr"
URL="${SOLR}/admin/cores?action=STATUS&wt=json"
echo "Resolving cores with curl> $URL"
CORES=$( curl -s curl -s "$URL" | jq '.status | ..[] | .cloud.replica' 2> /dev/null | tr -d '"' )
if [[ "." == ".$CORES" ]]; then
>&2 echo "No cores found with $URL"
continue
fi
for CORE in $CORES; do
O_URL="${SOLR}/${CORE}/update?optimize=true&maxSegments=${MAX_SEGMENTS}&waitFlush=true"
echo "Optimizing $CORE (might take hours) with curl> $O_URL"
curl "$O_URL"
done
SOLR_PORT=$(( SOLR_PORT+10 ))
done