mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-10 18:37:57 +01:00
Change some '+ ""' to '#.toString'
Further migration to Java 8 (e.g. Map#getOrDefault) Gets the TPS per Paper API if Paper is installed Adds CPU Usage Graph Backend Still ToDo: 1. Conversion from old TPS structure to new one 2. Frontend
This commit is contained in:
parent
96c48af3b1
commit
8d2b1dbb1c
11
Plan/pom.xml
11
Plan/pom.xml
@ -11,6 +11,10 @@
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>destroystokyo-repo</id>
|
||||
<url>https://repo.destroystokyo.com/repository/maven-public//</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<!-- Spigot 1.12 built with Buildtools for Database classes.-->
|
||||
@ -20,6 +24,13 @@
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- PaperSpigot 1.12 built for TPS Getter Support.-->
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Framework for easier plugin development-->
|
||||
<dependency>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
|
@ -73,7 +73,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
|
||||
private WebSocketServer uiServer;
|
||||
|
||||
private ServerVariableHolder serverVariableHolder;
|
||||
public ServerVariableHolder serverVariableHolder;
|
||||
private int bootAnalysisTaskID = -1;
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@ public class ServerVariableHolder {
|
||||
|
||||
private final int maxPlayers;
|
||||
private final String ip;
|
||||
private final boolean usingPaper;
|
||||
|
||||
/**
|
||||
* Constructor, grabs the variables.
|
||||
@ -22,6 +23,7 @@ public class ServerVariableHolder {
|
||||
public ServerVariableHolder(Server server) {
|
||||
maxPlayers = server.getMaxPlayers();
|
||||
ip = server.getIp();
|
||||
usingPaper = server.getName().equals("Paper");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,4 +43,13 @@ public class ServerVariableHolder {
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the server is using PaperSpigot.
|
||||
*
|
||||
* @return if the server is using PaperSpigot.
|
||||
*/
|
||||
public boolean isUsingPaper() {
|
||||
return usingPaper;
|
||||
}
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ public class AnalyzeCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Phrase.ERROR_WEBSERVER_OFF_ANALYSIS + "", sender)) {
|
||||
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Phrase.ERROR_WEBSERVER_OFF_ANALYSIS.toString(), sender)) {
|
||||
return true;
|
||||
}
|
||||
if (!Check.isTrue(analysisCache.isAnalysisEnabled(), Phrase.ERROR_ANALYSIS_DISABLED_TEMPORARILY + "", sender)) {
|
||||
if (!Check.isTrue(analysisCache.isAnalysisEnabled(), Phrase.ERROR_ANALYSIS_DISABLED_TEMPORARILY.toString(), sender)) {
|
||||
if (!analysisCache.isCached()) {
|
||||
return true;
|
||||
}
|
||||
@ -117,13 +117,13 @@ public class AnalyzeCommand extends SubCommand {
|
||||
*/
|
||||
private void sendAnalysisMessage(ISender sender) {
|
||||
boolean textUI = Settings.USE_ALTERNATIVE_UI.isTrue();
|
||||
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER + "");
|
||||
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER.toString());
|
||||
if (textUI) {
|
||||
sender.sendMessage(TextUI.getAnalysisMessages());
|
||||
} else {
|
||||
// Link
|
||||
String url = HtmlUtils.getServerAnalysisUrlWithProtocol();
|
||||
String message = Phrase.CMD_LINK + "";
|
||||
String message = Phrase.CMD_LINK.toString();
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
sender.sendMessage(message + url);
|
||||
|
@ -25,7 +25,7 @@ public class InfoCommand extends SubCommand {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public InfoCommand(Plan plugin) {
|
||||
super("info", CommandType.CONSOLE, Permissions.INFO.getPermission(), Phrase.CMD_USG_INFO + "");
|
||||
super("info", CommandType.CONSOLE, Permissions.INFO.getPermission(), Phrase.CMD_USG_INFO.toString());
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@ -34,11 +34,11 @@ public class InfoCommand extends SubCommand {
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
ChatColor tColor = Phrase.COLOR_SEC.color();
|
||||
String[] messages = {
|
||||
Phrase.CMD_INFO_HEADER + "",
|
||||
Phrase.CMD_INFO_HEADER.toString(),
|
||||
Phrase.CMD_INFO_VERSION.parse(plugin.getDescription().getVersion()),
|
||||
Phrase.CMD_BALL.toString() + tColor + " " + Version.checkVersion(plugin),
|
||||
Phrase.CMD_MANAGE_STATUS_ACTIVE_DB.parse(plugin.getDB().getConfigName()),
|
||||
Phrase.CMD_FOOTER + ""
|
||||
Phrase.CMD_FOOTER.toString()
|
||||
};
|
||||
sender.sendMessage(messages);
|
||||
return true;
|
||||
|
@ -7,13 +7,7 @@ import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.SubCommand;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.*;
|
||||
import main.java.com.djrapitops.plan.command.ConditionUtils;
|
||||
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
|
||||
import main.java.com.djrapitops.plan.ui.text.TextUI;
|
||||
@ -25,6 +19,9 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandException;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This command is used to cache UserData to InspectCache and display the link.
|
||||
*
|
||||
@ -42,7 +39,7 @@ public class InspectCommand extends SubCommand {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public InspectCommand(Plan plugin) {
|
||||
super("inspect", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.INSPECT.getPermission(), Phrase.CMD_USG_INSPECT + "", Phrase.ARG_PLAYER + "");
|
||||
super("inspect", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.INSPECT.getPermission(), Phrase.CMD_USG_INSPECT.toString(), Phrase.ARG_PLAYER.toString());
|
||||
|
||||
this.plugin = plugin;
|
||||
inspectCache = plugin.getInspectCache();
|
||||
@ -50,7 +47,7 @@ public class InspectCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Phrase.ERROR_WEBSERVER_OFF_INSPECT + "", sender)) {
|
||||
if (!Check.isTrue(ConditionUtils.pluginHasViewCapability(), Phrase.ERROR_WEBSERVER_OFF_INSPECT.toString(), sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class ManageBackupCommand extends SubCommand {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageBackupCommand(Plan plugin) {
|
||||
super("backup", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_BACKUP + "", "<DB>");
|
||||
super("backup", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_BACKUP.toString(), "<DB>");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@ -37,7 +37,7 @@ public class ManageBackupCommand extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
try {
|
||||
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_BACKUP + ""), sender)) {
|
||||
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_BACKUP.toString()), sender)) {
|
||||
return true;
|
||||
}
|
||||
String dbName = args[0].toLowerCase();
|
||||
@ -49,14 +49,14 @@ public class ManageBackupCommand extends SubCommand {
|
||||
final Database database = ManageUtils.getDB(plugin, dbName);
|
||||
|
||||
// If DB is null return
|
||||
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE + "", sender)) {
|
||||
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
|
||||
Log.error(dbName + " was null!");
|
||||
return true;
|
||||
}
|
||||
|
||||
runBackupTask(sender, args, database);
|
||||
} catch (NullPointerException e) {
|
||||
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
|
||||
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ public class ManageCleanCommand extends SubCommand {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageCleanCommand(Plan plugin) {
|
||||
super("clean", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_CLEAN + "", "<DB>");
|
||||
super("clean", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_CLEAN.toString(), "<DB>");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
if (!Check.isTrue(args.length != 0, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE + "", sender)) {
|
||||
if (!Check.isTrue(args.length != 0, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString(), sender)) {
|
||||
return true;
|
||||
}
|
||||
String dbName = args[0].toLowerCase();
|
||||
@ -49,7 +49,7 @@ public class ManageCleanCommand extends SubCommand {
|
||||
final Database database = ManageUtils.getDB(plugin, dbName);
|
||||
|
||||
// If DB is null return
|
||||
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE + "", sender)) {
|
||||
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
|
||||
Log.error(dbName + " was null!");
|
||||
return true;
|
||||
}
|
||||
@ -64,7 +64,7 @@ public class ManageCleanCommand extends SubCommand {
|
||||
public void run() {
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
|
||||
database.clean();
|
||||
sender.sendMessage(Phrase.MANAGE_SUCCESS + "");
|
||||
sender.sendMessage(Phrase.MANAGE_SUCCESS.toString());
|
||||
this.cancel();
|
||||
}
|
||||
}).runTaskAsynchronously();
|
||||
|
@ -71,9 +71,9 @@ public class ManageClearCommand extends SubCommand {
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
|
||||
|
||||
if (database.removeAllData()) {
|
||||
sender.sendMessage(Phrase.MANAGE_CLEAR_SUCCESS + "");
|
||||
sender.sendMessage(Phrase.MANAGE_CLEAR_SUCCESS.toString());
|
||||
} else {
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
|
||||
}
|
||||
} finally {
|
||||
this.cancel();
|
||||
|
@ -29,14 +29,14 @@ public class ManageHotswapCommand extends SubCommand {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageHotswapCommand(Plan plugin) {
|
||||
super("hotswap", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_HOTSWAP + "", "<DB>");
|
||||
super("hotswap", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_HOTSWAP.toString(), "<DB>");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE + "", sender)) {
|
||||
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString(), sender)) {
|
||||
return true;
|
||||
}
|
||||
String dbName = args[0].toLowerCase();
|
||||
@ -53,7 +53,7 @@ public class ManageHotswapCommand extends SubCommand {
|
||||
final Database database = ManageUtils.getDB(plugin, dbName);
|
||||
|
||||
// If DB is null return
|
||||
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE + "", sender)) {
|
||||
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
|
||||
Log.error(dbName + " was null!");
|
||||
return true;
|
||||
}
|
||||
@ -62,7 +62,7 @@ public class ManageHotswapCommand extends SubCommand {
|
||||
database.getVersion(); //Test db connection
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
|
||||
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class ManageImportCommand extends SubCommand {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageImportCommand(Plan plugin) {
|
||||
super("import", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_IMPORT + "", Phrase.ARG_IMPORT + "");
|
||||
super("import", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_IMPORT.toString(), Phrase.ARG_IMPORT.toString());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@ -74,12 +74,12 @@ public class ManageImportCommand extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sender.sendMessage(Phrase.MANAGE_IMPORTING + "");
|
||||
sender.sendMessage(Phrase.MANAGE_IMPORTING.toString());
|
||||
List<UUID> uuids = Fetch.getIOfflinePlayers().stream().map(IOfflinePlayer::getUniqueId).collect(Collectors.toList());
|
||||
if (importer.importData(uuids, importArguments)) {
|
||||
sender.sendMessage(Phrase.MANAGE_SUCCESS + "");
|
||||
sender.sendMessage(Phrase.MANAGE_SUCCESS.toString());
|
||||
} else {
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
|
||||
}
|
||||
} finally {
|
||||
this.cancel();
|
||||
|
@ -5,8 +5,6 @@ import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.SubCommand;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
@ -15,6 +13,9 @@ import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.ManageUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This manage subcommand is used to move all data from one database to another.
|
||||
*
|
||||
@ -33,14 +34,14 @@ public class ManageMoveCommand extends SubCommand {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageMoveCommand(Plan plugin) {
|
||||
super("move", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_MOVE + "", Phrase.ARG_MOVE + "");
|
||||
super("move", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_MOVE.toString(), Phrase.ARG_MOVE.toString());
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
if (!Check.isTrue(args.length >= 2, Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_MOVE + ""), sender)) {
|
||||
if (!Check.isTrue(args.length >= 2, Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_MOVE.toString()), sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -57,7 +58,7 @@ public class ManageMoveCommand extends SubCommand {
|
||||
if (!Check.isTrue(isCorrectDB, Phrase.MANAGE_ERROR_INCORRECT_DB + toDB, sender)) {
|
||||
return true;
|
||||
}
|
||||
if (!Check.isTrue(!Verify.equalsIgnoreCase(fromDB, toDB), Phrase.MANAGE_ERROR_SAME_DB + "", sender)) {
|
||||
if (!Check.isTrue(!Verify.equalsIgnoreCase(fromDB, toDB), Phrase.MANAGE_ERROR_SAME_DB.toString(), sender)) {
|
||||
return true;
|
||||
}
|
||||
if (!Check.isTrue(Verify.contains("-a", args), Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(args[1])), sender)) {
|
||||
@ -66,14 +67,14 @@ public class ManageMoveCommand extends SubCommand {
|
||||
|
||||
final Database fromDatabase = ManageUtils.getDB(plugin, fromDB);
|
||||
|
||||
if (!Check.isTrue(Verify.notNull(fromDatabase), Phrase.MANAGE_DATABASE_FAILURE + "", sender)) {
|
||||
if (!Check.isTrue(Verify.notNull(fromDatabase), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
|
||||
Log.error(fromDB + " was null!");
|
||||
return true;
|
||||
}
|
||||
|
||||
final Database toDatabase = ManageUtils.getDB(plugin, toDB);
|
||||
|
||||
if (!Check.isTrue(Verify.notNull(toDatabase), Phrase.MANAGE_DATABASE_FAILURE + "", sender)) {
|
||||
if (!Check.isTrue(Verify.notNull(toDatabase), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
|
||||
Log.error(toDB + " was null!");
|
||||
return true;
|
||||
}
|
||||
@ -96,9 +97,9 @@ public class ManageMoveCommand extends SubCommand {
|
||||
sender.sendMessage(Phrase.MANAGE_MOVE_SUCCESS + "");
|
||||
boolean movedToCurrentDatabase = Verify.equalsIgnoreCase(toDatabase.getConfigName(), plugin.getDB().getConfigName());
|
||||
|
||||
Check.isTrue(!movedToCurrentDatabase, Phrase.MANAGE_DB_CONFIG_REMINDER + "", sender);
|
||||
Check.isTrue(!movedToCurrentDatabase, Phrase.MANAGE_DB_CONFIG_REMINDER.toString(), sender);
|
||||
} else {
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass().getName() + " " + getTaskName(), e);
|
||||
|
@ -5,8 +5,6 @@ import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.SubCommand;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
@ -15,6 +13,9 @@ import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This manage subcommand is used to remove a single player's data from the
|
||||
* database.
|
||||
@ -31,14 +32,14 @@ public class ManageRemoveCommand extends SubCommand {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageRemoveCommand(Plan plugin) {
|
||||
super("remove", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_REMOVE + "", 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE + "", sender)) {
|
||||
if (!Check.isTrue(args.length >= 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString(), sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -73,11 +74,11 @@ public class ManageRemoveCommand extends SubCommand {
|
||||
if (plugin.getDB().removeAccount(uuid.toString())) {
|
||||
sender.sendMessage(Phrase.MANAGE_REMOVE_SUCCESS.parse(playerName, plugin.getDB().getConfigName()));
|
||||
} else {
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL.toString());
|
||||
}
|
||||
} finally {
|
||||
this.cancel();
|
||||
|
@ -5,9 +5,6 @@ import com.djrapitops.plugin.command.ISender;
|
||||
import com.djrapitops.plugin.command.SubCommand;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
@ -17,6 +14,10 @@ import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.ManageUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This manage subcommand is used to restore a backup.db file in the
|
||||
* /plugins/Plan folder.
|
||||
@ -33,14 +34,14 @@ public class ManageRestoreCommand extends SubCommand {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageRestoreCommand(Plan plugin) {
|
||||
super("restore", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_RESTORE + "", Phrase.ARG_RESTORE + "");
|
||||
super("restore", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_RESTORE.toString(), Phrase.ARG_RESTORE.toString());
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
if (!Check.isTrue(args.length >= 2, Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_RESTORE + ""), sender)) {
|
||||
if (!Check.isTrue(args.length >= 2, Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_RESTORE.toString()), sender)) {
|
||||
return true;
|
||||
}
|
||||
String db = args[1].toLowerCase();
|
||||
@ -55,7 +56,7 @@ public class ManageRestoreCommand extends SubCommand {
|
||||
|
||||
final Database database = ManageUtils.getDB(plugin, db);
|
||||
|
||||
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE + "", sender)) {
|
||||
if (!Check.isTrue(Verify.notNull(database), Phrase.MANAGE_DATABASE_FAILURE.toString(), sender)) {
|
||||
Log.error(db + " was null!");
|
||||
return true;
|
||||
}
|
||||
@ -82,7 +83,7 @@ public class ManageRestoreCommand extends SubCommand {
|
||||
}
|
||||
SQLiteDB backupDB = new SQLiteDB(plugin, backupDBName);
|
||||
if (!backupDB.init()) {
|
||||
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
|
||||
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE.toString());
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
|
||||
|
@ -22,7 +22,7 @@ public class ManageStatusCommand extends SubCommand {
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageStatusCommand(Plan plugin) {
|
||||
super("status", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_STATUS + "");
|
||||
super("status", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_STATUS.toString());
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@ -30,13 +30,13 @@ public class ManageStatusCommand extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
|
||||
String[] messages = new String[]{
|
||||
Phrase.CMD_MANAGE_STATUS_HEADER + "",
|
||||
Phrase.CMD_MANAGE_STATUS_HEADER.toString(),
|
||||
Phrase.CMD_MANAGE_STATUS_ACTIVE_DB.parse(plugin.getDB().getConfigName()),
|
||||
Phrase.CMD_MANAGE_STATUS_QUEUE_PROCESS.parse("" + plugin.getHandler().getProcessTask().size()),
|
||||
Phrase.CMD_MANAGE_STATUS_QUEUE_SAVE.parse("" + plugin.getHandler().getSaveTask().size()),
|
||||
Phrase.CMD_MANAGE_STATUS_QUEUE_GET.parse("" + plugin.getHandler().getGetTask().size()),
|
||||
Phrase.CMD_MANAGE_STATUS_QUEUE_CLEAR.parse("" + plugin.getHandler().getClearTask().size()),
|
||||
Phrase.CMD_FOOTER + ""
|
||||
Phrase.CMD_FOOTER.toString()
|
||||
};
|
||||
|
||||
sender.sendMessage(messages);
|
||||
|
@ -16,6 +16,7 @@ public class TPS {
|
||||
private final long date;
|
||||
private final double tps;
|
||||
private final int players;
|
||||
private final double cpuUsage;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -23,11 +24,13 @@ public class TPS {
|
||||
* @param date time of the average calculation.
|
||||
* @param tps average tps for the last minute.
|
||||
* @param players average players for the last minute.
|
||||
* @param cpuUsage average CPU usage for the last minute.
|
||||
*/
|
||||
public TPS(long date, double tps, int players) {
|
||||
public TPS(long date, double tps, int players, double cpuUsage) {
|
||||
this.date = date;
|
||||
this.tps = tps;
|
||||
this.players = players;
|
||||
this.cpuUsage = cpuUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,6 +60,15 @@ public class TPS {
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the average CPU Usage for the minute.
|
||||
*
|
||||
* @return 0-20 double
|
||||
*/
|
||||
public double getCPUUsage() {
|
||||
return cpuUsage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
@ -80,11 +92,12 @@ public class TPS {
|
||||
final TPS other = (TPS) obj;
|
||||
return this.date == other.date
|
||||
&& Double.doubleToLongBits(this.tps) == Double.doubleToLongBits(other.tps)
|
||||
&& this.players == other.players;
|
||||
&& this.players == other.players
|
||||
&& this.cpuUsage == other.cpuUsage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TPS{" + date + "|" + tps + "|" + players + '}';
|
||||
return "TPS{" + date + "|" + tps + "|" + players + "|" + cpuUsage + "}";
|
||||
}
|
||||
}
|
||||
|
@ -363,11 +363,14 @@ public class DataCacheHandler extends SessionCache {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<List<TPS>> copy = new ArrayList<>(unsavedTPSHistory);
|
||||
|
||||
for (List<TPS> history : copy) {
|
||||
final long lastDate = history.get(history.size() - 1).getDate();
|
||||
final double averageTPS = MathUtils.averageDouble(history.stream().map(TPS::getTps));
|
||||
final int averagePlayersOnline = (int) MathUtils.averageInt(history.stream().map(TPS::getPlayers));
|
||||
averages.add(new TPS(lastDate, averageTPS, averagePlayersOnline));
|
||||
final double averageCPUUsage = MathUtils.averageDouble(history.stream().map(TPS::getCPUUsage));
|
||||
|
||||
averages.add(new TPS(lastDate, averageTPS, averagePlayersOnline, averageCPUUsage));
|
||||
}
|
||||
unsavedTPSHistory.removeAll(copy);
|
||||
return averages;
|
||||
@ -516,10 +519,9 @@ public class DataCacheHandler extends SessionCache {
|
||||
* @param command "/command"
|
||||
*/
|
||||
public void handleCommand(String command) {
|
||||
if (!commandUse.containsKey(command)) {
|
||||
commandUse.put(command, 0);
|
||||
}
|
||||
commandUse.put(command, commandUse.get(command) + 1);
|
||||
int amount = commandUse.getOrDefault(command, 0);
|
||||
|
||||
commandUse.put(command, amount + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,6 +55,7 @@ public class InspectCacheHandler {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
handler.getUserDataForProcessing(cacher, uuid, false);
|
||||
}
|
||||
|
||||
@ -103,10 +104,7 @@ public class InspectCacheHandler {
|
||||
* @return -1 when not cached or Epoch millisecond.
|
||||
*/
|
||||
public long getCacheTime(UUID uuid) {
|
||||
if (cacheTimes.containsKey(uuid)) {
|
||||
return cacheTimes.get(uuid);
|
||||
}
|
||||
return -1;
|
||||
return cacheTimes.getOrDefault(uuid, -1L);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,10 @@ import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.TPS;
|
||||
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -36,32 +39,70 @@ public class TPSCountTimer extends AbsRunnable {
|
||||
long nanoTime = System.nanoTime();
|
||||
long now = MiscUtils.getTime();
|
||||
long diff = nanoTime - lastCheckNano;
|
||||
on
|
||||
lastCheckNano = nanoTime;
|
||||
|
||||
if (diff > nanoTime) { // First run's diff = nanoTime + 1, no calc possible.
|
||||
Log.debug("First run of TPSCountTimer Task.");
|
||||
return;
|
||||
}
|
||||
diff -= TimeAmount.MILLISECOND.ns() * 40L; // 40ms removed because the run appears to take 40-50ms, screwing the tps.
|
||||
|
||||
TPS tps = calculateTPS(diff, now);
|
||||
history.add(tps);
|
||||
|
||||
if (history.size() >= 60) {
|
||||
handler.addTPSLastMinute(history);
|
||||
history.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public TPS calculateTPS(long diff, long now) {
|
||||
/**
|
||||
* Calculates the TPS
|
||||
*
|
||||
* @param diff The time difference between the last run and the new run
|
||||
* @param now The time right now
|
||||
* @return
|
||||
*/
|
||||
private TPS calculateTPS(long diff, long now) {
|
||||
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
|
||||
int availableProcessors = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
|
||||
final double averageCPUUsage = MathUtils.round(operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0);
|
||||
|
||||
int playersOnline = plugin.getServer().getOnlinePlayers().size();
|
||||
|
||||
if (plugin.serverVariableHolder.isUsingPaper()) {
|
||||
return getTPSPaper(now, averageCPUUsage, playersOnline);
|
||||
} else {
|
||||
diff -= TimeAmount.MILLISECOND.ns() * 40L; // 40ms removed because the run appears to take 40-50ms, screwing the tps.
|
||||
return getTPS(diff, now, averageCPUUsage, playersOnline);
|
||||
}
|
||||
}
|
||||
|
||||
private TPS getTPSPaper(long now, double cpuUsage, int playersOnline) {
|
||||
double tps = plugin.getServer().getTPS()[0];
|
||||
|
||||
if (tps > 20) {
|
||||
tps = 20;
|
||||
}
|
||||
|
||||
tps = MathUtils.round(tps);
|
||||
|
||||
return new TPS(now, tps, playersOnline, cpuUsage);
|
||||
}
|
||||
|
||||
private TPS getTPS(long diff, long now, double cpuUsage, int playersOnline) {
|
||||
if (diff < TimeAmount.SECOND.ns()) { // No tick count above 20
|
||||
diff = TimeAmount.SECOND.ns();
|
||||
}
|
||||
int playersOnline = plugin.getServer().getOnlinePlayers().size();
|
||||
|
||||
long twentySeconds = 20L * TimeAmount.SECOND.ns();
|
||||
while (diff > twentySeconds) {
|
||||
history.add(new TPS(now, 0, playersOnline));
|
||||
history.add(new TPS(now, 0, playersOnline, cpuUsage));
|
||||
diff -= twentySeconds;
|
||||
}
|
||||
|
||||
double tpsN = twentySeconds / diff;
|
||||
|
||||
return new TPS(now, tpsN, playersOnline);
|
||||
return new TPS(now, tpsN, playersOnline, cpuUsage);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.database.tables;
|
||||
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.data.TPS;
|
||||
import main.java.com.djrapitops.plan.database.DBUtils;
|
||||
@ -13,6 +8,12 @@ import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class representing database table plan_tps
|
||||
*
|
||||
@ -24,6 +25,7 @@ public class TPSTable extends Table {
|
||||
private final String columnDate;
|
||||
private final String columnTPS;
|
||||
private final String columnPlayers;
|
||||
private final String columnCPUUsage;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -35,6 +37,7 @@ public class TPSTable extends Table {
|
||||
columnDate = "date";
|
||||
columnTPS = "tps";
|
||||
columnPlayers = "players_online";
|
||||
columnCPUUsage = "cpu_usage";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,7 +46,8 @@ public class TPSTable extends Table {
|
||||
execute("CREATE TABLE IF NOT EXISTS " + tableName + " ("
|
||||
+ columnDate + " bigint NOT NULL, "
|
||||
+ columnTPS + " double NOT NULL, "
|
||||
+ columnPlayers + " integer NOT NULL"
|
||||
+ columnPlayers + " integer NOT NULL, "
|
||||
+ columnCPUUsage + " double NOT NULL"
|
||||
+ ")"
|
||||
);
|
||||
return true;
|
||||
@ -69,7 +73,8 @@ public class TPSTable extends Table {
|
||||
long date = set.getLong(columnDate);
|
||||
double tps = set.getDouble(columnTPS);
|
||||
int players = set.getInt(columnPlayers);
|
||||
data.add(new TPS(date, tps, players));
|
||||
double cpuUsage = set.getDouble(columnCPUUsage);
|
||||
data.add(new TPS(date, tps, players, cpuUsage));
|
||||
}
|
||||
return data;
|
||||
} finally {
|
||||
@ -97,8 +102,9 @@ public class TPSTable extends Table {
|
||||
statement = prepareStatement("INSERT INTO " + tableName + " ("
|
||||
+ columnDate + ", "
|
||||
+ columnTPS + ", "
|
||||
+ columnPlayers
|
||||
+ ") VALUES (?, ?, ?)");
|
||||
+ columnPlayers + ", "
|
||||
+ columnCPUUsage
|
||||
+ ") VALUES (?, ?, ?, ?)");
|
||||
|
||||
boolean commitRequired = false;
|
||||
int i = 0;
|
||||
@ -106,6 +112,7 @@ public class TPSTable extends Table {
|
||||
statement.setLong(1, tps.getDate());
|
||||
statement.setDouble(2, tps.getTps());
|
||||
statement.setInt(3, tps.getPlayers());
|
||||
statement.setDouble(4, tps.getCPUUsage());
|
||||
statement.addBatch();
|
||||
commitRequired = true;
|
||||
i++;
|
||||
|
@ -247,10 +247,10 @@ public class AnalysisUtils {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
int day = getDayOfYear(session);
|
||||
if (!uniqueJoins.containsKey(day)) {
|
||||
uniqueJoins.put(day, new HashSet<>());
|
||||
}
|
||||
|
||||
uniqueJoins.computeIfAbsent(day, computedDay -> new HashSet<>());
|
||||
uniqueJoins.get(day).add(uuid);
|
||||
}
|
||||
});
|
||||
|
@ -168,4 +168,15 @@ public class MathUtils {
|
||||
|
||||
return biggest.isPresent() ? biggest.getAsLong() : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounds the double to a double with two digits at the end.
|
||||
* Output: #.##
|
||||
*
|
||||
* @param number The number that's rounded
|
||||
* @return The rounded number
|
||||
*/
|
||||
public static double round(double number) {
|
||||
return Math.round(number * 100.0) / 100.0;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
|
||||
import main.java.com.djrapitops.plan.database.tables.TPSTable;
|
||||
import main.java.com.djrapitops.plan.utilities.ManageUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -33,6 +34,8 @@ import test.java.utils.TestInit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.Charset;
|
||||
@ -398,10 +401,13 @@ public class DatabaseTest {
|
||||
TPSTable tpsTable = db.getTpsTable();
|
||||
List<TPS> expected = new ArrayList<>();
|
||||
Random r = new Random();
|
||||
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000)));
|
||||
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000)));
|
||||
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000)));
|
||||
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000)));
|
||||
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
|
||||
int availableProcessors = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
|
||||
final double averageCPUUsage = MathUtils.round(operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0);
|
||||
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage));
|
||||
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage));
|
||||
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage));
|
||||
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage));
|
||||
tpsTable.saveTPSData(expected);
|
||||
assertEquals(expected, tpsTable.getTPSData());
|
||||
}
|
||||
@ -414,11 +420,14 @@ public class DatabaseTest {
|
||||
List<TPS> expected = new ArrayList<>();
|
||||
Random r = new Random();
|
||||
long now = System.currentTimeMillis();
|
||||
expected.add(new TPS(now, r.nextDouble(), r.nextInt(100000000)));
|
||||
expected.add(new TPS(now - 1000L, r.nextDouble(), r.nextInt(100000000)));
|
||||
expected.add(new TPS(now - 3000L, r.nextDouble(), r.nextInt(100000000)));
|
||||
expected.add(new TPS(now - (690000L * 1000L), r.nextDouble(), r.nextInt(100000000)));
|
||||
TPS tooOldTPS = new TPS(now - (691400L * 1000L), r.nextDouble(), r.nextInt(100000000));
|
||||
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
|
||||
int availableProcessors = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
|
||||
final double averageCPUUsage = MathUtils.round(operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0);
|
||||
expected.add(new TPS(now, r.nextDouble(), r.nextInt(100000000), averageCPUUsage));
|
||||
expected.add(new TPS(now - 1000L, r.nextDouble(), r.nextInt(100000000), averageCPUUsage));
|
||||
expected.add(new TPS(now - 3000L, r.nextDouble(), r.nextInt(100000000), averageCPUUsage));
|
||||
expected.add(new TPS(now - (690000L * 1000L), r.nextDouble(), r.nextInt(100000000), averageCPUUsage));
|
||||
TPS tooOldTPS = new TPS(now - (691400L * 1000L), r.nextDouble(), r.nextInt(100000000), averageCPUUsage);
|
||||
expected.add(tooOldTPS);
|
||||
tpsTable.saveTPSData(expected);
|
||||
tpsTable.clean();
|
||||
|
Loading…
Reference in New Issue
Block a user