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 {
try {
createTables();
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
}
} catch (DBOpException e) {
registerIndexCreationTask();
registerPatchTask();
} catch (DBOpException | IllegalArgumentException 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.
* <p>