mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-30 12:01:26 +01:00
Remove rocksdb
This commit is contained in:
parent
3bdc842393
commit
08ce627db7
@ -127,9 +127,6 @@ dependencies {
|
|||||||
// https://jitpack.io/#Articdive/Jnoise
|
// https://jitpack.io/#Articdive/Jnoise
|
||||||
api 'com.github.Articdive:Jnoise:2.1.0'
|
api 'com.github.Articdive:Jnoise:2.1.0'
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/org.rocksdb/rocksdbjni
|
|
||||||
api 'org.rocksdb:rocksdbjni:6.16.4'
|
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
api 'org.apache.logging.log4j:log4j-core:2.14.0'
|
api 'org.apache.logging.log4j:log4j-core:2.14.0'
|
||||||
// SLF4J is the base logger for most libraries, therefore we can hook it into log4j2.
|
// SLF4J is the base logger for most libraries, therefore we can hook it into log4j2.
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
package net.minestom.server.storage.systems;
|
|
||||||
|
|
||||||
import net.minestom.server.MinecraftServer;
|
|
||||||
import net.minestom.server.storage.StorageOptions;
|
|
||||||
import net.minestom.server.storage.StorageSystem;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.rocksdb.*;
|
|
||||||
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@link StorageSystem} which is local using OS files system
|
|
||||||
* It does make use of the RocksDB library.
|
|
||||||
* <p>
|
|
||||||
* The location represents the path of the folder.
|
|
||||||
* <p>
|
|
||||||
* Warning: will create some log files in the location folder when opened, those are generated by RocksDB.
|
|
||||||
*/
|
|
||||||
public class FileStorageSystem implements StorageSystem {
|
|
||||||
|
|
||||||
private Options options;
|
|
||||||
|
|
||||||
static {
|
|
||||||
RocksDB.loadLibrary();
|
|
||||||
}
|
|
||||||
|
|
||||||
private RocksDB rocksDB;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean exists(@NotNull String location) {
|
|
||||||
return Files.isDirectory(Paths.get(location));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void open(@NotNull String location, @NotNull StorageOptions storageOptions) {
|
|
||||||
options = new Options().setCreateIfMissing(true);
|
|
||||||
|
|
||||||
if (storageOptions.hasCompression()) {
|
|
||||||
options.setCompressionType(CompressionType.ZSTD_COMPRESSION);
|
|
||||||
options.setCompressionOptions(new CompressionOptions().setLevel(4));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.rocksDB = RocksDB.open(options, location);
|
|
||||||
} catch (RocksDBException e) {
|
|
||||||
MinecraftServer.getExceptionManager().handleException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] get(@NotNull String key) {
|
|
||||||
try {
|
|
||||||
return rocksDB.get(getKey(key));
|
|
||||||
} catch (RocksDBException e) {
|
|
||||||
MinecraftServer.getExceptionManager().handleException(e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(@NotNull String key, byte[] data) {
|
|
||||||
try {
|
|
||||||
this.rocksDB.put(getKey(key), data);
|
|
||||||
} catch (RocksDBException e) {
|
|
||||||
MinecraftServer.getExceptionManager().handleException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(@NotNull String key) {
|
|
||||||
try {
|
|
||||||
this.rocksDB.delete(getKey(key));
|
|
||||||
} catch (RocksDBException e) {
|
|
||||||
MinecraftServer.getExceptionManager().handleException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
try {
|
|
||||||
if (options != null)
|
|
||||||
this.options.close();
|
|
||||||
|
|
||||||
this.rocksDB.closeE();
|
|
||||||
} catch (RocksDBException e) {
|
|
||||||
MinecraftServer.getExceptionManager().handleException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] getKey(String key) {
|
|
||||||
return key.getBytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -15,8 +15,6 @@ import net.minestom.server.extras.optifine.OptifineSupport;
|
|||||||
import net.minestom.server.instance.block.BlockManager;
|
import net.minestom.server.instance.block.BlockManager;
|
||||||
import net.minestom.server.instance.block.rule.vanilla.RedstonePlacementRule;
|
import net.minestom.server.instance.block.rule.vanilla.RedstonePlacementRule;
|
||||||
import net.minestom.server.ping.ResponseData;
|
import net.minestom.server.ping.ResponseData;
|
||||||
import net.minestom.server.storage.StorageManager;
|
|
||||||
import net.minestom.server.storage.systems.FileStorageSystem;
|
|
||||||
import net.minestom.server.utils.identity.NamedAndIdentified;
|
import net.minestom.server.utils.identity.NamedAndIdentified;
|
||||||
import net.minestom.server.utils.time.TimeUnit;
|
import net.minestom.server.utils.time.TimeUnit;
|
||||||
import net.minestom.server.utils.time.UpdateOption;
|
import net.minestom.server.utils.time.UpdateOption;
|
||||||
@ -53,10 +51,6 @@ public class Main {
|
|||||||
|
|
||||||
commandManager.setUnknownCommandCallback((sender, command) -> sender.sendMessage(Component.text("Unknown command", NamedTextColor.RED)));
|
commandManager.setUnknownCommandCallback((sender, command) -> sender.sendMessage(Component.text("Unknown command", NamedTextColor.RED)));
|
||||||
|
|
||||||
|
|
||||||
StorageManager storageManager = MinecraftServer.getStorageManager();
|
|
||||||
storageManager.defineDefaultStorageSystem(FileStorageSystem::new);
|
|
||||||
|
|
||||||
MinecraftServer.getBenchmarkManager().enable(new UpdateOption(10 * 1000, TimeUnit.MILLISECOND));
|
MinecraftServer.getBenchmarkManager().enable(new UpdateOption(10 * 1000, TimeUnit.MILLISECOND));
|
||||||
|
|
||||||
MinecraftServer.getSchedulerManager().buildShutdownTask(() -> System.out.println("Good night")).schedule();
|
MinecraftServer.getSchedulerManager().buildShutdownTask(() -> System.out.println("Good night")).schedule();
|
||||||
|
Loading…
Reference in New Issue
Block a user