server: database improves:

- fixed broken database in some use cases (example: AI and choose name dialog, related to #11285);
- added docs and debug tools for sql queries, caches and memory analyse (see DebugUtil);
- refactor code to use shared settings;
- deleted outdated and un-used code (db logs, stats, etc);
This commit is contained in:
Oleg Agafonov 2024-07-18 21:22:10 +04:00
parent c448612c97
commit bf3f26ccc1
18 changed files with 376 additions and 394 deletions

View file

@ -1,59 +0,0 @@
package mage.utils.properties;
import org.apache.log4j.Logger;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* @author noxx
*/
public final class PropertiesUtil {
private static final Logger logger = Logger.getLogger(PropertiesUtil.class);
private static final String LOG_JDBC_URL = "jdbc:h2:file:./db/mage.h2;AUTO_SERVER=TRUE";
private static final String FEEDBACK_JDBC_URL = "jdbc:h2:file:./db/feedback.h2;AUTO_SERVER=TRUE";
private static Properties properties = new Properties();
static {
try (InputStream in = PropertiesUtil.class.getResourceAsStream("/xmage.properties")) {
if(in != null) {
properties.load(in);
} else {
logger.warn("No xmage.properties were found");
}
} catch (FileNotFoundException fnfe) {
logger.warn("No xmage.properties were found on classpath");
} catch (IOException e) {
logger.error("Couldn't load properties");
e.printStackTrace();
}
}
/**
* Hide constructor
*/
private PropertiesUtil() {
}
public static String getDBLogUrl () {
String url = properties.getProperty(PropertyKeys.KEY_DB_LOG_URL, LOG_JDBC_URL);
if (url != null) {
return url.trim();
}
return null;
}
public static String getDBFeedbackUrl () {
String url = properties.getProperty(PropertyKeys.KEY_DB_FEEDBACK_URL, FEEDBACK_JDBC_URL);
if (url != null) {
return url.trim();
}
return null;
}
}

View file

@ -1,10 +0,0 @@
package mage.utils.properties;
/**
* @author noxx
*/
public final class PropertyKeys {
public static final String KEY_DB_LOG_URL = "db.log.url";
public static final String KEY_DB_FEEDBACK_URL = "db.feedback.url";
}