WindowCache: conditional JMX setup
Make it possible to programmatically suppress the JMX bean registration. In EGit it is not needed but can be rather costly because it occurs during plug-in activation and accesses the git user config. Bug: 563740 Change-Id: I07ef7ae2f0208d177d2a03862846a8efe0191956 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
parent
c6213ad33a
commit
089eacb273
|
@ -470,7 +470,9 @@ else if (eb < 4)
|
|||
|
||||
mbean = new StatsRecorderImpl();
|
||||
statsRecorder = mbean;
|
||||
if (cfg.getExposeStatsViaJmx()) {
|
||||
Monitoring.registerMBean(mbean, "block_cache"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if (maxFiles < 1)
|
||||
throw new IllegalArgumentException(JGitText.get().openFilesMustBeAtLeast1);
|
||||
|
|
|
@ -47,6 +47,8 @@ public class WindowCacheConfig {
|
|||
|
||||
private int streamFileThreshold;
|
||||
|
||||
private boolean exposeStats;
|
||||
|
||||
/**
|
||||
* Create a default configuration.
|
||||
*/
|
||||
|
@ -58,6 +60,7 @@ public WindowCacheConfig() {
|
|||
packedGitMMAP = false;
|
||||
deltaBaseCacheLimit = 10 * MB;
|
||||
streamFileThreshold = PackConfig.DEFAULT_BIG_FILE_THRESHOLD;
|
||||
exposeStats = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,6 +222,39 @@ public void setStreamFileThreshold(int newLimit) {
|
|||
streamFileThreshold = newLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell whether the statistics JMX bean should be automatically registered.
|
||||
* <p>
|
||||
* Registration of that bean via JMX is additionally subject to a boolean
|
||||
* JGit-specific user config "jmx.WindowCacheStats". The bean will be
|
||||
* registered only if this user config is {@code true} <em>and</em>
|
||||
* {@code getExposeStatsViaJmx() == true}.
|
||||
* </p>
|
||||
* <p>
|
||||
* By default, this returns {@code true} unless changed via
|
||||
* {@link #setExposeStatsViaJmx(boolean)}.
|
||||
*
|
||||
* @return whether to expose WindowCacheStats statistics via JMX upon
|
||||
* {@link #install()}
|
||||
* @since 5.8
|
||||
*/
|
||||
public boolean getExposeStatsViaJmx() {
|
||||
return exposeStats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines whether the statistics JMX MBean should be automatically set up.
|
||||
* (By default {@code true}.) If set to {@code false}, the JMX monitoring
|
||||
* bean is not registered.
|
||||
*
|
||||
* @param expose
|
||||
* whether to register the JMX Bean
|
||||
* @since 5.8
|
||||
*/
|
||||
public void setExposeStatsViaJmx(boolean expose) {
|
||||
exposeStats = expose;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update properties by setting fields from the configuration.
|
||||
* <p>
|
||||
|
|
Loading…
Reference in New Issue