Package org.lmdbjava

Class Verifier

  • All Implemented Interfaces:
    Callable<Long>

    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 given Dbi and value size. The key is simply the long 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:

    1. Ensure the Env passed at construction time complies with the requirements specified at Verifier(org.lmdbjava.Env)
    2. 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)
    3. 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
    4. Raise a ticket on the LmdbJava Issue Tracker that confirms the above details along with the failing operating system and Java version
    • 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 to DBI_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 until stop() 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.

        Specified by:
        call in interface Callable<Long>
        Returns:
        number of database rows successfully verified
      • 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 execute
        unit - units used to express the duration
        Returns:
        number of database rows successfully verified