modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/availability/AvailabilityCollectorRunnable.java
| 166 ----------
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/availability/AvailabilityContext.java
| 35 --
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
| 29 +
modules/core/plugin-container/pom.xml
| 5
modules/core/plugin-container/src/main/java/org/rhq/core/pc/availability/AvailabilityCollectorThreadPool.java
| 105 ------
modules/core/plugin-container/src/main/java/org/rhq/core/pc/availability/AvailabilityContextImpl.java
| 23 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityProxy.java
| 72 +---
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
| 20 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
| 13
modules/core/plugin-container/src/test/java/org/rhq/core/pc/availability/AvailabilityCollectorTest.java
| 88 -----
modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyConcurrencyTest.java
| 53 +++
modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyTest.java
| 41 ++
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java
| 44 ++
modules/plugins/database/src/test/java/org/rhq/plugins/database/ComponentTest.java
| 14
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
| 37 --
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java
| 1
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
| 7
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
| 43 --
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
| 34 --
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/ServerPluginConfiguration.java
| 12
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 19 -
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractJBossAS7PluginTest.java
| 18 -
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
| 6
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/ManagedServerTest.java
| 5
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
| 5
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
| 36 --
modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
| 6
modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/ComponentTest.java
| 14
modules/plugins/oracle/src/test/java/org/rhq/plugins/oracle/ComponentTest.java
| 7
modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/ComponentTest.java
| 3
30 files changed, 242 insertions(+), 719 deletions(-)
New commits:
commit e4c0b12f83c3d51f111591e7fc7773125e655e17
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Dec 9 12:49:46 2013 -0500
BZ 1039664 - log warning if jon agent rpm is detected
diff --git
a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java
b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java
index e4c27f8..8f6d0b0 100644
---
a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java
+++
b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java
@@ -26,6 +26,7 @@ package org.rhq.server.control;
import java.io.Console;
import java.io.File;
+import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@@ -74,6 +75,8 @@ public class RHQControl {
String commandName = findCommand(commands, args);
command = commands.get(commandName);
+ logWarningIfAgentRPMIsInstalled(command);
+
validateInstallCommand(command, args);
// in case the installer gets killed, prepare the shutdown hook to try
the undo
@@ -119,6 +122,47 @@ public class RHQControl {
return;
}
+ private void logWarningIfAgentRPMIsInstalled(ControlCommand command) {
+ // we only care about warning if the user is installing or upgrading; otherwise,
just return silently
+ if (!"install".equalsIgnoreCase(command.getName()) &&
(!"upgrade".equalsIgnoreCase(command.getName()))) {
+ return;
+ }
+
+ // see if we can find an RPM installation somewhere.
+ boolean rpmInstalled;
+ File rpmParentLocation = new File("/usr/share");
+ File[] rpms = rpmParentLocation.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ if (name.startsWith("jboss-on-")) {
+ File jonDir = new File(dir, name);
+ // technically, we should look for the agent in new File(jonDir,
"agent") because that's the rpm install dir.
+ // but there are no other rpms other than the agent, so if we see
this jboss-on-* location, we know the agent is here.
+ log.warn("An agent RPM installation was found in ["
+ + jonDir
+ + "]!!! You will not be able to successfully run this older
agent anymore. You should manually remove it.");
+ return true;
+ } else {
+ return false;
+ }
+ }
+ });
+
+ // if there is an RPM install on this box, we need to pause for some time to give
the user a chance to read the message
+ rpmInstalled = (rpms != null && rpms.length > 0);
+ if (rpmInstalled) {
+ try {
+ log.warn("Please read the above warnings about the existence of
agent RPM installations. This "
+ + command.getName() + " will resume in a few seconds.");
+ Thread.sleep(30000L);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ return;
+ }
+
private void validateInstallCommand(ControlCommand command, String[] args) {
if (!"install".equalsIgnoreCase(command.getName())) {
return;
commit 988034f36abce65ed3bf4a6fa1846a0d540398ba
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Dec 9 12:11:49 2013 -0500
BZ 1037855 - related to the fix for BZ 971556 - fix test
diff --git
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyConcurrencyTest.java
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyConcurrencyTest.java
index bc54cdb..8c42a09 100644
---
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyConcurrencyTest.java
+++
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyConcurrencyTest.java
@@ -71,7 +71,7 @@ public class AvailabilityProxyConcurrencyTest implements
AvailabilityFacet {
Mockito.when(resourceContainer.getResourceComponent()).thenReturn(resourceComponent);
// our one proxy we want to call concurrently
- final AvailabilityProxy ap = new AvailabilityProxy(resourceContainer);
+ final AvailabilityProxy ap = new TestAvailabilityProxy(resourceContainer);
// make sure our mock object uses our own thread pool when submitting the
task
Mockito.when(resourceContainer.submitAvailabilityCheck(ap)).thenAnswer(
@@ -148,4 +148,16 @@ public class AvailabilityProxyConcurrencyTest implements
AvailabilityFacet {
}
return UP;
}
+
+ // for our test, we want to ensure the sync avail check doesn't time out - so
increase the timeout limit
+ private class TestAvailabilityProxy extends AvailabilityProxy {
+ public TestAvailabilityProxy(ResourceContainer rc) {
+ super(rc);
+ }
+
+ @Override
+ protected long getSyncTimeout() {
+ return 5000L;
+ }
+ }
}
\ No newline at end of file
commit 273c9a9593fe488f5f1ac85dfcf66253d1f19d25
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Dec 9 10:12:43 2013 -0500
BZ 1037855 - related to the fix for BZ 971556 - don't cache the thread pool in teh
avail proxy because this screws up in the arquillian test framework due to restarts of
the PC
this has a good side effect though - it shrinks the size of the proxy, which is good
as it lowers the PC footprint
diff --git a/modules/core/plugin-container/pom.xml
b/modules/core/plugin-container/pom.xml
index 426e097..5fad36b 100644
--- a/modules/core/plugin-container/pom.xml
+++ b/modules/core/plugin-container/pom.xml
@@ -71,6 +71,11 @@
</dependency>
<!-- Test dependencies -->
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
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 49a7452..965470e 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
@@ -24,13 +24,13 @@ import static org.rhq.core.domain.measurement.AvailabilityType.UP;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.availability.AvailabilityFacet;
@@ -110,17 +110,13 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
AVAIL_ASYNC_TIMEOUT = asyncAvailTimeout;
}
- private final AvailabilityFacet resourceComponent;
-
- private final ExecutorService executor;
-
private Future<AvailabilityType> availabilityFuture = null;
private volatile Thread current;
private long lastSubmitTime = 0;
- private AvailabilityType lastAvail = UNKNOWN;
+ private final ResourceContainer resourceContainer;
/**
* Number of consecutive avail sync timeouts for the resource. This value is reset if
availability is
@@ -129,15 +125,11 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
*/
private byte availSyncConsecutiveTimeouts = 0;
- private final ClassLoader classLoader;
-
/**
* Constructs a new proxy.
*/
- public AvailabilityProxy(AvailabilityFacet resourceComponent, ExecutorService
executor, ClassLoader classLoader) {
- this.resourceComponent = resourceComponent;
- this.executor = executor;
- this.classLoader = classLoader;
+ public AvailabilityProxy(ResourceContainer resourceContainer) {
+ this.resourceContainer = resourceContainer;
}
@Override
@@ -145,8 +137,8 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
current = Thread.currentThread();
ClassLoader originalContextClassLoader = current.getContextClassLoader();
try {
- Thread.currentThread().setContextClassLoader(classLoader);
- return resourceComponent.getAvailability();
+
Thread.currentThread().setContextClassLoader(this.resourceContainer.getResourceClassLoader());
+ return this.resourceContainer.getResourceComponent().getAvailability();
} finally {
current.setContextClassLoader(originalContextClassLoader);
}
@@ -162,7 +154,6 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
*/
@Override
public AvailabilityType getAvailability() {
- // TODO take out DevDebug printlns when we're confident we don't need
them
AvailabilityType avail = UNKNOWN;
try {
@@ -172,7 +163,6 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
if (availabilityFuture.isDone()) {
// hold onto and report the last known value if necessary
avail = availabilityFuture.get();
- // System.out.println("DevDebug 1 [" +
System.currentTimeMillis() + "] future done avail [" + avail.name() +
"]");
} else {
// We are still waiting on the previously submitted async avail check
- let's just return
@@ -181,58 +171,49 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
// In this case, throw a detailed exception to the avail checker.
long elapsedTime = System.currentTimeMillis() - lastSubmitTime;
if (elapsedTime > getAsyncTimeout()) {
- // System.out.println("DevDebug 2 [" +
System.currentTimeMillis() + "] async timeout");
Throwable t = new Throwable();
if (current != null) {
t.setStackTrace(current.getStackTrace());
}
String msg = "Availability check ran too long [" +
elapsedTime + "ms], canceled for ["
- + resourceComponent + "]; Stack trace includes the timed
out thread's stack trace.";
+ + this.resourceContainer + "]; Stack trace includes the
timed out thread's stack trace.";
availabilityFuture.cancel(true);
// try again, maybe the situation will resolve in time for the
next check
- availabilityFuture = executor.submit(this);
+ availabilityFuture =
this.resourceContainer.submitAvailabilityCheck(this);
lastSubmitTime = System.currentTimeMillis();
- // System.out.println("DevDebug 3 [" +
System.currentTimeMillis() + "] async timeout submit");
throw new TimeoutException(msg, t);
} else {
- // System.out.println("DevDebug 4 [" +
System.currentTimeMillis() + "] no async timeout, return lastAvail [" +
lastAvail.name() + "]");
- return lastAvail;
+ return getLastAvailabilityType();
}
}
}
// request a thread to do an avail check
- availabilityFuture = executor.submit(this);
+ availabilityFuture = this.resourceContainer.submitAvailabilityCheck(this);
lastSubmitTime = System.currentTimeMillis();
- // System.out.println("DevDebug 5 [" + System.currentTimeMillis()
+ "] standard submit");
// if we have exceeded the timeout too many times in a row assume that this
is a slow
// resource and stop performing synchronous checks, which would likely fail
to return fast enough anyway.
if (availSyncConsecutiveTimeouts < getSyncTimeoutLimit()) {
// attempt to get availability synchronously
avail = availabilityFuture.get(getSyncTimeout(), TimeUnit.MILLISECONDS);
- // System.out.println("DevDebug 6 [" +
System.currentTimeMillis() + "] sync avail [" + avail.name() + "]");
// success (failure will throw exception)
availSyncConsecutiveTimeouts = 0;
availabilityFuture = null;
} else if (availSyncConsecutiveTimeouts == getSyncTimeoutLimit()) {
- // System.out.println("DevDebug 7 [" +
System.currentTimeMillis() + "] sync disabled");
-
// log one time that we are disabling synchronous checks for this
resource
++availSyncConsecutiveTimeouts;
if (LOG.isDebugEnabled()) {
- LOG.debug("Disabling synchronous availability collection for
[" + resourceComponent + "]; ["
+ LOG.debug("Disabling synchronous availability collection for
[" + resourceContainer + "]; ["
+ getSyncTimeoutLimit() + "] consecutive timeouts exceeding
[" + getSyncTimeout() + "ms]");
}
}
} catch (InterruptedException e) {
- // System.out.println("DevDebug 8 [" + System.currentTimeMillis()
+ "] Interrupted");
-
LOG.debug("InterruptedException; shut down is (likely) in
progress.");
availabilityFuture.cancel(true);
availabilityFuture = null;
@@ -243,8 +224,6 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
throw new RuntimeException("Availability check failed",
e.getCause());
} catch (java.util.concurrent.TimeoutException e) {
- // System.out.println("DevDebug 9 [" + System.currentTimeMillis()
+ "] Sync Timeout");
-
// failed to get avail synchronously. next call to the future will return
availability (we hope)
++availSyncConsecutiveTimeouts;
}
@@ -260,7 +239,7 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
break;
default:
if (LOG.isDebugEnabled()) {
- LOG.debug("ResourceComponent [" + resourceComponent + "]
getAvailability() returned " + type
+ LOG.debug("ResourceComponent [" + this.resourceContainer +
"] getAvailability() returned " + type
+ ". This is invalid and is being replaced with DOWN.");
}
result = DOWN;
@@ -269,27 +248,33 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
// whenever changing to UP we reset the timeout counter. This is because DOWN
resources often respond
// slowly to getAvailability() calls (for example, waiting for a connection
attempt to time out). When a
// resource comes up we should give it a chance to respond quickly and provide
live avail.
- if (result != lastAvail) {
+ AvailabilityType lastAvail = getLastAvailabilityType();
+ if (result != getLastAvailabilityType()) {
if (result == UP) {
if (availSyncConsecutiveTimeouts >= getSyncTimeoutLimit()) {
- // System.out.println("DevDebug 10 [" +
System.currentTimeMillis() + "] Enabling Sync");
-
if (LOG.isDebugEnabled()) {
- LOG.debug("Enabling synchronous availability collection for
[" + resourceComponent
+ LOG.debug("Enabling synchronous availability collection for
[" + resourceContainer
+ "]; Availability has just changed from [" +
lastAvail + "] to UP.");
}
}
availSyncConsecutiveTimeouts = 0;
}
- lastAvail = result;
}
- // System.out.println("DevDebug 11 [" + System.currentTimeMillis() +
"] returning processAvail [" + result.getName()+ "]");
-
return result;
}
+ private AvailabilityType getLastAvailabilityType() {
+ Availability av = this.resourceContainer.getAvailability();
+ if (av != null) {
+ AvailabilityType avt = av.getAvailabilityType();
+ return (avt != null) ? avt : AvailabilityType.UNKNOWN;
+ } else {
+ return AvailabilityType.UNKNOWN;
+ }
+ }
+
/**
* Override point. Typically for testing.
* @return something other than the env var setting.
@@ -323,9 +308,8 @@ public class AvailabilityProxy implements AvailabilityFacet,
Callable<Availabili
*/
@Override
public String toString() {
- return "AvailabilityProxy [resourceComponent=" + resourceComponent +
", lastAvail=" + lastAvail
- + ", lastSubmitTime=" + new java.util.Date(lastSubmitTime) +
", executor=" + executor
- + ", availabilityFuture=" + availabilityFuture + ",
current=" + current + ", timeouts="
- + availSyncConsecutiveTimeouts + "]";
+ return "AvailabilityProxy [resource=" + resourceContainer + ",
lastSubmitTime="
+ + new java.util.Date(lastSubmitTime) + ", availabilityFuture=" +
availabilityFuture + ", current="
+ + current + ", timeouts=" + availSyncConsecutiveTimeouts +
"]";
}
}
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
index aadd71d..2e7563b 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
@@ -217,8 +217,7 @@ public class ResourceContainer implements Serializable {
public void setResourceComponent(ResourceComponent resourceComponent) {
synchronized (this) {
this.resourceComponent = resourceComponent;
- this.availabilityProxy = new AvailabilityProxy(resourceComponent,
AVAIL_CHECK_THREAD_POOL,
- resourceClassLoader);
+ this.availabilityProxy = new AvailabilityProxy(this); // now that we have a
component, we can collect its avail via a proxy
}
}
@@ -305,6 +304,16 @@ public class ResourceContainer implements Serializable {
}
/**
+ * Submits a task to perform an availability check asynchonrously.
+ * NOTE: this is package scoped so the avail proxy can call it and submit itself as a
task to the containers thread pool.
+ *
+ * @return the future that will provide the avail value
+ */
+ Future<AvailabilityType>
submitAvailabilityCheck(Callable<AvailabilityType> callable) {
+ return AVAIL_CHECK_THREAD_POOL.submit(callable);
+ }
+
+ /**
* Updates the measurementSchedule with the modifications made in the
measurementScheduleUpdate.
*
* @param measurementScheduleUpdate the updates to the current measurementSchedule
diff --git
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyConcurrencyTest.java
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyConcurrencyTest.java
index 06753ca..bc54cdb 100644
---
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyConcurrencyTest.java
+++
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyConcurrencyTest.java
@@ -25,30 +25,67 @@ import java.util.Hashtable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.pluginapi.availability.AvailabilityFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
@Test
public class AvailabilityProxyConcurrencyTest implements AvailabilityFacet {
+ @BeforeMethod
+ @AfterMethod
+ public void clearInterrupts() {
+ // make sure we don't leave interrupt flag set, if somehow the test set it
+ Thread.interrupted();
+ }
+
private AtomicInteger numberOfFacetCalls = new AtomicInteger(-1);
public void testConcurrentAvailChecks() throws Exception {
Thread.interrupted(); // clear any hanging around interrupt status
- ExecutorService executor = Executors.newCachedThreadPool();
+ final ExecutorService executor = Executors.newCachedThreadPool();
try {
+ // mock out the resource container
+ ResourceComponent<?> resourceComponent =
Mockito.mock(ResourceComponent.class);
+ Mockito.when(resourceComponent.getAvailability()).thenAnswer(new
Answer<AvailabilityType>() {
+ public AvailabilityType answer(InvocationOnMock invocation) throws
Throwable {
+ return AvailabilityProxyConcurrencyTest.this.getAvailability();
+ }
+ });
+ ResourceContainer resourceContainer = Mockito.mock(ResourceContainer.class);
+
Mockito.when(resourceContainer.getResourceClassLoader()).thenReturn(getClass().getClassLoader());
+
Mockito.when(resourceContainer.getResourceComponent()).thenReturn(resourceComponent);
+
// our one proxy we want to call concurrently
- final AvailabilityProxy ap = new AvailabilityProxy(this, executor,
getClass().getClassLoader());
+ final AvailabilityProxy ap = new AvailabilityProxy(resourceContainer);
+
+ // make sure our mock object uses our own thread pool when submitting the
task
+ Mockito.when(resourceContainer.submitAvailabilityCheck(ap)).thenAnswer(
+ new Answer<Future<AvailabilityType>>() {
+ public Future<AvailabilityType> answer(InvocationOnMock
invocation) throws Throwable {
+ return executor.submit(ap);
+ }
+ });
// prime the pump by getting the first one without problems
AvailabilityType firstAvail = ap.getAvailability();
assert UP.equals(firstAvail) : "Can't even get our first avail
correctly: " + firstAvail;
+ Mockito.when(resourceContainer.getAvailability()).thenReturn(
+ new Availability(new Resource(1), AvailabilityType.UP)); // our last
avail is UP and will always be UP from now on
// create several threads that will concurrently call getAvailability
final int numThreads = 10;
diff --git
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyTest.java
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyTest.java
index e861845..952a27b 100644
---
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyTest.java
+++
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/AvailabilityProxyTest.java
@@ -25,13 +25,20 @@ import static org.testng.AssertJUnit.fail;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.availability.AvailabilityFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
/**
* @author Elias Ross
@@ -44,12 +51,39 @@ public class AvailabilityProxyTest implements AvailabilityFacet {
private AvailabilityType returnedAvail = UP;
private final ExecutorService executor = Executors.newCachedThreadPool();
+ @BeforeMethod
+ @AfterMethod
+ public void clearInterrupts() {
+ // make sure we don't leave interrupt flag set, if somehow the test set it
+ Thread.interrupted();
+ }
+
/**
* Run a test. Note this may not be 100% reliable, as it depends on thread execution
to
* happen according to our sleep schedule...
*/
public void test() throws InterruptedException {
- TestAvailabilityProxy ap = new TestAvailabilityProxy(this, executor,
getClass().getClassLoader());
+ // mock out the resource container
+ ResourceComponent<?> resourceComponent =
Mockito.mock(ResourceComponent.class);
+ Mockito.when(resourceComponent.getAvailability()).thenAnswer(new
Answer<AvailabilityType>() {
+ public AvailabilityType answer(InvocationOnMock invocation) throws Throwable
{
+ return AvailabilityProxyTest.this.getAvailability();
+ }
+ });
+ ResourceContainer resourceContainer = Mockito.mock(ResourceContainer.class);
+
Mockito.when(resourceContainer.getResourceClassLoader()).thenReturn(getClass().getClassLoader());
+
Mockito.when(resourceContainer.getResourceComponent()).thenReturn(resourceComponent);
+
+ // our one proxy we want to call concurrently
+ final TestAvailabilityProxy ap = new TestAvailabilityProxy(resourceContainer);
+
+ // make sure our mock object uses our own thread pool when submitting the task
+ Mockito.when(resourceContainer.submitAvailabilityCheck(ap)).thenAnswer(new
Answer<Future<AvailabilityType>>() {
+ public Future<AvailabilityType> answer(InvocationOnMock invocation)
throws Throwable {
+ return executor.submit(ap);
+ }
+ });
+
LOG.debug("proxy " + ap);
assertEquals("should be up", UP, ap.getAvailability()); // waits 1ms
and returns synchronously
@@ -125,9 +159,8 @@ public class AvailabilityProxyTest implements AvailabilityFacet {
private Long asyncTimeout = null;
private Long syncTimeout = null;
- public TestAvailabilityProxy(AvailabilityFacet resourceComponent, ExecutorService
executor,
- ClassLoader classLoader) {
- super(resourceComponent, executor, classLoader);
+ public TestAvailabilityProxy(ResourceContainer rc) {
+ super(rc);
}
@Override
commit f89a8b4ce8c647c93255db0645758eded2423239
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Dec 6 12:57:30 2013 -0500
BZ 1037855 - related to the fix for BZ 971556 - we can remove the old async avail
infrastructure in plugin container since all resources now do resource async avail
diff --git
a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/availability/AvailabilityCollectorRunnable.java
b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/availability/AvailabilityCollectorRunnable.java
index 5ce5bd7..eabc7b3 100644
---
a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/availability/AvailabilityCollectorRunnable.java
+++
b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/availability/AvailabilityCollectorRunnable.java
@@ -23,94 +23,16 @@
package org.rhq.core.pluginapi.availability;
import java.util.concurrent.Executor;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.util.exception.ThrowableUtil;
/**
- * A class that can be used by plugins whose components may not be able to collect
availability statuses fast enough.
- *
- * Typically, availability checks are very fast (sub-second). However, the plugin
container puts a time limit
- * on how long it will wait for a plugin's resource component to return availability
status from calls to
- * {@link AvailabilityFacet#getAvailability()}. This time limit is typically on the order
of several seconds.
- * The purpose of this time limit is to avoid having a rogue or misbehaving plugin from
causing delays in availability
- * reporting for the rest of the resources being managed within the system.
- *
- * This class provides an implementation to help resource components that can't
guarantee how fast its
- * availability checks will be. Some managed resources simply can't respond to
availability checks fast enough. In this
- * case, this class will provide an asynchronous method that will collect availability
without a timeout being involved
- * (in other words, availability will be retrieved by waiting as long as it takes). In
order to tell the plugin container
- * what the managed resource's current availability is, this class will provide a
fast method to return the last known
- * availability of the resource. In other words, it will be able to return the last know
availability that was last retrieved
- * by the asynchronous task - this retrieval of the last known availability will be very
fast.
- *
- * @since 1.3
- * @author John Mazzitelli
+ * @deprecated this is no longer necessary in 4.10+ since the plugin container makes all
avail checks asynchronous now
*/
+@Deprecated()
public class AvailabilityCollectorRunnable implements Runnable {
- private static final Log log =
LogFactory.getLog(AvailabilityCollectorRunnable.class);
-
- /**
- * The minimum interval allowed between availability checks, in milliseconds.
- */
public static final long MIN_INTERVAL = 60000L;
-
- /**
- * The thread pool to give this runnable a thread to run in when it needs to check
availability.
- */
- private final Executor threadPool;
-
- /**
- * If <code>true</code>, this collector runnable should be actively
polling the resource for availability status.
- */
- private final AtomicBoolean started = new AtomicBoolean(false);
-
- /**
- * The classloader to be used when checking availability.
- */
- private final ClassLoader contextClassloader;
-
- /**
- * The object that is used to check the availability for the managed resource.
- */
private final AvailabilityFacet availabilityChecker;
-
- /**
- * The time, in milliseconds, that this collector will pause in between availability
checks.
- */
- private final long interval;
-
- /**
- * The last known availability for the resource that this collector is monitoring.
- */
- private AtomicReference<AvailabilityType> lastKnownAvailability = new
AtomicReference<AvailabilityType>();
-
- /**
- * Just a cache of the facet toString used in log messages. We don't want to keep
calling toString on the
- * facet for fear we might get some odd blocking or exceptions thrown. So we call it
once and cache it here.
- */
- private final String facetId;
-
- /**
- * Creates a collector instance that will perform availability checking for a
particular managed resource.
- *
- * The interval is the time, in milliseconds, this collector will wait between
availability checks.
- * This is the amount of time this collector will sleep after each time an
availability
- * check returned with the latest status. A typically value should be something
around 1 minute
- * but if an availability check takes alot of system resources to perform or
adversely affects the
- * managed resource if performed too often, you can make this longer.
- * The shortest value allowed, however, is {@link #MIN_INTERVAL}.
- *
- * @param availabilityChecker the object that is used to periodically check the
managed resource (must not be <code>null</code>)
- * @param interval the interval, in millis, between checking availabilities.
- * @param contextClassloader the context classloader that will be used when checking
availability
- * @param threadPool the thread pool to be used to submit this runnable when it needs
to start
- */
public AvailabilityCollectorRunnable(AvailabilityFacet availabilityChecker, long
interval,
ClassLoader contextClassloader, Executor threadPool) {
@@ -118,100 +40,20 @@ public class AvailabilityCollectorRunnable implements Runnable {
throw new IllegalArgumentException("availabilityChecker is null");
}
- if (threadPool == null) {
- throw new IllegalArgumentException("threadPool is null");
- }
-
- if (interval < MIN_INTERVAL) {
- log.info("Interval is too short [" + interval + "] - setting
to minimum of [" + MIN_INTERVAL + "]");
- interval = MIN_INTERVAL;
- }
-
- if (contextClassloader == null) {
- contextClassloader = Thread.currentThread().getContextClassLoader();
- }
-
- this.threadPool = threadPool;
this.availabilityChecker = availabilityChecker;
- this.contextClassloader = contextClassloader;
- this.interval = interval;
- this.lastKnownAvailability.set(AvailabilityType.DOWN);
- this.facetId = availabilityChecker.toString();
}
- /**
- * This returns the last known availability status that was most recently retrieved
from the managed resource.
- * This will not perform a live check on the managed resource; instead, it
immediately returns the last known
- * state of the managed resource. For those resource components using this
availability collector utility,
- * their {@link AvailabilityFacet#getAvailability()} method should simply be calling
this method.
- *
- * @return {@link AvailabilityType#UP} if the resource can be accessed; otherwise
{@link AvailabilityType#DOWN}
- */
public AvailabilityType getLastKnownAvailability() {
- return this.lastKnownAvailability.get();
+ // this deprecated class will fall back to doing a sync call
+ return this.availabilityChecker.getAvailability();
}
- /**
- * For those resource components using this availability collector utility,
- * their {@link
org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)}
method must call this
- * to start the availability checking that this object performs.
- */
public void start() {
- boolean isStarted = (this.started.getAndSet(true));
- if (isStarted) {
- log.debug("Availability collector runnable [" + this.facetId +
"] is already started");
- } else {
- this.threadPool.execute(this);
- log.debug("Availability collector runnable [" + this.facetId +
"] submitted to thread pool");
- }
}
- /**
- * For those resource components using this availability collector utility,
- * their {@link org.rhq.core.pluginapi.inventory.ResourceComponent#stop()} method
must call this
- * to stop the availability checking that this object performs.
- */
public void stop() {
- this.started.set(false);
- log.debug("Availability collector runnable [" + this.facetId + "]
was told to stop");
}
- /**
- * Performs the actual availability checking. This is the method that is invoked
- * after this runnable is {@link #start() submitted to the thread pool}.
- * You should not be calling this method directly - use {@link #start()} instead.
- */
public void run() {
- log.debug("Availability collector runnable [" + this.facetId + "]
started");
-
- ClassLoader originalClassloader =
Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(this.contextClassloader);
-
- try {
- // while we are still running, we need to sleep then get the new
availability
- do {
- try {
- AvailabilityType availability =
this.availabilityChecker.getAvailability();
- this.lastKnownAvailability.set(availability);
- } catch (Throwable t) {
- log.warn("Availability collector [" + this.facetId
- + "] failed to get availability - keeping the last known
availability of ["
- + this.lastKnownAvailability.get() + "]. Cause: " +
ThrowableUtil.getAllMessages(t));
- }
-
- try {
- Thread.sleep(this.interval);
- } catch (InterruptedException e) {
- // we got interrupted, we assume we need to shutdown
- this.started.set(false);
- log.debug("Availability collector [" + this.facetId +
"] interrupted");
- }
- } while (this.started.get());
- } finally {
- Thread.currentThread().setContextClassLoader(originalClassloader);
- }
-
- log.debug("Availability collector runnable [" + this.facetId + "]
stopped");
- return;
}
}
diff --git
a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/availability/AvailabilityContext.java
b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/availability/AvailabilityContext.java
index a6f90b4..37ef4d6 100644
---
a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/availability/AvailabilityContext.java
+++
b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/availability/AvailabilityContext.java
@@ -21,8 +21,6 @@
package org.rhq.core.pluginapi.availability;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
/**
* Resource specific context through which to make availability related calls back into
the plugin container.
@@ -32,30 +30,9 @@ import org.rhq.core.pluginapi.inventory.ResourceContext;
public interface AvailabilityContext {
/**
- * Under certain circumstances, a resource component may want to perform asynchronous
availability checks, as
- * opposed to {@link AvailabilityFacet#getAvailability()} blocking waiting for the
managed resource to return
- * its availability status. Using asynchronous availability checking frees the
resource component from having
- * to guarantee that the managed resource will provide availability status in a
timely fashion.
- *
- * If the resource component needs to perform asynchronous availability checking, it
should call this
- * method to create an instance of {@link AvailabilityCollectorRunnable} inside the
{@link ResourceComponent#start} method.
- * It should then call the returned object's {@link
AvailabilityCollectorRunnable#start()} method within the same resource
- * component {@link ResourceComponent#start(ResourceContext)} method. The resource
component should call the
- * {@link AvailabilityCollectorRunnable#stop()} method when the resource component
- * {@link ResourceComponent#stop() stops}. The resource component's {@link
AvailabilityFacet#getAvailability()} method
- * should simply return the value returned by {@link
AvailabilityCollectorRunnable#getLastKnownAvailability()}. This
- * method will be extremely fast since it simply returns the last availability that
was retrieved by the
- * given availability checker. Only when the availability checker finishes checking
for availability of the managed resource
- * (however long it takes to do so) will the last known availability state change.
- *
- * For more information, read the javadoc in {@link AvailabilityCollectorRunnable}.
- *
- * @param availChecker the object that will perform the actual check of the managed
resource's availability
- * @param interval the interval, in milliseconds, between availability checks. The
minimum value allowed
- * for this parameter is {@link
AvailabilityCollectorRunnable#MIN_INTERVAL}.
- *
- * @return the availability collector runnable that will perform the asynchronous
checking
+ * @deprecated this is no longer useful - all resources' avail checks are async
since 4.10
*/
+ @Deprecated
public AvailabilityCollectorRunnable
createAvailabilityCollectorRunnable(AvailabilityFacet availChecker,
long interval);
@@ -64,7 +41,7 @@ public interface AvailabilityContext {
* metric. At times the plugin may want the PC to request an availability check be
done prior to the next
* scheduled check time. For example, Start/Stop/Restart operation implementations
may want to request that the PC
* check availability sooner rather than later, to pick up the new lifecycle state.
This method should be used
- * sparingly, and should not in general override the scheduled avail checks.
+ * sparingly, and should not in general override the scheduled avail checks.
*/
public void requestAvailabilityCheck();
@@ -72,7 +49,7 @@ public interface AvailabilityContext {
* This method will return the last reported AvailabilityType, which can be null if
not yet reported. This
* method *does not* invoke a call to {link {@link
AvailabilityFacet#getAvailability()}, raher it will return
* the result of the most recent call to that method, made by the plugin container.
- *
+ *
* @return the last reported availability type, or null if not yet reported.
*/
public AvailabilityType getLastReportedAvailability();
@@ -83,7 +60,7 @@ public interface AvailabilityContext {
* that alerting and availability reporting will essentionally be ignored for the
resource until it is
* again enabled. A user is free to enable a resource disabled by the component
code. If the resource is
* already disabled then the call has no effect.
- *
+ *
* @see {@link #enable()}
*/
public void disable();
@@ -93,7 +70,7 @@ public interface AvailabilityContext {
* a user can set a resource ENABLED. This should be used with care by component
code as it does not care
* how the resource was DISABLED. It can override a user action. If the resource is
already disabled then
* the call has no effect.
- *
+ *
* @see {@link #disable()}
*/
public void enable();
diff --git
a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
index 956fb97..86cf746 100644
---
a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
+++
b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
@@ -24,6 +24,7 @@ import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.inventory.AvailabilityExecutor;
import org.rhq.core.pc.inventory.AvailabilityExecutor.Scan;
import org.rhq.core.pc.inventory.ForceAvailabilityExecutor;
@@ -146,12 +147,22 @@ public class AvailTest extends Arquillian {
resourceComponent.start(c.getResourceContext());
}
}
+
+ // this is a hack to get this test to pass. If you run this test class on its
own, it passes fine.
+ // but if you run it in conjunction with other tests (e.g. mvn
-Dtest=AvailTest,DiscoveryCallbackAbortTest)
+ // then it fails. It appears our arquillian test infrastructure is shutting down
the PC / ResourceContainer
+ // but the ResourceContainer is not getting reinitialized by the time this test
class needs it. What then
+ // happens is the avail thread pool in ResourceContainer is shutdown and will not
accept any more tasks, causing failures.
+ // We should try to figure out why the Arquillian infrastructure is doing this,
but for now, to get tests
+ // passing again, this one-line fix needs to be here.
+ ResourceContainer.initialize(new PluginContainerConfiguration());
}
@Test(groups = "pc.itest.avail", priority = 20)
public void testDiscovery() throws Exception {
Assert.assertNotNull(pluginContainer);
Assert.assertTrue(pluginContainer.isStarted());
+ Assert.assertTrue(pluginContainer.isRunning());
// make sure we have all the resource containers for all the resources
Assert.assertEquals(parentContainers1.size(), 2, "missing parent1");
@@ -172,6 +183,8 @@ public class AvailTest extends Arquillian {
@Test(groups = "pc.itest.avail", priority = 21)
public void testAvailReport() throws Exception {
+ Assert.assertTrue(pluginContainer.isStarted());
+ Assert.assertTrue(pluginContainer.isRunning());
AvailabilityExecutor executor = new
ForceAvailabilityExecutor(this.pluginContainer.getInventoryManager());
dumpContainers("testAvailReport() Start");
AvailabilityReport report = executor.call();
@@ -215,6 +228,8 @@ public class AvailTest extends Arquillian {
@Test(groups = "pc.itest.avail", priority = 21)
public void testScheduling() throws Exception {
+ Assert.assertTrue(pluginContainer.isStarted());
+ Assert.assertTrue(pluginContainer.isRunning());
AvailabilityExecutor executor = new
ForceAvailabilityExecutor(this.pluginContainer.getInventoryManager());
AvailabilityReport report = executor.call();
Assert.assertNotNull(report);
@@ -270,6 +285,8 @@ public class AvailTest extends Arquillian {
// If a parent changes to UP, its children must all be checked as they could
legitimately be something
// other than UP.
public void testForceChildrenOfParentUp() throws Exception {
+ Assert.assertTrue(pluginContainer.isStarted());
+ Assert.assertTrue(pluginContainer.isRunning());
// don't use a ForceAvailabilityExecutor for this test, we want to manipulate
what gets checked
AvailabilityExecutor executor = new
AvailabilityExecutor(this.pluginContainer.getInventoryManager());
AvailabilityReport report = executor.call();
@@ -284,7 +301,7 @@ public class AvailTest extends Arquillian {
}
}
Assert.assertEquals(numUp, 1);
- // only the platform should have been checked, all others should only have been
scheduled for a check
+ // only the platform should have been checked, all others should only have been
scheduled for a check
AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
assertScan(scan, false, true, 29, 0, 1, 28, 0, 0);
@@ -333,6 +350,8 @@ public class AvailTest extends Arquillian {
@Test(groups = "pc.itest.avail", priority = 21)
// If a parent changes to DOWN, its children should all defer to being DOWN as well.
public void testDeferToParentDown() throws Exception {
+ Assert.assertTrue(pluginContainer.isStarted());
+ Assert.assertTrue(pluginContainer.isRunning());
// don't use a ForceAvailabilityExecutor for this test, we want to manipulate
what gets checked
AvailabilityExecutor executor = new
AvailabilityExecutor(this.pluginContainer.getInventoryManager());
AvailabilityReport report = executor.call();
@@ -347,7 +366,7 @@ public class AvailTest extends Arquillian {
}
}
Assert.assertEquals(numUp, 1);
- // only the platform should have been checked, all others should only have been
scheduled for a check
+ // only the platform should have been checked, all others should only have been
scheduled for a check
AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
assertScan(scan, false, true, 29, 0, 1, 28, 0, 0);
@@ -403,7 +422,9 @@ public class AvailTest extends Arquillian {
@Test(groups = "pc.itest.avail", priority = 21)
public void testCheckOnlyEligible() throws Exception {
- // Force all the avails to UP to start so we can avoid the scenario in
testForceChildrenOfParentUp()
+ Assert.assertTrue(pluginContainer.isStarted());
+ Assert.assertTrue(pluginContainer.isRunning());
+ // Force all the avails to UP to start so we can avoid the scenario in
testForceChildrenOfParentUp()
AvailabilityExecutor executor = new
ForceAvailabilityExecutor(this.pluginContainer.getInventoryManager());
AvailabilityReport report = executor.call();
Assert.assertNotNull(report);
@@ -468,6 +489,8 @@ public class AvailTest extends Arquillian {
@Test(groups = "pc.itest.avail", priority = 21)
public void testDeferToParent() throws Exception {
+ Assert.assertTrue(pluginContainer.isStarted());
+ Assert.assertTrue(pluginContainer.isRunning());
AvailabilityExecutor executor = new
ForceAvailabilityExecutor(this.pluginContainer.getInventoryManager());
AvailabilityReport report = executor.call();
Assert.assertNotNull(report);
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/availability/AvailabilityCollectorThreadPool.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/availability/AvailabilityCollectorThreadPool.java
deleted file mode 100644
index c4951d9..0000000
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/availability/AvailabilityCollectorThreadPool.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.core.pc.availability;
-
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.pc.PluginContainer;
-import org.rhq.core.pc.util.LoggingThreadFactory;
-import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
-
-/**
- * A utility class that can be used by plugins whose components may not be able to
collect availability statuses
- * fast enough. This thread pool object can be used to submit {@link
AvailabilityCollectorRunnable} instances,
- * each of which will be used to collect availability statuses for a managed resource.
- *
- * This class is used in conjunction with instances of {@link
AvailabilityCollectorRunnable} - read its javadoc for more.
- *
- * @author John Mazzitelli
- */
-public class AvailabilityCollectorThreadPool implements Executor {
- private static final Log log =
LogFactory.getLog(AvailabilityCollectorThreadPool.class);
-
- /**
- * To avoid many plugins/components needing to spawn their own thread pools/threads,
this
- * will allow everyone to reuse the same thread pool. This thread pool will be
allowed to grow as needed,
- * but will reuse threads when they become available.
- */
- private ExecutorService threadPool;
-
- public void initialize() {
- synchronized (this) {
- if (threadPool == null) {
- log.debug("Initializing AvailabilityCollector thread pool");
- ThreadFactory daemonFactory = new
LoggingThreadFactory("AvailabilityCollector", true);
- threadPool = Executors.newCachedThreadPool(daemonFactory);
- }
- }
- return;
- }
-
- public void shutdown() {
-
- synchronized (this) {
- if (threadPool != null) {
- log.debug("Shutting down AvailabilityCollector thread
pool...");
- PluginContainer pluginContainer = PluginContainer.getInstance();
- pluginContainer.shutdownExecutorService(threadPool, true);
- threadPool = null;
- }
- }
- return;
- }
-
- /**
- * Given a {@link AvailabilityCollectorRunnable} instance, this will run that
instance in a thread, thus
- * allowing the availability status for a managed resource to be periodically checked
asynchronously. The
- * given runnable will store its last known availability status so it can be
retrieved very fast.
- *
- * The given runnable must be of type {@link AvailabilityCollectorRunnable},
otherwise a runtime exception will occur.
- *
- * @param runnable the availability collector runnable that will be invoked in a
thread to being collecting
- * availability status of a managed resource.
- */
- public void execute(Runnable runnable) {
- if (runnable instanceof AvailabilityCollectorRunnable) {
- synchronized (this) {
- if (threadPool != null) {
- threadPool.execute(runnable);
- }
- }
- return;
- } else if (runnable == null) {
- throw new NullPointerException("runnable == null");
- } else {
- throw new IllegalArgumentException("Runnable is of type [" +
runnable.getClass() + "]; must be of type ["
- + AvailabilityCollectorRunnable.class + "]");
- }
- }
-}
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/availability/AvailabilityContextImpl.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/availability/AvailabilityContextImpl.java
index 32fb361..2919014 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/availability/AvailabilityContextImpl.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/availability/AvailabilityContextImpl.java
@@ -20,8 +20,6 @@
package org.rhq.core.pc.availability;
-import java.util.concurrent.Executor;
-
import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
@@ -36,29 +34,20 @@ import org.rhq.core.pluginapi.availability.AvailabilityFacet;
public class AvailabilityContextImpl implements AvailabilityContext {
private final Resource resource;
- private final Executor availCollectionThreadPool;
- public AvailabilityContextImpl(Resource resource, Executor availCollectionThreadPool)
{
+ public AvailabilityContextImpl(Resource resource) {
super();
this.resource = resource;
- this.availCollectionThreadPool = availCollectionThreadPool;
}
- /* (non-Javadoc)
- * @see
org.rhq.core.pluginapi.availability.AvailabilityContext#createAvailabilityCollectorRunnable(org.rhq.core.pluginapi.availability.AvailabilityFacet,
long)
- */
@Override
- public AvailabilityCollectorRunnable
createAvailabilityCollectorRunnable(AvailabilityFacet availChecker,
- long interval) {
-
- // notice that we assume we are called with the same context classloader that
will be need by the avail checker
- return new AvailabilityCollectorRunnable(availChecker, interval,
- Thread.currentThread().getContextClassLoader(),
this.availCollectionThreadPool);
+ @Deprecated
+ public AvailabilityCollectorRunnable
createAvailabilityCollectorRunnable(AvailabilityFacet facet, long i) {
+ // even though this shouldn't be used, plugins may still be using this. Allow
for these to still be
+ // created for backward compatibility, but its a dummy object nevertheless.
+ return new AvailabilityCollectorRunnable(facet, i, null, null);
}
- /* (non-Javadoc)
- * @see
org.rhq.core.pluginapi.availability.AvailabilityContext#requestAvailabilityCheck()
- */
@Override
public void requestAvailabilityCheck() {
PluginContainer.getInstance().getInventoryManager().requestAvailabilityCheck(resource);
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index 5b01a26..35ba2af 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -89,7 +89,6 @@ import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.ServerServices;
import org.rhq.core.pc.agent.AgentRegistrar;
import org.rhq.core.pc.agent.AgentService;
-import org.rhq.core.pc.availability.AvailabilityCollectorThreadPool;
import org.rhq.core.pc.availability.AvailabilityContextImpl;
import org.rhq.core.pc.component.ComponentInvocationContextImpl;
import org.rhq.core.pc.content.ContentContextImpl;
@@ -215,11 +214,6 @@ public class InventoryManager extends AgentService implements
ContainerService,
private DiscoveryComponentProxyFactory discoveryComponentProxyFactory;
/**
- * Used by resource components that want to perform asynchronous availability
checking.
- */
- private AvailabilityCollectorThreadPool availabilityCollectors;
-
- /**
* Handles the resource upgrade during the initialization of the inventory manager.
*/
private ResourceUpgradeDelegate resourceUpgradeDelegate = new
ResourceUpgradeDelegate(this);
@@ -242,11 +236,6 @@ public class InventoryManager extends AgentService implements
ContainerService,
this.agent = new Agent(this.configuration.getContainerName(), null, 0, null,
null);
- //make sure the avail collectors are available before we instantiate any
- //resource context - either from disk or from anywhere else.
- availabilityCollectors = new AvailabilityCollectorThreadPool();
- availabilityCollectors.initialize();
-
if (configuration.isInsideAgent()) {
loadFromDisk();
}
@@ -306,7 +295,6 @@ public class InventoryManager extends AgentService implements
ContainerService,
this.persistToDisk();
}
this.discoveryComponentProxyFactory.shutdown();
- this.availabilityCollectors.shutdown();
this.inventoryEventListeners.clear();
this.resourceContainersByUUID.clear();
this.resourceContainerByResourceId.clear();
@@ -1977,7 +1965,7 @@ public class InventoryManager extends AgentService implements
ContainerService,
getEventContext(resource), // for event access
getOperationContext(resource), // for operation manager access
getContentContext(resource), // for content manager access
- getAvailabilityContext(resource, this.availabilityCollectors), // for
components that want to perform async avail checking
+ getAvailabilityContext(resource),
getInventoryContext(resource),
this.configuration.getPluginContainerDeployment(), // helps components make determinations
of what to do
new ComponentInvocationContextImpl());
}
@@ -1997,7 +1985,7 @@ public class InventoryManager extends AgentService implements
ContainerService,
getEventContext(resource), // for event access
getOperationContext(resource), // for operation manager access
getContentContext(resource), // for content manager access
- getAvailabilityContext(resource, this.availabilityCollectors), // for
components that want avail manager access
+ getAvailabilityContext(resource), // for components that want avail manager
access
getInventoryContext(resource),
this.configuration.getPluginContainerDeployment()); // helps components make
determinations of what to do
}
@@ -2815,12 +2803,12 @@ public class InventoryManager extends AgentService implements
ContainerService,
// };
// }
- private AvailabilityContext getAvailabilityContext(Resource resource, Executor
availCollectionThreadPool) {
+ private AvailabilityContext getAvailabilityContext(Resource resource) {
if (null == resource.getUuid() || resource.getUuid().isEmpty()) {
log.error("RESOURCE UUID IS NOT SET! Availability features may not
work!");
}
- AvailabilityContext availabilityContext = new AvailabilityContextImpl(resource,
availCollectionThreadPool);
+ AvailabilityContext availabilityContext = new AvailabilityContextImpl(resource);
return availabilityContext;
}
diff --git
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/availability/AvailabilityCollectorTest.java
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/availability/AvailabilityCollectorTest.java
deleted file mode 100644
index ec0538b..0000000
---
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/availability/AvailabilityCollectorTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.core.pc.availability;
-
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
-import org.rhq.core.pluginapi.availability.AvailabilityFacet;
-
-@Test
-public class AvailabilityCollectorTest {
-
- private AvailabilityCollectorThreadPool threadPool;
-
- @BeforeTest
- public void beforeTest() {
- threadPool = new AvailabilityCollectorThreadPool();
- threadPool.initialize();
- }
-
- @AfterTest
- public void afterTest() {
- threadPool.shutdown();
- threadPool = null;
- }
-
- public void testCollector() throws Exception {
-
- AvailabilityType[] avail = new AvailabilityType[] { AvailabilityType.UP };
- TestAvailabilityFacet component = new TestAvailabilityFacet(avail);
- AvailabilityCollectorRunnable runnable = new
AvailabilityCollectorRunnable(component, 60000L, null,
- this.threadPool);
- runnable.start();
- Thread.sleep(1000L);
- assert AvailabilityType.UP == runnable.getLastKnownAvailability();
-
- // availability collector cannot allow for collections faster than 60s. So we
can't have tests faster than this.
- // set this if-check to true to fully test the collector (which takes a couple
mins of wait time to complete)
- if (System.getProperty("AvailabilityCollectorTest.longtest",
"false").equals("true")) {
- avail[0] = AvailabilityType.DOWN;
- System.out.println("~~~~~~~~~~sleeping for 60 secs");
- Thread.sleep(60100L);
- assert AvailabilityType.DOWN == runnable.getLastKnownAvailability() :
"Collector should have seen the change";
-
- runnable.stop();
- avail[0] = AvailabilityType.UP;
- System.out.println("~~~~~~~~~~sleeping for 60 secs");
- Thread.sleep(60100L);
- assert AvailabilityType.DOWN == runnable.getLastKnownAvailability() :
"Collector should have stopped and not see the change";
- }
- }
-
- protected class TestAvailabilityFacet implements AvailabilityFacet {
- private AvailabilityType[] avail;
-
- public TestAvailabilityFacet(AvailabilityType[] avail) {
- this.avail = avail;
- }
-
- public AvailabilityType getAvailability() {
- System.out.println("~~~~~~~~~~" + new java.util.Date() + " ==
" + this.avail[0]);
- return this.avail[0];
- }
- }
-}
diff --git
a/modules/plugins/database/src/test/java/org/rhq/plugins/database/ComponentTest.java
b/modules/plugins/database/src/test/java/org/rhq/plugins/database/ComponentTest.java
index 050aa2e..6caba36 100644
--- a/modules/plugins/database/src/test/java/org/rhq/plugins/database/ComponentTest.java
+++ b/modules/plugins/database/src/test/java/org/rhq/plugins/database/ComponentTest.java
@@ -19,13 +19,16 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
import javax.xml.bind.JAXBElement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeSuite;
+
import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager;
import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
import org.rhq.core.clientapi.descriptor.configuration.ConfigurationProperty;
@@ -73,10 +76,6 @@ import org.rhq.core.system.ProcessInfo;
import org.rhq.core.system.SystemInfo;
import org.rhq.core.system.SystemInfoFactory;
import org.rhq.core.system.pquery.ProcessInfoQuery;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeSuite;
/**
* Base class for RHQ Component Testing.
@@ -136,7 +135,6 @@ public abstract class ComponentTest {
private final String pluginContainerName = "rhq";
private final OperationContext operationContext = new OperationContextImpl(0);
private final ContentContext contentContext = new ContentContextImpl(0);
- private final Executor availCollectorThreadPool = Executors.newCachedThreadPool();
private PluginContainerDeployment pluginContainerDeployment = null;
private Resource platform;
private ResourceContainer platformContainer;
@@ -279,7 +277,7 @@ public abstract class ComponentTest {
String rclassname = pmm.getComponentClass(type);
ResourceComponent component = (ResourceComponent)
Class.forName(rclassname).newInstance();
- availabilityContext = new
AvailabilityContextImpl(cresource,availCollectorThreadPool);
+ availabilityContext = new AvailabilityContextImpl(cresource);
inventoryContext = new InventoryContextImpl(cresource);
EventContext eventContext = new EventContextImpl(resource);
diff --git
a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
index fb8bd27..67ae62d 100644
---
a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
+++
b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
@@ -72,8 +72,6 @@ import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
-import org.rhq.core.pluginapi.availability.AvailabilityFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.content.ContentContext;
@@ -135,17 +133,7 @@ public class ApplicationServerComponent<T extends
ResourceComponent<?>> implemen
private LogFileEventResourceComponentHelper logFileEventDelegate;
private CreateChildResourceFacetDelegate createChildResourceDelegate;
- private AvailabilityCollectorRunnable availCollector;
-
public AvailabilityType getAvailability() {
- if (this.availCollector != null) {
- return this.availCollector.getLastKnownAvailability();
- } else {
- return getAvailabilityNow();
- }
- }
-
- private AvailabilityType getAvailabilityNow() {
connectToProfileService();
AvailabilityType availability;
if (this.connection != null) {
@@ -200,35 +188,10 @@ public class ApplicationServerComponent<T extends
ResourceComponent<?>> implemen
this.createChildResourceDelegate = new CreateChildResourceFacetDelegate(this,
this.getResourceContext());
- // prepare to perform async avail checking
- Configuration pc = resourceContext.getPluginConfiguration();
- String availCheckPeriodProp = pc.getSimpleValue(
-
ApplicationServerPluginConfigurationProperties.AVAIL_CHECK_PERIOD_CONFIG_PROP, null);
- if (availCheckPeriodProp != null) {
- try {
- long availCheckMillis = Integer.parseInt(availCheckPeriodProp) * 1000L;
- this.availCollector =
resourceContext.getAvailabilityContext().createAvailabilityCollectorRunnable(
- new AvailabilityFacet() {
- public AvailabilityType getAvailability() {
- return getAvailabilityNow();
- }
- }, availCheckMillis);
- this.availCollector.start();
- } catch (NumberFormatException nfe) {
- log.error("avail check period config prop was not a valid number.
Cause: " + nfe);
- this.availCollector = null;
- }
- }
-
return;
}
public void stop() {
- if (this.availCollector != null) {
- this.availCollector.stop();
- this.availCollector = null;
- }
-
this.logFileEventDelegate.stopLogFileEventPollers();
disconnectFromProfileService();
this.jmxConnectionHelper.closeConnection();
diff --git
a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java
b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java
index c770844..7c30135 100644
---
a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java
+++
b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java
@@ -45,7 +45,6 @@ public class ApplicationServerPluginConfigurationProperties {
public static final String SHUTDOWN_MBEAN_OPERATION_CONFIG_PROP =
"shutdownMBeanOperation";
public static final String SHUTDOWN_METHOD_CONFIG_PROP = "shutdownMethod";
public static final String SCRIPT_PREFIX_CONFIG_PROP = "scriptPrefix";
- public static final String AVAIL_CHECK_PERIOD_CONFIG_PROP =
"availabilityCheckPeriod";
private ApplicationServerPluginConfigurationProperties() {
}
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 e213719..306aed6 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
@@ -1029,13 +1029,6 @@
description="Name of the operation to invoke when shutting down this
server through JMX.
Note that only operations with no parameter or with one
int parameter are supported. If the
operation requires an int parameter, '0' will be
supplied." />
- <c:simple-property name="availabilityCheckPeriod"
- description="The amount of time, in seconds, that must elapse between
availability checks to see if the server is up. If set, the availability checks will be
performed asynchronously thus allowing slow-responding servers to avoid being falsely
reported as down."
- units="seconds" required="false"
type="integer">
- <c:constraint>
- <c:integer-constraint minimum="60" />
- </c:constraint>
- </c:simple-property>
<c:simple-property name="serviceAvailabilityRefreshInterval"
units="minutes" required="false"
default="15" type="integer"
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
index 944d7c5..5e2f272 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -43,8 +43,6 @@ import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
-import org.rhq.core.pluginapi.availability.AvailabilityFacet;
import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
@@ -87,7 +85,6 @@ public abstract class BaseServerComponent<T extends
ResourceComponent<?>> extend
private StartScriptConfiguration startScriptConfig;
private ServerPluginConfiguration serverPluginConfig;
private AvailabilityType previousAvailabilityType;
- private AvailabilityCollectorRunnable availabilityCollector;
private String releaseVersion;
@Override
@@ -102,23 +99,6 @@ public abstract class BaseServerComponent<T extends
ResourceComponent<?>> extend
logFileEventDelegate = new LogFileEventResourceComponentHelper(context);
logFileEventDelegate.startLogFileEventPollers();
startScriptConfig = new StartScriptConfiguration(pluginConfiguration);
-
- Integer availabilityCheckPeriod = null;
- try {
- availabilityCheckPeriod = serverPluginConfig.getAvailabilityCheckPeriod();
- } catch (NumberFormatException e) {
- log.error("Avail check period config prop was not a valid number. Cause:
" + e);
- }
- if (availabilityCheckPeriod != null) {
- long availCheckMillis = availabilityCheckPeriod * 1000L;
- this.availabilityCollector =
resourceContext.getAvailabilityContext().createAvailabilityCollectorRunnable(
- new AvailabilityFacet() {
- public AvailabilityType getAvailability() {
- return getAvailabilityNow();
- }
- }, availCheckMillis);
- this.availabilityCollector.start();
- }
}
@Override
@@ -126,29 +106,10 @@ public abstract class BaseServerComponent<T extends
ResourceComponent<?>> extend
connection.shutdown();
logFileEventDelegate.stopLogFileEventPollers();
previousAvailabilityType = null;
- if (this.availabilityCollector != null) {
- this.availabilityCollector.stop();
- this.availabilityCollector = null;
- }
}
@Override
public AvailabilityType getAvailability() {
- AvailabilityType ret;
- if (this.availabilityCollector != null) {
- ret = this.availabilityCollector.getLastKnownAvailability();
- } else {
- ret = getAvailabilityNow();
- }
-
- if (ret == AvailabilityType.DOWN) {
- releaseVersion = null;
- }
-
- return ret;
- }
-
- private AvailabilityType getAvailabilityNow() {
AvailabilityType availabilityType;
try {
readAttribute("launch-type");
@@ -166,6 +127,10 @@ public abstract class BaseServerComponent<T extends
ResourceComponent<?>> extend
previousAvailabilityType = availabilityType;
}
+ if (availabilityType == AvailabilityType.DOWN) {
+ releaseVersion = null;
+ }
+
return availabilityType;
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
index ac92616..5c02170 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
@@ -19,8 +19,6 @@
package org.rhq.modules.plugins.jbossas7;
-import static
org.rhq.modules.plugins.jbossas7.helper.ServerPluginConfiguration.Property.AVAIL_CHECK_PERIOD_CONFIG_PROP;
-
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
@@ -33,8 +31,6 @@ import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
-import org.rhq.core.pluginapi.availability.AvailabilityFacet;
import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceContext;
@@ -56,7 +52,6 @@ public class ManagedASComponent extends
BaseComponent<HostControllerComponent<?>
private static final String MANAGED_SERVER_TYPE_NAME = "Managed Server";
private LogFileEventResourceComponentHelper logFileEventDelegate;
- private AvailabilityCollectorRunnable availabilityCollector;
@Override
public void start(ResourceContext<HostControllerComponent<?>>
hostControllerComponentResourceContext)
@@ -66,33 +61,12 @@ public class ManagedASComponent extends
BaseComponent<HostControllerComponent<?>
logFileEventDelegate = new LogFileEventResourceComponentHelper(context);
logFileEventDelegate.startLogFileEventPollers();
- Integer availabilityCheckPeriod = null;
- try {
- availabilityCheckPeriod =
pluginConfiguration.getSimple(AVAIL_CHECK_PERIOD_CONFIG_PROP).getIntegerValue();
- } catch (NumberFormatException e) {
- log.error("Avail check period config prop was not a valid number. Cause:
" + e);
- }
- if (availabilityCheckPeriod != null) {
- long availCheckMillis = availabilityCheckPeriod * 1000L;
- this.availabilityCollector =
hostControllerComponentResourceContext.getAvailabilityContext()
- .createAvailabilityCollectorRunnable(new AvailabilityFacet() {
- public AvailabilityType getAvailability() {
- return getAvailabilityNow();
- }
- }, availCheckMillis);
- this.availabilityCollector.start();
- }
-
}
@Override
public void stop() {
super.stop();
logFileEventDelegate.stopLogFileEventPollers();
- if (this.availabilityCollector != null) {
- this.availabilityCollector.stop();
- this.availabilityCollector = null;
- }
}
/**
@@ -103,14 +77,6 @@ public class ManagedASComponent extends
BaseComponent<HostControllerComponent<?>
*/
@Override
public AvailabilityType getAvailability() {
- if (this.availabilityCollector != null) {
- return this.availabilityCollector.getLastKnownAvailability();
- } else {
- return getAvailabilityNow();
- }
- }
-
- private AvailabilityType getAvailabilityNow() {
if (context.getResourceType().getName().equals(MANAGED_SERVER_TYPE_NAME)) {
Address theAddress = new Address();
String host = pluginConfiguration.getSimpleValue("domainHost",
"local");
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/ServerPluginConfiguration.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/ServerPluginConfiguration.java
index 3832ed2..4695e61 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/ServerPluginConfiguration.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/ServerPluginConfiguration.java
@@ -22,7 +22,6 @@ package org.rhq.modules.plugins.jbossas7.helper;
import java.io.File;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.modules.plugins.jbossas7.JBossProductType;
/**
@@ -45,7 +44,6 @@ public class ServerPluginConfiguration {
public static final String LOG_DIR = "logDir";
public static final String PRODUCT_TYPE = "productType";
public static final String HOST_CONFIG_FILE = "hostConfigFile";
- public static final String AVAIL_CHECK_PERIOD_CONFIG_PROP =
"availabilityCheckPeriod";
}
private Configuration pluginConfig;
@@ -146,14 +144,4 @@ public class ServerPluginConfiguration {
hostConfigFile.toString() : null);
}
- public Integer getAvailabilityCheckPeriod() {
- PropertySimple propertySimple =
this.pluginConfig.getSimple(Property.AVAIL_CHECK_PERIOD_CONFIG_PROP);
- return propertySimple == null ? null : propertySimple.getIntegerValue();
- }
-
- public void setAvailabilityCheckPeriod(Integer availabilityCheckPeriod) {
- this.pluginConfig.setSimpleValue(Property.AVAIL_CHECK_PERIOD_CONFIG_PROP,
- availabilityCheckPeriod == null ? null :
availabilityCheckPeriod.toString());
- }
-
}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 6cc3857..2dcf2bd 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -102,16 +102,6 @@
</c:group>
'>
- <!ENTITY availabilityCheckPeriod '
- <c:simple-property name="availabilityCheckPeriod"
- description="The amount of time, in seconds, that must
elapse between availability checks to see if the server is up. If set, the availability
checks will be performed asynchronously thus allowing slow-responding servers to avoid
being falsely reported as down. Minimum value is 60 seconds."
- units="seconds" required="false"
type="integer">
- <c:constraint>
- <c:integer-constraint minimum="60"/>
- </c:constraint>
- </c:simple-property>
-'>
-
<!ENTITY serverKindMetrics '
<metric property="_skm:release-codename" dataType="trait"
displayName="Server Code Name"/>
<metric property="_skm:release-version" dataType="trait"
displayName="Server Version"/>
@@ -952,9 +942,6 @@
&startScriptPluginConfigGroup;
&logSources;
- <c:group name="advanced" displayName="Advanced"
hiddenByDefault="true">
- &availabilityCheckPeriod;
- </c:group>
</plugin-configuration>
<process-scan name="HostController"
query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
@@ -1272,9 +1259,6 @@
&startScriptPluginConfigGroup;
&logSources;
- <c:group name="advanced" displayName="Advanced"
hiddenByDefault="true">
- &availabilityCheckPeriod;
- </c:group>
</plugin-configuration>
<process-scan name="StandaloneAS"
query="process|basename|match=^java.*,arg|org.jboss.as.standalone|match=.*"/>
@@ -1723,9 +1707,6 @@
<plugin-configuration>
<c:simple-property name="path" readOnly="true"/>
&logSources;
- <c:group name="advanced" displayName="Advanced"
hiddenByDefault="true">
- &availabilityCheckPeriod;
- </c:group>
</plugin-configuration>
<operation name="start" description="Start this server
instance." displayName="Start">
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractJBossAS7PluginTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractJBossAS7PluginTest.java
index 8c61c8e..32e83f2 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractJBossAS7PluginTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractJBossAS7PluginTest.java
@@ -19,8 +19,6 @@
package org.rhq.modules.plugins.jbossas7.itest;
-import static org.rhq.core.domain.measurement.AvailabilityType.UP;
-import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.util.Set;
@@ -37,7 +35,6 @@ import org.rhq.core.pc.inventory.InventoryManager;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.plugin.testutil.AbstractAgentPluginTest;
import org.rhq.core.pluginapi.operation.OperationResult;
-import org.rhq.modules.plugins.jbossas7.helper.ServerPluginConfiguration;
import org.rhq.modules.plugins.jbossas7.itest.domain.DomainServerComponentTest;
import org.rhq.modules.plugins.jbossas7.itest.standalone.StandaloneServerComponentTest;
import org.rhq.test.arquillian.AfterDiscovery;
@@ -157,21 +154,6 @@ public abstract class AbstractJBossAS7PluginTest extends
AbstractAgentPluginTest
return serverResource;
}
- protected void testAsynchronousAvailabilityCheck(Resource resource) throws Exception
{
- // Activate asynchronous availability checking
- ServerPluginConfiguration serverPluginConfig = new
ServerPluginConfiguration(resource.getPluginConfiguration());
- int availabilityCheckPeriod = 65;
- serverPluginConfig.setAvailabilityCheckPeriod(availabilityCheckPeriod);
- restartResourceComponent(resource);
-
- Thread.sleep((3 * availabilityCheckPeriod * 1000L) / 2);
- assertEquals(getAvailability(resource), UP);
-
- // Deactivate asynchronous availability checking as subsequent tests may rely on
immediate availabilty checking
- serverPluginConfig.setAvailabilityCheckPeriod(null);
- restartResourceComponent(resource);
- }
-
private void restartResourceComponent(Resource resource) throws
PluginContainerException {
InventoryManager inventoryManager = this.pluginContainer.getInventoryManager();
inventoryManager.deactivateResource(resource);
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
index 269474b..7706e23 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java
@@ -80,12 +80,6 @@ public class DomainServerComponentTest extends
AbstractServerComponentTest {
testServerAttributeValidation();
}
- @Test(priority = 1002)
- public void testDomainServerAsynchronousAvailabilityCheck() throws Exception {
- testAsynchronousAvailabilityCheck(getServerResource());
- }
-
-
// ******************************* METRICS ******************************* //
@Test(priority = 1003, enabled = true)
public void testDomainReleaseVersionTrait() throws Exception {
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/ManagedServerTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/ManagedServerTest.java
index 42bab08..cbc4400 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/ManagedServerTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/ManagedServerTest.java
@@ -93,11 +93,6 @@ public class ManagedServerTest extends AbstractJBossAS7PluginTest {
assertEquals(avail, AvailabilityType.UP);
}
- @Test(priority = 1022)
- public void testManagedServerAsynchronousAvailabilityCheck() throws Exception {
- testAsynchronousAvailabilityCheck(getResource());
- }
-
private Resource getResource() {
InventoryManager im = pluginContainer.getInventoryManager();
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
index 32f92c7..dd1b0ec 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java
@@ -156,11 +156,6 @@ public class StandaloneServerComponentTest extends
AbstractServerComponentTest {
}
- @Test(priority = 8)
- public void testStandaloneServerAsynchronousAvailabilityCheck() throws Exception {
- testAsynchronousAvailabilityCheck(getServerResource());
- }
-
protected String getExpectedStartScriptFileName() {
return (File.separatorChar == '/') ? "standalone.sh" :
"standalone.bat";
}
diff --git
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
index 4e092af..873caaa 100644
---
a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
+++
b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
@@ -80,8 +80,6 @@ import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.CreateResourceStatus;
-import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
-import org.rhq.core.pluginapi.availability.AvailabilityFacet;
import org.rhq.core.pluginapi.content.ContentContext;
import org.rhq.core.pluginapi.content.ContentFacet;
import org.rhq.core.pluginapi.content.ContentServices;
@@ -141,7 +139,6 @@ public class JBossASServerComponent<T extends
ResourceComponent<?>> implements M
public static final String SHUTDOWN_MBEAN_OPERATION_CONFIG_PROP =
"shutdownMbeanOperation";
public static final String SHUTDOWN_METHOD_CONFIG_PROP = "shutdownMethod";
public static final String JAVA_HOME_PATH_CONFIG_PROP = "javaHomePath";
- public static final String AVAIL_CHECK_PERIOD_CONFIG_PROP =
"availabilityCheckPeriod";
public static final String BINDING_ADDRESS_CONFIG_PROP = "bindingAddress";
@@ -204,8 +201,6 @@ public class JBossASServerComponent<T extends
ResourceComponent<?>> implements M
private MainDeployer mainDeployer;
- private AvailabilityCollectorRunnable availCollector;
-
private boolean loggedHijackedJnpUrlError;
// ResourceComponent Implementation --------------------------------------------
@@ -263,33 +258,10 @@ public class JBossASServerComponent<T extends
ResourceComponent<?>> implements M
this.logFileEventDelegate = new
LogFileEventResourceComponentHelper(this.resourceContext);
this.logFileEventDelegate.startLogFileEventPollers();
- // prepare to perform async avail checking
- String availCheckPeriodProp =
pluginConfig.getSimpleValue(AVAIL_CHECK_PERIOD_CONFIG_PROP, null);
- if (availCheckPeriodProp != null) {
- try {
- long availCheckMillis = Integer.parseInt(availCheckPeriodProp) * 1000L;
- this.availCollector =
resourceContext.getAvailabilityContext().createAvailabilityCollectorRunnable(
- new AvailabilityFacet() {
- public AvailabilityType getAvailability() {
- return getAvailabilityNow();
- }
- }, availCheckMillis);
- this.availCollector.start();
- } catch (NumberFormatException nfe) {
- log.error("avail check period config prop was not a valid number.
Cause: " + nfe);
- this.availCollector = null;
- }
- }
-
return;
}
public void stop() {
- if (this.availCollector != null) {
- this.availCollector.stop();
- this.availCollector = null;
- }
-
this.logFileEventDelegate.stopLogFileEventPollers();
if (this.connection != null) {
try {
@@ -304,14 +276,6 @@ public class JBossASServerComponent<T extends
ResourceComponent<?>> implements M
}
public AvailabilityType getAvailability() {
- if (this.availCollector != null) {
- return this.availCollector.getLastKnownAvailability();
- } else {
- return getAvailabilityNow();
- }
- }
-
- private AvailabilityType getAvailabilityNow() {
try {
File serverHomeViaJnp = getServerHome();
if
(this.configPath.getCanonicalPath().equals(serverHomeViaJnp.getCanonicalPath())) {
diff --git a/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
index 36bc9fb..90776d1 100644
--- a/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
@@ -158,12 +158,6 @@
description="Name of the operation to invoke when
shutting down this server through JMX.
Note that only operations with no parameter or with one
int parameter are supported. If the
operation requires an int parameter, '0' will be
supplied."/>
- <c:simple-property name="availabilityCheckPeriod"
description="The amount of time, in seconds, that must elapse between availability
checks to see if the server is up. If set, the availability checks will be performed
asynchronously thus allowing slow-responding servers to avoid being falsely reported as
down."
- units="seconds" required="false"
type="integer">
- <c:constraint>
- <c:integer-constraint minimum="60"/>
- </c:constraint>
- </c:simple-property>
<c:simple-property name="childJmxServerName"
displayName="JBoss AS JVM Name" default="JVM"
readOnly="true" required="false"
diff --git a/modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/ComponentTest.java
b/modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/ComponentTest.java
index 610cb61..3b431d6 100644
--- a/modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/ComponentTest.java
+++ b/modules/plugins/mysql/src/test/java/org/rhq/plugins/mysql/ComponentTest.java
@@ -38,13 +38,16 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
import javax.xml.bind.JAXBElement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeSuite;
+
import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager;
import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
import org.rhq.core.clientapi.descriptor.configuration.ConfigurationProperty;
@@ -92,10 +95,6 @@ import org.rhq.core.system.ProcessInfo;
import org.rhq.core.system.SystemInfo;
import org.rhq.core.system.SystemInfoFactory;
import org.rhq.core.system.pquery.ProcessInfoQuery;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeSuite;
/**
* Base class for RHQ Component Testing.
@@ -155,7 +154,6 @@ public abstract class ComponentTest {
private final String pluginContainerName = "rhq";
private final OperationContext operationContext = new OperationContextImpl(0);
private final ContentContext contentContext = new ContentContextImpl(0);
- private final Executor availCollectorThreadPool = Executors.newCachedThreadPool();
private PluginContainerDeployment pluginContainerDeployment = null;
private Resource platform;
private ResourceContainer platformContainer;
@@ -295,7 +293,7 @@ public abstract class ComponentTest {
String rclassname = pmm.getComponentClass(type);
ResourceComponent component = (ResourceComponent)
Class.forName(rclassname).newInstance();
- AvailabilityContext availContext = new
AvailabilityContextImpl(cresource,availCollectorThreadPool);
+ AvailabilityContext availContext = new AvailabilityContextImpl(cresource);
InventoryContext inventoryContext = new InventoryContextImpl(cresource);
EventContext eventContext = new EventContextImpl(resource);
diff --git
a/modules/plugins/oracle/src/test/java/org/rhq/plugins/oracle/ComponentTest.java
b/modules/plugins/oracle/src/test/java/org/rhq/plugins/oracle/ComponentTest.java
index 569bd09..e98c2e9 100644
--- a/modules/plugins/oracle/src/test/java/org/rhq/plugins/oracle/ComponentTest.java
+++ b/modules/plugins/oracle/src/test/java/org/rhq/plugins/oracle/ComponentTest.java
@@ -10,7 +10,6 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.Executors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -134,7 +133,7 @@ public abstract class ComponentTest {
ResourceDiscoveryComponent resourceDiscoveryComponent = new
NothingDiscoveringDiscoveryComponent();
EventContext eventContext = new EventContextImpl(resource);
- AvailabilityContext availContext = new AvailabilityContextImpl(resource,
Executors.newCachedThreadPool());
+ AvailabilityContext availContext = new AvailabilityContextImpl(resource);
InventoryContext inventoryContext = new InventoryContextImpl(resource);
ResourceContext context = new ResourceContext(resource,
parentResourceComponent, parentResourceContext,
resourceDiscoveryComponent, systemInfo, temporaryDirectory,
dataDirectory, pluginContainerName,
@@ -172,7 +171,7 @@ public abstract class ComponentTest {
log.debug("rdc=" + rdc);
EventContext eventContext = new EventContextImpl(resource);
- AvailabilityContext availContext = new AvailabilityContextImpl(resource,
Executors.newCachedThreadPool());
+ AvailabilityContext availContext = new AvailabilityContextImpl(resource);
InventoryContext inventoryContext = new InventoryContextImpl(resource);
ResourceContext context = new ResourceContext(resource, component, parentContext,
resourceDiscoveryComponent,
systemInfo, temporaryDirectory, dataDirectory, pluginContainerName,
eventContext, operationContext,
@@ -204,7 +203,7 @@ public abstract class ComponentTest {
ResourceComponent component = (ResourceComponent)
Class.forName(rclassname).newInstance();
EventContext eventContext = new EventContextImpl(resource);
- AvailabilityContext availContext = new AvailabilityContextImpl(resource,
Executors.newCachedThreadPool());
+ AvailabilityContext availContext = new AvailabilityContextImpl(resource);
InventoryContext inventoryContext = new InventoryContextImpl(resource);
ResourceContext context = new ResourceContext(cresource, parentComponent,
parentContext,
resourceDiscoveryComponent, systemInfo, temporaryDirectory, dataDirectory,
pluginContainerName,
diff --git
a/modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/ComponentTest.java
b/modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/ComponentTest.java
index cd90737..24b6d9f 100644
---
a/modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/ComponentTest.java
+++
b/modules/plugins/snmptrapd/src/test/java/org/rhq/plugins/snmptrapd/ComponentTest.java
@@ -4,7 +4,6 @@ import java.io.File;
import java.io.InputStream;
import java.util.Set;
import java.util.UUID;
-import java.util.concurrent.Executors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -98,7 +97,7 @@ public abstract class ComponentTest {
OperationContext operationContext = new OperationContextImpl(0);
ContentContext contentContext = new ContentContextImpl(0);
PluginContainerDeployment pluginContainerDeployment = null;
- AvailabilityContext availContext = new AvailabilityContextImpl(resource,
Executors.newCachedThreadPool());
+ AvailabilityContext availContext = new AvailabilityContextImpl(resource);
InventoryContext inventoryContext = new InventoryContextImpl(resource);
ResourceContext context = new ResourceContext(resource, parentResourceComponent,
parentResourceContext,
resourceDiscoveryComponent, systemInfo, temporaryDirectory, dataDirectory,
pluginContainerName,