Package sync

Class SyncMultiTypeWrapper

java.lang.Object
sync.SyncMultiTypeWrapper

public class SyncMultiTypeWrapper
extends java.lang.Object
An intensive test of multi-threading using MultiTypeWrapper as the test subject. This primarily tests the functionality of the InstanceTracker class and its multi-threading synchronization capabilities. The test intentionally tries to create race conditions and deadlock by spinning up thousands of threads all trying to access the same two instancesTrackers for MultiTypeWrapper.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static org.apache.logging.log4j.Logger logger
    The constant logger.
    static int RANDOM_INSTANCES
    The constant RANDOM_INSTANCES.
    static int RANDOM_INVALID_INSTANCES
    The constant RANDOM_INVALID_INSTANCES.
    static java.util.List<Lambda0<java.lang.Object>> RANDOM_LAMBDAS
    The constant RANDOM_LAMBDAS.
    static int THREADS
    The constant THREADS.
    static int WARM_UP_ITERATIONS
    The constant WARM_UP_ITERATIONS.
  • Constructor Summary

    Constructors 
    Constructor Description
    SyncMultiTypeWrapper​(Lambda0<java.util.Map<java.lang.String,​java.lang.Object>> both, Lambda0<java.util.Map<java.lang.String,​java.lang.Object>> from, Lambda0<java.util.Map<java.lang.Object,​java.lang.String>> to, Lambda0<java.util.Map<java.lang.Class,​org.apache.logging.log4j.Level>> loggingLevels)
    Instantiates a new Sync multi type wrapper with the provided params
  • Method Summary

    Modifier and Type Method Description
    static java.util.Collection getTestParams()
    Gets test params.
    void logCounter()
    Logs the number of MultiTypeWrappers that were instantiated during the test
    static <K,​ V> java.util.LinkedHashMap<K,​V> randomizeMapOrder​(java.util.Map<K,​V> orig)
    Randomize map order linked hash map.
    void restoreDefaultLoggingLevels()
    Restore default logging levels.
    void run()
    Starts all the test threads, and then waits for them to finish.
    void runWarmUps()
    Run single-threaded warm ups, to ensure the JVM is prepared for the test
    void setTargetLoggingLevels()
    Sets target logging levels, to prevent excessive output to the console

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SyncMultiTypeWrapper

      public SyncMultiTypeWrapper​(Lambda0<java.util.Map<java.lang.String,​java.lang.Object>> both, Lambda0<java.util.Map<java.lang.String,​java.lang.Object>> from, Lambda0<java.util.Map<java.lang.Object,​java.lang.String>> to, Lambda0<java.util.Map<java.lang.Class,​org.apache.logging.log4j.Level>> loggingLevels)
      Instantiates a new Sync multi type wrapper with the provided params
      Parameters:
      both - the both
      from - the from
      to - the to
      loggingLevels - the logging levels
  • Method Details

    • randomizeMapOrder

      public static <K,​ V> java.util.LinkedHashMap<K,​V> randomizeMapOrder​(java.util.Map<K,​V> orig)
      Randomize map order linked hash map.
      Type Parameters:
      K - the type parameter
      V - the type parameter
      Parameters:
      orig - the orig
      Returns:
      the linked hash map
    • getTestParams

      public static java.util.Collection getTestParams()
      Gets test params.
      Returns:
      the test params
    • setTargetLoggingLevels

      public void setTargetLoggingLevels()
      Sets target logging levels, to prevent excessive output to the console
    • restoreDefaultLoggingLevels

      public void restoreDefaultLoggingLevels()
      Restore default logging levels.
    • logCounter

      public void logCounter()
      Logs the number of MultiTypeWrappers that were instantiated during the test
    • run

      public void run() throws java.lang.InterruptedException
      Starts all the test threads, and then waits for them to finish.
      Throws:
      java.lang.InterruptedException - if there was an issue waiting for one of the threads to finish
    • runWarmUps

      public void runWarmUps()
      Run single-threaded warm ups, to ensure the JVM is prepared for the test