Class Verifier
- java.lang.Object
-
- org.lmdbjava.Verifier
-
public final class Verifier extends Object implements Callable<Long>
Verifies correct operation of LmdbJava in a given environment.Due to the large variety of operating systems and Java platforms typically used with LmdbJava, this class provides a convenient verification of correct operating behavior through a potentially long duration set of tests that carefully verify correct storage and retrieval of successively larger database entries.
The verifier currently operates by incrementing a
long
identifier that deterministically maps to a givenDbi
and value size. The key is simply thelong
identifier. The value commences with a CRC that includes the identifier and the random bytes of the value. Each entry is written out, and then the prior entry is retrieved using its key. The prior entry's value is evaluated for accuracy and then deleted. Transactions are committed in batches to ensure successive transactions correctly retrieve the results of earlier transactions.Please note the verification approach may be modified in the future.
If an exception is raised by this class, please:
- Ensure the
Env
passed at construction time complies with the requirements specified atVerifier(org.lmdbjava.Env)
- Attempt to use a different file system to store the database (be especially careful to not use network file systems, remote file systems, read-only file systems etc)
- Record the full exception message and stack trace, then run the verifier again to see if it fails at the same or a different point
- Raise a ticket on the LmdbJava Issue Tracker that confirms the above details along with the failing operating system and Java version
- Ensure the
-
-
Field Summary
Fields Modifier and Type Field Description static int
DBI_COUNT
Number of DBIs the created environment should allow.
-
Constructor Summary
Constructors Constructor Description Verifier(Env<ByteBuffer> env)
Create an instance of the verifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Long
call()
Run the verifier untilstop()
is called or an exception occurs.long
runFor(long duration, TimeUnit unit)
Execute the verifier for the given duration.
-
-
-
Field Detail
-
DBI_COUNT
public static final int DBI_COUNT
Number of DBIs the created environment should allow.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Verifier
public Verifier(Env<ByteBuffer> env)
Create an instance of the verifier.The caller must provide an
Env
configured with a suitable local storage location, maximum DBIs equal toDBI_COUNT
, and a map size large enough to accommodate the intended verification duration.ALL EXISTING DATA IN THE DATABASE WILL BE DELETED. The caller must not interact with the
Env
in any way (eg querying, transactions etc) while the verifier is executing.- Parameters:
env
- target that complies with the above requirements (required)
-
-
Method Detail
-
call
public Long call()
Run the verifier untilstop()
is called or an exception occurs.Successful return of this method indicates no faults were detected. If any fault was detected the exception message will detail the exact point that the fault was encountered.
-
runFor
public long runFor(long duration, TimeUnit unit)
Execute the verifier for the given duration.This provides a simple way to execute the verifier for those applications which do not wish to manage threads directly.
- Parameters:
duration
- amount of time to executeunit
- units used to express the duration- Returns:
- number of database rows successfully verified
-
-