summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/tickets/ITicketService.java
diff options
context:
space:
mode:
authorFlorian Zschocke <fzs@users.noreply.github.com>2017-03-18 13:37:25 +0100
committerGitHub <noreply@github.com>2017-03-18 13:37:25 +0100
commit2f74123ca0deaa138609a2126e0fc897167dac48 (patch)
tree683607a1e3dab5d29e18b77d0c4705632b74e117 /src/main/java/com/gitblit/tickets/ITicketService.java
parent71211a8cdfae8d528130cedf3e67d21e130ee8a0 (diff)
parent63dbdfda13daa78a26f1c2e77b0a4bfd5a35df8d (diff)
downloadgitblit-2f74123ca0deaa138609a2126e0fc897167dac48.tar.gz
gitblit-2f74123ca0deaa138609a2126e0fc897167dac48.zip
Merge pull request #1168 from lucamilanesio/bump-to-lucene-5.5.2
Bump to Lucene 5.5.2 The new code will create Lucene indices in a new directory named after codec and index version. This provides for easy and safe up- and downgrades. But it also means that the old indices will stick around on disk. What this version is missing is a kind of "garbage collection" deleting old, unused indices when they are no longer needed. That task needs to be done manually currently. We should at leas at some point provide a script for it.
Diffstat (limited to 'src/main/java/com/gitblit/tickets/ITicketService.java')
-rw-r--r--src/main/java/com/gitblit/tickets/ITicketService.java43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/main/java/com/gitblit/tickets/ITicketService.java b/src/main/java/com/gitblit/tickets/ITicketService.java
index 20b6505b..3252a603 100644
--- a/src/main/java/com/gitblit/tickets/ITicketService.java
+++ b/src/main/java/com/gitblit/tickets/ITicketService.java
@@ -181,7 +181,24 @@ public abstract class ITicketService implements IManager {
* @since 1.4.0
*/
@Override
- public abstract ITicketService start();
+ public final ITicketService start() {
+ onStart();
+ if (shouldReindex()) {
+ log.info("Re-indexing all tickets...");
+// long startTime = System.currentTimeMillis();
+ reindex();
+// float duration = (System.currentTimeMillis() - startTime) / 1000f;
+// log.info("Built Lucene index over all tickets in {} secs", duration);
+ }
+ return this;
+ }
+
+ /**
+ * Start the specific ticket service implementation.
+ *
+ * @since 1.9.0
+ */
+ public abstract void onStart();
/**
* Stop the service.
@@ -197,6 +214,12 @@ public abstract class ITicketService implements IManager {
}
/**
+ * Closes any open resources used by this service.
+ * @since 1.4.0
+ */
+ protected abstract void close();
+
+ /**
* Creates a ticket notifier. The ticket notifier is not thread-safe!
* @since 1.4.0
*/
@@ -274,12 +297,6 @@ public abstract class ITicketService implements IManager {
}
/**
- * Closes any open resources used by this service.
- * @since 1.4.0
- */
- protected abstract void close();
-
- /**
* Reset all caches in the service.
* @since 1.4.0
*/
@@ -1343,6 +1360,18 @@ public abstract class ITicketService implements IManager {
return indexer.queryFor(query, page, pageSize, sortBy, descending);
}
+
+ /**
+ * Checks tickets should get re-indexed.
+ *
+ * @return true if tickets should get re-indexed, false otherwise.
+ */
+ private boolean shouldReindex()
+ {
+ return indexer.shouldReindex();
+ }
+
+
/**
* Destroys an existing index and reindexes all tickets.
* This operation may be expensive and time-consuming.