Package com.ultikits.ultitools.manager
Class DataStoreManager
java.lang.Object
com.ultikits.ultitools.manager.DataStoreManager
Data store manager.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclose()Unregister all data stores.static DataStoregetDatastore(String type) Get data store.private static StringGoes through i18n, but must not let that break the diagnostic itself.static voidRegister data store.static voidreportBackendSelection(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.static voidunregister(DataStore dataStore) Unregister data store.
-
Field Details
-
dataMap
Registered stores by type. AConcurrentHashMapbecausegetDatastore(String)reads it without the writers' lock (#515): a plainHashMapread 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
Register data store.- Parameters:
dataStore- Data store
-
unregister
Unregister data store.- Parameters:
dataStore- Data store
-
close
public static void close()Unregister all data stores. -
getDatastore
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.typeis not configured).- Parameters:
logger- Logger to write toconfigured- Configureddatasource.type, may be nullmysqlEnabled- Whethermysql.enableis truemysqlAvailable- Whether the MySQL data source was actually createdactual- Store type actually in use
-
localize
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.
-