Merge from 1.5 branch: NIHVIVO-3973 If the Solr index is not available, do not offer the user the ability to re-index. Show an error message instead.
This commit is contained in:
parent
eb1d4b9631
commit
9cdffd0c09
2 changed files with 36 additions and 6 deletions
|
@ -15,6 +15,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.solr.client.solrj.SolrServer;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||
|
@ -26,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Red
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.WorkLevel;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.WorkLevelStamp;
|
||||
|
||||
|
@ -151,9 +154,20 @@ public class IndexController extends FreemarkerHttpServlet {
|
|||
body.put("elapsed", formatElapsedTime(since, new Date()));
|
||||
body.put("expected", formatElapsedTime(since, expectedCompletion));
|
||||
body.put("hasPreviousBuild", since.getTime() > 0L);
|
||||
body.put("indexIsConnected", testIndexConnection());
|
||||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||
}
|
||||
|
||||
private Boolean testIndexConnection() {
|
||||
try {
|
||||
SolrSetup.getSolrServer(getServletContext()).ping();
|
||||
return Boolean.TRUE;
|
||||
} catch (Exception e) {
|
||||
log.error("Can't connect to the Solr server.", e);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
private Date figureExpectedCompletion(Date startTime, long totalToDo,
|
||||
long completedCount) {
|
||||
Date now = new Date();
|
||||
|
@ -183,11 +197,11 @@ public class IndexController extends FreemarkerHttpServlet {
|
|||
|
||||
private String figureCurrentTask(Collection<String> flags) {
|
||||
if (flags.contains(IndexBuilder.FLAG_REBUILDING)) {
|
||||
return "rebuilt";
|
||||
return "Rebuilding";
|
||||
} else if (flags.contains(IndexBuilder.FLAG_UPDATING)) {
|
||||
return "updated";
|
||||
return "Updating";
|
||||
} else {
|
||||
return "";
|
||||
return "Not working on";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,20 @@
|
|||
|
||||
<h2>Search Index Status</h2>
|
||||
|
||||
<#if worklevel == "IDLE">
|
||||
<#if !indexIsConnected>
|
||||
<!-- Can't contact the Solr server. Indexing would be impossible. Show an error message. -->
|
||||
<section id="error-alert" role="alert">
|
||||
<img src="${urls.images}/iconAlert.png" width="24" height="24" alert="Error alert icon" />
|
||||
<p>The search index is not connected.</p>
|
||||
<p><tt>SolrServer.ping()</tt> failed.
|
||||
<p>Check startup status page and/or Tomcat logs for more information.</p>
|
||||
</section>
|
||||
|
||||
<#elseif worklevel == "IDLE">
|
||||
<!-- Solr indexer is idle. Show the button that rebuilds the index. -->
|
||||
<h3>The search indexer is idle.</h3>
|
||||
<#if hasPreviousBuild??>
|
||||
<p>Most recent update was at ${since?string("hh:mm:ss a, MMMM dd, yyyy")}</p>
|
||||
<p>The most recent update was at ${since?string("hh:mm:ss a, MMMM dd, yyyy")}</p>
|
||||
</#if>
|
||||
|
||||
<form action="${actionUrl}" method="POST">
|
||||
|
@ -17,11 +28,16 @@
|
|||
Reset the search index and re-populate it.
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<#elseif totalToDo == 0>
|
||||
<!-- Solr indexer is preparing the list of records. Show elapsed time since request. -->
|
||||
<h3>Preparing to rebuild the search index. </h3>
|
||||
<p>since ${since?string("hh:mm:ss a, MMMM dd, yyyy")}, elapsed time ${elapsed}</p>
|
||||
|
||||
<#else>
|
||||
<h3>The search index is currently being ${currentTask}.</h3>
|
||||
<!-- Solr indexer is re-building the index. Show the progress. -->
|
||||
<h3>${currentTask} the search index.</h3>
|
||||
<p>since ${since?string("hh:mm:ss a, MMMM dd, yyyy")}, elapsed time ${elapsed}, estimated total time ${expected}</p>
|
||||
<p>Completed ${completedCount} out of ${totalToDo} index records.</p>
|
||||
|
||||
</#if>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue