}
@Override
- public BranchTicketService start() {
+ public void onStart() {
log.info("{} started", getClass().getSimpleName());
- return this;
}
@Override
}
@Override
- public FileTicketService start() {
+ public void onStart() {
log.info("{} started", getClass().getSimpleName());
- return this;
}
@Override
* @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.
return this;
}
+ /**
+ * 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
return indexer.hasTickets(repository);
}
- /**
- * 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
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.
}
@Override
- public NullTicketService start() {
+ public void onStart() {
log.info("{} started", getClass().getSimpleName());
- return this;
}
@Override
}
@Override
- public RedisTicketService start() {
+ public void onStart() {
log.info("{} started", getClass().getSimpleName());
if (!isReady()) {
log.warn("{} is not ready!", getClass().getSimpleName());
}
- return this;
}
@Override
return false;
}
+ /**
+ * 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
*
int i = Integer.parseInt(val);
return i;
}
-}
\ No newline at end of file
+}
{
return indexFolder.exists() &&
indexFolder.isDirectory() &&
- (indexFolder.list().length > 1);
+ (indexFolder.list().length > 1); // Must have more than 'write.lock'
}
}
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,
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,
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,
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,