Class DataStoreManager

java.lang.Object
com.ultikits.ultitools.manager.DataStoreManager

@Internal public class DataStoreManager extends Object
Data store manager.
  • Field Details

    • dataMap

      private static final Map<String,DataStore> dataMap
      Registered stores by type. A ConcurrentHashMap because getDatastore(String) reads it without the writers' lock (#515): a plain HashMap read during a writer's resize could miss a present key, and nothing ordered the read after the write.
  • Constructor Details

    • DataStoreManager

      public DataStoreManager()
  • Method Details

    • register

      public static void register(DataStore dataStore)
      Register data store.
      Parameters:
      dataStore - Data store
    • unregister

      public static void unregister(DataStore dataStore)
      Unregister data store.
      Parameters:
      dataStore - Data store
    • close

      public static void close()
      Unregister all data stores.
    • getDatastore

      public static DataStore getDatastore(String type)
      Get data store. If the data store does not exist, it will return the default Json store.
      Parameters:
      type - Data store type
      Returns:
      Data store
    • reportBackendSelection

      public static void reportBackendSelection(Logger logger, String configured, boolean mysqlEnabled, boolean mysqlAvailable, String actual)
      Report at SEVERE level that the data store actually in use is not the configured one. When the configured and actual types disagree, writes what config asked for, what is actually in use, and why into the log.

      The fallback itself is silent: getDatastore(String) falls back to json when it cannot find the requested type, the server starts normally, and what an operator actually sees is "the server came up but all the player data is gone". The INFO-level "datasource: json" line in the startup banner does not solve this -- it only reports the actual value, never mentioning that config asked for something else. See issue #183.

      Produces no log at all when config and actual agree (including the default case where datasource.type is not configured).

      Parameters:
      logger - Logger to write to
      configured - Configured datasource.type, may be null
      mysqlEnabled - Whether mysql.enable is true
      mysqlAvailable - Whether the MySQL data source was actually created
      actual - Store type actually in use
    • localize

      private static String localize(String text)
      Goes through i18n, but must not let that break the diagnostic itself. This path only runs once something has already gone wrong, so falling back to the original text when the language dictionary is unavailable is better than throwing an NPE.