Skip to content

Commit

Permalink
update or add templates for solr lss
Browse files Browse the repository at this point in the history
  • Loading branch information
rrotter committed Nov 2, 2023
1 parent 24bd848 commit b0172b1
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 21 deletions.
75 changes: 75 additions & 0 deletions templates/profile/hathitrust/solr_lss/index-release-lss.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#! /bin/bash

TODAY=`date +%Y-%m-%d`
#TODAY="2019-08-31"

SYMLINK=/htsolr/current_snap
TARGET=/htsolr/lss/.snapshot/<%= @snapshot_name %>_${TODAY}

# check if the administrative LSS release stop flag is set
if [ -f /htsolr/lss/flags/STOPLSSRELEASE ]; then
/bin/echo "LSS release stop flag present...skip release today"
exit 1
fi

# check that today's snap exists
if [ ! -d ${TARGET} ]; then
/bin/echo "missing today's snapshot...aborting release"
exit 1
fi

# check todays snap for 'busy' flag
if [ -f ${TARGET}/flags/busy ]; then
/bin/echo "indexing and/or optimization ocurring on a shard...skip release today"
exit 1
fi

<% if not @is_primary_site %>#<% end %># check whether release happened at mirror site
<% if not @is_primary_site %>#<% end %>if ! curl -A SOLR -s --retry 5 --fail https://babel.hathitrust.org/flags/web/lss-release-${TODAY} --resolve "babel.hathitrust.org:443:<%= @mirror_site_ip %>" >& /dev/null; then
<% if not @is_primary_site %>#<% end %> /bin/echo "Mirror site index release appears to have failed...skip release today"
<% if not @is_primary_site %>#<% end %> exit 1
<% if not @is_primary_site %>#<% end %>fi

SEGMENTS=`ls ${TARGET}/cores/<%= @solr_core %>/core-<%= @solr_core %>x/data/index/*.fdt | wc -l`
if [ ${SEGMENTS} -lt 1 ] || [ ${SEGMENTS} -gt 2 ]; then
/bin/echo "at least one core served by `hostname -s` has an improper number of segments...aborting release"
exit 1
fi

# stop solr
systemctl stop solr
if [ $? -ne 0 ]; then
/bin/echo "error stopping lss solr on `hostname -s`"
exit 1
fi

# replace the snapshot symlink
rm -f ${SYMLINK} && ln -s ${TARGET} ${SYMLINK}
if [ $? -ne 0 ]; then
/bin/echo "error removing or creating ${SYMLINK} symlink...solr WILL NOT be started on `hostname -s`"
exit 1
fi

# if all went well, start solr
systemctl start solr
if [ $? -ne 0 ]; then
/bin/echo "error starting solr-current-lss on `hostname -s`"
exit 1
fi

<% if not @is_primary_node %>#<% end %># touch release flag (only on first core/node, so it happens once per datacenter)
<% if not @is_primary_node %>#<% end %>rm -f /htapps/babel/flags/web/lss-release-*
<% if not @is_primary_node %>#<% end %>touch /htapps/babel/flags/web/lss-release-${TODAY}

# run the first query to initialize solr
INITQUERY=0
if ! wget -q -T 60 -t 5 -O - "http://solr-sdr-search-<%= @solr_core %>:8081/solr/core-<%= @solr_core %>x/select/?q=aardvark&version=2.2&start=0&rows=10&indent=on" >& /dev/null; then
/bin/echo "WARN: failed to perform initial query against core <%= @solr_core %> after successful release"
INITQUERY=1
fi
if ! wget -q -T 60 -t 5 -O - "http://solr-sdr-search-<%= @solr_core %>:8081/solr/core-<%= @solr_core %>y/select?indent=on&q=*:*&rows=0" >& /dev/null; then
/bin/echo "WARN: failed to perform initial query against core <%= @solr_core %>y after successful release"
INITQUERY=1
fi

exit ${INITQUERY}
3 changes: 2 additions & 1 deletion templates/profile/hathitrust/solr_lss/log4j.properties.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Managed by puppet (nebula/profile/hathitrust/solr_lss/log4j.properties.erb)
# Logging level
solr.log=${solr.solr.home}/../logs
solr.log=<%= @solr_home %>/logs
log4j.rootLogger=INFO, file

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
Expand Down
24 changes: 8 additions & 16 deletions templates/profile/hathitrust/solr_lss/solr.in.sh.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Managed by puppet (nebula/profile/hathitrust/solr_lss/solr.in.sh.erb)
SOLR_JAVA_HOME="<%= @java_home %>"
SOLR_HEAP="<%= @heap %>"

GC_LOG_OPTS="-verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails \
-XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime"
GC_LOG_OPTS=""

GC_TUNE="-XX:NewRatio=3 \
-XX:SurvivorRatio=4 \
-XX:TargetSurvivorRatio=90 \
-XX:MaxTenuringThreshold=8 \
-XX:+UseConcMarkSweepGC \
-XX:+UseParNewGC \
-XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 \
-XX:+CMSScavengeBeforeRemark \
-XX:PretenureSizeThreshold=64m \
Expand All @@ -22,18 +20,12 @@ GC_TUNE="-XX:NewRatio=3 \
SOLR_TIMEZONE="<%= @timezone %>"
ENABLE_REMOTE_JMX_OPTS="true"
SOLR_OPTS="$SOLR_OPTS -Xss256k"
SOLR_PID_DIR="<%= @home %>"
SOLR_HOME="<%= @home %>"
LOG4J_PROPS="<%= @log4j_props %>"
SOLR_LOGS_DIR="<%= @logs %>"
SOLR_PORT=<%= @port %>

# To address http://lucene.472066.n3.nabble.com/Re-Several-critical-vulnerabilities-discovered-in-Apache-Solr-XXE-amp-RCE-td4358308.html
# See AEIM-549
#
# 2017-10-17 skorner
SOLR_OPTS="$SOLR_OPTS -Ddisable.configEdit=true"

# tburtonw May 25 2018: prevent rotating logs every time solr is restarted
SOLR_LOG_PRESTART_ROTATION=false
SOLR_HOME="<%= @solr_home %>"
SOLR_PID_DIR=$SOLR_HOME
LOG4J_PROPS=$SOLR_HOME/log4j.properties
SOLR_LOGS_DIR=$SOLR_HOME/logs
SOLR_PORT=<%= @port %>

SOLR_LOG_PRESTART_ROTATION=false
8 changes: 4 additions & 4 deletions templates/profile/hathitrust/solr_lss/solr.service.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Managed by puppet (nebula/profile/hathitrust/solr_lss/solr.service.erb)
[Unit]
Description=Solr Current for LSS
After=network.target
Description=Solr for LSS
After=network.target htsolr-lss.mount

[Service]
User=solr
Type=forking
Environment="SOLR_INCLUDE=<%= @solr_in_sh %>"
Environment="SOLR_INCLUDE=<%= @solr_home %>/solr.in.sh"
Environment="UMASK=002"
ExecStart=<%= @solr_bin %> start
ExecStop=<%= @solr_bin %> stop
Restart=always

[Install]
WantedBy=multi-user.target

3 changes: 3 additions & 0 deletions templates/profile/hathitrust/solr_lss/solr.xml.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
# Managed by puppet (nebula/profile/hathitrust/solr_lss/solr.xml.erb)
-->
<solr>
<solrcloud>
<str name="host">${host:}</str>
Expand Down

0 comments on commit b0172b1

Please sign in to comment.