Compare commits
3 Commits
4a4af2576d
...
34e8eb0259
Author | SHA1 | Date | |
---|---|---|---|
|
34e8eb0259 | ||
|
6cbaad6ebd | ||
|
e3944dc3be |
6
pom.xml
6
pom.xml
|
@ -12,8 +12,8 @@
|
|||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<native.maven.plugin.version>0.9.28</native.maven.plugin.version>
|
||||
<gestalt.version>0.24.1</gestalt.version>
|
||||
<rocksdb.version>8.8.1</rocksdb.version>
|
||||
<gestalt.version>0.24.2</gestalt.version>
|
||||
<rocksdb.version>9.0.0</rocksdb.version>
|
||||
<imageName>rockserver-core</imageName>
|
||||
<mainClass>it.cavallium.rockserver.core.Main</mainClass>
|
||||
</properties>
|
||||
|
@ -37,7 +37,7 @@
|
|||
<dependency>
|
||||
<groupId>com.github.seancfoley</groupId>
|
||||
<artifactId>ipaddress</artifactId>
|
||||
<version>5.4.0</version>
|
||||
<version>5.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
|
|
|
@ -7,6 +7,7 @@ import it.cavallium.rockserver.core.impl.DbCompressionDecoder;
|
|||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.github.gestalt.config.builder.GestaltBuilder;
|
||||
import org.github.gestalt.config.builder.SourceBuilder;
|
||||
import org.github.gestalt.config.exceptions.GestaltException;
|
||||
|
@ -22,7 +23,6 @@ public class ConfigParser {
|
|||
gsb = new GestaltBuilder();
|
||||
gsb
|
||||
.setTreatMissingArrayIndexAsError(false)
|
||||
.setTreatEmptyCollectionAsErrors(false)
|
||||
.setTreatNullValuesInClassAsErrors(false)
|
||||
.setTreatMissingValuesAsErrors(false)
|
||||
.addDecoder(new DataSizeDecoder())
|
||||
|
|
|
@ -42,15 +42,7 @@ public class ConfigPrinter {
|
|||
}
|
||||
|
||||
public static List<VolumeConfig> getVolumeConfigs(GlobalDatabaseConfig g) throws GestaltException {
|
||||
try {
|
||||
return List.of(g.volumes());
|
||||
} catch (GestaltException ex) {
|
||||
if (ex.getMessage().startsWith("Failed to get cached object from proxy config while calling method:")) {
|
||||
return List.of();
|
||||
} else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String stringifyGlobalDatabase(GlobalDatabaseConfig o) throws GestaltException {
|
||||
|
|
|
@ -2,10 +2,14 @@ package it.cavallium.rockserver.core.impl.rocksdb;
|
|||
|
||||
import it.cavallium.rockserver.core.common.RocksDBException.RocksDBErrorType;
|
||||
import it.cavallium.rockserver.core.config.*;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import org.github.gestalt.config.exceptions.GestaltException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.rocksdb.*;
|
||||
import org.rocksdb.util.Environment;
|
||||
import org.rocksdb.util.SizeUnit;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -30,20 +34,53 @@ public class RocksDBLoader {
|
|||
private static final boolean USE_CLOCK_CACHE
|
||||
= Boolean.parseBoolean(System.getProperty("it.cavallium.dbengine.clockcache.enable", "false"));
|
||||
private static final CacheFactory CACHE_FACTORY = USE_CLOCK_CACHE ? new ClockCacheFactory() : new LRUCacheFactory();
|
||||
private static final String bugJniLibraryFileName = Environment.getJniLibraryFileName("rocksdbjni");
|
||||
private static final String jniLibraryFileName = Environment.getJniLibraryFileName("rocksdb");
|
||||
@Nullable
|
||||
private static final String fallbackJniLibraryFileName = Environment.getFallbackJniLibraryFileName("rocksdb");
|
||||
@Nullable
|
||||
private static final String bugFallbackJniLibraryFileName = Environment.getFallbackJniLibraryFileName("rocksdbjni");
|
||||
|
||||
public static void loadLibrary() {
|
||||
RocksDB.loadLibrary();
|
||||
/* todo: rocksdb does not support loading the library outside of the default mechanism
|
||||
try {
|
||||
var jniPath = Path.of(".").resolve("jni").resolve(RocksDBMetadata.getRocksDBVersionHash());
|
||||
String currentUsersHomeDir = System.getProperty("user.home");
|
||||
var jniPath = Path.of(currentUsersHomeDir).resolve(".jni").resolve("rocksdb").resolve(RocksDBMetadata.getRocksDBVersionHash());
|
||||
if (Files.notExists(jniPath)) {
|
||||
Files.createDirectories(jniPath);
|
||||
}
|
||||
// todo:
|
||||
loadLibraryFromJarToTemp(jniPath);
|
||||
|
||||
RocksDB.loadLibrary(List.of(jniPath.toAbsolutePath().toString()));
|
||||
} catch (IOException e) {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static Path loadLibraryFromJarToTemp(final Path tmpDir) throws IOException {
|
||||
var temp1 = tmpDir.resolve(bugJniLibraryFileName);
|
||||
if (Files.exists(temp1)) {
|
||||
return temp1;
|
||||
}
|
||||
try (InputStream is = RocksDB.class.getClassLoader().getResourceAsStream(jniLibraryFileName)) {
|
||||
if (is != null) {
|
||||
Files.copy(is, temp1, StandardCopyOption.REPLACE_EXISTING);
|
||||
return temp1;
|
||||
}
|
||||
}
|
||||
|
||||
if (bugFallbackJniLibraryFileName == null) {
|
||||
throw new RuntimeException("rocksdb was not found inside JAR.");
|
||||
}
|
||||
|
||||
var temp2 = tmpDir.resolve(bugFallbackJniLibraryFileName);
|
||||
try (InputStream is = RocksDB.class.getClassLoader().getResourceAsStream(fallbackJniLibraryFileName)) {
|
||||
if (is != null) {
|
||||
Files.copy(is, temp2, StandardCopyOption.REPLACE_EXISTING);
|
||||
return temp2;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("rocksdb was not found inside JAR.");
|
||||
}
|
||||
|
||||
|
||||
|
@ -537,7 +574,7 @@ public class RocksDBLoader {
|
|||
}
|
||||
}
|
||||
|
||||
record DbPathRecord(Path path, long targetSize) {}
|
||||
public record DbPathRecord(Path path, long targetSize) {}
|
||||
|
||||
public static boolean isDisableAutoCompactions() {
|
||||
return parseBoolean(System.getProperty("it.cavallium.dbengine.compactions.auto.disable", "false"));
|
||||
|
|
Loading…
Reference in New Issue
Block a user