modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityProxy.java
| 21 ++++++----
1 file changed, 13 insertions(+), 8 deletions(-)
New commits:
commit bd327772cdf65afeed256c154fe4b10c7f6e62cb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Nov 27 10:27:02 2013 -0500
To reduce the memory footprint of the proxy, make logger static.
We don't want one logger instance per proxy.
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityProxy.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityProxy.java
index 40edfa7..4e14581 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityProxy.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityProxy.java
@@ -40,11 +40,16 @@ import org.rhq.core.pluginapi.availability.AvailabilityFacet;
* second, the next call to {@link #getAvailability()} will return the
* calculated availability, if available.
*
+ * With the potential of having thousands, and even tens of thousands, of instances
+ * of this proxy, we must ensure that we keep it as lean as possible to reduce
+ * memory footprint of the agent. For example, we do not create a logger object for
+ * every proxy. Instead, LOG is static. This should be OK for how this proxy is used.
+ *
* @author Elias Ross
*/
public class AvailabilityProxy implements AvailabilityFacet,
Callable<AvailabilityType> {
- private final Log log = LogFactory.getLog(AvailabilityProxy.class);
+ private static final Log LOG = LogFactory.getLog(AvailabilityProxy.class); //
purposefully static, don't create one per proxy
/**
* How long to wait for a resource to return their availability immediately (in ms).
@@ -177,13 +182,13 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
} else if (availAsyncConsecutiveTimeouts == AVAIL_SYNC_TIMEOUT_LIMIT) {
// log one time that we are disabling synchronous checks for this
resource
++availAsyncConsecutiveTimeouts;
- if (log.isDebugEnabled()) {
- log.debug("Disabling synchronous availability collection for
[" + resourceComponent + "]; ["
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Disabling synchronous availability collection for
[" + resourceComponent + "]; ["
+ AVAIL_SYNC_TIMEOUT_LIMIT + "] consective timeouts
exceeding [" + AVAIL_SYNC_TIMEOUT + "ms]");
}
}
} catch (InterruptedException e) {
- log.debug("InterruptedException; shut down is (likely) in
progress.");
+ LOG.debug("InterruptedException; shut down is (likely) in
progress.");
availabilityFuture.cancel(true);
availabilityFuture = null;
Thread.currentThread().interrupt();
@@ -207,8 +212,8 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
case DOWN:
break;
default:
- if (log.isDebugEnabled()) {
- log.debug("ResourceComponent " + resourceComponent + "
getAvailability() returned " + type
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("ResourceComponent " + resourceComponent + "
getAvailability() returned " + type
+ ". This is invalid and is being replaced with DOWN.");
}
result = DOWN;
@@ -220,8 +225,8 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
if (result != last) {
if (result == UP) {
if (availAsyncConsecutiveTimeouts >= AVAIL_SYNC_TIMEOUT_LIMIT) {
- if (log.isDebugEnabled()) {
- log.debug("Enabling synchronous availability collection for
[" + resourceComponent
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Enabling synchronous availability collection for
[" + resourceComponent
+ "]; Availability has just changed from [" + last
+ "] to UP.");
}
}
Show replies by date