Display recrawl job report also when job is actively running

pull/154/head
luccioman 7 years ago
parent 6425963cee
commit 59f7763af6

@ -64,41 +64,12 @@
and are added in small chunks.</p>
<div class="container-fluid">
<div class="row">
#(recrawljobrunning)#
#(recrawlReport)#::
<div class="col-md-10 col-lg-6">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Last Re-Crawl job report</h3>
</div>
<div class="panel-body">
<table class="table">
<tbody>
<tr>
<th scope="row">Start time</th>
<td>#[startTime]#</td>
</tr>
<tr>
<th scope="row">End time</th>
<td>#[endTime]#</td>
</tr>
<tr>
<th scope="row">Count</th>
<td>#[recrawledUrlsCount]# URLs added to the crawler queue for recrawl</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
#(/recrawlReport)#
#(/recrawljobrunning)#
<form action="IndexReIndexMonitor_p.html?setup=recrawljob" method="post" enctype="multipart/form-data" accept-charset="UTF-8" class="col-md-10 col-lg-6">
<form action="IndexReIndexMonitor_p.html?setup=recrawljob" method="post" enctype="multipart/form-data" accept-charset="UTF-8" class="col-md-10 col-lg-6">
<input type="hidden" name="transactionToken" value="#[transactionToken]#" />
<table><tr valign="top"><td>
<fieldset>
#(recrawljobrunning)#
<fieldset>
<div class="form-group">
<label>Solr query <input type="text" name="recrawlquerytext" size="40" value="#[recrawlquerytext]#" /></label>
<input type="submit" name="simulateRecrawl" value="Simulate" class="btn btn-default" title="Check only how many documents would be selected for recrawl"/>
@ -117,10 +88,9 @@
<input type="submit" name="recrawlDefaults" value="Set defaults" class="btn btn-default" title="Reset to default values"/>
<input type="submit" name="recrawlnow" value="start recrawl job now" class="btn btn-primary"/>
to re-crawl documents selected with the given query.
::<input type="submit" name="stoprecrawl" value="stop recrawl job" class="btn btn-danger"/>
</fieldset>::
#(/recrawljobrunning)#
</fieldset>
</td>
<td>
#(recrawljobrunning)#::
@ -145,11 +115,50 @@
<td>include failed urls</td><td><input type="checkbox" name="includefailedurls" onchange="this.form.submit()" #(includefailedurls)#::checked="checked"#(/includefailedurls)# /></td>
</tr>
</table>
<input type="submit" name="stoprecrawl" value="stop recrawl job" class="btn btn-danger"/>
</fieldset>
#(/recrawljobrunning)#
</td>
</tr></table>
</form>
#(recrawlReport)#::
<div class="col-md-10 col-lg-6">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">#(jobStatus)#::::Last #(/jobStatus)#Re-Crawl job report</h3>
</div>
<div class="panel-body">
<table class="table">
<tbody>
<tr>
<th scope="row">Status</th>
<td>#(jobStatus)#Running::Shutdown in progress::Terminated#(/jobStatus)#</td>
</tr>
<tr>
<th scope="row">Start time</th>
<td>#[startTime]#</td>
</tr>
<tr>
<th scope="row">End time</th>
<td>#[endTime]#</td>
</tr>
<tr>
<th scope="row">Count</th>
<td>#[recrawledUrlsCount]# URLs added to the crawler queue for recrawl</td>
</tr>
</tbody>
</table>
#(jobStatus)#
<a class="btn btn-default" href="IndexReIndexMonitor_p.html" role="button"><span class="glyphicon glyphicon-refresh"></span> Refresh</a>
::
<a class="btn btn-default" href="IndexReIndexMonitor_p.html" role="button"><span class="glyphicon glyphicon-refresh"></span> Refresh</a>
::
#(/jobStatus)#
</div>
</div>
</div>
#(/recrawlReport)#
</div>
</div>
#%env/templates/footer.template%#

@ -190,6 +190,9 @@ public class IndexReIndexMonitor_p {
}
}
}
processRecrawlReport(header, sb, prop, (RecrawlBusyThread)recrawlbt);
// just post status of recrawlThread
if (recrawlbt != null && !recrawlbt.shutdownInProgress()) { // provide status
prop.put("recrawljobrunning", 1);
@ -198,7 +201,6 @@ public class IndexReIndexMonitor_p {
prop.put("recrawljobrunning_includefailedurls", ((RecrawlBusyThread) recrawlbt).getIncludeFailed());
} else {
prop.put("recrawljobrunning", 0);
processRecrawlReport(header, sb, prop, (RecrawlBusyThread)recrawlbt);
prop.put("recrawljobrunning_recrawlquerytext", recrawlQuery);
prop.put("recrawljobrunning_includefailedurls", inclerrdoc);
}
@ -208,31 +210,47 @@ public class IndexReIndexMonitor_p {
}
/**
* Write information on the eventual last recrawl job terminated
* Write information on the eventual currently running or last recrawl job terminated
* @param header current request header. Must not be null.
* @param sb Switchboard instance holding server environment
* @param prop this template result
* @param recrawlbt the eventual terminated recrawl thread
* @param prop this template result to write on. Must not be null.
* @param recrawlbt the eventual recrawl thread
*/
private static void processRecrawlReport(final RequestHeader header, final Switchboard sb,
final serverObjects prop, final RecrawlBusyThread recrawlbt) {
if (recrawlbt != null) {
prop.put("recrawljobrunning_recrawlReport", 1);
String lng = sb.getConfig("locale.language", Locale.ENGLISH.getLanguage());
prop.put("recrawlReport", 1);
Locale formatLocale;
if ("browser".equals(lng)) {
/* Only use the client locale when locale.language is set to browser */
formatLocale = header.getLocale();
if (sb != null) {
String lng = sb.getConfig("locale.language", Locale.ENGLISH.getLanguage());
if ("browser".equals(lng)) {
/* Only use the client locale when locale.language is set to browser */
formatLocale = header.getLocale();
} else {
formatLocale = Locale.forLanguageTag(lng);
}
} else {
formatLocale = Locale.forLanguageTag(lng);
/* Match the default language used in html templates */
formatLocale = Locale.ENGLISH;
}
final DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)
.withLocale(formatLocale);
prop.put("recrawljobrunning_recrawlReport_startTime", formatDateTime(formatter, recrawlbt.getStartTime()));
prop.put("recrawljobrunning_recrawlReport_endTime", formatDateTime(formatter, recrawlbt.getEndTime()));
prop.put("recrawljobrunning_recrawlReport_recrawledUrlsCount", recrawlbt.getRecrawledUrlsCount());
int jobStatus;
if(recrawlbt.isAlive()) {
if(recrawlbt.shutdownInProgress()) {
jobStatus = 1; // Shutdown in progress
} else {
jobStatus = 0; // Running
}
} else {
jobStatus = 2; // Terminated
}
prop.put("recrawlReport_jobStatus", jobStatus);
prop.put("recrawlReport_startTime", formatDateTime(formatter, recrawlbt.getStartTime()));
prop.put("recrawlReport_endTime", formatDateTime(formatter, recrawlbt.getEndTime()));
prop.put("recrawlReport_recrawledUrlsCount", recrawlbt.getRecrawledUrlsCount());
} else {
prop.put("recrawljobrunning_recrawlReport", 0);
prop.put("recrawlReport", 0);
}
}

Loading…
Cancel
Save