modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java | 41 ++++++++-- modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 10 ++ 2 files changed, 44 insertions(+), 7 deletions(-)
New commits: commit 4ad3388b4081b9689699c2d705f9162ab33fc37e Author: John Sanda jsanda@redhat.com Date: Fri Feb 10 21:50:04 2012 -0500
[BZ 788638] Make service availability refresh interval configurable
The refresh interval is now configurable from the application server component. The interval setting then applies to all descendant services.
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java index 374ae95..201484e 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java @@ -99,11 +99,11 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen private final Log log = LogFactory.getLog(this.getClass());
/** - * The availability watermark specifies a duration that if exceeded means a managed + * The availability refresh interval specifies a duration that if exceeded means a managed * component refresh is needed to perform an availability check. That duration is set * to 15 minutes. */ - private static final long AVAIL_WATERMARK = 1000 * 60 * 15; // 15 minutes + private static final long AVAIL_REFRESH_INTERVAL = 1000 * 60 * 15; // 15 minutes
/** * The ManagedComponent is fetched from the server in {@link #getManagedComponent} throughout @@ -114,6 +114,8 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen * perform an availability check. */ private long lastComponentRefresh = 0L; + + private long availRefreshInterval = AVAIL_REFRESH_INTERVAL;
private RunState runState = RunState.UNKNOWN;
@@ -124,7 +126,7 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
public AvailabilityType getAvailability() { long timeSinceComponentRefresh = System.currentTimeMillis() - lastComponentRefresh; - if (timeSinceComponentRefresh > AVAIL_WATERMARK) { + if (timeSinceComponentRefresh > availRefreshInterval) { getManagedComponent(); }
@@ -141,11 +143,14 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { super.start(resourceContext); - this.componentType = ConversionUtils.getComponentType(getResourceContext().getResourceType()); + componentType = ConversionUtils.getComponentType(getResourceContext().getResourceType()); Configuration pluginConfig = resourceContext.getPluginConfiguration(); - this.componentName = pluginConfig.getSimple(Config.COMPONENT_NAME).getStringValue(); - log.trace("Started ResourceComponent for " + getResourceDescription() + ", managing " + this.componentType - + " component '" + this.componentName + "'."); + componentName = pluginConfig.getSimple(Config.COMPONENT_NAME).getStringValue(); + initAvailRefreshInterval(resourceContext); + if (log.isTraceEnabled()) { + log.trace("Started ResourceComponent for " + getResourceDescription() + ", managing " + this.componentType + + " component '" + this.componentName + "'."); + } }
public void stop() { @@ -476,4 +481,26 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen return value.toString(); } } + + private void initAvailRefreshInterval(ResourceContext<ProfileServiceComponent<?>> context) { + ProfileServiceComponent<?> component = context.getParentResourceComponent(); + while (component != null) { + if (component instanceof ApplicationServerComponent) { + break; + } + component = (ProfileServiceComponent<?>) component.getResourceContext().getParentResourceComponent(); + } + + if (component == null) { + if (log.isDebugEnabled()) { + log.debug("Failed to find parent " + ApplicationServerComponent.class.getSimpleName() + + ". Using default component refresh interval, " + AVAIL_REFRESH_INTERVAL + " ms"); + } + return; + } + + String interval = component.getResourceContext().getPluginConfiguration().getSimpleValue( + "serviceAvailabilityRefreshInterval", Long.toString(AVAIL_REFRESH_INTERVAL)); + availRefreshInterval = Long.parseLong(interval) * 1000 * 60; + } } diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml index bac3e20..38ae6b4 100644 --- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml @@ -997,6 +997,16 @@ </c:constraint> </c:simple-property>
+ <c:simple-property name="serviceAvailabilityRefreshInterval" units="minutes" required="false" + default="15" type="integer" + description="The amount of time, in minutes, that can elapse for service availability checks + without having to refresh the managed object from the server. Services cache information + used to perform availability checks. This property determines how frequently that + data needs to be reloaded from the server. Any time the managed object is + loaded from the server, like for collecting metrics, the availability information + is updated and the interval is reset. Note that this property does not effect the + frequency of availability scans performed by the agent."/> + <c:simple-property name="childJmxServerName" displayName="JBoss AS JVM Name" default="JVM" readOnly="true" required="false" description="The name of the JBoss AS JVM resource."/>
rhq-commits@lists.fedorahosted.org