Standard code formatting

This commit is contained in:
Peter Lawrey
2018-04-21 10:49:49 +01:00
parent c7efd950f8
commit 9323cf28a7
270 changed files with 2801 additions and 2551 deletions
@@ -36,15 +36,15 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Base interface for {@link ChronicleMapBuilder} and {@link ChronicleSetBuilder}, i. e. defines
* <i>Chronicle hash container</i> configurations.
*
* <p>
* <p>{@code ChronicleHashBuilder} is mutable. Configuration methods mutate the builder and return
* <i>the builder itself</i> back to support chaining pattern, rather than the builder copies with
* the corresponding configuration changed. To make an independent configuration, {@linkplain
* #clone} the builder.
*
* <p>
* <p>{@code ChronicleHashBuilder} instances are not safe for concurrent use from multiple threads,
* if at least one of the threads mutates the {@code ChronicleHashBuilder}'s state.
*
* <p>
* <p><a name="low-level-config"></a>There are some "low-level" configurations in this builder,
* that require deep understanding of the Chronicle implementation design to be properly used.
* Know what you do. These configurations are applied as-is, without extra round-ups, adjustments,
@@ -73,7 +73,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* recommended to give some distinctive name to each created {@code ChronicleHash}, because this
* name is used when logging errors and warnings inside Chronicle Map library itself, so having
* the concrete {@code ChronicleHash} name in logs may help to debug.
*
* <p>
* <p>{@code name()} is a JVM-level configuration, it is not stored in the persistence file (or
* the other way to say this: they are not parts of <a
* href="https://github.com/OpenHFT/Chronicle-Map/tree/master/spec">the Chronicle Map data store
@@ -102,25 +102,25 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* containers, created by this builder. However, in many cases {@link #averageKey(Object)} might
* be easier to use and more reliable. If key size is always the same, call {@link
* #constantKeySizeBySample(Object)} method instead of this one.
*
* <p>
* <p>{@code ChronicleHashBuilder} implementation heuristically chooses
* {@linkplain #actualChunkSize(int) the actual chunk size} based on this configuration, that,
* however, might result to quite high internal fragmentation, i. e. losses because only
* integral number of chunks could be allocated for the entry. If you want to avoid this, you
* should manually configure the actual chunk size in addition to this average key size
* configuration, which is anyway needed.
*
* <p>
* <p>If key is a boxed primitive type, a value interface or {@link Byteable} subclass, i. e. if
* key size is known statically, it is automatically accounted and shouldn't be specified by
* user.
*
* <p>
* <p>Calling this method clears any previous {@link #constantKeySizeBySample(Object)} and
* {@link #averageKey(Object)} configurations.
*
* @param averageKeySize the average number of bytes, taken by serialized form of keys
* @return this builder back
* @throws IllegalStateException if key size is known statically and shouldn't be configured
* by user
* @throws IllegalStateException if key size is known statically and shouldn't be configured
* by user
* @throws IllegalArgumentException if the given {@code keySize} is non-positive
* @see #averageKey(Object)
* @see #constantKeySizeBySample(Object)
@@ -134,18 +134,18 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* the configured {@link #keyMarshallers(SizedReader, SizedWriter) keys marshallers}.
* In some cases, {@link #averageKeySize(double)} might be easier to use, than constructing the
* "average key". If key size is always the same, call {@link #constantKeySizeBySample(
* Object)} method instead of this one.
*
*Object)} method instead of this one.
* <p>
* <p>{@code ChronicleHashBuilder} implementation heuristically chooses
* {@linkplain #actualChunkSize(int) the actual chunk size} based on this configuration, that,
* however, might result to quite high internal fragmentation, i. e. losses because only
* integral number of chunks could be allocated for the entry. If you want to avoid this, you
* should manually configure the actual chunk size in addition to this average key size
* configuration, which is anyway needed.
*
* <p>
* <p>If key is a boxed primitive type or {@link Byteable} subclass, i. e. if key size is known
* statically, it is automatically accounted and shouldn't be specified by user.
*
* <p>
* <p>Calling this method clears any previous {@link #constantKeySizeBySample(Object)} and
* {@link #averageKeySize(double)} configurations.
*
@@ -163,13 +163,13 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* Configures the constant number of bytes, taken by serialized form of keys, put into hash
* containers, created by this builder. This is done by providing the {@code sampleKey}, all
* keys should take the same number of bytes in serialized form, as this sample object.
*
* <p>
* <p>If keys are of boxed primitive type or {@link Byteable} subclass, i. e. if key size is
* known statically, it is automatically accounted and this method shouldn't be called.
*
* <p>
* <p>If key size varies, method {@link #averageKeySize(double)} should be called instead of
* this one.
*
* <p>
* <p>Calling this method clears any previous {@link #averageKey(Object)} and
* {@link #averageKeySize(double)} configurations.
*
@@ -182,7 +182,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
/**
* Configures the size in bytes of allocation unit of hash container instances, created by this
* builder.
*
* <p>
* <p>{@link ChronicleMap} and {@link ChronicleSet} store their data off-heap, so it is required
* to serialize key (and values, in {@code ChronicleMap} case) (unless they are direct {@link
* Byteable} instances). Serialized key bytes (+ serialized value bytes, in {@code ChronicleMap}
@@ -192,16 +192,16 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* could only allocate 100, 200, 300... bytes for an entry. If say 150 bytes of entry space are
* required by the entry, 200 bytes will be allocated, 150 used and 50 wasted. This is called
* internal fragmentation.
*
* <p>
* <p>To minimize memory overuse and improve speed, you should pay decent attention to this
* configuration. Alternatively, you can just trust the heuristics and doesn't configure
* the chunk size.
*
* <p>
* <p>Specify chunk size so that most entries would take from 5 to several dozens of chunks.
* However, remember that operations with entries that span several chunks are a bit slower,
* than with entries which take a single chunk. Particularly avoid entries to take more than
* 64 chunks.
*
* <p>
* <p>Example: if values in your {@code ChronicleMap} are adjacency lists of some social graph,
* where nodes are represented as {@code long} ids, and adjacency lists are serialized in
* efficient manner, for example as {@code long[]} arrays. Typical number of connections is
@@ -213,7 +213,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* .averageValueSize(150 * 8) // 150 is average adjacency list size
* .actualChunkSize(30 * 8) // average 5-6 chunks per entry
* .create();}</pre>
*
* <p>
* <p>This is a <a href="#low-level-config">low-level configuration</a>. The configured number
* of bytes is used as-is, without anything like round-up to the multiple of 8 or 16, or any
* other adjustment.
@@ -238,7 +238,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* @param maxChunksPerEntry how many chunks a single entry could span at most
* @return this builder back
* @throws IllegalArgumentException if the given {@code maxChunksPerEntry} is lesser than 1
* or greater than 64
* or greater than 64
* @see #actualChunkSize(int)
*/
B maxChunksPerEntry(int maxChunksPerEntry);
@@ -249,21 +249,21 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* (and this is by default), this number of entries is also the maximum. If you try to insert
* more entries, than the configured {@code maxBloatFactor}, multiplied by the given number of
* {@code entries}, {@link IllegalStateException} <i>might</i> be thrown.
*
* <p>
* <p>This configuration should represent the expected maximum number of entries in a stable
* state, {@link #maxBloatFactor(double) maxBloatFactor} - the maximum bloat up coefficient,
* during exceptional bursts.
*
* <p>
* <p>To be more precise - try to configure the {@code entries} so, that the created hash
* container is going to serve about 99% requests being less or equal than this number
* of entries in size.
*
* <p>
* <p><b>You shouldn't put additional margin over the actual target number of entries.</b>
* This bad practice was popularized by {@link HashMap#HashMap(int)} and {@link
* HashSet#HashSet(int)} constructors, which accept <i>capacity</i>, that should be multiplied
* by <i>load factor</i> to obtain the actual maximum expected number of entries.
* {@code ChronicleMap} and {@code ChronicleSet} don't have a notion of load factor.
*
* <p>
* <p>The default target number of entries is 2^20 (~ 1 million).
*
* @param entries the target size of the maps or sets, created by this builder
@@ -277,10 +277,10 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* Configures the maximum number of times, the hash containers, created by this builder,
* are allowed to grow in size beyond the configured {@linkplain #entries(long) target number
* of entries}.
*
* <p>
* <p>{@link #entries(long)} should represent the expected maximum number of entries in a stable
* state, {@code maxBloatFactor} - the maximum bloat up coefficient, during exceptional bursts.
*
* <p>
* <p>This configuration should be used for self-checking. Even if you configure impossibly
* large {@code maxBloatFactor}, the created {@code ChronicleHash}, of cause, will be still
* operational, and even won't allocate any extra resources before they are actually needed.
@@ -291,9 +291,9 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* will have a terribly slow and fat, but operational application, instead of a fail with
* {@code IllegalStateException}, which will quickly show you, that there is a bug in you
* application.
*
* <p>
* <p>The default maximum bloat factor factor is {@code 1.0} - i. e. "no bloat is expected".
*
* <p>
* <p>It is strongly advised not to configure {@code maxBloatFactor} to more than {@code 10.0},
* almost certainly, you either should configure {@code ChronicleHash}es completely differently,
* or this data store doesn't fit to your case.
@@ -302,7 +302,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* to bloat up beyond the {@link #entries(long)}
* @return this builder back
* @throws IllegalArgumentException if the given {@code maxBloatFactor} is NaN, lesser than 1.0
* or greater than 1000.0 (one thousand)
* or greater than 1000.0 (one thousand)
* @see #entries(long)
*/
B maxBloatFactor(double maxBloatFactor);
@@ -312,16 +312,16 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* guarantee that segments won't tier (due to bad hash distribution or natural variance),
* configuring {@code allowSegmentTiering(false)} makes Chronicle Hashes, created by this
* builder, to throw {@code IllegalStateException} immediately when some segment overflows.
*
* <p>
* <p>Useful exactly for testing hash distribution and variance of segment filling.
*
* <p>
* <p>Default is {@code true}, segments are allowed to tier.
*
* <p>
* <p>When configured to {@code false}, {@link #maxBloatFactor(double)} configuration becomes
* irrelevant, because effectively no bloat is allowed.
*
* @param allowSegmentTiering if {@code true}, when a segment overflows a next tier
* is allocated to accommodate new entries
* is allocated to accommodate new entries
* @return this builder back
*/
B allowSegmentTiering(boolean allowSegmentTiering);
@@ -330,20 +330,20 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* Configures probabilistic fraction of segments, which shouldn't become tiered, if Chronicle
* Hash size is {@link #entries(long)}, assuming hash code distribution of the keys, inserted
* into configured Chronicle Hash, is good.
*
* <p>
* <p>The last caveat means that the configured percentile and affects segment size relying on
* Poisson distribution law, if inserted entries (keys) fall into all segments randomly. If
* e. g. the keys, inserted into the Chronicle Hash, are purposely selected to collide by
* a certain range of hash code bits, so that they all fall into the same segment (a DOS
* attacker might do this), this segment is obviously going to be tiered.
*
* <p>
* <p>This configuration affects the actual number of segments, if {@link #entries(long)} and
* {@link #entriesPerSegment(long)} or {@link #actualChunksPerSegmentTier(long)} are configured.
* It affects the actual number of entries per segment/chunks per segment tier, if {@link
* #entries(long)} and {@link #actualSegments(int)} are configured. If all 4 configurations,
* mentioned in this paragraph, are specified, {@code nonTieredSegmentsPercentile} doesn't make
* any effect.
*
* <p>
* <p>Default value is 0.99999, i. e. if hash code distribution of the keys is good, only one
* segment of 100K is tiered on average. If your segment size is small and you want to improve
* memory footprint of Chronicle Hash (probably compromising latency percentiles), you might
@@ -352,7 +352,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* @param nonTieredSegmentsPercentile Fraction of segments which shouldn't be tiered
* @return this builder back
* @throws IllegalArgumentException if {@code nonTieredSegmentsPercentile} is out of (0.5, 1.0)
* range (both bounds are excluded)
* range (both bounds are excluded)
*/
B nonTieredSegmentsPercentile(double nonTieredSegmentsPercentile);
@@ -361,7 +361,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* of the hash containers, created by this builder. Configuring both the actual number of
* entries per segment and {@linkplain #actualSegments(int) actual segments} replaces a single
* {@link #entries(long)} configuration.
*
* <p>
* <p>This is a <a href="#low-level-config">low-level configuration</a>.
*
* @param entriesPerSegment the actual maximum number entries per segment in the
@@ -389,7 +389,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* Configures the actual number of segments in the hash containers, created by this builder.
* With {@linkplain #entriesPerSegment(long) actual number of segments}, this
* configuration replaces a single {@link #entries(long)} call.
*
* <p>
* <p>This is a <a href="#low-level-config">low-level configuration</a>. The configured number
* is used as-is, without anything like round-up to the closest power of 2.
*
@@ -405,7 +405,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* Configures the {@code DataAccess} and {@code SizedReader} used to serialize and deserialize
* keys to and from off-heap memory in hash containers, created by this builder.
*
* @param keyReader the new bytes &rarr; key object reader strategy
* @param keyReader the new bytes &rarr; key object reader strategy
* @param keyDataAccess the new strategy of accessing the keys' bytes for writing
* @return this builder back
* @see #keyMarshallers(SizedReader, SizedWriter)
@@ -453,7 +453,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
/**
* Configures the marshaller used to serialize actual key sizes to off-heap memory in hash
* containers, created by this builder.
*
* <p>
* <p>Default key size marshaller is so-called "stop bit encoding" marshalling. If {@linkplain
* #constantKeySizeBySample(Object) constant key size} is configured, or defaulted if the key
* type is always constant and {@code ChronicleHashBuilder} implementation knows about it, this
@@ -474,7 +474,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* net.openhft.chronicle.core.OS#is64Bit()}.
*
* @param aligned64BitMemoryOperationsAtomic {@code true} if aligned 8-byte memory operations
* are atomic
* are atomic
* @return this builder back
*/
B aligned64BitMemoryOperationsAtomic(boolean aligned64BitMemoryOperationsAtomic);
@@ -484,7 +484,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* checksums. It is used to detect data corruption during recovery after crashes. See the
* <a href="https://github.com/OpenHFT/Chronicle-Map#entry-checksums">Entry Checksums section
* </a> in the Chronicle Map tutorial for more information.
*
* <p>
* <p>By default, {@linkplain #createPersistedTo(File) persisted} hash containers, created by
* {@code ChronicleMapBuilder} <i>do</i> compute and store entry checksums, but hash containers,
* created in the process memory via {@link #create()} - don't.
@@ -512,25 +512,25 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* if the file doesn't yet exist and maps its off-heap memory to the file. All changes to the
* map are persisted to disk (this is an operating system guarantee) independently from JVM
* process lifecycle.
*
* <p>
* <p>Multiple containers could give access to the same data simultaneously, either inside a
* single JVM or across processes. Access is synchronized correctly across all instances, i. e.
* hash container mapping the data from the first JVM isn't able to modify the data,
* concurrently accessed from the second JVM by another hash container instance, mapping the
* same data.
*
* <p>
* <p>On container's {@link ChronicleHash#close() close()} the data isn't removed, it remains on
* disk and available to be opened again (given the same file name) or during different JVM
* run.
*
* <p>
* <p>This method is shortcut for {@code instance().persistedTo(file).create()}.
*
* @param file the file with existing hash container or a desired location of a new off-heap
* persisted hash container
* @return a hash container mapped to the given file
* @throws NullPointerException if the given file is null
* @throws IOException if any IO error, related to off-heap memory allocation or file mapping,
* or establishing replication connections, occurs
* @throws IOException if any IO error, related to off-heap memory allocation or file mapping,
* or establishing replication connections, occurs
* @see ChronicleHash#file()
* @see ChronicleHash#close()
* @see #create()
@@ -544,7 +544,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* from this builder, if the file doesn't exist yet, and maps its off-heap memory to the file.
* This method is equivalent to {@link #createOrRecoverPersistedTo(File, boolean)
* createOrRecoverPersistedTo(file, true)}.
*
* <p>
* <p><b>This method couldn't be used, if the Chronicle Map was created using an older version
* of the Chronicle Map library, and then {@code createOrRecoverPersistedTo()} is called with
* a newer version of the Chronicle Map library.</b> In this case, {@link
@@ -553,11 +553,11 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
*
* @param file the persistence file for existing of future hash container
* @return a {@code ChronicleHash} instance, mapped to the given instance
* @throws NullPointerException if the given file is null
* @throws IOException if any IO error occurs on reading data from the file, or related to
* off-heap memory allocation or file mapping, or establishing replication connections. Probably
* the file is corrupted on OS level, and should be recovered on that level first, before
* calling this procedure.
* @throws NullPointerException if the given file is null
* @throws IOException if any IO error occurs on reading data from the file, or related to
* off-heap memory allocation or file mapping, or establishing replication connections. Probably
* the file is corrupted on OS level, and should be recovered on that level first, before
* calling this procedure.
* @throws ChronicleHashRecoveryFailedException if recovery is impossible
* @see #createPersistedTo(File)
* @see #createOrRecoverPersistedTo(File, boolean)
@@ -572,23 +572,23 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* In other words, this methods behaves like {@link #createPersistedTo(File)}, if the given
* file doesn't exist, and {@link #recoverPersistedTo(File, boolean)
* recoverPersistedTo(file, sameLibraryVersion)}, if the file exists.
*
* <p>
* <p>The difference between this method and {@link #createOrRecoverPersistedTo(File, boolean,
* ChronicleHashCorruption.Listener)} is that this method just logs the encountered corruptions,
* instead of passing them to the specified corruption listener.
*
* @param file the persistence file for existing of future hash container
* @param file the persistence file for existing of future hash container
* @param sameLibraryVersion if this builder is configured with the same configurations, as the
* builder, which created the Chronicle Map in the given file initially, and <b>the same version
* of the Chronicle Map library was used</b>. In this case, the header of the file is overridden
* (with presumably the same configurations), protecting from {@link
* ChronicleHashRecoveryFailedException}, if the header is corrupted.
* builder, which created the Chronicle Map in the given file initially, and <b>the same version
* of the Chronicle Map library was used</b>. In this case, the header of the file is overridden
* (with presumably the same configurations), protecting from {@link
* ChronicleHashRecoveryFailedException}, if the header is corrupted.
* @return a {@code ChronicleHash} instance, mapped to the given instance
* @throws NullPointerException if the given file is null
* @throws IOException if any IO error occurs on reading data from the file, or related to
* off-heap memory allocation or file mapping, or establishing replication connections. Probably
* the file is corrupted on OS level, and should be recovered on that level first, before
* calling this procedure.
* @throws NullPointerException if the given file is null
* @throws IOException if any IO error occurs on reading data from the file, or related to
* off-heap memory allocation or file mapping, or establishing replication connections. Probably
* the file is corrupted on OS level, and should be recovered on that level first, before
* calling this procedure.
* @throws ChronicleHashRecoveryFailedException if recovery is impossible
* @see #createPersistedTo(File)
* @see #recoverPersistedTo(File, boolean)
@@ -603,23 +603,23 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* file doesn't exist, and {@link
* #recoverPersistedTo(File, boolean, ChronicleHashCorruption.Listener)
* recoverPersistedTo(file, sameLibraryVersion, corruptionListener)}, if the file exists.
*
* <p>
* <p>If this procedure encounters corruptions, it fixes them (<i>recovers</i> from them) and
* notifies the provided corruption listener with the details about the corruption. See the
* documentation for {@link ChronicleHashCorruption} for more information.
*
* @param file the persistence file for existing of future hash container
* @param file the persistence file for existing of future hash container
* @param sameLibraryVersion if this builder is configured with the same configurations, as the
* builder, which created the Chronicle Map in the given file initially, and <b>the same version
* of the Chronicle Map library was used</b>. In this case, the header of the file is overridden
* (with presumably the same configurations), protecting from {@link
* ChronicleHashRecoveryFailedException}, if the header is corrupted.
* builder, which created the Chronicle Map in the given file initially, and <b>the same version
* of the Chronicle Map library was used</b>. In this case, the header of the file is overridden
* (with presumably the same configurations), protecting from {@link
* ChronicleHashRecoveryFailedException}, if the header is corrupted.
* @return a {@code ChronicleHash} instance, mapped to the given instance
* @throws NullPointerException if the given file or corruptionListener is null
* @throws IOException if any IO error occurs on reading data from the file, or related to
* off-heap memory allocation or file mapping, or establishing replication connections. Probably
* the file is corrupted on OS level, and should be recovered on that level first, before
* calling this procedure.
* @throws NullPointerException if the given file or corruptionListener is null
* @throws IOException if any IO error occurs on reading data from the file, or related to
* off-heap memory allocation or file mapping, or establishing replication connections. Probably
* the file is corrupted on OS level, and should be recovered on that level first, before
* calling this procedure.
* @throws ChronicleHashRecoveryFailedException if recovery is impossible
* @see #createOrRecoverPersistedTo(File, boolean)
* @see #recoverPersistedTo(File, boolean)
@@ -637,11 +637,11 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* Chronicle Hash memory), or a sudden power loss, or a file corruption (that, in addition to
* the already mentioned consequences, might lead to data corruption, i. e. presence of entries
* which were never put into the Chronicle Hash).
*
* <p>
* <p>This method, unlike {@link #createPersistedTo(File)} or {@link
* #createOrRecoverPersistedTo(File, boolean)} methods, expects that the given file already
* exists.
*
* <p>
* <p>"Recovery" of the hash container is changing the memory of the data structure so that
* after the recovery the hash container is in some correct state: with "clean" locks, coherent
* entry counters, not containing provably corrupt entries, etc. <i>If {@link
@@ -650,17 +650,17 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* it assumes the entry is corrupt and deletes it from the Chronicle Hash.</i> See the
* <a href="https://github.com/OpenHFT/Chronicle-Map#recovery">Recovery section</a> in the
* Chronicle Map tutorial for more information.
*
* <p>
* <p>The difference between this method and {@link #recoverPersistedTo(File, boolean,
* ChronicleHashCorruption.Listener)} is that this method just logs the encountered corruptions,
* instead of passing them to the specified corruption listener.
*
* <p>
* <p>At the moment this method is called and executed, no other thread or process should be
* mapping to the given file, and trying to access the given file. Otherwise the outcomes of
* the {@code recoverPersistedTo()} call, as well as the behaviour of the concurrent thread or
* process, accessing the same Chronicle Map, are unspecified: exception or error could be
* thrown, the Chronicle Map persisted to the given file could be further corrupted.
*
* <p>
* <p>It is strongly recommended to configure this builder with the same configurations, as
* the builder, that created the given file for the first time, and pass {@code true} as the
* {@code sameBuilderConfigAndLibraryVersion} argument <b>(another requirement is running
@@ -670,19 +670,19 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* further. Fortunately, the header should never be corrupted on an "ordinary" process
* crash/termination or power loss, only on direct file corruption.
*
* @param file a hash container was mapped to the given file
* @param file a hash container was mapped to the given file
* @param sameBuilderConfigAndLibraryVersion if this builder is configured with the same
* configurations, as the builder, which created the file (the persisted Chronicle Hash
* instance) for the first time, and <b>with the same version of the Chronicle Map library</b>.
* In this case, the header of the file is overridden (with presumably the same configurations),
* protecting from {@link ChronicleHashRecoveryFailedException}, if the header is corrupted.
* configurations, as the builder, which created the file (the persisted Chronicle Hash
* instance) for the first time, and <b>with the same version of the Chronicle Map library</b>.
* In this case, the header of the file is overridden (with presumably the same configurations),
* protecting from {@link ChronicleHashRecoveryFailedException}, if the header is corrupted.
* @return a recovered Chronicle Hash instance, mapped to the given file
* @throws NullPointerException if the given file is null
* @throws FileNotFoundException if the file doesn't exist
* @throws IOException if any IO error occurs on reading data from the file, or related to
* off-heap memory allocation or file mapping, or establishing replication connections. Probably
* the file is corrupted on OS level, and should be recovered on that level first, before
* calling this procedure.
* @throws NullPointerException if the given file is null
* @throws FileNotFoundException if the file doesn't exist
* @throws IOException if any IO error occurs on reading data from the file, or related to
* off-heap memory allocation or file mapping, or establishing replication connections. Probably
* the file is corrupted on OS level, and should be recovered on that level first, before
* calling this procedure.
* @throws ChronicleHashRecoveryFailedException if recovery is impossible
* @see #createOrRecoverPersistedTo(File, boolean)
* @see #createPersistedTo(File)
@@ -698,11 +698,11 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* Chronicle Hash memory), or a sudden power loss, or a file corruption (that, in addition to
* the already mentioned consequences, might lead to data corruption, i. e. presence of entries
* which were never put into the Chronicle Hash).
*
* <p>
* <p>This method, unlike {@link #createPersistedTo(File)} or {@link
* #createOrRecoverPersistedTo(File, boolean, ChronicleHashCorruption.Listener)} methods,
* expects that the given file already exists.
*
* <p>
* <p>"Recovery" of the hash container is changing the memory of the data structure so that
* after the recovery the hash container is in some correct state: with "clean" locks, coherent
* entry counters, not containing provably corrupt entries, etc. <i>If {@link
@@ -711,30 +711,30 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
* it assumes the entry is corrupt and deletes it from the Chronicle Hash.</i> See the
* <a href="https://github.com/OpenHFT/Chronicle-Map#recovery">Recovery section</a> in the
* Chronicle Map tutorial for more information.
*
* <p>
* <p>If this procedure encounters corruptions, it fixes them (<i>recovers</i> from them) and
* notifies the provided corruption listener with the details about the corruption. See the
* documentation for {@link ChronicleHashCorruption} for more information.
*
* <p>
* <p>At the moment this method is called and executed, no other thread or process should be
* mapping to the given file, and trying to access the given file. Otherwise the outcomes of
* the {@code recoverPersistedTo()} call, as well as the behaviour of the concurrent thread or
* process, accessing the same Chronicle Map, are unspecified: exception or error could be
* thrown, the Chronicle Map persisted to the given file could be further corrupted.
*
* @param file a hash container was mapped to the given file
* @param file a hash container was mapped to the given file
* @param sameBuilderConfigAndLibraryVersion if this builder is configured with the same
* configurations, as the builder, which created the file (the persisted Chronicle Hash
* instance) for the first time, and <b>with the same version of the Chronicle Map library</b>.
* In this case, the header of the file is overridden (with presumably the same configurations),
* protecting from {@link ChronicleHashRecoveryFailedException}, if the header is corrupted.
* configurations, as the builder, which created the file (the persisted Chronicle Hash
* instance) for the first time, and <b>with the same version of the Chronicle Map library</b>.
* In this case, the header of the file is overridden (with presumably the same configurations),
* protecting from {@link ChronicleHashRecoveryFailedException}, if the header is corrupted.
* @return a recovered Chronicle Hash instance, mapped to the given file
* @throws NullPointerException if the given file or corruptionListener is null
* @throws FileNotFoundException if the file doesn't exist
* @throws IOException if any IO error occurs on reading data from the file, or related to
* off-heap memory allocation or file mapping, or establishing replication connections. Probably
* the file is corrupted on OS level, and should be recovered on that level first, before
* calling this procedure.
* @throws NullPointerException if the given file or corruptionListener is null
* @throws FileNotFoundException if the file doesn't exist
* @throws IOException if any IO error occurs on reading data from the file, or related to
* off-heap memory allocation or file mapping, or establishing replication connections. Probably
* the file is corrupted on OS level, and should be recovered on that level first, before
* calling this procedure.
* @throws ChronicleHashRecoveryFailedException if recovery is impossible
* @see #recoverPersistedTo(File, boolean)
* @see #createOrRecoverPersistedTo(File, boolean, ChronicleHashCorruption.Listener)