Fix for Issue 18 - Use property autofetch.garbageCollectionOnShutdown to

control GC on shutdown behavior
This commit is contained in:
Robin Bygrave
2013-04-25 16:54:18 +12:00
parent 97cc2984cf
commit 384931d92e
2 changed files with 32 additions and 5 deletions
@@ -24,6 +24,8 @@ public class AutofetchConfig {
private int profileUpdateFrequency = 60;
private int garbageCollectionWait = 100;
private boolean garbageCollectionOnShutdown;
public AutofetchConfig() {
}
@@ -207,6 +209,28 @@ public class AutofetchConfig {
this.garbageCollectionWait = garbageCollectionWait;
}
/**
* Return true if GC should be trigger on shutdown.
* <p>
* Autofetch profiling information is collected as part of garbage collection.
* </p>
*/
public boolean isGarbageCollectionOnShutdown() {
return garbageCollectionOnShutdown;
}
/**
* Set to true if you want GC to trigger on shutdown.
* <p>
* This would be done if you want to try and collect Autofetch profiling information
* on shutdown.
* </p>
*/
public void setGarbageCollectionOnShutdown(boolean garbageCollectionOnShutdown) {
this.garbageCollectionOnShutdown = garbageCollectionOnShutdown;
}
/**
* Load the settings from the properties file.
*/
@@ -215,10 +239,10 @@ public class AutofetchConfig {
logDirectory = p.get("autofetch.logDirectory", null);
queryTuning = p.getBoolean("autofetch.querytuning", false);
queryTuningAddVersion = p.getBoolean("autofetch.queryTuningAddVersion", false);
garbageCollectionOnShutdown = p.getBoolean("autofetch.garbageCollectionOnShutdown", false);
profiling = p.getBoolean("autofetch.profiling", false);
mode = p
.getEnum(AutofetchMode.class, "autofetch.implicitmode", AutofetchMode.DEFAULT_ONIFEMPTY);
mode = p.getEnum(AutofetchMode.class, "autofetch.implicitmode", AutofetchMode.DEFAULT_ONIFEMPTY);
profilingMin = p.getInt("autofetch.profiling.min", 1);
profilingBase = p.getInt("autofetch.profiling.base", 10);
@@ -68,6 +68,8 @@ public class DefaultAutoFetchManager implements AutoFetchManager, Serializable {
private transient boolean queryTuningAddVersion;
private transient boolean garbageCollectionOnShutdown;
private transient AutofetchMode mode;
/**
@@ -93,6 +95,7 @@ public class DefaultAutoFetchManager implements AutoFetchManager, Serializable {
AutofetchConfig autofetchConfig = serverConfig.getAutofetchConfig();
garbageCollectionOnShutdown = autofetchConfig.isGarbageCollectionOnShutdown();
queryTuning = autofetchConfig.isQueryTuning();
queryTuningAddVersion = autofetchConfig.isQueryTuningAddVersion();
profiling = autofetchConfig.isProfiling();
@@ -269,10 +272,10 @@ public class DefaultAutoFetchManager implements AutoFetchManager, Serializable {
* </p>
*/
public void shutdown() {
//if (useFileLogging) {
if (garbageCollectionOnShutdown) {
collectUsageViaGC(-1);
serialize();
//}
}
}
/**