summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/gitblit/tickets/BranchTicketService.java3
-rw-r--r--src/main/java/com/gitblit/tickets/FileTicketService.java3
-rw-r--r--src/main/java/com/gitblit/tickets/ITicketService.java43
-rw-r--r--src/main/java/com/gitblit/tickets/NullTicketService.java3
-rw-r--r--src/main/java/com/gitblit/tickets/RedisTicketService.java3
-rw-r--r--src/main/java/com/gitblit/tickets/TicketIndexer.java14
-rw-r--r--src/main/java/com/gitblit/utils/LuceneIndexStore.java2
-rw-r--r--src/test/java/com/gitblit/tests/BranchTicketServiceTest.java2
-rw-r--r--src/test/java/com/gitblit/tests/FileTicketServiceTest.java2
-rw-r--r--src/test/java/com/gitblit/tests/RedisTicketServiceTest.java2
-rw-r--r--src/test/java/com/gitblit/tests/UITicketTest.java2
11 files changed, 58 insertions, 21 deletions
diff --git a/src/main/java/com/gitblit/tickets/BranchTicketService.java b/src/main/java/com/gitblit/tickets/BranchTicketService.java
index 7bef435a..8430c546 100644
--- a/src/main/java/com/gitblit/tickets/BranchTicketService.java
+++ b/src/main/java/com/gitblit/tickets/BranchTicketService.java
@@ -110,9 +110,8 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi
}
@Override
- public BranchTicketService start() {
+ public void onStart() {
log.info("{} started", getClass().getSimpleName());
- return this;
}
@Override
diff --git a/src/main/java/com/gitblit/tickets/FileTicketService.java b/src/main/java/com/gitblit/tickets/FileTicketService.java
index 1e82f0de..05670468 100644
--- a/src/main/java/com/gitblit/tickets/FileTicketService.java
+++ b/src/main/java/com/gitblit/tickets/FileTicketService.java
@@ -80,9 +80,8 @@ public class FileTicketService extends ITicketService {
}
@Override
- public FileTicketService start() {
+ public void onStart() {
log.info("{} started", getClass().getSimpleName());
- return this;
}
@Override
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.
diff --git a/src/main/java/com/gitblit/tickets/NullTicketService.java b/src/main/java/com/gitblit/tickets/NullTicketService.java
index 3947b945..050c6990 100644
--- a/src/main/java/com/gitblit/tickets/NullTicketService.java
+++ b/src/main/java/com/gitblit/tickets/NullTicketService.java
@@ -61,9 +61,8 @@ public class NullTicketService extends ITicketService {
}
@Override
- public NullTicketService start() {
+ public void onStart() {
log.info("{} started", getClass().getSimpleName());
- return this;
}
@Override
diff --git a/src/main/java/com/gitblit/tickets/RedisTicketService.java b/src/main/java/com/gitblit/tickets/RedisTicketService.java
index 0f9ad174..4e632317 100644
--- a/src/main/java/com/gitblit/tickets/RedisTicketService.java
+++ b/src/main/java/com/gitblit/tickets/RedisTicketService.java
@@ -83,12 +83,11 @@ public class RedisTicketService extends ITicketService {
}
@Override
- public RedisTicketService start() {
+ public void onStart() {
log.info("{} started", getClass().getSimpleName());
if (!isReady()) {
log.warn("{} is not ready!", getClass().getSimpleName());
}
- return this;
}
@Override
diff --git a/src/main/java/com/gitblit/tickets/TicketIndexer.java b/src/main/java/com/gitblit/tickets/TicketIndexer.java
index bc08fc88..7c164487 100644
--- a/src/main/java/com/gitblit/tickets/TicketIndexer.java
+++ b/src/main/java/com/gitblit/tickets/TicketIndexer.java
@@ -227,6 +227,18 @@ public class TicketIndexer {
}
/**
+ * Checks if a tickets index exists, that is compatible with Lucene.INDEX_VERSION
+ * and the Lucene codec version.
+ *
+ * @return true if no tickets index is found, false otherwise.
+ *
+ * @since 1.9.0
+ */
+ boolean shouldReindex() {
+ return ! this.indexStore.hasIndex();
+ }
+
+ /**
* Bulk Add/Update tickets in the Lucene index
*
* @param tickets
@@ -665,4 +677,4 @@ public class TicketIndexer {
int i = Integer.parseInt(val);
return i;
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/com/gitblit/utils/LuceneIndexStore.java b/src/main/java/com/gitblit/utils/LuceneIndexStore.java
index 0ccfd2e8..c05e2019 100644
--- a/src/main/java/com/gitblit/utils/LuceneIndexStore.java
+++ b/src/main/java/com/gitblit/utils/LuceneIndexStore.java
@@ -92,7 +92,7 @@ public class LuceneIndexStore
{
return indexFolder.exists() &&
indexFolder.isDirectory() &&
- (indexFolder.list().length > 1);
+ (indexFolder.list().length > 1); // Must have more than 'write.lock'
}
}
diff --git a/src/test/java/com/gitblit/tests/BranchTicketServiceTest.java b/src/test/java/com/gitblit/tests/BranchTicketServiceTest.java
index 0a5de196..0e9d8874 100644
--- a/src/test/java/com/gitblit/tests/BranchTicketServiceTest.java
+++ b/src/test/java/com/gitblit/tests/BranchTicketServiceTest.java
@@ -59,7 +59,7 @@ public class BranchTicketServiceTest extends TicketServiceTest {
IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, pluginManager, userManager).start();
- BranchTicketService service = new BranchTicketService(
+ BranchTicketService service = (BranchTicketService) new BranchTicketService(
runtimeManager,
pluginManager,
notificationManager,
diff --git a/src/test/java/com/gitblit/tests/FileTicketServiceTest.java b/src/test/java/com/gitblit/tests/FileTicketServiceTest.java
index 1fb2eed9..c4a63c41 100644
--- a/src/test/java/com/gitblit/tests/FileTicketServiceTest.java
+++ b/src/test/java/com/gitblit/tests/FileTicketServiceTest.java
@@ -58,7 +58,7 @@ public class FileTicketServiceTest extends TicketServiceTest {
IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, pluginManager, userManager).start();
- FileTicketService service = new FileTicketService(
+ FileTicketService service = (FileTicketService) new FileTicketService(
runtimeManager,
pluginManager,
notificationManager,
diff --git a/src/test/java/com/gitblit/tests/RedisTicketServiceTest.java b/src/test/java/com/gitblit/tests/RedisTicketServiceTest.java
index 48011ade..5f3cb94f 100644
--- a/src/test/java/com/gitblit/tests/RedisTicketServiceTest.java
+++ b/src/test/java/com/gitblit/tests/RedisTicketServiceTest.java
@@ -66,7 +66,7 @@ public class RedisTicketServiceTest extends TicketServiceTest {
IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, pluginManager, userManager).start();
- RedisTicketService service = new RedisTicketService(
+ RedisTicketService service = (RedisTicketService) new RedisTicketService(
runtimeManager,
pluginManager,
notificationManager,
diff --git a/src/test/java/com/gitblit/tests/UITicketTest.java b/src/test/java/com/gitblit/tests/UITicketTest.java
index 54aa1e1e..e89c32fc 100644
--- a/src/test/java/com/gitblit/tests/UITicketTest.java
+++ b/src/test/java/com/gitblit/tests/UITicketTest.java
@@ -83,7 +83,7 @@ public class UITicketTest extends GitblitUnitTest {
IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, pluginManager, userManager).start();
- BranchTicketService service = new BranchTicketService(
+ BranchTicketService service = (BranchTicketService) new BranchTicketService(
runtimeManager,
pluginManager,
notificationManager,