diff --git a/bundler/src/main/java/io/ib67/sfcraft/bundler/BundleReader.java b/bundler/src/main/java/io/ib67/sfcraft/bundler/BundleReader.java index 21cc63c..0e618d1 100644 --- a/bundler/src/main/java/io/ib67/sfcraft/bundler/BundleReader.java +++ b/bundler/src/main/java/io/ib67/sfcraft/bundler/BundleReader.java @@ -33,7 +33,6 @@ public class BundleReader { } public void extract(Path bundle, Path destination) throws IOException { - var symbolsToLink = new HashMap(); var readMaps = new HashMap(); try (var zstd = new ZstdInputStreamNoFinalizer(Files.newInputStream(bundle, StandardOpenOption.READ)); var in = new EntryInputStream(zstd)) { diff --git a/bundler/src/main/java/io/ib67/sfcraft/bundler/region/RegionParser.java b/bundler/src/main/java/io/ib67/sfcraft/bundler/region/RegionParser.java index ea527d9..0cec9df 100644 --- a/bundler/src/main/java/io/ib67/sfcraft/bundler/region/RegionParser.java +++ b/bundler/src/main/java/io/ib67/sfcraft/bundler/region/RegionParser.java @@ -119,7 +119,7 @@ public class RegionParser implements Closeable { case 2 -> new DeflaterInputStream(new ByteBufInputStream(in)); case 3 -> new ByteBufInputStream(in); case 4 -> new LZ4BlockInputStream(new ByteBufInputStream(in)); - // user defined compression algorithm, no going to support. + // user defined compression algorithm, not going to support. // (or mcc) default -> throw new IOException("Unsupported compression type. " + compressionType); }; diff --git a/src/main/java/io/ib67/sfcraft/BackupWorker.java b/src/main/java/io/ib67/sfcraft/BackupWorker.java index 1bb680a..bc3d587 100644 --- a/src/main/java/io/ib67/sfcraft/BackupWorker.java +++ b/src/main/java/io/ib67/sfcraft/BackupWorker.java @@ -44,7 +44,6 @@ public record BackupWorker( // tmp file path log.info("Creating bundle {}", tmpBundle); BundleWriter.createBundle(tmpBundle, subject.changedFiles(), config); - return strategy.createBackup(subject.name(), subject.root(), tmpBundle); } catch (Exception e) { throw e; } finally { @@ -55,7 +54,9 @@ public record BackupWorker( log.error("Expect BACKUP state but got {}", BACKUP_LOCK.get()); Thread.sleep(2000); } - Files.deleteIfExists(tmpBundle); } + var result = strategy.createBackup(subject.name(), subject.root(), tmpBundle); + Files.deleteIfExists(tmpBundle); + return result; } } diff --git a/src/main/java/io/ib67/sfcraft/WorldDir.java b/src/main/java/io/ib67/sfcraft/WorldDir.java deleted file mode 100644 index dc6d917..0000000 --- a/src/main/java/io/ib67/sfcraft/WorldDir.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.ib67.sfcraft; - -import lombok.SneakyThrows; - -import java.nio.file.FileVisitOption; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -public record WorldDir( - Path root -) { - public Path region() { - return root.resolve("region"); - } - - public Path poi() { - return root.resolve("poi"); - } - - public Path entities() { - return root.resolve("entities"); - } - - @SneakyThrows - public List otherDimensions() { - try (var w = Files.walk(root)) { - return w.filter(it -> Files.exists(it.resolve("region")) && Files.exists(it.resolve("poi"))) - .map(WorldDir::new) - .toList(); - } - } - - /** - * @return Files expect poi, region, entities, playerdata and things in dimension folder. - */ - @SneakyThrows - public List otherFiles() { - var otherDimensions = otherDimensions(); - try (var f = Files.walk(root)) { - return f.filter(it -> Files.isRegularFile(it) - && otherDimensions.stream().noneMatch(a -> it.startsWith(a.root))) - .filter(it -> !it.getFileName().toString().contains("session.lock")) - .toList(); - } - } - - @SneakyThrows - public List everything() { - try (var f = Files.walk(root)) { - return f.filter(Files::isRegularFile) - .filter(it -> !it.getFileName().toString().contains("session.lock")) - .toList(); - } - } -} diff --git a/src/main/java/io/ib67/sfcraft/mixin/MixinRegionBasedStorage.java b/src/main/java/io/ib67/sfcraft/mixin/MixinRegionBasedStorage.java index db050b9..5f65f73 100644 --- a/src/main/java/io/ib67/sfcraft/mixin/MixinRegionBasedStorage.java +++ b/src/main/java/io/ib67/sfcraft/mixin/MixinRegionBasedStorage.java @@ -31,8 +31,18 @@ public abstract class MixinRegionBasedStorage { if (witness == IOState.BACKUP) { // yield out and keep blocking. // The backup worker will wait for us setting this back to backup. + int i =0; Globals.BACKUP_LOCK.set(IOState.BACKUP); while (Globals.BACKUP_LOCK.getAcquire() == IOState.BACKUP) { + if(i==0){ + System.out.println("Server is performing backup, ChunkIO will wait for it."); + } + if(i++ > 3000){ + System.err.println("WARNING: BACKUP_LOCK is holding for 10 minutes!"); + System.err.println("ChunkIO will not wait for backup anymore, writting to disk..."); + System.err.println("You may adjust this behaviour in configuration"); + break; + } Thread.sleep(2000); } } @@ -42,7 +52,7 @@ public abstract class MixinRegionBasedStorage { value.sync(); } } finally { - // we asserts that there are no other threads calling sync() + // we assert that there are no other threads calling sync() // so we can just jump back to the witness value. // witness: AUTO_SAVE or IDLE Globals.BACKUP_LOCK.compareAndExchange(IOState.STORAGE_SYNC, witness);