Started using index creation task

This commit is contained in:
Rsl1122 2019-01-10 14:21:33 +02:00
parent 84b723a44a
commit fd22735084

View File

@ -214,20 +214,32 @@ public abstract class SQLDB extends Database {
private void setupDatabase() throws DBInitException { private void setupDatabase() throws DBInitException {
try { try {
createTables(); createTables();
registerIndexCreationTask();
Patch[] patches = patches(); registerPatchTask();
} catch (DBOpException | IllegalArgumentException e) {
try {
runnableFactory.create("Database Patch", new PatchTask(patches, locale, logger, errorHandler))
.runTaskLaterAsynchronously(TimeAmount.toTicks(5L, TimeUnit.SECONDS));
} catch (Exception ignore) {
// Task failed to register because plugin is being disabled
}
} catch (DBOpException e) {
throw new DBInitException("Failed to set-up Database", e); throw new DBInitException("Failed to set-up Database", e);
} }
} }
private void registerPatchTask() {
Patch[] patches = patches();
try {
runnableFactory.create("Database Patch", new PatchTask(patches, locale, logger, errorHandler))
.runTaskLaterAsynchronously(TimeAmount.toTicks(5L, TimeUnit.SECONDS));
} catch (Exception ignore) {
// Task failed to register because plugin is being disabled
}
}
private void registerIndexCreationTask() {
try {
runnableFactory.create("Database Index Creation", new CreateIndexTask(this))
.runTaskAsynchronously();
} catch (Exception ignore) {
// Task failed to register because plugin is being disabled
}
}
/** /**
* Creates the tables that contain data. * Creates the tables that contain data.
* <p> * <p>