Module reload fix, Better Thread-Performance-Warning

This commit is contained in:
Jascha Starke 2013-10-01 16:58:01 +02:00
parent 4b345cf880
commit 9275b9b4a5
9 changed files with 23 additions and 27 deletions

View file

@ -1,7 +1,5 @@
package de.jaschastarke.minecraft.limitedcreative;
import org.bukkit.configuration.ConfigurationSection;
import de.jaschastarke.bukkit.lib.Core;
import de.jaschastarke.bukkit.lib.configuration.ConfigurationContainer;
import de.jaschastarke.bukkit.lib.configuration.PluginConfiguration;
@ -31,25 +29,13 @@ public class Config extends PluginConfiguration {
super(plugin);
}
@Override
public void setValues(ConfigurationSection sect) {
super.setValues(sect);
if (plugin.getModules().count() > 0)
setModuleStates();
}
public void setModuleStates() {
ModuleEntry<IModule> metricsEntry = plugin.getModule(FeatureMetrics.class).getModuleEntry();
metricsEntry.setEnabled(getMetrics());
}
@Override
public void setValue(IConfigurationNode node, Object pValue) throws InvalidValueException {
super.setValue(node, pValue);
if (node.getName().equals("metrics")) {
setModuleStates();
ModuleEntry<IModule> metricsEntry = plugin.getModule(FeatureMetrics.class).getModuleEntry();
metricsEntry.setEnabled(getMetrics());
}
}

View file

@ -35,11 +35,10 @@ public class LimitedCreative extends Core {
addModule(new ModCmdBlocker(this));
addModule(new ModGameModePerm(this));
addModule(new ModBlockStates(this));
addModule(new FeatureMetrics(this));
addModule(new FeatureMetrics(this)).setDefaultEnabled(config.getMetrics());
listeners.addListener(new DependencyListener(this));
config.setModuleStates();
config.saveDefault();
try {

View file

@ -56,7 +56,7 @@ public class BlockStateConfig extends Configuration implements IConfigurationSub
@Override
public void setValues(ConfigurationSection sect) {
super.setValues(sect);
entry.setEnabled(getEnabled());
entry.setDefaultEnabled(getEnabled());
}
@Override
public String getName() {

View file

@ -19,9 +19,11 @@ import de.jaschastarke.minecraft.limitedcreative.blockstate.ThreadedModel;
public class ThreadLink {
private static final int BATCH_ACTION_LENGTH = 10;
private static final int QUEUE_ACCESS_WARNING_DURATION = 5;
private static final int QUEUE_ACCESS_WARNING_DURATION = 5; // ms
private static final int COUNT_WARNING_QUEUE = 5;
private static final int COUNT_ERROR_QUEUE = 20;
private static final int QUEUE_TIMING_DURATION = 500; // ms
private long lastTimeout;
private Stack<Action> updateQueue = new Stack<Action>();
private boolean shutdown = false;
@ -56,6 +58,7 @@ public class ThreadLink {
public void run() {
if (getModule().isDebug())
log.debug("DB-Thread '" + Thread.currentThread().getName() + "' started.");
lastTimeout = System.currentTimeMillis();
while (!shutdown || !updateQueue.isEmpty()) {
try {
List<Action> acts = new LinkedList<Action>();
@ -63,9 +66,17 @@ public class ThreadLink {
while (updateQueue.isEmpty() && !shutdown)
updateQueue.wait();
if (updateQueue.size() > (BATCH_ACTION_LENGTH * COUNT_ERROR_QUEUE)) {
getLog().severe("Extrem large DB-Queue in " + Thread.currentThread().getName() + ": " + updateQueue.size());
if (System.currentTimeMillis() - lastTimeout > QUEUE_TIMING_DURATION) {
getLog().warn("Extrem large DB-Queue in " + Thread.currentThread().getName() + ": " + updateQueue.size());
lastTimeout = System.currentTimeMillis();
}
} else if (updateQueue.size() > (BATCH_ACTION_LENGTH * COUNT_WARNING_QUEUE)) {
getLog().warn("Large DB-Queue in " + Thread.currentThread().getName() + ": " + updateQueue.size());
if (System.currentTimeMillis() - lastTimeout > QUEUE_TIMING_DURATION) {
getLog().info("Large DB-Queue in " + Thread.currentThread().getName() + ": " + updateQueue.size());
lastTimeout = System.currentTimeMillis();
}
} else if (updateQueue.size() <= BATCH_ACTION_LENGTH) {
lastTimeout = System.currentTimeMillis();
}
for (int i = 0; i < BATCH_ACTION_LENGTH && !updateQueue.isEmpty(); i++) {
acts.add(updateQueue.pop());

View file

@ -38,7 +38,7 @@ public class CmdBlockerConfig extends Configuration implements IConfigurationSub
@Override
public void setValues(ConfigurationSection sect) {
super.setValues(sect);
entry.setEnabled(getEnabled());
entry.setDefaultEnabled(getEnabled());
}
@Override

View file

@ -48,7 +48,7 @@ public class GMPermConfig extends Configuration implements IConfigurationSubGrou
@Override
public void setValues(ConfigurationSection sect) {
super.setValues(sect);
entry.setEnabled(getEnabled());
entry.setDefaultEnabled(getEnabled());
}
@Override
public String getName() {

View file

@ -53,7 +53,7 @@ public class InventoryConfig extends Configuration implements IConfigurationSubG
}
super.setValues(sect);
entry.setEnabled(getEnabled());
entry.setDefaultEnabled(getEnabled());
// Config Upgrade
if (!sect.contains("storeCreative") && sect.contains("creative"))

View file

@ -50,7 +50,7 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
@Override
public void setValues(ConfigurationSection sect) {
super.setValues(sect);
entry.setEnabled(getEnabled());
entry.setDefaultEnabled(getEnabled());
// Config Upgrade
if (!sect.contains("interact") && sect.contains("sign")) {

View file

@ -47,7 +47,7 @@ public class RegionConfig extends Configuration implements IConfigurationSubGrou
@Override
public void setValues(ConfigurationSection sect) {
super.setValues(sect);
entry.setEnabled(getEnabled());
entry.setDefaultEnabled(getEnabled());
// Config Upgrade
if (!sect.contains("rememberOptional") && sect.contains("remember"))