Added base changes for database migration command (unfinished)

This commit is contained in:
Intelli 2024-09-29 18:35:27 -06:00
parent fc0c8ff9ac
commit de978fce2c
14 changed files with 95 additions and 73 deletions

View file

@ -100,7 +100,7 @@ public class Consumer extends Process implements Runnable, Thread.UncaughtExcept
private static void pauseConsumer(int process_id) {
try {
while ((ConfigHandler.serverRunning || ConfigHandler.converterRunning) && (Consumer.isPaused || ConfigHandler.pauseConsumer || ConfigHandler.purgeRunning || Consumer.consumer_id.get(process_id)[1] == 1)) {
while ((ConfigHandler.serverRunning || ConfigHandler.converterRunning || ConfigHandler.migrationRunning) && (Consumer.isPaused || ConfigHandler.pauseConsumer || ConfigHandler.purgeRunning || Consumer.consumer_id.get(process_id)[1] == 1)) {
pausedSuccess = true;
Thread.sleep(100);
}

View file

@ -10,6 +10,7 @@ import java.util.Map.Entry;
import org.bukkit.Material;
import net.coreprotect.config.Config;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.consumer.Consumer;
import net.coreprotect.database.Database;
@ -74,7 +75,7 @@ public class Process {
}
Statement statement = connection.createStatement();
Database.performCheckpoint(statement);
Database.performCheckpoint(statement, Config.getGlobal().MYSQL);
Consumer.isPaused = true;
ArrayList<Object[]> consumerData = Consumer.consumer.get(processId);
@ -91,7 +92,7 @@ public class Process {
return;
}
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
// Scan through usernames, ensure everything is loaded in memory.
for (Entry<Integer, String[]> entry : users.entrySet()) {
String[] data = entry.getValue();
@ -104,7 +105,7 @@ public class Process {
}
}
updateLockTable(statement, (lastRun ? 0 : 1));
Database.commitTransaction(statement);
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
// Create prepared statements
PreparedStatement preparedStmtSigns = Database.prepareStatement(connection, Database.SIGN, false);
@ -123,7 +124,7 @@ public class Process {
PreparedStatement preparedStmtBlockdata = Database.prepareStatement(connection, Database.BLOCKDATA, false);
// Scan through consumer data
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
for (int i = 0; i < consumerDataSize; i++) {
Object[] data = consumerData.get(i);
if (data != null) {
@ -242,7 +243,7 @@ public class Process {
if (Consumer.interrupt) {
commit(statement, preparedStmtSigns, preparedStmtBlocks, preparedStmtSkulls, preparedStmtContainers, preparedStmtItems, preparedStmtWorlds, preparedStmtChat, preparedStmtCommand, preparedStmtSession, preparedStmtEntities, preparedStmtMaterials, preparedStmtArt, preparedStmtEntity, preparedStmtBlockdata);
Thread.sleep(500);
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
}
}
catch (Exception e) {
@ -302,7 +303,7 @@ public class Process {
preparedStmtArt.executeBatch();
preparedStmtEntity.executeBatch();
preparedStmtBlockdata.executeBatch();
Database.commitTransaction(statement);
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
}
catch (Exception e) {
e.printStackTrace();