mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-26 10:44:43 +02:00
Give periodic status messages to the console in conversion
This commit is contained in:
@ -11,6 +11,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
public interface DatabaseManager {
|
||||
// One month in milliseconds
|
||||
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||
// During convertUsers, how often to output a status
|
||||
public final int progressInterval = 200;
|
||||
|
||||
/**
|
||||
* Purge users with 0 power level from the database.
|
||||
|
@ -411,6 +411,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
public void convertUsers(DatabaseManager destination) {
|
||||
BufferedReader in = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
int convertedUsers = 0;
|
||||
long startMillis = System.currentTimeMillis();
|
||||
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
@ -427,6 +429,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
convertedUsers++;
|
||||
if ((convertedUsers % DatabaseManager.progressInterval) == 0) {
|
||||
// Can't use Bukkit.broadcastMessage because async
|
||||
System.out.println(String.format("[mcMMO] Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / ((System.currentTimeMillis() - startMillis) / 1000D)));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -447,6 +447,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "WHERE u.user = ?");
|
||||
List<String> usernames = getStoredUsers();
|
||||
ResultSet result = null;
|
||||
int convertedUsers = 0;
|
||||
long startMillis = System.currentTimeMillis();
|
||||
for (String playerName : usernames) {
|
||||
statement.setString(1, playerName);
|
||||
try {
|
||||
@ -458,6 +460,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
convertedUsers++;
|
||||
if ((convertedUsers % DatabaseManager.progressInterval) == 0) {
|
||||
// Can't use Bukkit.broadcastMessage because async
|
||||
System.out.println(String.format("[mcMMO] Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / ((System.currentTimeMillis() - startMillis) / 1000D)));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e) {
|
||||
|
Reference in New Issue
Block a user