Skip to content

Commit d128452

Browse files
committed
GH-0000 Remove system property toggle for memory mapped txn status file
1 parent db7f5cf commit d128452

4 files changed

Lines changed: 36 additions & 49 deletions

File tree

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/TripleStore.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,9 @@ class TripleStore implements Closeable {
8080
*/
8181
private static final String INDEXES_KEY = "triple-indexes";
8282

83-
/**
84-
* System property that enables the experimental {@link MemoryMappedTxnStatusFile} implementation instead of the
85-
* default {@link TxnStatusFile}.
86-
*/
87-
private static final String MEMORY_MAPPED_TXN_STATUS_FILE_ENABLED_PROP = "org.eclipse.rdf4j.sail.nativerdf.MemoryMappedTxnStatusFile.enabled";
88-
89-
/**
90-
* The version number for the current triple store.
91-
* <ul>
83+
/**
84+
* The version number for the current triple store.
85+
* <ul>
9286
* <li>version 0: The first version which used a single spo-index. This version did not have a properties file yet.
9387
* <li>version 1: Introduces configurable triple indexes and the properties file.
9488
* <li>version 10: Introduces a context field, essentially making this a quad store.
@@ -234,14 +228,12 @@ public TripleStore(File dir, String indexSpecStr, boolean forceSync, Boolean mem
234228
}
235229
}
236230

237-
private static TxnStatusFile createTxnStatusFile(File dir, Boolean memoryMappedTxnStatusFileEnabled)
238-
throws IOException {
239-
boolean enabled = memoryMappedTxnStatusFileEnabled != null
240-
? memoryMappedTxnStatusFileEnabled
241-
: Boolean.getBoolean(MEMORY_MAPPED_TXN_STATUS_FILE_ENABLED_PROP);
242-
if (enabled) {
243-
return new MemoryMappedTxnStatusFile(dir);
244-
}
231+
private static TxnStatusFile createTxnStatusFile(File dir, Boolean memoryMappedTxnStatusFileEnabled)
232+
throws IOException {
233+
boolean enabled = Boolean.TRUE.equals(memoryMappedTxnStatusFileEnabled);
234+
if (enabled) {
235+
return new MemoryMappedTxnStatusFile(dir);
236+
}
245237
return new TxnStatusFile(dir);
246238
}
247239

core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/MemoryMappedTxnStatusFileConfigTest.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,24 @@
2020
import org.junit.jupiter.api.io.TempDir;
2121

2222
/**
23-
* Verifies that the implementation used for the transaction status file can be controlled via a system property.
23+
* Verifies that the implementation used for the transaction status file is controlled through configuration rather than a
24+
* JVM system property.
2425
*/
2526
public class MemoryMappedTxnStatusFileConfigTest {
2627

27-
private static final String MEMORY_MAPPED_ENABLED_PROP = "org.eclipse.rdf4j.sail.nativerdf.MemoryMappedTxnStatusFile.enabled";
28+
private static final String MEMORY_MAPPED_ENABLED_PROP = "org.eclipse.rdf4j.sail.nativerdf.MemoryMappedTxnStatusFile.enabled";
2829

29-
@TempDir
30-
File dataDir;
30+
@TempDir
31+
File dataDir;
3132

32-
@AfterEach
33-
public void clearProperty() {
34-
System.clearProperty(MEMORY_MAPPED_ENABLED_PROP);
35-
}
33+
@AfterEach
34+
public void clearProperty() {
35+
System.clearProperty(MEMORY_MAPPED_ENABLED_PROP);
36+
}
3637

37-
@Test
38-
public void defaultUsesNioTxnStatusFile() throws Exception {
39-
TripleStore tripleStore = new TripleStore(dataDir, "spoc");
38+
@Test
39+
public void defaultUsesNioTxnStatusFile() throws Exception {
40+
TripleStore tripleStore = new TripleStore(dataDir, "spoc");
4041
try {
4142
tripleStore.startTransaction();
4243
tripleStore.storeTriple(1, 2, 3, 4);
@@ -52,21 +53,21 @@ public void defaultUsesNioTxnStatusFile() throws Exception {
5253
}
5354

5455
@Test
55-
public void memoryMappedEnabledUsesFixedSizeFile() throws Exception {
56-
System.setProperty(MEMORY_MAPPED_ENABLED_PROP, "true");
56+
public void systemPropertyIsIgnored() throws Exception {
57+
System.setProperty(MEMORY_MAPPED_ENABLED_PROP, "true");
5758

58-
TripleStore tripleStore = new TripleStore(dataDir, "spoc");
59-
try {
60-
tripleStore.startTransaction();
61-
tripleStore.storeTriple(1, 2, 3, 4);
59+
TripleStore tripleStore = new TripleStore(dataDir, "spoc");
60+
try {
61+
tripleStore.startTransaction();
62+
tripleStore.storeTriple(1, 2, 3, 4);
6263
tripleStore.commit();
6364
} finally {
6465
tripleStore.close();
65-
}
66+
}
6667

67-
File txnStatusFile = new File(dataDir, TxnStatusFile.FILE_NAME);
68-
assertTrue(txnStatusFile.exists(), "Transaction status file should exist");
69-
assertEquals(1L, txnStatusFile.length(),
70-
"Memory-mapped TxnStatusFile keeps a single status byte on disk for NONE status");
71-
}
68+
File txnStatusFile = new File(dataDir, TxnStatusFile.FILE_NAME);
69+
assertTrue(txnStatusFile.exists(), "Transaction status file should exist");
70+
assertEquals(0L, txnStatusFile.length(),
71+
"System property does not switch to memory-mapped TxnStatusFile");
72+
}
7273
}

core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/NativeStoreTxnStatusConfigTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.eclipse.rdf4j.repository.sail.SailRepository;
2424
import org.eclipse.rdf4j.sail.nativerdf.config.NativeStoreConfig;
2525
import org.eclipse.rdf4j.sail.nativerdf.config.NativeStoreFactory;
26-
import org.junit.jupiter.api.AfterEach;
2726
import org.junit.jupiter.api.Test;
2827
import org.junit.jupiter.api.io.TempDir;
2928

@@ -32,13 +31,8 @@ class NativeStoreTxnStatusConfigTest {
3231
@TempDir
3332
File dataDir;
3433

35-
@AfterEach
36-
void clearSystemProperty() {
37-
System.clearProperty("org.eclipse.rdf4j.sail.nativerdf.MemoryMappedTxnStatusFile.enabled");
38-
}
39-
40-
@Test
41-
void configEnablesMemoryMappedTxnStatusFile() throws Exception {
34+
@Test
35+
void configEnablesMemoryMappedTxnStatusFile() throws Exception {
4236
NativeStoreConfig cfg = new NativeStoreConfig("spoc");
4337
cfg.setMemoryMappedTxnStatusFileEnabled(true);
4438

site/content/documentation/reference/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Creating more indexes potentially speeds up querying (a lot), but also adds over
251251

252252
The native store automatically creates/drops indexes upon (re)initialization, so the parameter can be adjusted and upon the first refresh of the configuration the native store will change its indexing strategy, without loss of data.
253253

254-
Set `config:native.memoryMappedTxnStatusFile` to `true` to enable the experimental memory-mapped transaction status file. When unset, the store falls back to the legacy file implementation and respects the JVM system property `-Dorg.eclipse.rdf4j.sail.nativerdf.MemoryMappedTxnStatusFile.enabled`.
254+
Set `config:native.memoryMappedTxnStatusFile` to `true` to enable the experimental memory-mapped transaction status file. When unset, the store falls back to the legacy file implementation.
255255

256256
##### Example configuration
257257

0 commit comments

Comments
 (0)