refactoring/renaming
This commit is contained in:
@@ -141,10 +141,10 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
|
||||
// }
|
||||
// }
|
||||
|
||||
public void addToWriteQueue(ChunkSizedFullDataSource datatype)
|
||||
public void addToWriteQueue(ChunkSizedFullDataSource chunkDataSource)
|
||||
{
|
||||
debugCheck();
|
||||
DhLodPos chunkPos = new DhLodPos((byte) (datatype.dataDetail + 4), datatype.x, datatype.z);
|
||||
DhLodPos chunkPos = new DhLodPos((byte) (chunkDataSource.dataDetail + 4), chunkDataSource.x, chunkDataSource.z);
|
||||
LodUtil.assertTrue(pos.getSectionBBoxPos().overlaps(chunkPos), "Chunk pos "+chunkPos+" doesn't overlap with section "+pos);
|
||||
//LOGGER.info("Write Chunk {} to file {}", chunkPos, pos);
|
||||
|
||||
@@ -156,7 +156,7 @@ public class FullDataMetaFile extends AbstractMetaDataContainerFile
|
||||
appendLock.lock();
|
||||
try
|
||||
{
|
||||
writeQueue.queue.add(datatype);
|
||||
writeQueue.queue.add(chunkDataSource);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
+9
-7
@@ -59,7 +59,9 @@ public abstract class AbstractMetaDataContainerFile
|
||||
/**
|
||||
* James tested this on windows (2023-02-18) and didn't have any issues,
|
||||
* so it will be turned on for now. If there turns out to be issues
|
||||
* we can always
|
||||
* we can always turn it off. <Br><br>
|
||||
*
|
||||
* original comment: <br>
|
||||
* Currently set to false because for some reason
|
||||
* Window is throwing PermissionDeniedException when trying to atomic replace a file...
|
||||
*/
|
||||
@@ -201,12 +203,12 @@ public abstract class AbstractMetaDataContainerFile
|
||||
tempFile = this.file;
|
||||
}
|
||||
|
||||
try (FileChannel file = FileChannel.open(tempFile.toPath(), StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING))
|
||||
try (FileChannel fileChannel = FileChannel.open(tempFile.toPath(), StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING))
|
||||
{
|
||||
file.position(METADATA_SIZE_IN_BYTES);
|
||||
fileChannel.position(METADATA_SIZE_IN_BYTES);
|
||||
int checksum;
|
||||
|
||||
try(DhUnclosableOutputStream bufferedOut = new DhUnclosableOutputStream(Channels.newOutputStream(file)); // Prevent closing the channel by anything but closing the file channel
|
||||
try(DhUnclosableOutputStream bufferedOut = new DhUnclosableOutputStream(Channels.newOutputStream(fileChannel)); // Prevent closing the channel by anything but closing the file channel
|
||||
CheckedOutputStream checkedOut = new CheckedOutputStream(bufferedOut, new Adler32())) // TODO: Is Adler32 ok?
|
||||
{
|
||||
dataWriterFunc.writeBufferToFile(bufferedOut); // TODO it might be nice to have a DH stream we pass in instead of the base BufferedOutputStream to make it clear the streams can't be closed
|
||||
@@ -214,7 +216,7 @@ public abstract class AbstractMetaDataContainerFile
|
||||
}
|
||||
|
||||
|
||||
file.position(0);
|
||||
fileChannel.position(0);
|
||||
// Write metadata
|
||||
ByteBuffer buffer = ByteBuffer.allocate(METADATA_SIZE_IN_BYTES);
|
||||
buffer.putInt(METADATA_IDENTITY_BYTES);
|
||||
@@ -230,10 +232,10 @@ public abstract class AbstractMetaDataContainerFile
|
||||
buffer.putLong(Long.MAX_VALUE); //buff.putLong(this.metaData.dataVersion.get()); // not currently implemented
|
||||
LodUtil.assertTrue(buffer.remaining() == METADATA_RESERVED_SIZE);
|
||||
buffer.flip();
|
||||
file.write(buffer);
|
||||
fileChannel.write(buffer);
|
||||
|
||||
|
||||
file.close();
|
||||
fileChannel.close();
|
||||
if (USE_ATOMIC_MOVE_REPLACE)
|
||||
{
|
||||
// Atomic move / replace the actual file
|
||||
|
||||
@@ -146,11 +146,10 @@ public class BatchGenerator implements IDhApiWorldGenerator
|
||||
//=========//
|
||||
|
||||
@Override
|
||||
public void close() { this.stop(true); }
|
||||
public void stop(boolean blocking)
|
||||
public void close()
|
||||
{
|
||||
LOGGER.info(BatchGenerator.class.getSimpleName()+" shutting down...");
|
||||
this.generationGroup.stop(blocking);
|
||||
this.generationGroup.stop(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -94,9 +94,9 @@ public class DhClientServerWorld extends AbstractDhWorld implements IDhClientWor
|
||||
if (wrapper instanceof IServerLevelWrapper)
|
||||
{
|
||||
LOGGER.info("Unloading level "+this.levelObjMap.get(wrapper));
|
||||
DhClientServerLevel level = this.levelObjMap.remove(wrapper);
|
||||
this.dhLevels.remove(level);
|
||||
level.close();
|
||||
DhClientServerLevel clientServerLevel = this.levelObjMap.remove(wrapper);
|
||||
clientServerLevel.saveAsync().join();
|
||||
clientServerLevel.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user