log migration status in F3 menu and chat

This commit is contained in:
James Seibel
2024-04-13 14:25:28 -05:00
parent 169429fe48
commit 7d4d899226
6 changed files with 44 additions and 1 deletions
@@ -78,6 +78,8 @@ public class ClientApi
public static final long SPAM_LOGGER_FLUSH_NS = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS);
private boolean configOverrideReminderPrinted = false;
private boolean showMigrationMessage = false;
public boolean rendererDisabledBecauseOfExceptions = false;
private long lastFlushNanoTime = 0;
@@ -470,6 +472,7 @@ public class ClientApi
{
// logging //
// dev build
if (ModInfo.IS_DEV_BUILD && !this.configOverrideReminderPrinted && MC.playerExists())
{
this.configOverrideReminderPrinted = true;
@@ -478,6 +481,18 @@ public class ClientApi
MC.sendChatMessage("Distant Horizons nightly experimental build version [" + ModInfo.VERSION+"].");
MC.sendChatMessage("You are running an unsupported version of Distant Horizons!");
MC.sendChatMessage("Here be dragons!");
MC.sendChatMessage("");
}
// data migration
if (this.showMigrationMessage
&& Config.Client.Advanced.LodBuilding.showMigrationChatWarning.get())
{
this.showMigrationMessage = false;
MC.sendChatMessage("Old Distant Horizons data is being migrated.");
MC.sendChatMessage("While running LODs may load slowly and DH world gen is disabled.");
MC.sendChatMessage("");
}
IProfilerWrapper profiler = MC.getProfiler();
@@ -629,5 +644,7 @@ public class ClientApi
}
}
// TODO there's probably a better way of handling chat messages
public void showMigrationMessageOnNextFrame() { this.showMigrationMessage = true; }
}
@@ -805,6 +805,13 @@ public class Config
+ "")
.build();
public static ConfigEntry<Boolean> showMigrationChatWarning = new ConfigEntry.Builder<Boolean>()
.set(true)
.comment(""
+ "Determines if a message should be displayed in the chat when LOD migration starts. \n"
+ "")
.build();
}
public static class Multiplayer
@@ -148,7 +148,7 @@ public class FullDataSourceProviderV1<TDhLevel extends IDhLevel>
{
ArrayList<FullDataSourceV1> dataSourceList = new ArrayList<>();
ArrayList<DhSectionPos> migrationPosList = ((FullDataSourceV1Repo) this.repo).getPositionsToMigrate(limit);
ArrayList<DhSectionPos> migrationPosList = this.repo.getPositionsToMigrate(limit);
for (int i = 0; i < migrationPosList.size(); i++)
{
DhSectionPos pos = migrationPosList.get(i);
@@ -20,9 +20,11 @@
package com.seibel.distanthorizons.core.file.fullDatafile;
import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode;
import com.seibel.distanthorizons.core.api.internal.ClientApi;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV1;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure;
import com.seibel.distanthorizons.core.file.AbstractNewDataSourceHandler;
import com.seibel.distanthorizons.core.level.IDhLevel;
@@ -34,6 +36,7 @@ import com.seibel.distanthorizons.core.sql.dto.FullDataSourceV2DTO;
import com.seibel.distanthorizons.core.sql.repo.FullDataSourceV2Repo;
import com.seibel.distanthorizons.core.util.ThreadUtil;
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
@@ -56,6 +59,7 @@ public class FullDataSourceProviderV2
implements IDebugRenderable
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
protected static final int NUMBER_OF_PARENT_UPDATE_TASKS_PER_THREAD = 50;
/** how many parent update tasks can be in the queue at once */
@@ -75,6 +79,9 @@ public class FullDataSourceProviderV2
private static final int MIGRATION_MAX_UPDATE_TIMEOUT_IN_MS = 5 * 60 * 1_000;
private static boolean migrationMessageShown = false;
protected final ThreadPoolExecutor migrationThreadPool;
/**
* Interrupting the migration thread pool doesn't work well and may corrupt the database
@@ -356,6 +363,8 @@ public class FullDataSourceProviderV2
ArrayList<FullDataSourceV1> legacyDataSourceList = this.legacyFileHandler.getDataSourcesToMigrate(MIGRATION_BATCH_COUNT);
if (!legacyDataSourceList.isEmpty())
{
ClientApi.INSTANCE.showMigrationMessageOnNextFrame();
// keep going until every data source has been migrated
int progressCount = 0;
while (!legacyDataSourceList.isEmpty() && this.migrationThreadRunning.get())
@@ -430,6 +439,8 @@ public class FullDataSourceProviderV2
this.migrationThreadRunning.set(false);
}
public int getMigrationCount() { return this.legacyFileHandler.getDataSourceMigrationCount(); }
//=======================//
@@ -272,6 +272,8 @@ public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandle
String updateCompletedTaskSize = (updateExecutor != null) ? updateExecutor.getCompletedTaskCount()+"" : "-";
int unsavedDataSourceCount = this.fullDataSourceProvider.getUnsavedDataSourceCount();
int migrationCount = this.fullDataSourceProvider.getMigrationCount();
ArrayList<String> lines = new ArrayList<>();
@@ -282,6 +284,10 @@ public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandle
{
lines.add("File Handler [" + dimName + "]");
lines.add(" File thread pool tasks: " + fileQueueSize + " (completed: " + fileCompletedTaskSize + ")");
if (migrationCount > 0)
{
lines.add(" Legacy Migration #: " + migrationCount);
}
lines.add(" Update thread pool tasks: " + updateQueueSize + " (completed: " + updateCompletedTaskSize + ")");
lines.add(" Level Unsaved #: " + this.clientLevel.getUnsavedDataSourceCount());
if (unsavedDataSourceCount != -1)
@@ -356,6 +356,8 @@
"Lossy World Compression",
"distanthorizons.config.client.advanced.lodBuilding.worldCompression.@tooltip":
"How should block data be compressed when creating LOD data? \nThis setting will only affect new or updated LOD data, \nany data already generated when this setting is changed will be \nunaffected until it is modified or re-loaded. \n\nMost Accurate: Merge Same Blocks \nHighest Compression: Visually Equal",
"distanthorizons.config.client.advanced.lodBuilding.showMigrationChatWarning":
"Log Migration In Chat",
"distanthorizons.config.client.advanced.multiplayer":