Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rhbz826310 - add indicator of currently processing table for search a…
Browse files Browse the repository at this point in the history
…dministration page
  • Loading branch information
davidmason committed Jul 2, 2012
1 parent 937fb52 commit d8c9020
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
Expand Up @@ -42,6 +42,11 @@ public boolean isInProgress()
return reindexAsync.getProcessHandle().isInProgress();
}

public String getCurrentClass()
{
return reindexAsync.getCurrentClassName();
}

public boolean isError()
{
return reindexAsync.getProcessHandle().hasError();
Expand Down
13 changes: 13 additions & 0 deletions zanata-war/src/main/java/org/zanata/action/ReindexAsyncBean.java
Expand Up @@ -51,6 +51,7 @@ public class ReindexAsyncBean

private Set<Class<?>> indexables = new HashSet<Class<?>>();
private HashMap<Class<?>, ReindexClassOptions> indexingOptions = new HashMap<Class<?>, ReindexClassOptions>();
private Class<?> currentClass;

private boolean hasError;

Expand Down Expand Up @@ -89,6 +90,15 @@ public ProcessHandle getProcessHandle()
return handle;
}

public String getCurrentClassName()
{
if (currentClass == null)
{
return "none";
}
return currentClass.getSimpleName();
}

/**
* Prepare to reindex lucene search index. This ensures that progress counts
* are properly initialised before the asynchronous startReindex() method is
Expand Down Expand Up @@ -157,17 +167,20 @@ public void startReindex()
if (!handle.shouldStop() && indexingOptions.get(clazz).isPurge())
{
log.info("purging index for {0}", clazz);
currentClass = clazz;
session.purgeAll(clazz);
handle.incrementProgress(1);
}
if (!handle.shouldStop() && indexingOptions.get(clazz).isReindex())
{
log.info("reindexing {0}", clazz);
currentClass = clazz;
reindex(clazz);
}
if (!handle.shouldStop() && indexingOptions.get(clazz).isOptimize())
{
log.info("optimizing {0}", clazz);
currentClass = clazz;
session.getSearchFactory().optimize(clazz);
handle.incrementProgress(1);
}
Expand Down
9 changes: 6 additions & 3 deletions zanata-war/src/main/resources/messages.properties
Expand Up @@ -290,11 +290,16 @@ jsf.ManageMaintainers=Manage Maintainers
jsf.ManageSearch=Manage Search
jsf.manageSearch.Actions=Actions
jsf.manageSearch.Table=Table
jsf.ManageSearch.SelectAll=Select All
jsf.ManageSearch.SelectNone=Clear Selection
jsf.ManageSearch.PerformSelectedActions=Perform Selected Actions
jsf.ManageSearch.CurrentProgress=Current Progress
jsf.ManageSearch.NoOperationsRunning=No operations are running
jsf.manageSearch.ProgressMessage=#{reindexAction.reindexProgress} of #{reindexAction.reindexCount} operations complete
jsf.manageSearch.CurrentTable=Processing table: #{reindexAction.currentClass}
jsf.manageSearch.ErrorMessage=Due to an error, some objects could not be reindexed. See server log for details.
jsf.manageSearch.PleaseReindex=Please reindex again to ensure the search index is up-to-date.
jsf.ManageSearch.ElapsedTime=Running for: #{reindexAction.elapsedTime}
jsf.ManageSearch.RemainingTime=Remaining (approx): #{reindexAction.estimatedTimeRemaining}
jsf.ManageSearch.Completed=Completed successfully (ran for #{reindexAction.elapsedTime})
Expand All @@ -317,6 +322,7 @@ jsf.manageSearch.optimize.WillNotInfluenceIndexTime=Will not influence indexing
jsf.manageSearch.optimize.RemovesObsoleteEntries=Also removes any obsolete entries from the index.
jsf.manageSearch.optimize.TempFileWarning=Warning: this operation uses a temp file that will require free disk space of approximately the current index size.
jsf.ManageUsers=Manage Users
jsf.Members=Members
jsf.MemberOf=Member of
Expand Down Expand Up @@ -381,9 +387,6 @@ jsf.RoleManager=Role Manager
jsf.RunningVersionInfo=Zanata version #{applicationConfiguration.version} (#{applicationConfiguration.buildTimestamp}).
jsf.Save=Save
jsf.Search=Search
jsf.search.reindex.ProgressMessage=#{reindexAction.reindexProgress} of #{reindexAction.reindexCount} operations complete
jsf.search.reindex.ErrorMessage=Due to an error, some objects could not be reindexed. See server log for details.
jsf.search.reindex.PleaseReindex=Please reindex again to ensure the search index is up-to-date.
jsf.SearchProjects=Search Projects
jsf.SearchResults=Search Results
jsf.SelectedLocales=Enabled Locales
Expand Down
11 changes: 7 additions & 4 deletions zanata-war/src/main/webapp/admin/search.xhtml
Expand Up @@ -26,7 +26,7 @@
value="#{reindexAction.classes.toArray()}" var="clazz"
reRender="actions">
<rich:column width="270px" sortBy="#{clazz.className}" sortOrder="ASCENDING" selfSorted="false">
<f:facet name="header">Table</f:facet>
<f:facet name="header">#{messages['jsf.manageSearch.Table']}</f:facet>
<h:outputText value="#{clazz.className}" />
</rich:column>
<rich:column width="auto" styleClass="centered">
Expand Down Expand Up @@ -91,16 +91,16 @@
<p>#{messages['jsf.ManageSearch.Aborted']}</p>
</h:outputText>
<h:outputText rendered="#{reindexAction.error}" escape="false">
<p>#{messages['jsf.search.reindex.ErrorMessage']}</p>
<p>#{messages['jsf.search.reindex.PleaseReindex']}</p>
<p>#{messages['jsf.manageSearch.ErrorMessage']}</p>
<p>#{messages['jsf.manageSearch.PleaseReindex']}</p>
</h:outputText>

<a4j:outputPanel>
<!-- minValue is -1 because of a bug when 0 is used -->
<rich:progressBar id="reindexProgressBar"
value="#{reindexAction.reindexProgress}"
interval="1000"
label="#{messages['jsf.search.reindex.ProgressMessage']}"
label="#{messages['jsf.manageSearch.ProgressMessage']}"
minValue="-1"
maxValue="#{reindexAction.reindexCount - 1}"
reRender="timeEstimate"
Expand All @@ -110,6 +110,9 @@
</a4j:outputPanel>

<a4j:outputPanel id="timeEstimate">
<h:outputText rendered="#{reindexAction.inProgress || reindexAction.canceled || reindexAction.error}">
<p>#{messages['jsf.manageSearch.CurrentTable']}</p>
</h:outputText>
<h:outputText rendered="#{reindexAction.inProgress}">
<p>#{messages['jsf.ManageSearch.ElapsedTime']}</p>
<p>#{messages['jsf.ManageSearch.RemainingTime']}</p>
Expand Down

0 comments on commit d8c9020

Please sign in to comment.