outoftime-sunspot 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/Manifest.txt +104 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +115 -0
- data/Rakefile +27 -0
- data/config/hoe.rb +74 -0
- data/config/requirements.rb +15 -0
- data/lib/light_config.rb +40 -0
- data/lib/sunspot/adapters.rb +54 -0
- data/lib/sunspot/conditions.rb +50 -0
- data/lib/sunspot/conditions_builder.rb +37 -0
- data/lib/sunspot/configuration.rb +17 -0
- data/lib/sunspot/field.rb +108 -0
- data/lib/sunspot/field_builder.rb +37 -0
- data/lib/sunspot/indexer.rb +65 -0
- data/lib/sunspot/query.rb +115 -0
- data/lib/sunspot/query_builder.rb +30 -0
- data/lib/sunspot/restriction.rb +72 -0
- data/lib/sunspot/scope_builder.rb +33 -0
- data/lib/sunspot/search.rb +83 -0
- data/lib/sunspot/session.rb +43 -0
- data/lib/sunspot/type.rb +62 -0
- data/lib/sunspot/util.rb +13 -0
- data/lib/sunspot/version.rb +10 -0
- data/lib/sunspot.rb +50 -0
- data/setup.rb +1585 -0
- data/solr/README.txt +36 -0
- data/solr/etc/jetty.xml +206 -0
- data/solr/etc/webdefault.xml +379 -0
- data/solr/exampledocs/books.csv +11 -0
- data/solr/exampledocs/hd.xml +46 -0
- data/solr/exampledocs/ipod_other.xml +50 -0
- data/solr/exampledocs/ipod_video.xml +35 -0
- data/solr/exampledocs/mem.xml +58 -0
- data/solr/exampledocs/monitor.xml +31 -0
- data/solr/exampledocs/monitor2.xml +30 -0
- data/solr/exampledocs/mp500.xml +39 -0
- data/solr/exampledocs/post.jar +0 -0
- data/solr/exampledocs/post.sh +28 -0
- data/solr/exampledocs/sd500.xml +33 -0
- data/solr/exampledocs/solr.xml +38 -0
- data/solr/exampledocs/spellchecker.xml +58 -0
- data/solr/exampledocs/utf8-example.xml +42 -0
- data/solr/exampledocs/vidcard.xml +52 -0
- data/solr/lib/jetty-6.1.3.jar +0 -0
- data/solr/lib/jetty-util-6.1.3.jar +0 -0
- data/solr/lib/jsp-2.1/ant-1.6.5.jar +0 -0
- data/solr/lib/jsp-2.1/core-3.1.1.jar +0 -0
- data/solr/lib/jsp-2.1/jsp-2.1.jar +0 -0
- data/solr/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
- data/solr/lib/servlet-api-2.5-6.1.3.jar +0 -0
- data/solr/solr/README.txt +52 -0
- data/solr/solr/bin/abc +176 -0
- data/solr/solr/bin/abo +176 -0
- data/solr/solr/bin/backup +108 -0
- data/solr/solr/bin/backupcleaner +142 -0
- data/solr/solr/bin/commit +128 -0
- data/solr/solr/bin/optimize +129 -0
- data/solr/solr/bin/readercycle +129 -0
- data/solr/solr/bin/rsyncd-disable +77 -0
- data/solr/solr/bin/rsyncd-enable +76 -0
- data/solr/solr/bin/rsyncd-start +145 -0
- data/solr/solr/bin/rsyncd-stop +105 -0
- data/solr/solr/bin/scripts-util +83 -0
- data/solr/solr/bin/snapcleaner +148 -0
- data/solr/solr/bin/snapinstaller +168 -0
- data/solr/solr/bin/snappuller +248 -0
- data/solr/solr/bin/snappuller-disable +77 -0
- data/solr/solr/bin/snappuller-enable +77 -0
- data/solr/solr/bin/snapshooter +109 -0
- data/solr/solr/conf/admin-extra.html +31 -0
- data/solr/solr/conf/protwords.txt +21 -0
- data/solr/solr/conf/schema.xml +231 -0
- data/solr/solr/conf/scripts.conf +24 -0
- data/solr/solr/conf/solrconfig.xml +394 -0
- data/solr/solr/conf/stopwords.txt +57 -0
- data/solr/solr/conf/synonyms.txt +31 -0
- data/solr/start.jar +0 -0
- data/solr/webapps/solr.war +0 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rcov.rake +6 -0
- data/tasks/solr.rake +12 -0
- data/tasks/website.rake +17 -0
- data/test/api/test_build_search.rb +216 -0
- data/test/api/test_helper.rb +4 -0
- data/test/api/test_indexer.rb +110 -0
- data/test/api/test_retrieve_search.rb +114 -0
- data/test/api/test_session.rb +46 -0
- data/test/custom_expectation.rb +53 -0
- data/test/integration/test_field_types.rb +62 -0
- data/test/integration/test_helper.rb +1 -0
- data/test/integration/test_keyword_search.rb +32 -0
- data/test/integration/test_pagination.rb +32 -0
- data/test/mocks/base_class.rb +2 -0
- data/test/mocks/comment.rb +28 -0
- data/test/mocks/mock_adapter.rb +25 -0
- data/test/mocks/post.rb +41 -0
- data/test/test_helper.rb +31 -0
- metadata +191 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
# contributor license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright ownership.
|
6
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
# (the "License"); you may not use this file except in compliance with
|
8
|
+
# the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
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.
|
17
|
+
#
|
18
|
+
# Shell script to stop rsyncd on master Solr server
|
19
|
+
|
20
|
+
orig_dir=$(pwd)
|
21
|
+
cd ${0%/*}/..
|
22
|
+
solr_root=$(pwd)
|
23
|
+
cd ${orig_dir}
|
24
|
+
|
25
|
+
unset user verbose debug
|
26
|
+
. ${solr_root}/bin/scripts-util
|
27
|
+
|
28
|
+
# set up variables
|
29
|
+
prog=${0##*/}
|
30
|
+
log=${solr_root}/logs/rsyncd.log
|
31
|
+
|
32
|
+
# define usage string
|
33
|
+
USAGE="\
|
34
|
+
usage: $prog [-u username] [-v]
|
35
|
+
-u specify user to sudo to before running script
|
36
|
+
-v increase verbosity
|
37
|
+
-V output debugging info
|
38
|
+
"
|
39
|
+
|
40
|
+
# parse args
|
41
|
+
while getopts u:vV OPTION
|
42
|
+
do
|
43
|
+
case $OPTION in
|
44
|
+
u)
|
45
|
+
user="$OPTARG"
|
46
|
+
;;
|
47
|
+
v)
|
48
|
+
verbose="v"
|
49
|
+
;;
|
50
|
+
V)
|
51
|
+
debug="V"
|
52
|
+
;;
|
53
|
+
*)
|
54
|
+
echo "$USAGE"
|
55
|
+
exit 1
|
56
|
+
esac
|
57
|
+
done
|
58
|
+
|
59
|
+
[[ -n $debug ]] && set -x
|
60
|
+
|
61
|
+
fixUser "$@"
|
62
|
+
|
63
|
+
logMessage stopped by $oldwhoami
|
64
|
+
logMessage command: $0 $@
|
65
|
+
|
66
|
+
# look for pid file
|
67
|
+
if [[ ! -f ${solr_root}/logs/rsyncd.pid ]]
|
68
|
+
then
|
69
|
+
logMessage "missing rsyncd pid file ${solr_root}/logs/rsyncd.pid"
|
70
|
+
exit 2
|
71
|
+
fi
|
72
|
+
|
73
|
+
# get PID from file
|
74
|
+
pid=$(<${solr_root}/logs/rsyncd.pid)
|
75
|
+
if [[ -z $pid ]]
|
76
|
+
then
|
77
|
+
logMessage "unable to get rsyncd's PID"
|
78
|
+
exit 2
|
79
|
+
fi
|
80
|
+
|
81
|
+
kill $pid
|
82
|
+
|
83
|
+
# wait until rsyncd dies or we time out
|
84
|
+
dead=0
|
85
|
+
timer=0
|
86
|
+
timeout=300
|
87
|
+
while (( ! dead && timer < timeout ))
|
88
|
+
do
|
89
|
+
if ps -eo pid | grep -qw $pid
|
90
|
+
then
|
91
|
+
kill $pid
|
92
|
+
(( timer++ ))
|
93
|
+
sleep 1
|
94
|
+
else
|
95
|
+
dead=1
|
96
|
+
fi
|
97
|
+
done
|
98
|
+
if ps -eo pid | grep -qw $pid
|
99
|
+
then
|
100
|
+
logMessage rsyncd failed to stop after $timeout seconds
|
101
|
+
exit 3
|
102
|
+
fi
|
103
|
+
|
104
|
+
# remove rsyncd.conf
|
105
|
+
/bin/rm -f ${solr_root}/conf/rsyncd.conf
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
# contributor license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright ownership.
|
6
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
# (the "License"); you may not use this file except in compliance with
|
8
|
+
# the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
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.
|
17
|
+
#
|
18
|
+
# util functions used by scripts
|
19
|
+
|
20
|
+
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
21
|
+
|
22
|
+
# set up variables
|
23
|
+
prog=${0##*/}
|
24
|
+
|
25
|
+
# source the config file if present
|
26
|
+
confFile=${solr_root}/conf/scripts.conf
|
27
|
+
if [[ -f $confFile ]]
|
28
|
+
then
|
29
|
+
. $confFile
|
30
|
+
fi
|
31
|
+
|
32
|
+
function fixUser
|
33
|
+
{
|
34
|
+
# set user to $(whoami) if not specified
|
35
|
+
if [[ -z ${user} ]]
|
36
|
+
then
|
37
|
+
user=$(whoami)
|
38
|
+
fi
|
39
|
+
|
40
|
+
# sudo
|
41
|
+
if [[ $(whoami) != ${user} ]]
|
42
|
+
then
|
43
|
+
sudo -u ${user} $0 "$@"
|
44
|
+
exit $?
|
45
|
+
fi
|
46
|
+
|
47
|
+
oldwhoami=$(who -m | cut -d' ' -f1 | sed -e's/^.*!//')
|
48
|
+
|
49
|
+
if [[ "${oldwhoami}" == "" ]]
|
50
|
+
then
|
51
|
+
oldwhoami=`ps h -Hfp $(pgrep -g0 ${0##*/}) | tail -1|cut -f1 -d" "`
|
52
|
+
fi
|
53
|
+
}
|
54
|
+
|
55
|
+
function timeStamp
|
56
|
+
{
|
57
|
+
date +'%Y/%m/%d %H:%M:%S'
|
58
|
+
}
|
59
|
+
|
60
|
+
function logMessage
|
61
|
+
{
|
62
|
+
echo $(timeStamp) $@>>$log
|
63
|
+
if [[ -n ${verbose} ]]
|
64
|
+
then
|
65
|
+
echo $@
|
66
|
+
fi
|
67
|
+
}
|
68
|
+
|
69
|
+
function logExit
|
70
|
+
{
|
71
|
+
end=`date +"%s"`
|
72
|
+
diff=`expr $end - $start`
|
73
|
+
echo "$(timeStamp) $1 (elapsed time: $diff sec)">>$log
|
74
|
+
exit $2
|
75
|
+
}
|
76
|
+
|
77
|
+
# create logs directory if not there
|
78
|
+
if [[ ! -d ${solr_root}/logs ]]
|
79
|
+
then
|
80
|
+
mkdir ${solr_root}/logs
|
81
|
+
fi
|
82
|
+
|
83
|
+
umask 002
|
@@ -0,0 +1,148 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
# contributor license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright ownership.
|
6
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
# (the "License"); you may not use this file except in compliance with
|
8
|
+
# the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
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.
|
17
|
+
#
|
18
|
+
# Shell script to clean up snapshots of a Solr Lucene collection.
|
19
|
+
|
20
|
+
orig_dir=$(pwd)
|
21
|
+
cd ${0%/*}/..
|
22
|
+
solr_root=$(pwd)
|
23
|
+
cd ${orig_dir}
|
24
|
+
|
25
|
+
unset days num data_dir user verbose debug
|
26
|
+
. ${solr_root}/bin/scripts-util
|
27
|
+
|
28
|
+
# set up variables
|
29
|
+
prog=${0##*/}
|
30
|
+
log=${solr_root}/logs/${prog}.log
|
31
|
+
|
32
|
+
# define usage string
|
33
|
+
USAGE="\
|
34
|
+
usage: $prog -D <days> | -N <num> [-d dir] [-u username] [-v]
|
35
|
+
-D <days> cleanup snapshots more than <days> days old
|
36
|
+
-N <num> keep the most recent <num> number of snapshots and
|
37
|
+
cleanup up the remaining ones that are not being pulled
|
38
|
+
-d specify directory holding index data
|
39
|
+
-u specify user to sudo to before running script
|
40
|
+
-v increase verbosity
|
41
|
+
-V output debugging info
|
42
|
+
"
|
43
|
+
|
44
|
+
# parse args
|
45
|
+
while getopts D:N:d:u:vV OPTION
|
46
|
+
do
|
47
|
+
case $OPTION in
|
48
|
+
D)
|
49
|
+
days="$OPTARG"
|
50
|
+
;;
|
51
|
+
N)
|
52
|
+
num="$OPTARG"
|
53
|
+
;;
|
54
|
+
d)
|
55
|
+
data_dir="$OPTARG"
|
56
|
+
;;
|
57
|
+
u)
|
58
|
+
user="$OPTARG"
|
59
|
+
;;
|
60
|
+
v)
|
61
|
+
verbose="v"
|
62
|
+
;;
|
63
|
+
V)
|
64
|
+
debug="V"
|
65
|
+
;;
|
66
|
+
*)
|
67
|
+
echo "$USAGE"
|
68
|
+
exit 1
|
69
|
+
esac
|
70
|
+
done
|
71
|
+
|
72
|
+
[[ -n $debug ]] && set -x
|
73
|
+
|
74
|
+
if [[ -z ${days} && -z ${num} ]]
|
75
|
+
then
|
76
|
+
echo "$USAGE"
|
77
|
+
exit 1
|
78
|
+
fi
|
79
|
+
|
80
|
+
fixUser "$@"
|
81
|
+
|
82
|
+
# use default value for data_dir if not specified
|
83
|
+
# relative path starts at ${solr_root}
|
84
|
+
if [[ -z ${data_dir} ]]
|
85
|
+
then
|
86
|
+
data_dir=${solr_root}/data
|
87
|
+
elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
|
88
|
+
then
|
89
|
+
data_dir=${solr_root}/${data_dir}
|
90
|
+
fi
|
91
|
+
|
92
|
+
function remove
|
93
|
+
{
|
94
|
+
syncing=`ps -fwwwu ${user}|grep -w rsync|grep -v grep|grep -w $1`
|
95
|
+
if [[ -n $syncing ]]
|
96
|
+
then
|
97
|
+
logMessage $1 not removed - rsync in progress
|
98
|
+
else
|
99
|
+
logMessage removing snapshot $1
|
100
|
+
/bin/rm -rf $1
|
101
|
+
fi
|
102
|
+
}
|
103
|
+
|
104
|
+
start=`date +"%s"`
|
105
|
+
|
106
|
+
logMessage started by $oldwhoami
|
107
|
+
logMessage command: $0 $@
|
108
|
+
|
109
|
+
# trap control-c
|
110
|
+
trap 'echo "caught INT/TERM, exiting now but partial cleanup may have already occured";logExit aborted 13' INT TERM
|
111
|
+
|
112
|
+
if [[ -n ${days} ]]
|
113
|
+
then
|
114
|
+
#is maxdepth supported?
|
115
|
+
find ${data_dir} -maxdepth 0 -name foobar >/dev/null 2>&1
|
116
|
+
if [ $? = 0 ]; then
|
117
|
+
maxdepth="-maxdepth 1"
|
118
|
+
else
|
119
|
+
unset maxdepth
|
120
|
+
fi
|
121
|
+
|
122
|
+
logMessage cleaning up snapshots more than ${days} days old
|
123
|
+
for i in `find ${data_dir} ${maxdepth} -name 'snapshot.*' -mtime +${days} -print`
|
124
|
+
do
|
125
|
+
remove $i
|
126
|
+
done
|
127
|
+
elif [[ -n ${num} ]]
|
128
|
+
then
|
129
|
+
logMessage cleaning up all snapshots except for the most recent ${num} ones
|
130
|
+
unset snapshots count
|
131
|
+
snapshots=`ls -cd ${data_dir}/snapshot.* 2>/dev/null`
|
132
|
+
if [[ $? == 0 ]]
|
133
|
+
then
|
134
|
+
count=`echo $snapshots|wc -w`
|
135
|
+
startpos=`expr $num + 1`
|
136
|
+
if [[ $count -gt $num ]]
|
137
|
+
then
|
138
|
+
for i in `echo $snapshots|cut -f${startpos}- -d" "`
|
139
|
+
do
|
140
|
+
remove $i
|
141
|
+
done
|
142
|
+
fi
|
143
|
+
fi
|
144
|
+
fi
|
145
|
+
|
146
|
+
logExit ended 0
|
147
|
+
|
148
|
+
|
@@ -0,0 +1,168 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
# contributor license agreements. See the NOTICE file distributed with
|
5
|
+
# this work for additional information regarding copyright ownership.
|
6
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
# (the "License"); you may not use this file except in compliance with
|
8
|
+
# the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
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.
|
17
|
+
#
|
18
|
+
# Shell script to install a snapshot into place as the Lucene collection
|
19
|
+
# for a Solr server
|
20
|
+
|
21
|
+
orig_dir=$(pwd)
|
22
|
+
cd ${0%/*}/..
|
23
|
+
solr_root=$(pwd)
|
24
|
+
cd ${orig_dir}
|
25
|
+
|
26
|
+
unset master_host master_status_dir data_dir user verbose debug
|
27
|
+
. ${solr_root}/bin/scripts-util
|
28
|
+
|
29
|
+
# set up variables
|
30
|
+
prog=${0##*/}
|
31
|
+
log=${solr_root}/logs/${prog}.log
|
32
|
+
|
33
|
+
# define usage string
|
34
|
+
USAGE="\
|
35
|
+
usage: $prog [-M master] [-S sdir] [-d dir] [-u username] [-v]
|
36
|
+
-M master specify hostname of master server from where to pull index
|
37
|
+
snapshot
|
38
|
+
-S specify directory holding snapshot status on master server
|
39
|
+
-d specify directory holding index data on local machine
|
40
|
+
-u specify user to sudo to before running script
|
41
|
+
-v increase verbosity
|
42
|
+
-V output debugging info
|
43
|
+
"
|
44
|
+
|
45
|
+
# parse args
|
46
|
+
while getopts M:S:d:u:vV OPTION
|
47
|
+
do
|
48
|
+
case $OPTION in
|
49
|
+
M)
|
50
|
+
master_host="$OPTARG"
|
51
|
+
;;
|
52
|
+
S)
|
53
|
+
master_status_dir="$OPTARG"
|
54
|
+
;;
|
55
|
+
d)
|
56
|
+
data_dir="$OPTARG"
|
57
|
+
;;
|
58
|
+
u)
|
59
|
+
user="$OPTARG"
|
60
|
+
;;
|
61
|
+
v)
|
62
|
+
verbose="v"
|
63
|
+
;;
|
64
|
+
V)
|
65
|
+
debug="V"
|
66
|
+
;;
|
67
|
+
*)
|
68
|
+
echo "$USAGE"
|
69
|
+
exit 1
|
70
|
+
esac
|
71
|
+
done
|
72
|
+
|
73
|
+
[[ -n $debug ]] && set -x
|
74
|
+
|
75
|
+
if [[ -z ${master_host} ]]
|
76
|
+
then
|
77
|
+
echo "name of master server missing in $confFile or command line."
|
78
|
+
echo "$USAGE"
|
79
|
+
exit 1
|
80
|
+
fi
|
81
|
+
|
82
|
+
if [[ -z ${master_status_dir} ]]
|
83
|
+
then
|
84
|
+
echo "directory holding snapshot status on master server missing in $confFile or command line."
|
85
|
+
echo "$USAGE"
|
86
|
+
exit 1
|
87
|
+
fi
|
88
|
+
|
89
|
+
fixUser "$@"
|
90
|
+
|
91
|
+
# use default value for data_dir if not specified
|
92
|
+
# relative path starts at ${solr_root}
|
93
|
+
if [[ -z ${data_dir} ]]
|
94
|
+
then
|
95
|
+
data_dir=${solr_root}/data
|
96
|
+
elif [[ "`echo ${data_dir}|cut -c1`" != "/" ]]
|
97
|
+
then
|
98
|
+
data_dir=${solr_root}/${data_dir}
|
99
|
+
fi
|
100
|
+
|
101
|
+
# assume relative path to start at ${solr_root}
|
102
|
+
if [[ "`echo ${master_status_dir}|cut -c1`" != "/" ]]
|
103
|
+
then
|
104
|
+
master_status_dir=${solr_root}/${master_status_dir}
|
105
|
+
fi
|
106
|
+
|
107
|
+
start=`date +"%s"`
|
108
|
+
|
109
|
+
logMessage started by $oldwhoami
|
110
|
+
logMessage command: $0 $@
|
111
|
+
|
112
|
+
# get directory name of latest snapshot
|
113
|
+
name=`ls ${data_dir}|grep 'snapshot\.'|grep -v wip|sort -r|head -1`
|
114
|
+
|
115
|
+
# clean up after INT/TERM
|
116
|
+
trap 'echo "caught INT/TERM, exiting now but partial installation may have already occured";/bin/rm -rf ${data_dir"/index.tmp$$;logExit aborted 13' INT TERM
|
117
|
+
|
118
|
+
# is there a snapshot
|
119
|
+
if [[ "${name}" == "" ]]
|
120
|
+
then
|
121
|
+
logMessage no shapshot available
|
122
|
+
logExit ended 0
|
123
|
+
fi
|
124
|
+
|
125
|
+
name=${data_dir}/${name}
|
126
|
+
|
127
|
+
# has snapshot already been installed
|
128
|
+
if [[ ${name} == `cat ${solr_root}/logs/snapshot.current 2>/dev/null` ]]
|
129
|
+
then
|
130
|
+
logMessage latest snapshot ${name} already installed
|
131
|
+
logExit ended 0
|
132
|
+
fi
|
133
|
+
|
134
|
+
# make sure master has directory for hold slaves stats/state
|
135
|
+
if
|
136
|
+
! ssh -o StrictHostKeyChecking=no ${master_host} mkdir -p ${master_status_dir}
|
137
|
+
then
|
138
|
+
logMessage failed to ssh to master ${master_host}, snapshot status not updated on master
|
139
|
+
fi
|
140
|
+
|
141
|
+
# install using hard links into temporary directory
|
142
|
+
# remove original index and then atomically copy new one into place
|
143
|
+
logMessage installing snapshot ${name}
|
144
|
+
cp -lr ${name}/ ${data_dir}/index.tmp$$
|
145
|
+
/bin/rm -rf ${data_dir}/index
|
146
|
+
mv -f ${data_dir}/index.tmp$$ ${data_dir}/index
|
147
|
+
|
148
|
+
# update distribution stats
|
149
|
+
echo ${name} > ${solr_root}/logs/snapshot.current
|
150
|
+
|
151
|
+
# push stats/state to master
|
152
|
+
if
|
153
|
+
! scp -q -o StrictHostKeyChecking=no ${solr_root}/logs/snapshot.current ${master_host}:${master_status_dir}/snapshot.current.`uname -n`
|
154
|
+
then
|
155
|
+
logMessage failed to ssh to master ${master_host}, snapshot status not updated on master
|
156
|
+
fi
|
157
|
+
|
158
|
+
# notify Solr to open a new Searcher
|
159
|
+
logMessage notifing Solr to open a new Searcher
|
160
|
+
${solr_root}/bin/commit
|
161
|
+
if [[ $? != 0 ]]
|
162
|
+
then
|
163
|
+
logMessage failed to connect to Solr server
|
164
|
+
logMessage snapshot installed but Solr server has not open a new Searcher
|
165
|
+
logExit failed 1
|
166
|
+
fi
|
167
|
+
|
168
|
+
logExit ended 0
|