Add warning before recovery operation starts, Fix #308

This commit is contained in:
Per Minborg
2021-07-28 11:34:33 +02:00
parent bfc493ec56
commit 909bec7118
2 changed files with 7 additions and 3 deletions
+1 -1
View File
@@ -414,7 +414,7 @@ ChronicleMap<Integer, PostalCodeRange> cityPostalCodes = ChronicleMap
If the Chronicle Map is configured to store entry checksums along with entries, recovery procedure
checks for each entry that the checksums is correct, otherwise it assumes the entry is corrupted and
deletes it from the Chronicle Map. If checksums are to stored, recovery procedure cannot guarantee
deletes it from the Chronicle Map. If checksums are not stored, recovery procedure cannot guarantee
correctness of entry data. See [Entry checksums](#entry-checksums) section for more information.
#### Key and Value Types
@@ -48,8 +48,6 @@ import net.openhft.chronicle.wire.TextWire;
import net.openhft.chronicle.wire.Wire;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
@@ -1833,6 +1831,12 @@ public final class ChronicleMapBuilder<K, V> implements
final boolean recover,
final boolean overrideBuilderConfig,
@Nullable final ChronicleHashCorruption.Listener corruptionListener) throws IOException {
if (recover) {
Jvm.warn().on(ChronicleMapBuilder.class, "Recovery operation needs exclusive access to the ChronicleMap or else the result is unspecified including the risk of loosing and/or corrupting partial or all data.");
Jvm.warn().on(ChronicleMapBuilder.class, "Do not use recovery as a standard way of opening a ChronicleMap.");
}
final ChronicleHashCorruptionImpl corruption = recover ? new ChronicleHashCorruptionImpl() : null;
try {
int headerSize = waitUntilReady(raf, file, recover);