forked from LogBlock/LogBlock
Added a debug configuration setting for timing and query information
This commit is contained in:
@ -426,7 +426,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state = conn.createStatement();
|
state = conn.createStatement();
|
||||||
rs = state.executeQuery(params.getQuery());
|
rs = executeQuery(state, params.getQuery());
|
||||||
sender.sendMessage(ChatColor.DARK_AQUA + params.getTitle() + ":");
|
sender.sendMessage(ChatColor.DARK_AQUA + params.getTitle() + ":");
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
rs.beforeFirst();
|
rs.beforeFirst();
|
||||||
@ -488,7 +488,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
state = conn.createStatement();
|
state = conn.createStatement();
|
||||||
file = new File("plugins/LogBlock/log/" + params.getTitle().replace(":", ".") + ".log");
|
file = new File("plugins/LogBlock/log/" + params.getTitle().replace(":", ".") + ".log");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Creating " + file.getName());
|
sender.sendMessage(ChatColor.GREEN + "Creating " + file.getName());
|
||||||
rs = state.executeQuery(params.getQuery());
|
rs = executeQuery(state, params.getQuery());
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
final FileWriter writer = new FileWriter(file);
|
final FileWriter writer = new FileWriter(file);
|
||||||
@ -559,7 +559,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state = conn.createStatement();
|
state = conn.createStatement();
|
||||||
rs = state.executeQuery(params.getQuery());
|
rs = executeQuery(state, params.getQuery());
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
final Player player = (Player)sender;
|
final Player player = (Player)sender;
|
||||||
final int y = rs.getInt("y");
|
final int y = rs.getInt("y");
|
||||||
@ -614,7 +614,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
new CommandSaveQueue(sender, null, false);
|
new CommandSaveQueue(sender, null, false);
|
||||||
if (!params.silent)
|
if (!params.silent)
|
||||||
sender.sendMessage(ChatColor.DARK_AQUA + "Searching " + params.getTitle() + ":");
|
sender.sendMessage(ChatColor.DARK_AQUA + "Searching " + params.getTitle() + ":");
|
||||||
rs = state.executeQuery(params.getQuery());
|
rs = executeQuery(state, params.getQuery());
|
||||||
final WorldEditor editor = new WorldEditor(logblock, params.world);
|
final WorldEditor editor = new WorldEditor(logblock, params.world);
|
||||||
|
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
@ -678,7 +678,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
state = conn.createStatement();
|
state = conn.createStatement();
|
||||||
if (!checkRestrictions(sender, params))
|
if (!checkRestrictions(sender, params))
|
||||||
return;
|
return;
|
||||||
rs = state.executeQuery(params.getQuery());
|
rs = executeQuery(state, params.getQuery());
|
||||||
if (!params.silent)
|
if (!params.silent)
|
||||||
sender.sendMessage(ChatColor.DARK_AQUA + "Searching " + params.getTitle() + ":");
|
sender.sendMessage(ChatColor.DARK_AQUA + "Searching " + params.getTitle() + ":");
|
||||||
final WorldEditor editor = new WorldEditor(logblock, params.world);
|
final WorldEditor editor = new WorldEditor(logblock, params.world);
|
||||||
@ -778,6 +778,17 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ResultSet executeQuery(Statement state, String query) throws SQLException {
|
||||||
|
if (Config.debug) {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
ResultSet rs = state.executeQuery(query);
|
||||||
|
getLogger().log(Level.INFO, "[LogBlock Debug] Time Taken: " + (System.currentTimeMillis() - startTime) + " milliseconds. Query: " + query );
|
||||||
|
return rs;
|
||||||
|
} else {
|
||||||
|
return state.executeQuery(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static List<String> argsToList(String[] arr, int offset) {
|
private static List<String> argsToList(String[] arr, int offset) {
|
||||||
final List<String> list = new ArrayList<String>(Arrays.asList(arr));
|
final List<String> list = new ArrayList<String>(Arrays.asList(arr));
|
||||||
for (int i = 0; i < offset; i++)
|
for (int i = 0; i < offset; i++)
|
||||||
|
@ -284,6 +284,9 @@ public class Consumer extends TimerTask
|
|||||||
public synchronized void run() {
|
public synchronized void run() {
|
||||||
if (queue.isEmpty() || !lock.tryLock())
|
if (queue.isEmpty() || !lock.tryLock())
|
||||||
return;
|
return;
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
int startSize = queue.size();
|
||||||
|
|
||||||
final Connection conn = logblock.getConnection();
|
final Connection conn = logblock.getConnection();
|
||||||
Statement state = null;
|
Statement state = null;
|
||||||
if (Config.queueWarningSize > 0 && queue.size() >= Config.queueWarningSize) {
|
if (Config.queueWarningSize > 0 && queue.size() >= Config.queueWarningSize) {
|
||||||
@ -365,6 +368,14 @@ public class Consumer extends TimerTask
|
|||||||
getLogger().log(Level.SEVERE, "[Consumer] SQL exception on close", ex);
|
getLogger().log(Level.SEVERE, "[Consumer] SQL exception on close", ex);
|
||||||
}
|
}
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
long timeElapsed = System.currentTimeMillis() - startTime;
|
||||||
|
int rowsProcessed = startSize - queue.size();
|
||||||
|
float rowPerTime = rowsProcessed / timeElapsed;
|
||||||
|
getLogger().log(Level.INFO, "[Consumer] Finished consumer cycle in " + timeElapsed + " milliseconds.");
|
||||||
|
getLogger().log(Level.INFO, "[Consumer] Total rows processed: " + rowsProcessed + ". row/time: " + String.format("%.4f", rowPerTime));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ public class Config
|
|||||||
public static Set<String> ignoredChat;
|
public static Set<String> ignoredChat;
|
||||||
public static SimpleDateFormat formatter;
|
public static SimpleDateFormat formatter;
|
||||||
public static boolean safetyIdCheck;
|
public static boolean safetyIdCheck;
|
||||||
|
public static boolean debug;
|
||||||
public static boolean logEnvironmentalKills;
|
public static boolean logEnvironmentalKills;
|
||||||
// Not loaded from config - checked at runtime
|
// Not loaded from config - checked at runtime
|
||||||
public static boolean mb4 = false;
|
public static boolean mb4 = false;
|
||||||
@ -129,6 +130,7 @@ public class Config
|
|||||||
def.put("tools.toolblock.mode", "LOOKUP");
|
def.put("tools.toolblock.mode", "LOOKUP");
|
||||||
def.put("tools.toolblock.permissionDefault", "OP");
|
def.put("tools.toolblock.permissionDefault", "OP");
|
||||||
def.put("safety.id.check", true);
|
def.put("safety.id.check", true);
|
||||||
|
def.put("debug", false);
|
||||||
for (final Entry<String, Object> e : def.entrySet())
|
for (final Entry<String, Object> e : def.entrySet())
|
||||||
if (!config.contains(e.getKey()))
|
if (!config.contains(e.getKey()))
|
||||||
config.set(e.getKey(), e.getValue());
|
config.set(e.getKey(), e.getValue());
|
||||||
@ -183,6 +185,7 @@ public class Config
|
|||||||
askClearLogAfterRollback = config.getBoolean("questioner.askClearLogAfterRollback", true);
|
askClearLogAfterRollback = config.getBoolean("questioner.askClearLogAfterRollback", true);
|
||||||
askRollbackAfterBan = config.getBoolean("questioner.askRollbackAfterBan", false);
|
askRollbackAfterBan = config.getBoolean("questioner.askRollbackAfterBan", false);
|
||||||
safetyIdCheck = config.getBoolean("safety.id.check", true);
|
safetyIdCheck = config.getBoolean("safety.id.check", true);
|
||||||
|
debug = config.getBoolean("debug", false);
|
||||||
banPermission = config.getString("questioner.banPermission");
|
banPermission = config.getString("questioner.banPermission");
|
||||||
final List<Tool> tools = new ArrayList<Tool>();
|
final List<Tool> tools = new ArrayList<Tool>();
|
||||||
final ConfigurationSection toolsSec = config.getConfigurationSection("tools");
|
final ConfigurationSection toolsSec = config.getConfigurationSection("tools");
|
||||||
|
Reference in New Issue
Block a user