mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 12:07:35 +01:00
APF 2.0.2
Fix Tests Debug Messages & Benchmarks addHelp method override
This commit is contained in:
parent
0269dde382
commit
3925a99ead
@ -28,7 +28,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.djrapitops</groupId>
|
<groupId>com.djrapitops</groupId>
|
||||||
<artifactId>abstract-plugin-framework</artifactId>
|
<artifactId>abstract-plugin-framework</artifactId>
|
||||||
<version>2.0.1</version>
|
<version>2.0.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- SoftDepended Plugins-->
|
<!-- SoftDepended Plugins-->
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package main.java.com.djrapitops.plan;
|
package main.java.com.djrapitops.plan;
|
||||||
|
|
||||||
|
import com.djrapitops.plugin.utilities.log.DebugInfo;
|
||||||
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,6 +58,48 @@ public class Log {
|
|||||||
Plan.getInstance().getPluginLogger().debug(message);
|
Plan.getInstance().getPluginLogger().debug(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for logging larger debug complexes.
|
||||||
|
*
|
||||||
|
* @param task complex this debug message is a part of.
|
||||||
|
* @param message message
|
||||||
|
* @return full debug complex so far.
|
||||||
|
*/
|
||||||
|
public static DebugInfo debug(String task, String message) {
|
||||||
|
DebugInfo debug = getDebug(task);
|
||||||
|
debug.addLine(message, MiscUtils.getTime());
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for logging larger debug complexes.
|
||||||
|
*
|
||||||
|
* @param task complex to get
|
||||||
|
* @return full debug complex so far.
|
||||||
|
*/
|
||||||
|
public static DebugInfo getDebug(String task) {
|
||||||
|
return Plan.getInstance().getPluginLogger().getDebug(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs the full debug complex to the debug log.
|
||||||
|
*
|
||||||
|
* @param task complex to log.
|
||||||
|
*/
|
||||||
|
public static void logDebug(String task) {
|
||||||
|
getDebug(task).toLog();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs the full debug complex to the debug log with an execution time.
|
||||||
|
*
|
||||||
|
* @param task complex to log.
|
||||||
|
* @param time execution time.
|
||||||
|
*/
|
||||||
|
public static void logDebug(String task, long time) {
|
||||||
|
getDebug(task).toLog(time);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs trace of caught Exception to Errors.txt and notifies on console.
|
* Logs trace of caught Exception to Errors.txt and notifies on console.
|
||||||
*
|
*
|
||||||
@ -80,7 +125,10 @@ public class Log {
|
|||||||
*
|
*
|
||||||
* @param message Message to log to Errors.txt [timestamp] Message
|
* @param message Message to log to Errors.txt [timestamp] Message
|
||||||
* @param filename Name of the file to write to.
|
* @param filename Name of the file to write to.
|
||||||
|
* @deprecated Should no longer be used, may break other log handling mechanisms.
|
||||||
|
* If exception requires additional information it should be placed in the source string.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void toLog(String message, String filename) {
|
public static void toLog(String message, String filename) {
|
||||||
Plan.getInstance().getPluginLogger().toLog(message, filename);
|
Plan.getInstance().getPluginLogger().toLog(message, filename);
|
||||||
}
|
}
|
||||||
@ -89,7 +137,9 @@ public class Log {
|
|||||||
* Used to get the name for the error log file.
|
* Used to get the name for the error log file.
|
||||||
*
|
*
|
||||||
* @return Name of the error log file.
|
* @return Name of the error log file.
|
||||||
|
* @deprecated Should no longer be used, Errors.txt is handled by a separate class.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static String getErrorsFilename() {
|
public static String getErrorsFilename() {
|
||||||
return Plan.getInstance().getPluginLogger().getErrorsFilename();
|
return Plan.getInstance().getPluginLogger().getErrorsFilename();
|
||||||
}
|
}
|
||||||
|
@ -122,20 +122,20 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
// Initializes BukkitPlugin variables, Checks version & Logs the debug header
|
// Initializes BukkitPlugin variables, Checks version & Logs the debug header
|
||||||
super.onEnableDefaultTasks();
|
super.onEnableDefaultTasks();
|
||||||
|
|
||||||
processStatus().startExecution("Enable");
|
Benchmark.start("Enable");
|
||||||
|
|
||||||
initLocale();
|
initLocale();
|
||||||
Benchmark.start("Enable: Reading server variables");
|
Benchmark.start("Reading server variables");
|
||||||
serverVariableHolder = new ServerVariableHolder(getServer());
|
serverVariableHolder = new ServerVariableHolder(getServer());
|
||||||
Benchmark.stop("Enable: Reading server variables");
|
Benchmark.stop("Enable", "Reading server variables");
|
||||||
|
|
||||||
Benchmark.start("Enable: Copy default config");
|
Benchmark.start("Copy default config");
|
||||||
getConfig().options().copyDefaults(true);
|
getConfig().options().copyDefaults(true);
|
||||||
getConfig().options().header(Phrase.CONFIG_HEADER.toString());
|
getConfig().options().header(Phrase.CONFIG_HEADER.toString());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
Benchmark.stop("Enable: Copy default config");
|
Benchmark.stop("Enable", "Copy default config");
|
||||||
|
|
||||||
Benchmark.start("Enable: Init Database");
|
Benchmark.start("Init Database");
|
||||||
Log.info(Phrase.DB_INIT.toString());
|
Log.info(Phrase.DB_INIT.toString());
|
||||||
if (Check.ErrorIfFalse(initDatabase(), Phrase.DB_FAILURE_DISABLE.toString())) {
|
if (Check.ErrorIfFalse(initDatabase(), Phrase.DB_FAILURE_DISABLE.toString())) {
|
||||||
Log.info(Phrase.DB_ESTABLISHED.parse(db.getConfigName()));
|
Log.info(Phrase.DB_ESTABLISHED.parse(db.getConfigName()));
|
||||||
@ -143,23 +143,23 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
disablePlugin();
|
disablePlugin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Benchmark.stop("Enable: Init Database");
|
Benchmark.stop("Enable", "Init Database");
|
||||||
|
|
||||||
Benchmark.start("Enable: Init DataCache");
|
Benchmark.start("Init DataCache");
|
||||||
this.handler = new DataCacheHandler(this);
|
this.handler = new DataCacheHandler(this);
|
||||||
this.inspectCache = new InspectCacheHandler(this);
|
this.inspectCache = new InspectCacheHandler(this);
|
||||||
this.analysisCache = new AnalysisCacheHandler(this);
|
this.analysisCache = new AnalysisCacheHandler(this);
|
||||||
Benchmark.stop("Enable: Init DataCache");
|
Benchmark.stop("Enable", "Init DataCache");
|
||||||
|
|
||||||
super.getRunnableFactory().createNew(new TPSCountTimer(this)).runTaskTimer(1000, TimeAmount.SECOND.ticks());
|
super.getRunnableFactory().createNew(new TPSCountTimer(this)).runTaskTimer(1000, TimeAmount.SECOND.ticks());
|
||||||
registerListeners();
|
registerListeners();
|
||||||
|
|
||||||
this.api = new API(this);
|
this.api = new API(this);
|
||||||
Benchmark.start("Enable: Handle Reload");
|
Benchmark.start("Handle Reload");
|
||||||
handler.handleReload();
|
handler.handleReload();
|
||||||
Benchmark.stop("Enable: Handle Reload");
|
Benchmark.stop("Enable", "Handle Reload");
|
||||||
|
|
||||||
Benchmark.start("Enable: Analysis refresh task registration");
|
Benchmark.start("Analysis refresh task registration");
|
||||||
// Analysis refresh settings
|
// Analysis refresh settings
|
||||||
boolean bootAnalysisIsEnabled = Settings.ANALYSIS_REFRESH_ON_ENABLE.isTrue();
|
boolean bootAnalysisIsEnabled = Settings.ANALYSIS_REFRESH_ON_ENABLE.isTrue();
|
||||||
int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber();
|
int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber();
|
||||||
@ -172,9 +172,9 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
if (analysisRefreshTaskIsEnabled) {
|
if (analysisRefreshTaskIsEnabled) {
|
||||||
startAnalysisRefreshTask(analysisRefreshMinutes);
|
startAnalysisRefreshTask(analysisRefreshMinutes);
|
||||||
}
|
}
|
||||||
Benchmark.stop("Enable: Analysis refresh task registration");
|
Benchmark.stop("Enable", "Analysis refresh task registration");
|
||||||
|
|
||||||
Benchmark.start("Enable: WebServer Initialization");
|
Benchmark.start("WebServer Initialization");
|
||||||
// Data view settings
|
// Data view settings
|
||||||
boolean webserverIsEnabled = Settings.WEBSERVER_ENABLED.isTrue();
|
boolean webserverIsEnabled = Settings.WEBSERVER_ENABLED.isTrue();
|
||||||
boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||||
@ -196,20 +196,20 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) {
|
if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) {
|
||||||
Log.infoColor(Phrase.NOTIFY_EMPTY_IP.toString());
|
Log.infoColor(Phrase.NOTIFY_EMPTY_IP.toString());
|
||||||
}
|
}
|
||||||
Benchmark.stop("Enable: WebServer Initialization");
|
Benchmark.stop("Enable", "WebServer Initialization");
|
||||||
|
|
||||||
registerCommand(new PlanCommand(this));
|
registerCommand(new PlanCommand(this));
|
||||||
|
|
||||||
Benchmark.start("Enable: Hook to 3rd party plugins");
|
Benchmark.start("Hook to 3rd party plugins");
|
||||||
hookHandler = new HookHandler(this);
|
hookHandler = new HookHandler(this);
|
||||||
Benchmark.stop("Enable: Hook to 3rd party plugins");
|
Benchmark.stop("Enable", "Hook to 3rd party plugins");
|
||||||
|
|
||||||
BStats bStats = new BStats(this);
|
BStats bStats = new BStats(this);
|
||||||
bStats.registerMetrics();
|
bStats.registerMetrics();
|
||||||
|
|
||||||
Log.debug("Verbose debug messages are enabled.");
|
Log.debug("Verbose debug messages are enabled.");
|
||||||
|
Log.logDebug("Enable", Benchmark.stop("Enable", "Enable"));
|
||||||
Log.info(Phrase.ENABLED.toString());
|
Log.info(Phrase.ENABLED.toString());
|
||||||
processStatus().finishExecution("Enable");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -248,7 +248,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
Benchmark.start("Enable: Register Listeners");
|
Benchmark.start("Register Listeners");
|
||||||
registerListener(new PlanPlayerListener(this));
|
registerListener(new PlanPlayerListener(this));
|
||||||
boolean chatListenerIsEnabled = Check.isTrue(Settings.GATHERCHAT.isTrue(), Phrase.NOTIFY_DISABLED_CHATLISTENER.toString());
|
boolean chatListenerIsEnabled = Check.isTrue(Settings.GATHERCHAT.isTrue(), Phrase.NOTIFY_DISABLED_CHATLISTENER.toString());
|
||||||
boolean commandListenerIsEnabled = Check.isTrue(Settings.GATHERCOMMANDS.isTrue(), Phrase.NOTIFY_DISABLED_COMMANDLISTENER.toString());
|
boolean commandListenerIsEnabled = Check.isTrue(Settings.GATHERCOMMANDS.isTrue(), Phrase.NOTIFY_DISABLED_COMMANDLISTENER.toString());
|
||||||
@ -269,7 +269,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
registerListener(new PlanDeathEventListener(this));
|
registerListener(new PlanDeathEventListener(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.stop("Enable: Register Listeners");
|
Benchmark.stop("Register Listeners");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -288,7 +288,6 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
|
|
||||||
for (Database database : databases) {
|
for (Database database : databases) {
|
||||||
String databaseType = database.getConfigName().toLowerCase().trim();
|
String databaseType = database.getConfigName().toLowerCase().trim();
|
||||||
Log.debug(databaseType + ": " + Verify.equalsIgnoreCase(dbType, databaseType));
|
|
||||||
if (Verify.equalsIgnoreCase(dbType, databaseType)) {
|
if (Verify.equalsIgnoreCase(dbType, databaseType)) {
|
||||||
this.db = database;
|
this.db = database;
|
||||||
break;
|
break;
|
||||||
@ -304,7 +303,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startAnalysisRefreshTask(int everyXMinutes) throws IllegalStateException {
|
private void startAnalysisRefreshTask(int everyXMinutes) throws IllegalStateException {
|
||||||
Benchmark.start("Enable: Schedule PeriodicAnalysisTask");
|
Benchmark.start("Schedule PeriodicAnalysisTask");
|
||||||
if (everyXMinutes <= 0) {
|
if (everyXMinutes <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -317,11 +316,11 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskTimerAsynchronously(everyXMinutes * TimeAmount.MINUTE.ticks(), everyXMinutes * TimeAmount.MINUTE.ticks());
|
}).runTaskTimerAsynchronously(everyXMinutes * TimeAmount.MINUTE.ticks(), everyXMinutes * TimeAmount.MINUTE.ticks());
|
||||||
Benchmark.stop("Enable: Schedule PeriodicAnalysisTask");
|
Benchmark.stop("Schedule PeriodicAnalysisTask");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startBootAnalysisTask() throws IllegalStateException {
|
private void startBootAnalysisTask() throws IllegalStateException {
|
||||||
Benchmark.start("Enable: Schedule boot analysis task");
|
Benchmark.start("Schedule boot analysis task");
|
||||||
Log.info(Phrase.ANALYSIS_BOOT_NOTIFY + "");
|
Log.info(Phrase.ANALYSIS_BOOT_NOTIFY + "");
|
||||||
ITask bootAnalysisTask = getRunnableFactory().createNew("BootAnalysisTask", new AbsRunnable() {
|
ITask bootAnalysisTask = getRunnableFactory().createNew("BootAnalysisTask", new AbsRunnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -333,7 +332,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
}
|
}
|
||||||
}).runTaskLaterAsynchronously(30 * TimeAmount.SECOND.ticks());
|
}).runTaskLaterAsynchronously(30 * TimeAmount.SECOND.ticks());
|
||||||
bootAnalysisTaskID = bootAnalysisTask.getTaskId();
|
bootAnalysisTaskID = bootAnalysisTask.getTaskId();
|
||||||
Benchmark.stop("Enable: Schedule boot analysis task");
|
Benchmark.stop("Enable", "Schedule boot analysis task");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -367,7 +366,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
String defaultLocale = "Default: EN";
|
String defaultLocale = "Default: EN";
|
||||||
|
|
||||||
String locale = Settings.LOCALE.toString().toUpperCase();
|
String locale = Settings.LOCALE.toString().toUpperCase();
|
||||||
Benchmark.start("Enable: Initializing locale");
|
Benchmark.start("Initializing locale");
|
||||||
File localeFile = new File(getDataFolder(), "locale.txt");
|
File localeFile = new File(getDataFolder(), "locale.txt");
|
||||||
|
|
||||||
String usingLocale;
|
String usingLocale;
|
||||||
@ -441,7 +440,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
* @implNote Removes clutter in the method
|
* @implNote Removes clutter in the method
|
||||||
*/
|
*/
|
||||||
private void stopInitLocale(String usingLocale) {
|
private void stopInitLocale(String usingLocale) {
|
||||||
Benchmark.stop("Enable: Initializing locale");
|
Benchmark.stop("Enable", "Initializing locale");
|
||||||
Log.info("Using locale: " + usingLocale);
|
Log.info("Using locale: " + usingLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,10 +28,10 @@ public class PlanCommand extends TreeCommand<Plan> {
|
|||||||
public PlanCommand(Plan plugin) {
|
public PlanCommand(Plan plugin) {
|
||||||
super(plugin, "plan", CommandType.CONSOLE, "", "", "plan");
|
super(plugin, "plan", CommandType.CONSOLE, "", "", "plan");
|
||||||
super.setDefaultCommand("inspect");
|
super.setDefaultCommand("inspect");
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -44,8 +44,7 @@ public class PlanCommand extends TreeCommand<Plan> {
|
|||||||
sCol + " /plan - List subcommands",
|
sCol + " /plan - List subcommands",
|
||||||
sCol + " /plan <subcommand> ? - in depth help"
|
sCol + " /plan <subcommand> ? - in depth help"
|
||||||
};
|
};
|
||||||
|
return help;
|
||||||
setInDepthHelp(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,10 +36,10 @@ public class AnalyzeCommand extends SubCommand {
|
|||||||
super("analyze, analyse, analysis, a", CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), Phrase.CMD_USG_ANALYZE.parse());
|
super("analyze, analyse, analysis, a", CommandType.CONSOLE, Permissions.ANALYZE.getPermission(), Phrase.CMD_USG_ANALYZE.parse());
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
analysisCache = plugin.getAnalysisCache();
|
analysisCache = plugin.getAnalysisCache();
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -52,8 +52,7 @@ public class AnalyzeCommand extends SubCommand {
|
|||||||
sCol + " /plan status can be used to check status of analysis while it is running.",
|
sCol + " /plan status can be used to check status of analysis while it is running.",
|
||||||
sCol + " Aliases: analyze, analyse, analysis, a"
|
sCol + " Aliases: analyze, analyse, analysis, a"
|
||||||
};
|
};
|
||||||
|
return help;
|
||||||
setInDepthHelp(help);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,10 +42,11 @@ public class InspectCommand extends SubCommand {
|
|||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
inspectCache = plugin.getInspectCache();
|
inspectCache = plugin.getInspectCache();
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -59,7 +60,7 @@ public class InspectCommand extends SubCommand {
|
|||||||
sCol + " Alias: /plan <name>"
|
sCol + " Alias: /plan <name>"
|
||||||
};
|
};
|
||||||
|
|
||||||
super.setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,11 +30,12 @@ public class ListCommand extends SubCommand {
|
|||||||
public ListCommand(Plan plugin) {
|
public ListCommand(Plan plugin) {
|
||||||
super("list, pl", CommandType.CONSOLE, Permissions.INSPECT_OTHER.getPermission(), "List to all cached players", "");
|
super("list, pl", CommandType.CONSOLE, Permissions.INSPECT_OTHER.getPermission(), "List to all cached players", "");
|
||||||
|
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
public String[] addHelp() {
|
||||||
|
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
String sCol = colorScheme.getSecondaryColor();
|
String sCol = colorScheme.getSecondaryColor();
|
||||||
@ -47,7 +48,7 @@ public class ListCommand extends SubCommand {
|
|||||||
sCol + " Alias: /plan pl"
|
sCol + " Alias: /plan pl"
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,10 +25,11 @@ public class ManageCommand extends TreeCommand<Plan> {
|
|||||||
*/
|
*/
|
||||||
public ManageCommand(Plan plugin) {
|
public ManageCommand(Plan plugin) {
|
||||||
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE + "", "plan m");
|
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE + "", "plan m");
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -43,7 +44,7 @@ public class ManageCommand extends TreeCommand<Plan> {
|
|||||||
sCol + " /plan m <subcommand> ? - in depth help"
|
sCol + " /plan m <subcommand> ? - in depth help"
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -37,10 +37,11 @@ public class QuickAnalyzeCommand extends SubCommand {
|
|||||||
super("qanalyze, qanalyse, qanalysis, qa", CommandType.CONSOLE, Permissions.QUICK_ANALYZE.getPermission(), Phrase.CMD_USG_QANALYZE.parse());
|
super("qanalyze, qanalyse, qanalysis, qa", CommandType.CONSOLE, Permissions.QUICK_ANALYZE.getPermission(), Phrase.CMD_USG_QANALYZE.parse());
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
analysisCache = plugin.getAnalysisCache();
|
analysisCache = plugin.getAnalysisCache();
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -54,7 +55,7 @@ public class QuickAnalyzeCommand extends SubCommand {
|
|||||||
sCol + " Aliases: qanalyze, ganalyse, qanalysis, qa"
|
sCol + " Aliases: qanalyze, ganalyse, qanalysis, qa"
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,10 +42,11 @@ public class QuickInspectCommand extends SubCommand {
|
|||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
inspectCache = plugin.getInspectCache();
|
inspectCache = plugin.getInspectCache();
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -59,7 +60,7 @@ public class QuickInspectCommand extends SubCommand {
|
|||||||
sCol + " Alias: /plan qi"
|
sCol + " Alias: /plan qi"
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,10 +35,11 @@ public class RegisterCommand extends SubCommand {
|
|||||||
public RegisterCommand(Plan plugin) {
|
public RegisterCommand(Plan plugin) {
|
||||||
super("register", CommandType.CONSOLE_WITH_ARGUMENTS, "", "Register a user for the webserver", "<password> [name] [access lvl]");
|
super("register", CommandType.CONSOLE_WITH_ARGUMENTS, "", "Register a user for the webserver", "<password> [name] [access lvl]");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -52,7 +53,7 @@ public class RegisterCommand extends SubCommand {
|
|||||||
sCol + " Passwords are hashed with PBKDF2 (64,000 iterations of SHA1) using a cryptographically-random salt."
|
sCol + " Passwords are hashed with PBKDF2 (64,000 iterations of SHA1) using a cryptographically-random salt."
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,10 +33,11 @@ public class SearchCommand extends SubCommand {
|
|||||||
public SearchCommand(Plan plugin) {
|
public SearchCommand(Plan plugin) {
|
||||||
super("search", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.SEARCH.getPermission(), Phrase.CMD_USG_SEARCH.toString(), Phrase.ARG_SEARCH.toString());
|
super("search", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.SEARCH.getPermission(), Phrase.CMD_USG_SEARCH.toString(), Phrase.ARG_SEARCH.toString());
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -49,7 +50,7 @@ public class SearchCommand extends SubCommand {
|
|||||||
sCol + " Example: /plan search 123 - Finds all users with 123 in their name."
|
sCol + " Example: /plan search 123 - Finds all users with 123 in their name."
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,10 +21,11 @@ public class WebUserCommand extends TreeCommand<Plan> {
|
|||||||
public WebUserCommand(Plan plugin, RegisterCommand register) {
|
public WebUserCommand(Plan plugin, RegisterCommand register) {
|
||||||
super(plugin, "webuser, web", CommandType.CONSOLE, Permissions.MANAGE_WEB.getPerm(), "Manage Webusers", "plan web");
|
super(plugin, "webuser, web", CommandType.CONSOLE, Permissions.MANAGE_WEB.getPerm(), "Manage Webusers", "plan web");
|
||||||
commands.add(register);
|
commands.add(register);
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -41,7 +42,7 @@ public class WebUserCommand extends TreeCommand<Plan> {
|
|||||||
sCol + " Alias: /plan web"
|
sCol + " Alias: /plan web"
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,10 +33,11 @@ public class ManageClearCommand extends SubCommand {
|
|||||||
super("clear", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_CLEAR + "", "<DB> [-a]");
|
super("clear", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_CLEAR + "", "<DB> [-a]");
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -50,7 +51,7 @@ public class ManageClearCommand extends SubCommand {
|
|||||||
sCol + " Alias: /plan pl"
|
sCol + " Alias: /plan pl"
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,10 +33,11 @@ public class ManageHotswapCommand extends SubCommand {
|
|||||||
super("hotswap", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_HOTSWAP.toString(), "<DB>");
|
super("hotswap", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_HOTSWAP.toString(), "<DB>");
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -49,7 +50,7 @@ public class ManageHotswapCommand extends SubCommand {
|
|||||||
sCol + " Does not change database if connection fails"
|
sCol + " Does not change database if connection fails"
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,10 +40,11 @@ public class ManageImportCommand extends SubCommand {
|
|||||||
public ManageImportCommand(Plan plugin) {
|
public ManageImportCommand(Plan plugin) {
|
||||||
super("import", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_IMPORT.toString(), Phrase.ARG_IMPORT.toString());
|
super("import", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_IMPORT.toString(), Phrase.ARG_IMPORT.toString());
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -57,7 +58,7 @@ public class ManageImportCommand extends SubCommand {
|
|||||||
sCol + " If a lot of users are not in the database, saving may take a long time."
|
sCol + " If a lot of users are not in the database, saving may take a long time."
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,10 +36,11 @@ public class ManageRemoveCommand extends SubCommand {
|
|||||||
super("remove", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_REMOVE.toString(), Phrase.ARG_PLAYER + " [-a]");
|
super("remove", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_REMOVE.toString(), Phrase.ARG_PLAYER + " [-a]");
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
setHelp(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHelp(Plan plugin) {
|
@Override
|
||||||
|
public String[] addHelp() {
|
||||||
ColorScheme colorScheme = plugin.getColorScheme();
|
ColorScheme colorScheme = plugin.getColorScheme();
|
||||||
|
|
||||||
String mCol = colorScheme.getMainColor();
|
String mCol = colorScheme.getMainColor();
|
||||||
@ -50,7 +51,7 @@ public class ManageRemoveCommand extends SubCommand {
|
|||||||
tCol + " Used to Remove user's data from the active database."
|
tCol + " Used to Remove user's data from the active database."
|
||||||
};
|
};
|
||||||
|
|
||||||
setInDepthHelp(help);
|
return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,7 +23,7 @@ public class WebDeleteCommand extends SubCommand {
|
|||||||
private final Plan plugin;
|
private final Plan plugin;
|
||||||
|
|
||||||
public WebDeleteCommand(Plan plugin) {
|
public WebDeleteCommand(Plan plugin) {
|
||||||
super("delete", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE_WEB.getPerm(), "Delete a webuser", "<username>");
|
super("delete, remove", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE_WEB.getPerm(), "Delete a webuser", "<username>");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,9 +142,9 @@ public class AnalysisData extends RawData {
|
|||||||
final List<RawData> parts = getAllParts();
|
final List<RawData> parts = getAllParts();
|
||||||
parts.forEach(part -> {
|
parts.forEach(part -> {
|
||||||
try {
|
try {
|
||||||
Benchmark.start("Analysis Phase: " + part.getClass().getSimpleName());
|
Benchmark.start(part.getClass().getSimpleName());
|
||||||
part.analyseData();
|
part.analyseData();
|
||||||
Benchmark.stop("Analysis Phase: " + part.getClass().getSimpleName());
|
Benchmark.stop("Analysis", part.getClass().getSimpleName());
|
||||||
if (part.isAnalysed()) {
|
if (part.isAnalysed()) {
|
||||||
addValues(part.getReplaceMap());
|
addValues(part.getReplaceMap());
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,23 @@ public class WebUser {
|
|||||||
return permLevel;
|
return permLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
WebUser webUser = (WebUser) o;
|
||||||
|
|
||||||
|
if (permLevel != webUser.permLevel) return false;
|
||||||
|
if (!user.equals(webUser.user)) return false;
|
||||||
|
return saltedPassHash.equals(webUser.saltedPassHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = user.hashCode();
|
||||||
|
result = 31 * result + saltedPassHash.hashCode();
|
||||||
|
result = 31 * result + permLevel;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,8 +166,7 @@ public class HookHandler {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addReplace.put(source.getPlaceholder(""), "Error occurred: " + e);
|
addReplace.put(source.getPlaceholder(""), "Error occurred: " + e);
|
||||||
Log.error("PluginDataSource caused an exception: " + source.getSourcePlugin());
|
Log.error("PluginDataSource caused an exception: " + source.getSourcePlugin());
|
||||||
Log.toLog("PluginDataSource caused an exception: " + source.getSourcePlugin(), Log.getErrorsFilename());
|
Log.toLog("PluginDataSource " + source.getSourcePlugin(), e);
|
||||||
Log.toLog(this.getClass().getName(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return addReplace;
|
return addReplace;
|
||||||
|
@ -12,6 +12,7 @@ import main.java.com.djrapitops.plan.database.Database;
|
|||||||
import main.java.com.djrapitops.plan.database.tables.*;
|
import main.java.com.djrapitops.plan.database.tables.*;
|
||||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -61,10 +62,9 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws IllegalArgumentException
|
* Starts repeating Async task that maintains the Database connection.
|
||||||
* @throws IllegalStateException
|
|
||||||
*/
|
*/
|
||||||
public void startConnectionPingTask() throws IllegalArgumentException, IllegalStateException {
|
public void startConnectionPingTask() {
|
||||||
// Maintains Connection.
|
// Maintains Connection.
|
||||||
plugin.getRunnableFactory().createNew(new AbsRunnable("DBConnectionPingTask " + getName()) {
|
plugin.getRunnableFactory().createNew(new AbsRunnable("DBConnectionPingTask " + getName()) {
|
||||||
@Override
|
@Override
|
||||||
@ -78,26 +78,28 @@ public abstract class SQLDB extends Database {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
connection = getNewConnection();
|
connection = getNewConnection();
|
||||||
} finally {
|
} finally {
|
||||||
if (statement != null) {
|
MiscUtils.close(statement);
|
||||||
try {
|
|
||||||
statement.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Log.error("Error at closing statement");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskTimerAsynchronously(60 * 20, 60 * 20);
|
}).runTaskTimerAsynchronously(60 * 20, 60 * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* Initializes the Database.
|
||||||
|
* <p>
|
||||||
|
* All tables exist in the database after call to this.
|
||||||
|
* Updates Schema to latest version.
|
||||||
|
* Converts Unsaved Bukkit player files to database data.
|
||||||
|
* Cleans the database.
|
||||||
|
*
|
||||||
|
* @return Was the Initialization successful.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean init() {
|
public boolean init() {
|
||||||
super.init();
|
super.init();
|
||||||
setStatus("Init");
|
setStatus("Init");
|
||||||
Benchmark.start("Database: Init " + getConfigName());
|
String benchName = "Init " + getConfigName();
|
||||||
|
Benchmark.start(benchName);
|
||||||
try {
|
try {
|
||||||
if (!checkConnection()) {
|
if (!checkConnection()) {
|
||||||
return false;
|
return false;
|
||||||
@ -109,12 +111,18 @@ public abstract class SQLDB extends Database {
|
|||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
Benchmark.stop("Database: Init " + getConfigName());
|
Benchmark.stop("Database", benchName);
|
||||||
|
Log.logDebug("Database");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return @throws SQLException
|
* Ensures connection functions correctly and all tables exist.
|
||||||
|
* <p>
|
||||||
|
* Updates to latest schema.
|
||||||
|
*
|
||||||
|
* @return Is the connection usable?
|
||||||
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public boolean checkConnection() throws SQLException {
|
public boolean checkConnection() throws SQLException {
|
||||||
if (connection == null || connection.isClosed()) {
|
if (connection == null || connection.isClosed()) {
|
||||||
@ -141,7 +149,7 @@ public abstract class SQLDB extends Database {
|
|||||||
setVersion(8);
|
setVersion(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Create tables");
|
Benchmark.start("DCreate tables");
|
||||||
|
|
||||||
for (Table table : getAllTables()) {
|
for (Table table : getAllTables()) {
|
||||||
if (!table.createTable()) {
|
if (!table.createTable()) {
|
||||||
@ -154,7 +162,7 @@ public abstract class SQLDB extends Database {
|
|||||||
Log.error("Failed to create table: " + securityTable.getTableName());
|
Log.error("Failed to create table: " + securityTable.getTableName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Benchmark.stop("Database: Create tables");
|
Benchmark.stop("Database", "Create tables");
|
||||||
|
|
||||||
if (!newDatabase && getVersion() < 8) {
|
if (!newDatabase && getVersion() < 8) {
|
||||||
setVersion(8);
|
setVersion(8);
|
||||||
@ -171,7 +179,7 @@ public abstract class SQLDB extends Database {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Benchmark.start("Database: Convert Bukkitdata to DB data");
|
Benchmark.start("Convert BukkitData to DB data");
|
||||||
Set<UUID> uuids = usersTable.getSavedUUIDs();
|
Set<UUID> uuids = usersTable.getSavedUUIDs();
|
||||||
uuids.removeAll(usersTable.getContainsBukkitData(uuids));
|
uuids.removeAll(usersTable.getContainsBukkitData(uuids));
|
||||||
if (uuids.isEmpty()) {
|
if (uuids.isEmpty()) {
|
||||||
@ -186,7 +194,7 @@ public abstract class SQLDB extends Database {
|
|||||||
plugin.getServer().getScheduler().cancelTask(id);
|
plugin.getServer().getScheduler().cancelTask(id);
|
||||||
}
|
}
|
||||||
saveMultipleUserData(getUserDataForUUIDS(uuids));
|
saveMultipleUserData(getUserDataForUUIDS(uuids));
|
||||||
Log.info("Conversion complete, took: " + FormatUtils.formatTimeAmount(Benchmark.stop("Database: Convert Bukkitdata to DB data")) + " ms");
|
Log.info("Conversion complete, took: " + FormatUtils.formatTimeAmount(Benchmark.stop("Database", "Convert BukkitData to DB data")) + " ms");
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Log.toLog(this.getClass().getName(), ex);
|
Log.toLog(this.getClass().getName(), ex);
|
||||||
} finally {
|
} finally {
|
||||||
@ -232,6 +240,7 @@ public abstract class SQLDB extends Database {
|
|||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
|
Log.logDebug("Database"); // Log remaining Debug info if present
|
||||||
setStatus("Closed");
|
setStatus("Closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,8 +294,8 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
setStatus("Remove account " + uuid);
|
setStatus("Remove account " + uuid);
|
||||||
Benchmark.start("Database: Remove Account");
|
Benchmark.start("Remove Account");
|
||||||
Log.debug("Removing Account: " + uuid);
|
Log.debug("Database", "Removing Account: " + uuid);
|
||||||
try {
|
try {
|
||||||
checkConnection();
|
checkConnection();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -310,7 +319,7 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
} finally {
|
} finally {
|
||||||
Benchmark.stop("Database: Remove Account");
|
Benchmark.stop("Database", "Remove Account");
|
||||||
setAvailable();
|
setAvailable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +331,7 @@ public abstract class SQLDB extends Database {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void giveUserDataToProcessors(UUID uuid, Collection<DBCallableProcessor> processors) throws SQLException {
|
public void giveUserDataToProcessors(UUID uuid, Collection<DBCallableProcessor> processors) throws SQLException {
|
||||||
Benchmark.start("Database: Give userdata to processors");
|
Benchmark.start("Give userdata to processors");
|
||||||
try {
|
try {
|
||||||
checkConnection();
|
checkConnection();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -361,7 +370,7 @@ public abstract class SQLDB extends Database {
|
|||||||
data.addSessions(sessions);
|
data.addSessions(sessions);
|
||||||
data.setPlayerKills(killsTable.getPlayerKills(userId));
|
data.setPlayerKills(killsTable.getPlayerKills(userId));
|
||||||
processors.forEach(processor -> processor.process(data));
|
processors.forEach(processor -> processor.process(data));
|
||||||
Benchmark.stop("Database: Give userdata to processors");
|
Benchmark.stop("Database", "Give userdata to processors");
|
||||||
setAvailable();
|
setAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +385,7 @@ public abstract class SQLDB extends Database {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
setStatus("Get userdata (multiple) for: " + uuidsCol.size());
|
setStatus("Get userdata (multiple) for: " + uuidsCol.size());
|
||||||
Benchmark.start("Database: Get UserData for " + uuidsCol.size());
|
Benchmark.start("Get UserData for " + uuidsCol.size());
|
||||||
Map<UUID, Integer> userIds = usersTable.getAllUserIds();
|
Map<UUID, Integer> userIds = usersTable.getAllUserIds();
|
||||||
Set<UUID> remove = uuidsCol.stream()
|
Set<UUID> remove = uuidsCol.stream()
|
||||||
.filter(uuid -> !userIds.containsKey(uuid))
|
.filter(uuid -> !userIds.containsKey(uuid))
|
||||||
@ -384,22 +393,32 @@ public abstract class SQLDB extends Database {
|
|||||||
List<UUID> uuids = new ArrayList<>(uuidsCol);
|
List<UUID> uuids = new ArrayList<>(uuidsCol);
|
||||||
Log.debug("Data not found for: " + remove.size());
|
Log.debug("Data not found for: " + remove.size());
|
||||||
uuids.removeAll(remove);
|
uuids.removeAll(remove);
|
||||||
Benchmark.start("Database: Create UserData objects for " + userIds.size());
|
Benchmark.start("Create UserData objects for " + userIds.size());
|
||||||
List<UserData> data = usersTable.getUserData(new ArrayList<>(uuids));
|
List<UserData> data = usersTable.getUserData(new ArrayList<>(uuids));
|
||||||
Benchmark.stop("Database: Create UserData objects for " + userIds.size());
|
Benchmark.stop("Database", "Create UserData objects for " + userIds.size());
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
Map<Integer, UUID> idUuidRel = userIds.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
|
Map<Integer, UUID> idUuidRel = userIds.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
|
||||||
List<Integer> ids = userIds.entrySet().stream().filter(e -> uuids.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList());
|
List<Integer> ids = userIds.entrySet().stream().filter(e -> uuids.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList());
|
||||||
Log.debug("Ids: " + ids.size());
|
Log.debug("Database", "Using IDs: " + ids.size());
|
||||||
Map<Integer, List<String>> nicknames = nicknamesTable.getNicknames(ids);
|
Map<Integer, List<String>> nicknames = nicknamesTable.getNicknames(ids);
|
||||||
Map<Integer, Set<InetAddress>> ipList = ipsTable.getIPList(ids);
|
Map<Integer, Set<InetAddress>> ipList = ipsTable.getIPList(ids);
|
||||||
Map<Integer, List<KillData>> playerKills = killsTable.getPlayerKills(ids, idUuidRel);
|
Map<Integer, List<KillData>> playerKills = killsTable.getPlayerKills(ids, idUuidRel);
|
||||||
Map<Integer, List<SessionData>> sessionData = sessionsTable.getSessionData(ids);
|
Map<Integer, List<SessionData>> sessionData = sessionsTable.getSessionData(ids);
|
||||||
Map<Integer, Map<String, Long>> gmTimes = gmTimesTable.getGMTimes(ids);
|
Map<Integer, Map<String, Long>> gmTimes = gmTimesTable.getGMTimes(ids);
|
||||||
Map<Integer, Map<String, Long>> worldTimes = worldTimesTable.getWorldTimes(ids);
|
Map<Integer, Map<String, Long>> worldTimes = worldTimesTable.getWorldTimes(ids);
|
||||||
Log.debug("Sizes: UUID:" + uuids.size() + " DATA:" + data.size() + " ID:" + userIds.size() + " N:" + nicknames.size() + " I:" + ipList.size() + " K:" + playerKills.size() + " S:" + sessionData.size());
|
|
||||||
|
Log.debug("Database", "Data found for:");
|
||||||
|
Log.debug("Database", "UUIDs: " + uuids.size());
|
||||||
|
Log.debug("Database", "IDs: " + userIds.size());
|
||||||
|
Log.debug("Database", "UserData: " + data.size());
|
||||||
|
Log.debug("Database", " Nicknames: " + nicknames.size());
|
||||||
|
Log.debug("Database", " IPs: " + ipList.size());
|
||||||
|
Log.debug("Database", " Kills: " + playerKills.size());
|
||||||
|
Log.debug("Database", " Sessions: " + sessionData.size());
|
||||||
|
Log.debug("Database", " GM Times: " + gmTimes.size());
|
||||||
|
Log.debug("Database", " World Times: " + worldTimes.size());
|
||||||
|
|
||||||
for (UserData uData : data) {
|
for (UserData uData : data) {
|
||||||
UUID uuid = uData.getUuid();
|
UUID uuid = uData.getUuid();
|
||||||
@ -420,7 +439,7 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.stop("Database: Get UserData for " + uuidsCol.size());
|
Benchmark.stop("Database", "Get UserData for " + uuidsCol.size());
|
||||||
setAvailable();
|
setAvailable();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -435,7 +454,7 @@ public abstract class SQLDB extends Database {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Save multiple Userdata");
|
Benchmark.start("Save multiple Userdata");
|
||||||
data.removeIf(Objects::isNull);
|
data.removeIf(Objects::isNull);
|
||||||
|
|
||||||
checkConnection();
|
checkConnection();
|
||||||
@ -473,7 +492,7 @@ public abstract class SQLDB extends Database {
|
|||||||
Integer id = userIds.get(uuid);
|
Integer id = userIds.get(uuid);
|
||||||
|
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
Log.debug("User not seen before, saving last: " + uuid);
|
Log.debug("Database", "User not seen before, saving last: " + uuid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +519,7 @@ public abstract class SQLDB extends Database {
|
|||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.filter(UserData::isAccessed)
|
.filter(UserData::isAccessed)
|
||||||
.forEach(UserData::stopAccessing);
|
.forEach(UserData::stopAccessing);
|
||||||
Benchmark.stop("Database: Save multiple Userdata");
|
Benchmark.stop("Database", "Save multiple Userdata");
|
||||||
setAvailable();
|
setAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,7 +538,8 @@ public abstract class SQLDB extends Database {
|
|||||||
}
|
}
|
||||||
setStatus("Save userdata: " + uuid);
|
setStatus("Save userdata: " + uuid);
|
||||||
checkConnection();
|
checkConnection();
|
||||||
Log.debug("DB_Save: " + data);
|
Log.debug("Database", "DB_Save:");
|
||||||
|
Log.debug("Database", data.toString());
|
||||||
data.access();
|
data.access();
|
||||||
usersTable.saveUserDataInformation(data);
|
usersTable.saveUserDataInformation(data);
|
||||||
int userId = usersTable.getUserId(uuid.toString());
|
int userId = usersTable.getUserId(uuid.toString());
|
||||||
@ -595,8 +615,9 @@ public abstract class SQLDB extends Database {
|
|||||||
plugin.processStatus().setStatus("DB-" + getName(), status);
|
plugin.processStatus().setStatus("DB-" + getName(), status);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAvailable() {
|
public void setAvailable() {
|
||||||
setStatus("Running");
|
setStatus("Running");
|
||||||
|
Log.logDebug("Database");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +50,7 @@ public class CommandUseTable extends Table {
|
|||||||
* @return @throws SQLException
|
* @return @throws SQLException
|
||||||
*/
|
*/
|
||||||
public Map<String, Integer> getCommandUse() throws SQLException {
|
public Map<String, Integer> getCommandUse() throws SQLException {
|
||||||
Benchmark.start("Database: Get CommandUse");
|
Benchmark.start("Get CommandUse");
|
||||||
Map<String, Integer> commandUse = new HashMap<>();
|
Map<String, Integer> commandUse = new HashMap<>();
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
@ -70,7 +70,7 @@ public class CommandUseTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get CommandUse");
|
Benchmark.stop("Database", "Get CommandUse");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public class CommandUseTable extends Table {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Save Commanduse");
|
Benchmark.start("Save Commanduse");
|
||||||
Map<String, Integer> newData = new HashMap<>(data);
|
Map<String, Integer> newData = new HashMap<>(data);
|
||||||
Map<String, Integer> saved = getCommandUse();
|
Map<String, Integer> saved = getCommandUse();
|
||||||
newData.keySet().removeAll(saved.keySet());
|
newData.keySet().removeAll(saved.keySet());
|
||||||
@ -106,7 +106,8 @@ public class CommandUseTable extends Table {
|
|||||||
|
|
||||||
updateCommands(updateData);
|
updateCommands(updateData);
|
||||||
commit();
|
commit();
|
||||||
Benchmark.stop("Database: Save Commanduse");
|
Benchmark.stop("Database", "Save Commanduse");
|
||||||
|
db.setAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCommands(Map<String, Integer> data) throws SQLException {
|
private void updateCommands(Map<String, Integer> data) throws SQLException {
|
||||||
|
@ -201,7 +201,7 @@ public class GMTimesTable extends Table {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Save GMTimes");
|
Benchmark.start("Save GMTimes");
|
||||||
|
|
||||||
Set<Integer> savedIDs = getSavedIDs();
|
Set<Integer> savedIDs = getSavedIDs();
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ public class GMTimesTable extends Table {
|
|||||||
|
|
||||||
List<List<Container<GMTimes>>> batches = DBUtils.splitIntoBatchesWithID(gmTimes);
|
List<List<Container<GMTimes>>> batches = DBUtils.splitIntoBatchesWithID(gmTimes);
|
||||||
|
|
||||||
batches.stream().forEach(batch -> {
|
batches.forEach(batch -> {
|
||||||
try {
|
try {
|
||||||
saveGMTimesBatch(batch);
|
saveGMTimesBatch(batch);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -231,7 +231,7 @@ public class GMTimesTable extends Table {
|
|||||||
gamemodeTimes.keySet().removeAll(savedIDs);
|
gamemodeTimes.keySet().removeAll(savedIDs);
|
||||||
|
|
||||||
addNewGMTimesRows(gamemodeTimes);
|
addNewGMTimesRows(gamemodeTimes);
|
||||||
Benchmark.stop("Database: Save GMTimes");
|
Benchmark.stop("Database", "Save GMTimes");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveGMTimesBatch(List<Container<GMTimes>> batch) throws SQLException {
|
private void saveGMTimesBatch(List<Container<GMTimes>> batch) throws SQLException {
|
||||||
@ -240,7 +240,7 @@ public class GMTimesTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int batchSize = batch.size();
|
int batchSize = batch.size();
|
||||||
Log.debug("Preparing insertion of GM Times... Batch Size: " + batchSize);
|
Log.debug("Database", "Preparing update of GM Times - Batch Size: " + batchSize);
|
||||||
|
|
||||||
String[] gms = getGMKeyArray();
|
String[] gms = getGMKeyArray();
|
||||||
Set<Integer> savedIDs = getSavedIDs();
|
Set<Integer> savedIDs = getSavedIDs();
|
||||||
@ -274,7 +274,7 @@ public class GMTimesTable extends Table {
|
|||||||
statement.addBatch();
|
statement.addBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.debug("Executing GM Times batch: " + batchSize);
|
Log.debug("Database", "Executing GM Times batch: " + batchSize);
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
@ -286,7 +286,7 @@ public class GMTimesTable extends Table {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Add GMTimes Rows");
|
Benchmark.start("Add GMTimes Rows");
|
||||||
|
|
||||||
Map<Integer, GMTimes> gmTimes = new HashMap<>();
|
Map<Integer, GMTimes> gmTimes = new HashMap<>();
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ public class GMTimesTable extends Table {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Benchmark.stop("Database: Add GMTimes Rows");
|
Benchmark.stop("Database", "Add GMTimes Rows");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addNewGMTimesBatch(List<Container<GMTimes>> batch) throws SQLException {
|
private void addNewGMTimesBatch(List<Container<GMTimes>> batch) throws SQLException {
|
||||||
@ -315,7 +315,7 @@ public class GMTimesTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int batchSize = batch.size();
|
int batchSize = batch.size();
|
||||||
Log.debug("Preparing insertion of GM Times... Batch Size: " + batchSize);
|
Log.debug("Database", "Preparing insertion of GM Times - Batch Size: " + batchSize);
|
||||||
|
|
||||||
String[] gms = getGMKeyArray();
|
String[] gms = getGMKeyArray();
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ public class GMTimesTable extends Table {
|
|||||||
statement.addBatch();
|
statement.addBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.debug("Executing GM Times batch: " + batchSize);
|
Log.debug("Database", "Executing GM Times batch: " + batchSize);
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
|
@ -74,7 +74,7 @@ public class IPsTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public List<InetAddress> getIPAddresses(int userId) throws SQLException {
|
public List<InetAddress> getIPAddresses(int userId) throws SQLException {
|
||||||
Benchmark.start("Database: Get Ips");
|
Benchmark.start("Get Ips");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -95,7 +95,7 @@ public class IPsTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get Ips");
|
Benchmark.stop("Database", "Get Ips");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ public class IPsTable extends Table {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Save Ips");
|
Benchmark.start("Save Ips");
|
||||||
ips.removeAll(getIPAddresses(userId));
|
ips.removeAll(getIPAddresses(userId));
|
||||||
|
|
||||||
if (ips.isEmpty()) {
|
if (ips.isEmpty()) {
|
||||||
@ -141,7 +141,7 @@ public class IPsTable extends Table {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Save Ips");
|
Benchmark.stop("Database", "Save Ips");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ public class IPsTable extends Table {
|
|||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Get Ips Multiple");
|
Benchmark.start("Get Ips Multiple");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ public class IPsTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get Ips Multiple");
|
Benchmark.stop("Database", "Get Ips Multiple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ public class IPsTable extends Table {
|
|||||||
if (ips == null || ips.isEmpty()) {
|
if (ips == null || ips.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Benchmark.start("Database: Save Ips Multiple");
|
Benchmark.start("Save Ips Multiple");
|
||||||
Map<Integer, Set<InetAddress>> saved = getIPList(ips.keySet());
|
Map<Integer, Set<InetAddress>> saved = getIPList(ips.keySet());
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -209,7 +209,7 @@ public class IPsTable extends Table {
|
|||||||
+ columnIP
|
+ columnIP
|
||||||
+ ") VALUES (?, ?)");
|
+ ") VALUES (?, ?)");
|
||||||
boolean commitRequired = false;
|
boolean commitRequired = false;
|
||||||
int i = 0;
|
int batchSize = 0;
|
||||||
for (Map.Entry<Integer, Set<InetAddress>> entrySet : ips.entrySet()) {
|
for (Map.Entry<Integer, Set<InetAddress>> entrySet : ips.entrySet()) {
|
||||||
Integer id = entrySet.getKey();
|
Integer id = entrySet.getKey();
|
||||||
Set<InetAddress> ipAddresses = entrySet.getValue();
|
Set<InetAddress> ipAddresses = entrySet.getValue();
|
||||||
@ -233,17 +233,17 @@ public class IPsTable extends Table {
|
|||||||
statement.setString(2, ip.getHostAddress());
|
statement.setString(2, ip.getHostAddress());
|
||||||
statement.addBatch();
|
statement.addBatch();
|
||||||
commitRequired = true;
|
commitRequired = true;
|
||||||
i++;
|
batchSize++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commitRequired) {
|
if (commitRequired) {
|
||||||
Log.debug("Executing ips batch: " + i);
|
Log.debug("Database", "Executing ips batch: " + batchSize);
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Save Ips Multiple");
|
Benchmark.stop("Database", "Save Ips Multiple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public class KillsTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public List<KillData> getPlayerKills(int userId) throws SQLException {
|
public List<KillData> getPlayerKills(int userId) throws SQLException {
|
||||||
Benchmark.start("Database: Get Kills");
|
Benchmark.start("Get Kills");
|
||||||
UsersTable usersTable = db.getUsersTable();
|
UsersTable usersTable = db.getUsersTable();
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
@ -100,7 +100,7 @@ public class KillsTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get Kills");
|
Benchmark.stop("Database", "Get Kills");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ public class KillsTable extends Table {
|
|||||||
if (kills == null) {
|
if (kills == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Benchmark.start("Database: Save Kills");
|
Benchmark.start("Save Kills");
|
||||||
kills.removeAll(getPlayerKills(userId));
|
kills.removeAll(getPlayerKills(userId));
|
||||||
if (kills.isEmpty()) {
|
if (kills.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -154,7 +154,7 @@ public class KillsTable extends Table {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Save Kills");
|
Benchmark.stop("Database", "Save Kills");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ public class KillsTable extends Table {
|
|||||||
if (ids == null || ids.isEmpty()) {
|
if (ids == null || ids.isEmpty()) {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
Benchmark.start("Database: Get Kills multiple");
|
Benchmark.start("Get Kills multiple");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -191,7 +191,7 @@ public class KillsTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get Kills multiple");
|
Benchmark.stop("Database", "Get Kills multiple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ public class KillsTable extends Table {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Save Kills multiple");
|
Benchmark.start("Save Kills multiple");
|
||||||
Map<Integer, List<KillData>> saved = getPlayerKills(kills.keySet(), uuids);
|
Map<Integer, List<KillData>> saved = getPlayerKills(kills.keySet(), uuids);
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
@ -258,13 +258,13 @@ public class KillsTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (commitRequired) {
|
if (commitRequired) {
|
||||||
Log.debug("Executing kills batch: " + i);
|
Log.debug("Database", "Executing kills batch: " + i);
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Save Kills multiple");
|
Benchmark.stop("Database", "Save Kills multiple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public class NicknamesTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public List<String> getNicknames(int userId) throws SQLException {
|
public List<String> getNicknames(int userId) throws SQLException {
|
||||||
Benchmark.start("Database: Get Nicknames");
|
Benchmark.start("Get Nicknames");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -109,7 +109,7 @@ public class NicknamesTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get Nicknames");
|
Benchmark.stop("Database", "Get Nicknames");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ public class NicknamesTable extends Table {
|
|||||||
if (names == null || names.isEmpty()) {
|
if (names == null || names.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Benchmark.start("Database: Save Nicknames");
|
Benchmark.start("Save Nicknames");
|
||||||
names.removeAll(getNicknames(userId));
|
names.removeAll(getNicknames(userId));
|
||||||
if (names.isEmpty()) {
|
if (names.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -146,13 +146,13 @@ public class NicknamesTable extends Table {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (commitRequired) {
|
if (commitRequired) {
|
||||||
Log.debug("Executing nicknames batch: " + i);
|
Log.debug("Database", "Executing nicknames batch: " + i);
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Save Nicknames");
|
Benchmark.stop("Database", "Save Nicknames");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ public class NicknamesTable extends Table {
|
|||||||
if (ids == null || ids.isEmpty()) {
|
if (ids == null || ids.isEmpty()) {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
Benchmark.start("Database: Get Nicknames Multiple");
|
Benchmark.start("Get Nicknames Multiple");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -208,7 +208,7 @@ public class NicknamesTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get Nicknames Multiple");
|
Benchmark.stop("Database", "Get Nicknames Multiple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ public class NicknamesTable extends Table {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Save Nicknames Multiple");
|
Benchmark.start("Save Nicknames Multiple");
|
||||||
|
|
||||||
Map<Integer, List<String>> saved = getNicknames(nicknames.keySet());
|
Map<Integer, List<String>> saved = getNicknames(nicknames.keySet());
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
@ -263,7 +263,7 @@ public class NicknamesTable extends Table {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Save Nicknames Multiple");
|
Benchmark.stop("Database", "Save Nicknames Multiple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class SessionsTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public List<SessionData> getSessionData(int userId) throws SQLException {
|
public List<SessionData> getSessionData(int userId) throws SQLException {
|
||||||
Benchmark.start("Database: Get Sessions");
|
Benchmark.start("Get Sessions");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -75,7 +75,7 @@ public class SessionsTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get Sessions");
|
Benchmark.stop("Database", "Get Sessions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,16 +108,14 @@ public class SessionsTable extends Table {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Save Sessions");
|
|
||||||
sessions.removeAll(getSessionData(userId));
|
sessions.removeAll(getSessionData(userId));
|
||||||
|
|
||||||
if (sessions.isEmpty()) {
|
if (sessions.isEmpty()) {
|
||||||
Benchmark.stop("Database: Save Sessions");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Benchmark.start("Save Sessions");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statement = prepareStatement("INSERT INTO " + tableName + " ("
|
statement = prepareStatement("INSERT INTO " + tableName + " ("
|
||||||
+ columnUserID + ", "
|
+ columnUserID + ", "
|
||||||
@ -141,7 +139,7 @@ public class SessionsTable extends Table {
|
|||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Save Sessions");
|
Benchmark.stop("Database", "Save Sessions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +153,7 @@ public class SessionsTable extends Table {
|
|||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Get Sessions multiple");
|
Benchmark.start("Get Sessions multiple");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
|
|
||||||
@ -184,7 +182,7 @@ public class SessionsTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get Sessions multiple");
|
Benchmark.stop("Database", "Get Sessions multiple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +195,7 @@ public class SessionsTable extends Table {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Database: Save Sessions multiple");
|
Benchmark.start("Save Sessions multiple");
|
||||||
|
|
||||||
Map<Integer, List<SessionData>> saved = getSessionData(sessions.keySet());
|
Map<Integer, List<SessionData>> saved = getSessionData(sessions.keySet());
|
||||||
for (Map.Entry<Integer, List<SessionData>> entrySet : sessions.entrySet()) {
|
for (Map.Entry<Integer, List<SessionData>> entrySet : sessions.entrySet()) {
|
||||||
@ -226,7 +224,7 @@ public class SessionsTable extends Table {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Benchmark.stop("Database: Save Sessions multiple");
|
Benchmark.stop("Database", "Save Sessions multiple");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveSessionBatch(List<Container<SessionData>> batch) throws SQLException {
|
private void saveSessionBatch(List<Container<SessionData>> batch) throws SQLException {
|
||||||
@ -235,7 +233,7 @@ public class SessionsTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int batchSize = batch.size();
|
int batchSize = batch.size();
|
||||||
Log.debug("Preparing insertion of sessions... Batch Size: " + batchSize);
|
Log.debug("Database", "Preparing insertion of sessions - Batch Size: " + batchSize);
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -258,7 +256,7 @@ public class SessionsTable extends Table {
|
|||||||
statement.addBatch();
|
statement.addBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.debug("Executing session batch: " + batchSize);
|
Log.debug("Database", "Executing session batch: " + batchSize);
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
|
@ -88,7 +88,7 @@ public class TPSTable extends Table {
|
|||||||
* @return @throws SQLException
|
* @return @throws SQLException
|
||||||
*/
|
*/
|
||||||
public List<TPS> getTPSData() throws SQLException {
|
public List<TPS> getTPSData() throws SQLException {
|
||||||
Benchmark.start("Database: Get TPS");
|
Benchmark.start("Get TPS");
|
||||||
List<TPS> data = new ArrayList<>();
|
List<TPS> data = new ArrayList<>();
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
@ -109,7 +109,7 @@ public class TPSTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get TPS");
|
Benchmark.stop("Database", "Get TPS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,14 +119,14 @@ public class TPSTable extends Table {
|
|||||||
*/
|
*/
|
||||||
public void saveTPSData(List<TPS> data) throws SQLException {
|
public void saveTPSData(List<TPS> data) throws SQLException {
|
||||||
List<List<TPS>> batches = DBUtils.splitIntoBatches(data);
|
List<List<TPS>> batches = DBUtils.splitIntoBatches(data);
|
||||||
batches.stream()
|
batches.forEach(batch -> {
|
||||||
.forEach(batch -> {
|
try {
|
||||||
try {
|
saveTPSBatch(batch);
|
||||||
saveTPSBatch(batch);
|
} catch (SQLException e) {
|
||||||
} catch (SQLException e) {
|
Log.toLog("UsersTable.saveUserDataInformationBatch", e);
|
||||||
Log.toLog("UsersTable.saveUserDataInformationBatch", e);
|
}
|
||||||
}
|
});
|
||||||
});
|
db.setAvailable();
|
||||||
commit();
|
commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ public class TPSTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int batchSize = batch.size();
|
int batchSize = batch.size();
|
||||||
Log.debug("Preparing insertion of TPS... Batch Size: " + batchSize);
|
Log.debug("Database", "Preparing insertion of TPS - Batch Size: " + batchSize);
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -161,7 +161,7 @@ public class TPSTable extends Table {
|
|||||||
statement.addBatch();
|
statement.addBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.debug("Executing tps batch: " + batchSize);
|
Log.debug("Database", "Executing tps batch: " + batchSize);
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
|
@ -107,7 +107,7 @@ public abstract class Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
protected PreparedStatement prepareStatement(String sql) throws SQLException {
|
protected PreparedStatement prepareStatement(String sql) throws SQLException {
|
||||||
Log.debug(sql);
|
Log.debug("Database", sql);
|
||||||
return getConnection().prepareStatement(sql);
|
return getConnection().prepareStatement(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,8 +175,9 @@ public abstract class Table {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits changes to .db file when using SQLite databse.
|
* Commits changes to .db file when using SQLite databse.
|
||||||
*
|
* <p>
|
||||||
* Auto Commit enabled when using MySQL
|
* Auto Commit enabled when using MySQL
|
||||||
|
*
|
||||||
* @throws SQLException If commit fails or there is nothing to commit.
|
* @throws SQLException If commit fails or there is nothing to commit.
|
||||||
*/
|
*/
|
||||||
protected void commit() throws SQLException {
|
protected void commit() throws SQLException {
|
||||||
|
@ -223,7 +223,7 @@ public class UsersTable extends Table {
|
|||||||
* @return @throws SQLException
|
* @return @throws SQLException
|
||||||
*/
|
*/
|
||||||
public Set<UUID> getSavedUUIDs() throws SQLException {
|
public Set<UUID> getSavedUUIDs() throws SQLException {
|
||||||
Benchmark.start("Database: Get Saved UUIDS");
|
Benchmark.start("Get Saved UUIDS");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -238,7 +238,7 @@ public class UsersTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get Saved UUIDS");
|
Benchmark.stop("Database", "Get Saved UUIDS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ public class UsersTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public UserData getUserData(UUID uuid) throws SQLException {
|
public UserData getUserData(UUID uuid) throws SQLException {
|
||||||
Benchmark.start("Database: Get UserData");
|
Benchmark.start("Get UserData");
|
||||||
boolean containsBukkitData = getContainsBukkitData(uuid);
|
boolean containsBukkitData = getContainsBukkitData(uuid);
|
||||||
UserData data = null;
|
UserData data = null;
|
||||||
if (containsBukkitData) {
|
if (containsBukkitData) {
|
||||||
@ -284,7 +284,7 @@ public class UsersTable extends Table {
|
|||||||
data = new UserData(Fetch.getIOfflinePlayer(uuid));
|
data = new UserData(Fetch.getIOfflinePlayer(uuid));
|
||||||
addUserInformationToUserData(data);
|
addUserInformationToUserData(data);
|
||||||
}
|
}
|
||||||
Benchmark.stop("Database: Get UserData");
|
Benchmark.stop("Database", "Get UserData");
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ public class UsersTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public List<UserData> getUserData(Collection<UUID> uuids) throws SQLException {
|
public List<UserData> getUserData(Collection<UUID> uuids) throws SQLException {
|
||||||
Benchmark.start("Database: Get UserData Multiple");
|
Benchmark.start("Get UserData Multiple");
|
||||||
List<UUID> containsBukkitData = getContainsBukkitData(uuids);
|
List<UUID> containsBukkitData = getContainsBukkitData(uuids);
|
||||||
List<UserData> datas = new ArrayList<>();
|
List<UserData> datas = new ArrayList<>();
|
||||||
datas.addAll(getUserDataForKnown(containsBukkitData));
|
datas.addAll(getUserDataForKnown(containsBukkitData));
|
||||||
@ -320,17 +320,17 @@ public class UsersTable extends Table {
|
|||||||
uuids.removeAll(containsBukkitData);
|
uuids.removeAll(containsBukkitData);
|
||||||
if (!uuids.isEmpty()) {
|
if (!uuids.isEmpty()) {
|
||||||
List<UserData> noBukkitData = new ArrayList<>();
|
List<UserData> noBukkitData = new ArrayList<>();
|
||||||
Benchmark.start("Database: Create UserData objects for No BukkitData players");
|
Benchmark.start("Create UserData objects for No BukkitData players");
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
UserData uData = new UserData(Fetch.getIOfflinePlayer(uuid));
|
UserData uData = new UserData(Fetch.getIOfflinePlayer(uuid));
|
||||||
noBukkitData.add(uData);
|
noBukkitData.add(uData);
|
||||||
}
|
}
|
||||||
Benchmark.stop("Database: Create UserData objects for No BukkitData players");
|
Benchmark.stop("Database", "Create UserData objects for No BukkitData players");
|
||||||
addUserInformationToUserData(noBukkitData);
|
addUserInformationToUserData(noBukkitData);
|
||||||
datas.addAll(noBukkitData);
|
datas.addAll(noBukkitData);
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.stop("Database: Get UserData Multiple");
|
Benchmark.stop("Database", "Get UserData Multiple");
|
||||||
return datas;
|
return datas;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private UserData getUserDataForKnown(UUID uuid) throws SQLException {
|
private UserData getUserDataForKnown(UUID uuid) throws SQLException {
|
||||||
Benchmark.start("Database: getUserDataForKnown UserData");
|
Benchmark.start("getUserDataForKnown UserData");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -401,13 +401,13 @@ public class UsersTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: getUserDataForKnown UserData");
|
Benchmark.stop("Database", "getUserDataForKnown UserData");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UserData> getUserDataForKnown(Collection<UUID> uuids) throws SQLException {
|
private List<UserData> getUserDataForKnown(Collection<UUID> uuids) throws SQLException {
|
||||||
Benchmark.start("Database: getUserDataForKnown Multiple");
|
Benchmark.start("getUserDataForKnown Multiple");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
List<UserData> datas = new ArrayList<>();
|
List<UserData> datas = new ArrayList<>();
|
||||||
@ -448,7 +448,7 @@ public class UsersTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: getUserDataForKnown Multiple");
|
Benchmark.stop("Database", "getUserDataForKnown Multiple");
|
||||||
}
|
}
|
||||||
return datas;
|
return datas;
|
||||||
}
|
}
|
||||||
@ -458,7 +458,7 @@ public class UsersTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public void addUserInformationToUserData(UserData data) throws SQLException {
|
public void addUserInformationToUserData(UserData data) throws SQLException {
|
||||||
Benchmark.start("Database: addUserInformationToUserData");
|
Benchmark.start("addUserInformationToUserData");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -488,7 +488,7 @@ public class UsersTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: addUserInformationToUserData");
|
Benchmark.stop("Database", "addUserInformationToUserData");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +497,7 @@ public class UsersTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public void addUserInformationToUserData(List<UserData> data) throws SQLException {
|
public void addUserInformationToUserData(List<UserData> data) throws SQLException {
|
||||||
Benchmark.start("Database: addUserInformationToUserData Multiple");
|
Benchmark.start("addUserInformationToUserData Multiple");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -533,7 +533,7 @@ public class UsersTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: addUserInformationToUserData Multiple");
|
Benchmark.stop("Database", "addUserInformationToUserData Multiple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,7 +542,7 @@ public class UsersTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public void saveUserDataInformation(UserData data) throws SQLException {
|
public void saveUserDataInformation(UserData data) throws SQLException {
|
||||||
Benchmark.start("Database: Save UserInfo");
|
Benchmark.start("Save UserInfo");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
UUID uuid = data.getUuid();
|
UUID uuid = data.getUuid();
|
||||||
@ -598,7 +598,7 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Save UserInfo");
|
Benchmark.stop("Database", "Save UserInfo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,7 +612,7 @@ public class UsersTable extends Table {
|
|||||||
try {
|
try {
|
||||||
statement = prepareStatement("SELECT age FROM " + tableName + " LIMIT 1");
|
statement = prepareStatement("SELECT age FROM " + tableName + " LIMIT 1");
|
||||||
set = statement.executeQuery();
|
set = statement.executeQuery();
|
||||||
Log.debug("UsersTable has V4 columns.");
|
Log.debug("Database", "UsersTable has V4 columns.");
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
return false;
|
return false;
|
||||||
@ -676,10 +676,10 @@ public class UsersTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public void saveUserDataInformationBatch(Collection<UserData> data) throws SQLException {
|
public void saveUserDataInformationBatch(Collection<UserData> data) throws SQLException {
|
||||||
Benchmark.start("Database: Save UserInfo multiple");
|
Benchmark.start("Save UserInfo multiple");
|
||||||
try {
|
try {
|
||||||
List<UserData> newUserdata = updateExistingUserData(data);
|
List<UserData> newUserdata = updateExistingUserData(data);
|
||||||
Benchmark.start("Database: Insert new UserInfo multiple");
|
Benchmark.start("Insert new UserInfo multiple");
|
||||||
|
|
||||||
List<List<UserData>> batches = DBUtils.splitIntoBatches(newUserdata);
|
List<List<UserData>> batches = DBUtils.splitIntoBatches(newUserdata);
|
||||||
|
|
||||||
@ -692,9 +692,9 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Benchmark.stop("Database: Insert new UserInfo multiple");
|
Benchmark.stop("Database", "Insert new UserInfo multiple");
|
||||||
} finally {
|
} finally {
|
||||||
Benchmark.stop("Database: Save UserInfo multiple");
|
Benchmark.stop("Database", "Save UserInfo multiple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,7 +704,7 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int batchSize = data.size();
|
int batchSize = data.size();
|
||||||
Log.debug("Preparing insertion of new users... Batch Size: " + batchSize);
|
Log.debug("Database", "Preparing insertion of new users - Batch Size: " + batchSize);
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -738,7 +738,7 @@ public class UsersTable extends Table {
|
|||||||
statement.addBatch();
|
statement.addBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.debug("Executing users batch: " + batchSize);
|
Log.debug("Database", "Executing users batch: " + batchSize);
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
@ -801,7 +801,7 @@ public class UsersTable extends Table {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (commitRequired) {
|
if (commitRequired) {
|
||||||
Log.debug("Executing userinfo batch update: " + i);
|
Log.debug("Database", "Executing userinfo batch update: " + i);
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
}
|
}
|
||||||
return saveLast;
|
return saveLast;
|
||||||
@ -816,7 +816,7 @@ public class UsersTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public Map<UUID, Integer> getUserIds(Collection<UUID> uuids) throws SQLException {
|
public Map<UUID, Integer> getUserIds(Collection<UUID> uuids) throws SQLException {
|
||||||
Benchmark.start("Database: Get User IDS Multiple");
|
Benchmark.start("Get User IDS Multiple");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -835,7 +835,7 @@ public class UsersTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get User IDS Multiple");
|
Benchmark.stop("Database", "Get User IDS Multiple");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -843,7 +843,7 @@ public class UsersTable extends Table {
|
|||||||
* @return @throws SQLException
|
* @return @throws SQLException
|
||||||
*/
|
*/
|
||||||
public Map<UUID, Integer> getAllUserIds() throws SQLException {
|
public Map<UUID, Integer> getAllUserIds() throws SQLException {
|
||||||
Benchmark.start("Database: Get User IDS ALL");
|
Benchmark.start("Get User IDS ALL");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -859,7 +859,7 @@ public class UsersTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get User IDS ALL");
|
Benchmark.stop("Database", "Get User IDS ALL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,7 +867,7 @@ public class UsersTable extends Table {
|
|||||||
* @return @throws SQLException
|
* @return @throws SQLException
|
||||||
*/
|
*/
|
||||||
public Map<Integer, Integer> getLoginTimes() throws SQLException {
|
public Map<Integer, Integer> getLoginTimes() throws SQLException {
|
||||||
Benchmark.start("Database: Get Logintimes");
|
Benchmark.start("Get Logintimes");
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
@ -882,7 +882,7 @@ public class UsersTable extends Table {
|
|||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
close(statement);
|
close(statement);
|
||||||
Benchmark.stop("Database: Get Logintimes");
|
Benchmark.stop("Database", "Get Logintimes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ public class VersionTable extends Table {
|
|||||||
if (set.next()) {
|
if (set.next()) {
|
||||||
version = set.getInt("version");
|
version = set.getInt("version");
|
||||||
}
|
}
|
||||||
|
Log.debug("Database", "DB Schema version: " + version);
|
||||||
return version;
|
return version;
|
||||||
} finally {
|
} finally {
|
||||||
close(set);
|
close(set);
|
||||||
|
@ -2,7 +2,6 @@ package main.java.com.djrapitops.plan.ui.html.tables;
|
|||||||
|
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.ui.html.Html;
|
import main.java.com.djrapitops.plan.ui.html.Html;
|
||||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.comparators.MapComparator;
|
import main.java.com.djrapitops.plan.utilities.comparators.MapComparator;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -26,7 +25,6 @@ public class CommandUseTableCreator {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String createSortedCommandUseTable(Map<String, Integer> commandUse) {
|
public static String createSortedCommandUseTable(Map<String, Integer> commandUse) {
|
||||||
Benchmark.start("Create CommandUse table");
|
|
||||||
List<String[]> sorted = MapComparator.sortByValue(commandUse);
|
List<String[]> sorted = MapComparator.sortByValue(commandUse);
|
||||||
StringBuilder html = new StringBuilder();
|
StringBuilder html = new StringBuilder();
|
||||||
if (sorted.isEmpty()) {
|
if (sorted.isEmpty()) {
|
||||||
@ -43,14 +41,12 @@ public class CommandUseTableCreator {
|
|||||||
try {
|
try {
|
||||||
html.append(Html.TABLELINE_2.parse(values[1], values[0]));
|
html.append(Html.TABLELINE_2.parse(values[1], values[0]));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Log.toLog("SortableCommandUseTableCreator", e);
|
Log.toLog("CommandUseTable - Cause: " + values[0] + " " + values[1], e);
|
||||||
Log.toLog("Cause: " + values[0] + " " + values[1], Log.getErrorsFilename());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Benchmark.stop("Create CommandUse table");
|
|
||||||
return html.toString();
|
return html.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.ui.html.tables;
|
|||||||
import main.java.com.djrapitops.plan.Settings;
|
import main.java.com.djrapitops.plan.Settings;
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.ui.html.Html;
|
import main.java.com.djrapitops.plan.ui.html.Html;
|
||||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
@ -28,7 +27,6 @@ public class PlayersTableCreator {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String createSortablePlayersTable(List<UserData> data) {
|
public static String createSortablePlayersTable(List<UserData> data) {
|
||||||
Benchmark.start("Create Players table");
|
|
||||||
StringBuilder html = new StringBuilder();
|
StringBuilder html = new StringBuilder();
|
||||||
|
|
||||||
long now = MiscUtils.getTime();
|
long now = MiscUtils.getTime();
|
||||||
@ -62,11 +60,9 @@ public class PlayersTableCreator {
|
|||||||
));
|
));
|
||||||
} catch (NullPointerException ignored) {
|
} catch (NullPointerException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.stop("Create Players table");
|
|
||||||
return html.toString();
|
return html.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ public class Benchmark {
|
|||||||
*/
|
*/
|
||||||
public static void start(String source) {
|
public static void start(String source) {
|
||||||
Plan.getInstance().benchmark().start(source);
|
Plan.getInstance().benchmark().start(source);
|
||||||
Log.debug(source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,4 +33,16 @@ public class Benchmark {
|
|||||||
}
|
}
|
||||||
return ms;
|
return ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to add Benchmark timings to larger Debug log task parts.
|
||||||
|
*
|
||||||
|
* @param task Task this benchmark is a part of.
|
||||||
|
* @param source Bench source
|
||||||
|
* @return Execution time in ms.
|
||||||
|
*/
|
||||||
|
public static long stop(String task, String source) {
|
||||||
|
long ms = Plan.getInstance().benchmark().stop(task, source);
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@ public class Check {
|
|||||||
public static boolean ErrorIfFalse(boolean condition, String message) {
|
public static boolean ErrorIfFalse(boolean condition, String message) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
Log.error(message);
|
Log.error(message);
|
||||||
Log.toLog(message, Log.getErrorsFilename());
|
|
||||||
}
|
}
|
||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ public class PassEncryptUtil {
|
|||||||
return skf.generateSecret(spec).getEncoded();
|
return skf.generateSecret(spec).getEncoded();
|
||||||
} catch (NoSuchAlgorithmException ex) {
|
} catch (NoSuchAlgorithmException ex) {
|
||||||
throw new CannotPerformOperationException(
|
throw new CannotPerformOperationException(
|
||||||
"Hash algorithm not supported.", ex
|
"Hash algorithm not supported: " + PBKDF2_ALGORITHM, ex
|
||||||
);
|
);
|
||||||
} catch (InvalidKeySpecException ex) {
|
} catch (InvalidKeySpecException ex) {
|
||||||
throw new CannotPerformOperationException(
|
throw new CannotPerformOperationException(
|
||||||
|
@ -60,7 +60,7 @@ public class Analysis {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.processStatus().startExecution("Analysis");
|
Benchmark.start("Analysis");
|
||||||
log(Phrase.ANALYSIS_START.toString());
|
log(Phrase.ANALYSIS_START.toString());
|
||||||
// Async task for Analysis
|
// Async task for Analysis
|
||||||
plugin.getRunnableFactory().createNew(new AbsRunnable("AnalysisTask") {
|
plugin.getRunnableFactory().createNew(new AbsRunnable("AnalysisTask") {
|
||||||
@ -84,8 +84,8 @@ public class Analysis {
|
|||||||
*/
|
*/
|
||||||
public boolean analyze(AnalysisCacheHandler analysisCache, Database db) {
|
public boolean analyze(AnalysisCacheHandler analysisCache, Database db) {
|
||||||
log(Phrase.ANALYSIS_FETCH_DATA.toString());
|
log(Phrase.ANALYSIS_FETCH_DATA.toString());
|
||||||
Benchmark.start("Analysis: Fetch Phase");
|
Benchmark.start("Fetch Phase");
|
||||||
|
Log.debug("Database", "Analysis Fetch");
|
||||||
plugin.processStatus().setStatus("Analysis", "Analysis Fetch Phase");
|
plugin.processStatus().setStatus("Analysis", "Analysis Fetch Phase");
|
||||||
try {
|
try {
|
||||||
inspectCache.cacheAllUserData(db);
|
inspectCache.cacheAllUserData(db);
|
||||||
@ -104,7 +104,8 @@ public class Analysis {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
tpsData = db.getTpsTable().getTPSData();
|
tpsData = db.getTpsTable().getTPSData();
|
||||||
Log.debug("TPS Data Size: " + tpsData.size());
|
Log.debug("Analysis", "Raw Data Size: " + rawData.size());
|
||||||
|
Log.debug("Analysis", "TPS Data Size: " + tpsData.size());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.toLog(this.getClass().getName(), ex);
|
Log.toLog(this.getClass().getName(), ex);
|
||||||
}
|
}
|
||||||
@ -122,7 +123,7 @@ public class Analysis {
|
|||||||
try {
|
try {
|
||||||
rawData.sort(new UserDataLastPlayedComparator());
|
rawData.sort(new UserDataLastPlayedComparator());
|
||||||
List<UUID> uuids = rawData.stream().map(UserData::getUuid).collect(Collectors.toList());
|
List<UUID> uuids = rawData.stream().map(UserData::getUuid).collect(Collectors.toList());
|
||||||
Benchmark.start("Analysis: Create Empty dataset");
|
Benchmark.start("Create Empty dataset");
|
||||||
DataCacheHandler handler = plugin.getHandler();
|
DataCacheHandler handler = plugin.getHandler();
|
||||||
Map<String, Integer> commandUse = handler.getCommandUse();
|
Map<String, Integer> commandUse = handler.getCommandUse();
|
||||||
|
|
||||||
@ -134,8 +135,8 @@ public class Analysis {
|
|||||||
analysisData.getPlayerCountPart().addPlayers(uuids);
|
analysisData.getPlayerCountPart().addPlayers(uuids);
|
||||||
activityPart.setRecentPlayers(rawData.stream().map(UserData::getName).collect(Collectors.toList()));
|
activityPart.setRecentPlayers(rawData.stream().map(UserData::getName).collect(Collectors.toList()));
|
||||||
|
|
||||||
Benchmark.stop("Analysis: Create Empty dataset");
|
Benchmark.stop("Analysis", "Create Empty dataset");
|
||||||
long fetchPhaseLength = Benchmark.stop("Analysis: Fetch Phase");
|
long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase");
|
||||||
|
|
||||||
Benchmark.start("Analysis Phase");
|
Benchmark.start("Analysis Phase");
|
||||||
plugin.processStatus().setStatus("Analysis", "Analysis Phase");
|
plugin.processStatus().setStatus("Analysis", "Analysis Phase");
|
||||||
@ -147,14 +148,16 @@ public class Analysis {
|
|||||||
fillDataset(analysisData, rawData);
|
fillDataset(analysisData, rawData);
|
||||||
// Analyze
|
// Analyze
|
||||||
analysisData.analyseData();
|
analysisData.analyseData();
|
||||||
Benchmark.stop("Analysis Phase");
|
Benchmark.stop("Analysis", "Analysis Phase");
|
||||||
|
|
||||||
log(Phrase.ANALYSIS_THIRD_PARTY.toString());
|
log(Phrase.ANALYSIS_THIRD_PARTY.toString());
|
||||||
plugin.processStatus().setStatus("Analysis", "Analyzing additional data sources (3rd party)");
|
plugin.processStatus().setStatus("Analysis", "Analyzing additional data sources (3rd party)");
|
||||||
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(uuids));
|
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(uuids));
|
||||||
|
|
||||||
analysisCache.cache(analysisData);
|
analysisCache.cache(analysisData);
|
||||||
long time = plugin.processStatus().finishExecution("Analysis");
|
long time = Benchmark.stop("Analysis", "Analysis");
|
||||||
|
|
||||||
|
Log.logDebug("Analysis", time);
|
||||||
|
|
||||||
if (Settings.ANALYSIS_LOG_FINISHED.isTrue()) {
|
if (Settings.ANALYSIS_LOG_FINISHED.isTrue()) {
|
||||||
Log.info(Phrase.ANALYSIS_COMPLETE.parse(String.valueOf(time), HtmlUtils.getServerAnalysisUrlWithProtocol()));
|
Log.info(Phrase.ANALYSIS_COMPLETE.parse(String.valueOf(time), HtmlUtils.getServerAnalysisUrlWithProtocol()));
|
||||||
@ -178,7 +181,7 @@ public class Analysis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> analyzeAdditionalPluginData(List<UUID> uuids) {
|
private Map<String, String> analyzeAdditionalPluginData(List<UUID> uuids) {
|
||||||
Benchmark.start("Analysis: 3rd party");
|
Benchmark.start("3rd party");
|
||||||
final Map<String, String> replaceMap = new HashMap<>();
|
final Map<String, String> replaceMap = new HashMap<>();
|
||||||
final HookHandler hookHandler = plugin.getHookHandler();
|
final HookHandler hookHandler = plugin.getHookHandler();
|
||||||
final List<PluginData> sources = hookHandler.getAdditionalDataSources().stream()
|
final List<PluginData> sources = hookHandler.getAdditionalDataSources().stream()
|
||||||
@ -192,7 +195,7 @@ public class Analysis {
|
|||||||
};
|
};
|
||||||
final AnalysisType bool = AnalysisType.BOOLEAN_PERCENTAGE;
|
final AnalysisType bool = AnalysisType.BOOLEAN_PERCENTAGE;
|
||||||
final AnalysisType boolTot = AnalysisType.BOOLEAN_TOTAL;
|
final AnalysisType boolTot = AnalysisType.BOOLEAN_TOTAL;
|
||||||
Log.debug("Analyzing additional sources: " + sources.size());
|
Log.debug("Analysis", "Additional Sources: " + sources.size());
|
||||||
sources.parallelStream().filter(Verify::notNull).forEach(source -> {
|
sources.parallelStream().filter(Verify::notNull).forEach(source -> {
|
||||||
try {
|
try {
|
||||||
Benchmark.start("Source " + source.getPlaceholder("").replace("%", ""));
|
Benchmark.start("Source " + source.getPlaceholder("").replace("%", ""));
|
||||||
@ -225,10 +228,10 @@ public class Analysis {
|
|||||||
|
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
} finally {
|
} finally {
|
||||||
Benchmark.stop("Source " + source.getPlaceholder("").replace("%", ""));
|
Benchmark.stop("Analysis", "Source " + source.getPlaceholder("").replace("%", ""));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Benchmark.stop("Analysis: 3rd party");
|
Benchmark.stop("Analysis", "3rd party");
|
||||||
return replaceMap;
|
return replaceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +263,7 @@ public class Analysis {
|
|||||||
|
|
||||||
long now = MiscUtils.getTime();
|
long now = MiscUtils.getTime();
|
||||||
|
|
||||||
Benchmark.start("Analysis: Fill Dataset");
|
Benchmark.start("Fill Dataset");
|
||||||
rawData.forEach(uData -> {
|
rawData.forEach(uData -> {
|
||||||
uData.access();
|
uData.access();
|
||||||
Map<String, Long> gmTimes = uData.getGmTimes().getTimes();
|
Map<String, Long> gmTimes = uData.getGmTimes().getTimes();
|
||||||
@ -307,6 +310,6 @@ public class Analysis {
|
|||||||
joinInfo.addSessions(uuid, sessions);
|
joinInfo.addSessions(uuid, sessions);
|
||||||
uData.stopAccessing();
|
uData.stopAccessing();
|
||||||
});
|
});
|
||||||
Benchmark.stop("Analysis: Fill Dataset");
|
Benchmark.stop("Analysis", "Fill Dataset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,8 +201,7 @@ public class AnalysisUtils {
|
|||||||
|
|
||||||
private static String logPluginDataCausedError(PluginData source, Throwable e) {
|
private static String logPluginDataCausedError(PluginData source, Throwable e) {
|
||||||
Log.error("A PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", ""));
|
Log.error("A PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", ""));
|
||||||
Log.toLog("A PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", ""), Log.getErrorsFilename());
|
Log.toLog("PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", ""), e);
|
||||||
Log.toLog("com.djrapitops.plan.utilities.AnalysisUtils", e);
|
|
||||||
return source.parseContainer("", "Exception during calculation.");
|
return source.parseContainer("", "Exception during calculation.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,39 +37,41 @@ public class DBUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testSplitIntoBatches() {
|
public void testSplitIntoBatches() {
|
||||||
List<Integer> list = new ArrayList<>();
|
List<Integer> list = new ArrayList<>();
|
||||||
for (int i = 0; i < 3000; i++) {
|
for (int i = 0; i < 21336; i++) {
|
||||||
list.add(i);
|
list.add(i);
|
||||||
}
|
}
|
||||||
List<List<Integer>> result = DBUtils.splitIntoBatches(list);
|
List<List<Integer>> result = DBUtils.splitIntoBatches(list);
|
||||||
assertEquals(2, result.size());
|
assertEquals(3, result.size());
|
||||||
assertEquals(2048, result.get(0).size());
|
assertEquals(10192, result.get(0).size());
|
||||||
assertEquals(952, result.get(1).size());
|
assertEquals(10192, result.get(1).size());
|
||||||
|
assertEquals(952, result.get(2).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSplitIntoBatchesSingleBatch() {
|
public void testSplitIntoBatchesSingleBatch() {
|
||||||
List<Integer> list = new ArrayList<>();
|
List<Integer> list = new ArrayList<>();
|
||||||
for (int i = 0; i < 2048; i++) {
|
for (int i = 0; i < 10192; i++) {
|
||||||
list.add(i);
|
list.add(i);
|
||||||
}
|
}
|
||||||
List<List<Integer>> result = DBUtils.splitIntoBatches(list);
|
List<List<Integer>> result = DBUtils.splitIntoBatches(list);
|
||||||
assertEquals(1, result.size());
|
assertEquals(1, result.size());
|
||||||
assertEquals(2048, result.get(0).size());
|
assertEquals(10192, result.get(0).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSplitIntoBatchesId() {
|
public void testSplitIntoBatchesId() {
|
||||||
Map<Integer, List<Integer>> map = new HashMap<>();
|
Map<Integer, List<Integer>> map = new HashMap<>();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
for (int j = 0; j < 300; j++) {
|
for (int j = 0; j < 2133; j++) {
|
||||||
map.computeIfAbsent(i, k -> new ArrayList<>());
|
map.computeIfAbsent(i, k -> new ArrayList<>());
|
||||||
map.get(i).add(j);
|
map.get(i).add(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<List<Container<Integer>>> result = DBUtils.splitIntoBatchesId(map);
|
List<List<Container<Integer>>> result = DBUtils.splitIntoBatchesId(map);
|
||||||
assertEquals(2, result.size());
|
assertEquals(3, result.size());
|
||||||
assertEquals(2048, result.get(0).size());
|
assertEquals(10192, result.get(0).size());
|
||||||
assertEquals(952, result.get(1).size());
|
assertEquals(10192, result.get(1).size());
|
||||||
|
assertEquals(946, result.get(2).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class DatabaseCommitTest {
|
|||||||
public void testCommitToDBFile5() throws SQLException, PassEncryptUtil.CannotPerformOperationException {
|
public void testCommitToDBFile5() throws SQLException, PassEncryptUtil.CannotPerformOperationException {
|
||||||
db.init();
|
db.init();
|
||||||
List<UserData> data = RandomData.randomUserData();
|
List<UserData> data = RandomData.randomUserData();
|
||||||
WebUser webUser = new WebUser("Test", PassEncryptUtil.createHash("surprise"), 0);
|
WebUser webUser = new WebUser("Test", "SHA1:rioegnorgiengoieng:oiegnoeigneo:352", 0);
|
||||||
db.getSecurityTable().addNewUser(webUser);
|
db.getSecurityTable().addNewUser(webUser);
|
||||||
db.close();
|
db.close();
|
||||||
db.init();
|
db.init();
|
||||||
|
@ -78,7 +78,7 @@ public class TestInit {
|
|||||||
|
|
||||||
// Abstract Plugin Framework Mocks.
|
// Abstract Plugin Framework Mocks.
|
||||||
BukkitLog<Plan> log = new BukkitLog<>(planMock, "console", "");
|
BukkitLog<Plan> log = new BukkitLog<>(planMock, "console", "");
|
||||||
BenchUtil bench = new BenchUtil();
|
BenchUtil bench = new BenchUtil(planMock);
|
||||||
ServerVariableHolder serverVariableHolder = new ServerVariableHolder(mockServer);
|
ServerVariableHolder serverVariableHolder = new ServerVariableHolder(mockServer);
|
||||||
ProcessStatus<Plan> process = new ProcessStatus<>(planMock);
|
ProcessStatus<Plan> process = new ProcessStatus<>(planMock);
|
||||||
Fetch fetch = new Fetch(planMock);
|
Fetch fetch = new Fetch(planMock);
|
||||||
|
Loading…
Reference in New Issue
Block a user