[rhq] modules/enterprise
by Simeon Pinder
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 192586ad401aff5a00bfaa6b7c78fbc82d2963da
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Dec 9 17:17:43 2013 -0500
BZ 1039664 - one more udpate to logged warning to refer to documentation.
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 8f6d0b0..24e4995 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
@@ -140,7 +140,8 @@ public class RHQControl {
// 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.");
+ + "]!!! You will not be able to successfully run this older agent anymore. You should consult the "
+ +"install documentation about manually removing and/or merging the old and new agent.");
return true;
} else {
return false;
10 years, 4 months
[rhq] Branch 'release/jon3.2.x' - modules/enterprise
by Simeon Pinder
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit d0e1a1f74b3dcd3f9fe864fcf1f3555891e3bc1e
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Dec 9 17:17:43 2013 -0500
BZ 1039664 - one more udpate to logged warning to refer to documentation.
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 8f6d0b0..24e4995 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
@@ -140,7 +140,8 @@ public class RHQControl {
// 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.");
+ + "]!!! You will not be able to successfully run this older agent anymore. You should consult the "
+ +"install documentation about manually removing and/or merging the old and new agent.");
return true;
} else {
return false;
10 years, 4 months
[rhq] Branch 'refs/tags/RHQ_4_9_0_JON320GA' - 2 commits - modules/enterprise
by Simeon Pinder
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java | 45 ++++++++++
1 file changed, 45 insertions(+)
New commits:
commit 15939eb445646f905f65fff2a054364a08524d0a
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Dec 9 17:17:43 2013 -0500
BZ 1039664 - one more udpate to logged warning to refer to documentation.
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 8f6d0b0..24e4995 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
@@ -140,7 +140,8 @@ public class RHQControl {
// 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.");
+ + "]!!! You will not be able to successfully run this older agent anymore. You should consult the "
+ +"install documentation about manually removing and/or merging the old and new agent.");
return true;
} else {
return false;
commit dbf6b06ce0934efdf23eaa9b9db5d7b0bf078f47
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
(cherry picked from commit e4c0b12f83c3d51f111591e7fc7773125e655e17)
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;
10 years, 4 months
[rhq] Branch 'rc/jon3.2.0.GA' - 2 commits - modules/enterprise
by Simeon Pinder
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java | 45 ++++++++++
1 file changed, 45 insertions(+)
New commits:
commit 15939eb445646f905f65fff2a054364a08524d0a
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Dec 9 17:17:43 2013 -0500
BZ 1039664 - one more udpate to logged warning to refer to documentation.
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 8f6d0b0..24e4995 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
@@ -140,7 +140,8 @@ public class RHQControl {
// 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.");
+ + "]!!! You will not be able to successfully run this older agent anymore. You should consult the "
+ +"install documentation about manually removing and/or merging the old and new agent.");
return true;
} else {
return false;
commit dbf6b06ce0934efdf23eaa9b9db5d7b0bf078f47
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
(cherry picked from commit e4c0b12f83c3d51f111591e7fc7773125e655e17)
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;
10 years, 4 months
[rhq] modules/plugins
by mazz
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java | 2 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/ServerPluginConfiguration.java | 11 ++++++++++
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java | 2 +
3 files changed, 15 insertions(+)
New commits:
commit 856d791b67a235636df1178e459a48d3f620ce87
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Dec 9 15:37:43 2013 -0500
BZ 1037855 - related to the fix for BZ 971556 - the last commit for this BZ caused the api check to fail.
putting back the obsolete, but public, constants and marking them as deprecated.
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 7c30135..c2a1ba1 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,6 +45,8 @@ 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";
+ @Deprecated
+ public static final String AVAIL_CHECK_PERIOD_CONFIG_PROP = "availabilityCheckPeriod";
private ApplicationServerPluginConfigurationProperties() {
}
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 4695e61..d4c7e48 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
@@ -44,6 +44,8 @@ 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";
+ @Deprecated
+ public static final String AVAIL_CHECK_PERIOD_CONFIG_PROP = "availabilityCheckPeriod";
}
private Configuration pluginConfig;
@@ -144,4 +146,13 @@ public class ServerPluginConfiguration {
hostConfigFile.toString() : null);
}
+ @Deprecated
+ public Integer getAvailabilityCheckPeriod() {
+ return 0;
+ }
+
+ @Deprecated
+ public void setAvailabilityCheckPeriod(Integer availabilityCheckPeriod) {
+ }
+
}
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 873caaa..01c795f 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
@@ -139,6 +139,8 @@ 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";
+ @Deprecated
+ public static final String AVAIL_CHECK_PERIOD_CONFIG_PROP = "availabilityCheckPeriod";
public static final String BINDING_ADDRESS_CONFIG_PROP = "bindingAddress";
10 years, 4 months
[rhq] modules/core modules/enterprise
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java | 48 ++++++----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java | 27 ++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java | 47 +++++----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java | 8 -
4 files changed, 75 insertions(+), 55 deletions(-)
New commits:
commit d01bb14a36a1121d377dc2445d1456c611c37007
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Dec 9 14:13:52 2013 -0500
[998945] Too many statement timeout exceptions in server log
[999165] Frequent statement timeouts while updating availabilities
I did a visual inspection of code looking for things that may
contribute to the slow updates and/or timeouts reported in these BZs. In
general the updates for availReports (infrequent but can spike in
certain scenarios, 1 per avail report) and availPing
(frequent, 1 per minute per agent) should be very fast and not in
themselves be an issue. Slowness in these queries is likely caused by the
Agent table being locked by some other longer running transaction.
Everything looked pretty clean with one exception. When backfilling an agent
due to an agent shutdown or suspect job detection, it looked like we
may have locked th agent table for the duration of the backfilling, which
can be a fairly large operation for a big agent inventory. I'm not sure
this is the problem, but this commit should allevaite the Agent table
locking while the backfilling is performed.
Also:
- move some inline JPA updates on the Agent to be NamedQuery in the Agent
entity. No need to build those every time we update an agent ping time.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
index 788e189..186c968 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
@@ -75,7 +75,7 @@ import org.rhq.core.domain.cloud.Server;
+ "SELECT a.id " //
+ " FROM Agent a " //
+ " WHERE a.server.name = :serverName " //
- + " AND a.status <> 0 "), //
+ + " AND a.status <> 0 "), //
@NamedQuery(name = Agent.QUERY_FIND_ALL_WITH_STATUS, query = "" //
+ "SELECT a.id " //
+ " FROM Agent a " //
@@ -83,7 +83,7 @@ import org.rhq.core.domain.cloud.Server;
@NamedQuery(name = Agent.QUERY_UPDATE_CLEAR_STATUS_BY_IDS, query = "" //
+ "UPDATE Agent a " //
+ " SET a.status = 0 " //
- + " WHERE a.id IN ( :agentIds ) "), //
+ + " WHERE a.id IN ( :agentIds ) "), //
@NamedQuery(name = Agent.QUERY_FIND_BY_AFFINITY_GROUP, query = "" //
+ "SELECT a " //
+ " FROM Agent a " //
@@ -137,7 +137,16 @@ import org.rhq.core.domain.cloud.Server;
@NamedQuery(name = Agent.QUERY_UPDATE_STATUS_FOR_ALL, query = "" //
+ " UPDATE Agent a " //
+ " SET a.status = -1 " // negative numbers so that bitmask strategy does not conflict with this one
- + " WHERE a.status = 0 ") //
+ + " WHERE a.status = 0 "), //
+ @NamedQuery(name = Agent.QUERY_UPDATE_LAST_AVAIL_REPORT, query = "" //
+ + " UPDATE Agent a " //
+ + " SET lastAvailabilityReport = :reportTime, backFilled = FALSE " //
+ + " WHERE id = :agentId "), //
+ @NamedQuery(name = Agent.QUERY_UPDATE_LAST_AVAIL_PING, query = "" //
+ + " UPDATE Agent a " //
+ + " SET lastAvailabilityPing = :now, backFilled = FALSE " //
+ + " WHERE name = :agentName ") //
+
})
@SequenceGenerator(allocationSize = org.rhq.core.domain.util.Constants.ALLOCATION_SIZE, name = "RHQ_AGENT_ID_SEQ", sequenceName = "RHQ_AGENT_ID_SEQ")
@Table(name = "RHQ_AGENT")
@@ -172,7 +181,10 @@ public class Agent implements Serializable {
public static final String QUERY_UPDATE_STATUS_BY_MEASUREMENT_BASELINE = "Agent.updateStatusByMeasurementBasleine";
public static final String QUERY_UPDATE_STATUS_BY_AGENT = "Agent.updateStatusByAgent";
public static final String QUERY_UPDATE_STATUS_FOR_ALL = "Agent.updateStatusForAll";
-
+
+ public static final String QUERY_UPDATE_LAST_AVAIL_REPORT = "Agent.updateLastAvailReport";
+ public static final String QUERY_UPDATE_LAST_AVAIL_PING = "Agent.updateLastAvailPing";
+
// this value is set, when authorized user wants to reset the token
public static final String SECURITY_TOKEN_RESET = "@#$reset$#@";
@@ -237,7 +249,8 @@ public class Agent implements Serializable {
* @param remoteEndpoint
* @param agentToken
*/
- public Agent(@NotNull String name, String address, int port, String remoteEndpoint, String agentToken) {
+ public Agent(@NotNull
+ String name, String address, int port, String remoteEndpoint, String agentToken) {
this.name = name;
this.address = address;
this.port = port;
@@ -269,7 +282,8 @@ public class Agent implements Serializable {
return this.name;
}
- public void setName(@NotNull String name) {
+ public void setName(@NotNull
+ String name) {
this.name = name;
}
@@ -284,7 +298,8 @@ public class Agent implements Serializable {
return this.address;
}
- public void setAddress(@NotNull String address) {
+ public void setAddress(@NotNull
+ String address) {
this.address = address;
}
@@ -313,7 +328,8 @@ public class Agent implements Serializable {
return agentToken;
}
- public void setAgentToken(@NotNull String agentToken) {
+ public void setAgentToken(@NotNull
+ String agentToken) {
this.agentToken = agentToken;
}
@@ -392,7 +408,7 @@ public class Agent implements Serializable {
/**
* Returns the {@link AffinityGroup} this agent currently belongs to.
- *
+ *
* @return the {@link AffinityGroup} this agent currently belongs to
*/
public AffinityGroup getAffinityGroup() {
@@ -401,7 +417,7 @@ public class Agent implements Serializable {
/**
* Sets the {@link AffinityGroup} this agent should belong to.
- *
+ *
* @param affinityGroup the {@link AffinityGroup} this agent should belong to
*/
public void setAffinityGroup(AffinityGroup affinityGroup) {
@@ -410,7 +426,7 @@ public class Agent implements Serializable {
/**
* Returns the {@link Server} this agent is currently communicating to.
- *
+ *
* @return the {@link Server} this agent is currently communicating to
*/
public Server getServer() {
@@ -418,8 +434,8 @@ public class Agent implements Serializable {
}
/**
- * Sets the {@link Server} this agent should communicate with.
- *
+ * Sets the {@link Server} this agent should communicate with.
+ *
* @param server the {@link Server} this agent should communicate with
*/
public void setServer(Server server) {
@@ -429,7 +445,7 @@ public class Agent implements Serializable {
/**
* Returns 0 if this agent is current. Otherwise, returns a mask of {@link Agent.Status}
* elements corresponding to the updates that have occurred that are related to this agent.
- *
+ *
* @return 0 if this agent is current. Otherwise, returns a mask of {@link Agent.Status}
* elements corresponding to the updates that have occurred that are related to this agent.
*/
@@ -440,8 +456,8 @@ public class Agent implements Serializable {
/**
* If this status was non-zero, some scheduled job would have had to come along to perform
* some work on behalf of this agent. After that work is complete, the status can be reset
- * (set to 0) signifying that no further work needs to be done on this agent (as long as the
- * status remains 0).
+ * (set to 0) signifying that no further work needs to be done on this agent (as long as the
+ * status remains 0).
*/
public void clearStatus() {
status = 0;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
index 1c23836..2d4d58d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerBean.java
@@ -242,8 +242,7 @@ public class AgentManagerBean implements AgentManagerLocal {
long maximumQuietTimeAllowed = 300000L;
try {
- String prop = systemManager.getUnmaskedSystemSettings(true).get(
- SystemSetting.AGENT_MAX_QUIET_TIME_ALLOWED);
+ String prop = systemManager.getUnmaskedSystemSettings(true).get(SystemSetting.AGENT_MAX_QUIET_TIME_ALLOWED);
if (prop != null) {
maximumQuietTimeAllowed = Long.parseLong(prop);
}
@@ -286,7 +285,7 @@ public class AgentManagerBean implements AgentManagerLocal {
// about a downed agent once, at the time it is first backfilled.
if (!record.isBackFilled()) {
LOG.info("Have not heard from agent [" + record.getAgentName() + "] since ["
- + new Date(record.getLastAvailabilityPing()) + "]. Will be backfilled since we suspect it is down");
+ + new Date(record.getLastAvailabilityPing()) + "]. Will be backfilled since we suspect it is down");
agentManager.backfillAgentInNewTransaction(subjectManager.getOverlord(), record.getAgentName(),
record.getAgentId());
@@ -304,20 +303,27 @@ public class AgentManagerBean implements AgentManagerLocal {
// problems
AvailabilityReportSerializer.getSingleton().lock(agentName);
try {
- // This marks the Agent as backfilled=true
- agentManager.setAgentBackfilled(agentId, true);
-
// This marks the top-level platform DOWN since we have not heard from it and all
// child resources UNKNOWN since they are not reporting and may very well be up
availabilityManager.updateAgentResourceAvailabilities(agentId, AvailabilityType.DOWN,
AvailabilityType.UNKNOWN);
+ // This marks the Agent as backfilled=true. Although doing this in its own transaction means the
+ // agent will be reflected as backfilled before the resource availability changes are committed, that
+ // should not matter, as it affects only availability reporting which 1) is locked out (see a few line above)
+ // and 2) at worst would only request a full avail report anyway, when detecting a backfilled agent.
+ // What this buys is it shortens the locking on the agent table, because backfilling a large inventory
+ // can take time. Performing this after the backfill to minimize the window between the commits as
+ // much as possible.
+ agentManager.setAgentBackfilledInNewTransaction(agentId, true);
+
} finally {
AvailabilityReportSerializer.getSingleton().unlock(agentName);
}
}
- public void setAgentBackfilled(int agentId, boolean backfilled) {
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public void setAgentBackfilledInNewTransaction(int agentId, boolean backfilled) {
Query query = entityManager.createNamedQuery(Agent.QUERY_SET_AGENT_BACKFILLED);
query.setParameter("agentId", agentId);
query.setParameter("backfilled", backfilled);
@@ -662,12 +668,7 @@ public class AgentManagerBean implements AgentManagerLocal {
* since we already know we have to update the agent row with the last avail ping time, might as well
* set the backfilled to false here (as opposed to called agentManager.setBackfilled(agentId, false)
*/
- String updateStatement = "" //
- + "UPDATE Agent " //
- + " SET lastAvailabilityPing = :now, backFilled = FALSE " //
- + " WHERE name = :agentName ";
-
- Query query = entityManager.createQuery(updateStatement);
+ Query query = entityManager.createNamedQuery(Agent.QUERY_UPDATE_LAST_AVAIL_PING);
query.setParameter("now", now);
query.setParameter("agentName", agentName);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java
index 7e2c3b9..4e07a08 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/AgentManagerLocal.java
@@ -44,11 +44,11 @@ import org.rhq.enterprise.server.agentclient.AgentClient;
@Local
public interface AgentManagerLocal {
- /**
+ /**
* Call this method to set the agent DOWN and mark it 'backfilled'. Also, sets all of its monitored resources
* to an UNKNOWN avail state since the agent is no longer reporting availability. Done in its own transaction to
* avoid large transactions if many agents are simultaneously backfilled.
- *
+ *
* @param subject
* @param agentName
* @param agentId
@@ -113,15 +113,17 @@ public interface AgentManagerLocal {
* @return list of all known agents in inventory
* @deprecated Use <code>findAgentsByCriteria()</code> instead
*/
+ @Deprecated
List<Agent> getAllAgents();
/**
* Returns a collection of paged agents, filtered by Server (if non-null).
*
- * @param serverId the server to filter the agent list by. pass null to view unfiltered results.
+ * @param serverId the server to filter the agent list by. pass null to view unfiltered results.
* @return list of all known agents in inventory
* @deprecated Use <code>findAgentsByCriteria()</code> instead
*/
+ @Deprecated
PageList<Agent> getAgentsByServer(Subject subject, Integer serverId, PageControl pageControl);
/**
@@ -136,7 +138,7 @@ public interface AgentManagerLocal {
* name exists, <code>null</code> is returned.
* This method is very efficient if you want to find a single agent by its name.
* If you need to get more than one agent, you could use <code>findAgentsByCriteria</code>.
- *
+ *
* @param agentName
*
* @return the agent whose name matches the given name; <code>null</code> if there is no agent with the given name
@@ -184,7 +186,7 @@ public interface AgentManagerLocal {
/**
* Given a resource ID, this will return the agent responsible for servicing that resource.
- * @param subject
+ * @param subject
*
* @param resourceId
*
@@ -246,9 +248,9 @@ public interface AgentManagerLocal {
/**
* Determines if the given agent version is supported by this server. In other words, this will
* return <code>true</code> if this server can talk to any agent of the given version.
- *
+ *
* @param agentVersion the version of the agent to verify
- *
+ *
* @return <code>true</code> if this server can support an agent with the given version; if the server
* knows it cannot communicate successfully with an agent of that version, <code>false</code>
* will be returned
@@ -259,9 +261,9 @@ public interface AgentManagerLocal {
* Returns the path on the server's file system where the agent update version file is found.
* The agent update version file contains information about the agent update binary, such
* as what version it is.
- *
+ *
* @return agent update version file location
- *
+ *
* @throws Exception if the file could not be created or found
*/
File getAgentUpdateVersionFile() throws Exception;
@@ -271,9 +273,9 @@ public interface AgentManagerLocal {
* of some name/value pairs.
* The agent update version file contains information about the agent update binary, such
* as what version it is.
- *
+ *
* @return version properties found in the agent update version file.
- *
+ *
* @throws Exception if cannot read the agent update version file
*/
Properties getAgentUpdateVersionFileContent() throws Exception;
@@ -281,9 +283,9 @@ public interface AgentManagerLocal {
/**
* Returns the path on the server's file system where the agent update binary is found.
* This is the actual agent distribution that can be installed on the agent machines.
- *
+ *
* @return agent update binary location
- *
+ *
* @throws Exception if the binary file does not exist
*/
File getAgentUpdateBinaryFile() throws Exception;
@@ -292,13 +294,18 @@ public interface AgentManagerLocal {
* DO NOT USE THIS. You should be using one of the getAgentUpdateXXX methods directly rather
* than looking in the download directory. Not all agent update files are located in this download
* directory anymore. This API will be removed from the public API in the near future.
- *
+ *
* @deprecated
*/
@Deprecated
File getAgentDownloadDir() throws Exception;
- void setAgentBackfilled(int agentId, boolean backfilled);
+ /**
+ * Do this in its own transaction to minimize locking on the agent table.
+ * @param agentId
+ * @param backfilled
+ */
+ void setAgentBackfilledInNewTransaction(int agentId, boolean backfilled);
/**
* Returns <code>true</code> if the agent is "suspect" and has been backfilled. A "suspect agent" means one that the
@@ -313,7 +320,7 @@ public interface AgentManagerLocal {
/**
* Returns <code>true</code> indicating successful ping of agent. Exposed so server could
- * initiate N requests so gwt clients wont face Single Origin Policy issues.
+ * initiate N requests so gwt clients wont face Single Origin Policy issues.
*
* @param agentId the id of the agent
*
@@ -323,17 +330,17 @@ public interface AgentManagerLocal {
/**
* Process a ping request from an agent, performing any requested actions and returning any requested data.
- *
+ *
* @param request
* @return The updated request object.
*/
public PingRequest handlePingRequest(PingRequest request);
-
+
/**
* Fetches the agents based on provided criteria.
- *
+ *
* Subject needs MANAGE_SETTINGS and MANAGE_INVENTORY permissions.
- *
+ *
* @param subject caller
* @param criteria the criteria
* @return list of agents
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
index 34922fe..629069f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/AvailabilityManagerBean.java
@@ -54,6 +54,7 @@ import org.rhq.core.domain.discovery.AvailabilityReport.Datum;
import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.ResourceAvailability;
+import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ResourceIdWithAvailabilityComposite;
@@ -1073,12 +1074,7 @@ public class AvailabilityManagerBean implements AvailabilityManagerLocal, Availa
* since we already know we have to update the agent row with the last avail report time, might as well
* set the backfilled to false here (as opposed to called agentManager.setBackfilled(agentId, false)
*/
- String updateStatement = "" //
- + "UPDATE Agent " //
- + " SET lastAvailabilityReport = :reportTime, backFilled = FALSE " //
- + " WHERE id = :agentId ";
-
- Query query = entityManager.createQuery(updateStatement);
+ Query query = entityManager.createNamedQuery(Agent.QUERY_UPDATE_LAST_AVAIL_REPORT);
query.setParameter("reportTime", System.currentTimeMillis());
query.setParameter("agentId", agentId);
10 years, 4 months
[rhq] 2 commits - modules/enterprise
by John Sanda
modules/enterprise/remoting/cli/src/main/samples/modules/util.js | 110 ++++++++-
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java | 114 +++++-----
2 files changed, 158 insertions(+), 66 deletions(-)
New commits:
commit 9a97e14e0a9812520fcfacd42185704dc1fc21bd
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Dec 9 14:46:45 2013 -0500
add support in foreach for paging over criteria query results
This is basically a port of the code in CriteriaQuery.java
diff --git a/modules/enterprise/remoting/cli/src/main/samples/modules/util.js b/modules/enterprise/remoting/cli/src/main/samples/modules/util.js
index b67eebc..18c34b3 100644
--- a/modules/enterprise/remoting/cli/src/main/samples/modules/util.js
+++ b/modules/enterprise/remoting/cli/src/main/samples/modules/util.js
@@ -13,32 +13,104 @@
/**
+ * <p>
* If obj is a JS array or a java.util.Collection, each element is passed to
- * the callback function. If obj is a java.util.Map, each map entry is passed
- * to the callback function as a key/value pair. If obj is none of the
- * aforementioned types, it is treated as a generic object and each of its
- * properties is passed to the callback function as a name/value pair.
+ * the callback function.
+ * </p>
+ * <p>
+ * If obj is a java.util.Map, each map entry is passed to the callback function
+ * as a key/value pair.
+ * </p>
+ * <p>
+ * If obj is a Criteria object, then the corresponding find by criteria method
+ * will be invoked. Each entity in the result set will be passed to the callback
+ * function. This function performs paging implicitly such that the callback will
+ * be invoked for all entities in the result set, even if it requires multiple
+ * criteria query finder method invocations.
+ * </p>
+ * <p>
+ * If obj is none of the aforementioned types, it is treated as a generic object
+ * and each of its properties is passed to the callback function as a name/value pair.
+ * </p>
*/
exports.foreach = function (obj, fn) {
+ var criteriaExecutors = {
+ Alert: function(criteria) { return AlertManager.findAlertsByCriteria(criteria); },
+ AlertDefinition: function(criteria) { return AlertDefinitionManager.findAlertDefinitionsByCriteria(criteria); },
+ Agent: function(criteria) { return AgentManager.findAgentsByCriteria(criteria); },
+ Availability: function(criteria) { return AvailabilityManager.findAvailabilityByCriteria(criteria); },
+ Bundle: function(criteria) { return BundleManager.findBundlesByCriteria(criteria); },
+ BundleDeployment: function(criteria) { return BundleManager.findBundleDeploymentsByCriteria(criteria); },
+ BundleDestination: function(criteria) { return BundleManager.findBundleDestinationsByCriteria(criteria); },
+ BundleFile: function(criteria) { return BundleManager.findBundleFilesByCriteria(criteria); },
+ BundleGroup: function(criteria) { return BundleManager.findBundleGroupsByCriteria(criteria); },
+ BundleResourceDeployment: function(criteria) { return BundleManager.findBundleResourceDeploymentsByCriteria(criteria); },
+ BundleVersion: function(criteria) { return BundleManager.findBundleVersionsByCriteria(criteria); },
+ DriftDefinition: function(criteria) { return DriftManager.findDriftDefinitionsByCriteria(criteria); },
+ DriftDefinitionTemplate: function(criteria) { return DriftDefinitionTemplateManager.findTemplatesByCriteria(criteria); },
+ Event: function(criteria) { return EventManager.findEventsByCriteria(criteria); },
+ GroupOperationHistory: function(criteria) { return OperationManager.findGroupOperationHistoriesByCriteria(criteria); },
+ GroupPluginConfigurationUpdate: function(criteria) { return ConfigurationManager.findGroupPluginConfigurationUpdatesByCriteria(criteria); },
+ GroupResourceConfigurationUpdate: function(criteria) { return ConfigurationManager.findGroupResourceConfigurationUpdatesByCriteria(criteria); },
+ InstalledPackage: function(criteria) { return ContentManager.findInstalledPackagesByCriteria(criteria); },
+ MeasurementDataTrait: function(criteria) { return MeasurementDataManager.findTraitsByCriteria(criteria); },
+ MeasurementDefinition: function(criteria) { return MeasurementDefinitionManager.findMeasurementDefinitionsByCriteria(criteria); },
+ JPADriftChangeSet: function(criteria) { return DriftManager.findDriftChangeSetsByCriteria(criteria); },
+ JPADrift: function(criteria) { return DriftManager.findDriftsByCriteria(criteria); },
+ MeasurementSchedule: function(criteria) { return MeasurementScheduleManager,findSchedulesByCriteria(criteria); },
+ OperationDefinition: function(criteria) { return OperationManager.findOperationDefinitionsByCriteria(criteria); },
+ ResourceOperationHistory: function(criteria) { return OperationManager.findResourceOperationHistoriesByCriteria(criteria); },
+ ResourceType: function(criteria) { return ResourceTypeManager.findResourceTypesByCriteria(criteria); },
+ Resource: function(criteria) { return ResourceManager.findResourcesByCriteria(criteria); },
+ Role: function(criteria) { return RoleManager.findRolesByCriteria(criteria); },
+ SavedSearch: function(criteria) { return SavedSearchManager.findSavedSearchesByCriteria(criteria); },
+ StorageNode: function(criteria) { return StorageNodeManager.findStorageNodesByCriteria(criteria); },
+ Subject: function(criteria) { return SubjectManager.findSubjectsByCriteria(criteria); },
+ Tag: function(criteria) { return TagManager.findTagsByCriteria(criteria); }
+ };
+
if (obj instanceof Array) {
for (i in obj) {
fn(obj[i]);
}
- }
- else if (obj instanceof java.util.Collection) {
+ } else if (obj instanceof java.util.Collection) {
var iterator = obj.iterator();
while (iterator.hasNext()) {
fn(iterator.next());
}
- }
- else if (obj instanceof java.util.Map) {
+ } else if (obj instanceof java.util.Map) {
var iterator = obj.entrySet().iterator()
while (iterator.hasNext()) {
var entry = iterator.next();
fn(entry.key, entry.value);
}
- }
- else { // assume we have a generic object
+ } else if (obj instanceof Criteria) {
+ var criteria = obj;
+ var executeQuery = criteriaExecutors[criteria.persistentClass];
+
+ if (executeQuery == null) {
+ throw "No criteria executor found for " + criteria.getClass().name + ". A new executor may need to be added to " +
+ "this script.";
+ }
+
+ var currentPage = executeQuery();
+
+ while (!currentPage.isEmpty()) {
+ util.foreach(currentPage, fn);
+ if (currentPage.pageControl == null && currentPage.pageControlOverrides == null) {
+ reachedEnd = true;
+ } else {
+ if (currentPage.pageControlOverrides != null) {
+ currentPage.pageControlOverrides.pageNumber = currentPage.pageControlOverrides.pageNumber + 1;
+ } else {
+ criteria.setPaging(currentPage.pageControl.pageNumber + 1, currentPage.pageControl.pageSize);
+ }
+
+ currentPage.clear();
+ currentPage = executeQuery();
+ }
+ }
+ } else { // assume we have a generic object
for (i in obj) {
fn(i, obj[i]);
}
@@ -277,4 +349,22 @@ exports.asHash = function(configuration) {
})(configuration);
return ret;
+}
+
+exports.walkTree = function(root, visitorFn, nodesProperty, filterFn) {
+ var nodes = root[nodesProperty];
+ var stack = [];
+ var pushChildNodesOntoStack = function(node) {
+ exports.foreach(node[nodesProperty], function(childNode) {
+ stack.push(childNode);
+ });
+ }
+
+ pushChildNodesOntoStack(root);
+
+ while (stack.length > 0) {
+ var node = stack.pop();
+ pushChildNodesOntoStack(node);
+
+ }
}
\ No newline at end of file
commit 0a0e9b552ce22a8d3786e84b9f9fe5bdc7aca7c8
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Dec 4 09:21:04 2013 -0500
add debug logging
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
index f9d355e..33528e6 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
@@ -52,7 +52,6 @@ import org.joda.time.Duration;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.util.StringUtil;
import org.rhq.server.metrics.domain.AggregateNumericMetric;
import org.rhq.server.metrics.domain.AggregateType;
import org.rhq.server.metrics.domain.MetricsIndexEntry;
@@ -158,68 +157,71 @@ public class MetricsServer {
public Iterable<MeasurementDataNumericHighLowComposite> findDataForResource(int scheduleId, long beginTime,
long endTime, int numberOfBuckets) {
+ Stopwatch stopwatch = new Stopwatch().start();
+ try {
+ DateTime begin = new DateTime(beginTime);
- if (log.isDebugEnabled()) {
- log.debug("Querying for metric data using parameters [scheduleId: " + scheduleId + ", beginTime: " +
- beginTime + ", endTime: " + endTime + ", numberOfBuckets: " + numberOfBuckets + "]");
- }
-
- DateTime begin = new DateTime(beginTime);
+ if (dateTimeService.isInRawDataRange(begin)) {
+ Iterable<RawNumericMetric> metrics = dao.findRawMetrics(scheduleId, beginTime, endTime);
+ return createRawComposites(metrics, beginTime, endTime, numberOfBuckets);
+ }
- if (dateTimeService.isInRawDataRange(begin)) {
- Iterable<RawNumericMetric> metrics = dao.findRawMetrics(scheduleId, beginTime, endTime);
- return createRawComposites(metrics, beginTime, endTime, numberOfBuckets);
- }
+ Iterable<AggregateNumericMetric> metrics = null;
+ if (dateTimeService.isIn1HourDataRange(begin)) {
+ metrics = dao.findOneHourMetrics(scheduleId, beginTime, endTime);
+ } else if (dateTimeService.isIn6HourDataRnage(begin)) {
+ metrics = dao.findSixHourMetrics(scheduleId, beginTime, endTime);
+ } else if (dateTimeService.isIn24HourDataRnage(begin)) {
+ metrics = dao.findTwentyFourHourMetrics(scheduleId, beginTime, endTime);
+ } else {
+ throw new IllegalArgumentException("beginTime[" + beginTime + "] is outside the accepted range.");
+ }
- Iterable<AggregateNumericMetric> metrics = null;
- if (dateTimeService.isIn1HourDataRange(begin)) {
- metrics = dao.findOneHourMetrics(scheduleId, beginTime, endTime);
- } else if (dateTimeService.isIn6HourDataRnage(begin)) {
- metrics = dao.findSixHourMetrics(scheduleId, beginTime, endTime);
- } else if (dateTimeService.isIn24HourDataRnage(begin)) {
- metrics = dao.findTwentyFourHourMetrics(scheduleId, beginTime, endTime);
- } else {
- throw new IllegalArgumentException("beginTime[" + beginTime + "] is outside the accepted range.");
+ return createComposites(metrics, beginTime, endTime, numberOfBuckets);
+ } finally {
+ stopwatch.stop();
+ if (log.isDebugEnabled()) {
+ log.debug("Retrieved resource data for [scheduleId: " + scheduleId + ", beginTime: " + beginTime +
+ ", endTime: " + endTime + "] in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
+ }
}
-
- return createComposites(metrics, beginTime, endTime, numberOfBuckets);
}
public List<MeasurementDataNumericHighLowComposite> findDataForGroup(List<Integer> scheduleIds, long beginTime,
long endTime, int numberOfBuckets) {
- if (log.isDebugEnabled()) {
- log.debug("Querying for metric data using parameters [scheduleIds: " + scheduleIds + ", beingTime: " +
- beginTime + ", endTime: " + endTime + ", numberOfBuckets: " + numberOfBuckets + "]");
- }
+ Stopwatch stopwatch = new Stopwatch().start();
+ try {
+ DateTime begin = new DateTime(beginTime);
- DateTime begin = new DateTime(beginTime);
+ if (dateTimeService.isInRawDataRange(begin)) {
+ Iterable<RawNumericMetric> metrics = dao.findRawMetrics(scheduleIds, beginTime, endTime);
+ return createRawComposites(metrics, beginTime, endTime, numberOfBuckets);
+ }
- if (dateTimeService.isInRawDataRange(begin)) {
- Iterable<RawNumericMetric> metrics = dao.findRawMetrics(scheduleIds, beginTime, endTime);
- return createRawComposites(metrics, beginTime, endTime, numberOfBuckets);
- }
+ Iterable<AggregateNumericMetric> metrics = null;
+ if (dateTimeService.isIn1HourDataRange(begin)) {
+ metrics = dao.findOneHourMetrics(scheduleIds, beginTime, endTime);
+ } else if (dateTimeService.isIn6HourDataRnage(begin)) {
+ metrics = dao.findSixHourMetrics(scheduleIds, beginTime, endTime);
+ } else if (dateTimeService.isIn24HourDataRnage(begin)) {
+ metrics = dao.findTwentyFourHourMetrics(scheduleIds, beginTime, endTime);
+ } else {
+ throw new IllegalArgumentException("beginTime[" + beginTime + "] is outside the accepted range.");
+ }
- Iterable<AggregateNumericMetric> metrics = null;
- if (dateTimeService.isIn1HourDataRange(begin)) {
- metrics = dao.findOneHourMetrics(scheduleIds, beginTime, endTime);
- } else if (dateTimeService.isIn6HourDataRnage(begin)) {
- metrics = dao.findSixHourMetrics(scheduleIds, beginTime, endTime);
- } else if (dateTimeService.isIn24HourDataRnage(begin)) {
- metrics = dao.findTwentyFourHourMetrics(scheduleIds, beginTime, endTime);
- } else {
- throw new IllegalArgumentException("beginTime[" + beginTime + "] is outside the accepted range.");
+ return createComposites(metrics, beginTime, endTime, numberOfBuckets);
+ } finally {
+ stopwatch.stop();
+ if (log.isDebugEnabled()) {
+ log.debug("Retrieved resource group data for [scheduleIds: " + scheduleIds + ", beginTime: " +
+ beginTime + ", endTime: " + endTime + "] in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
+ }
}
-
- return createComposites(metrics, beginTime, endTime, numberOfBuckets);
}
public AggregateNumericMetric getSummaryAggregate(int scheduleId, long beginTime, long endTime) {
- long start = System.currentTimeMillis();
+ Stopwatch stopwatch = new Stopwatch().start();
try {
- if (log.isDebugEnabled()) {
- log.debug("Calculating resource summary aggregate for [scheduleId: " + scheduleId + ", beginTime: " +
- beginTime + ", endTime: " + endTime + "]");
- }
DateTime begin = new DateTime(beginTime);
if (dateTimeService.isInRawDataRange(begin)) {
@@ -240,9 +242,11 @@ public class MetricsServer {
return calculateAggregate(metrics, beginTime);
} finally {
- long end = System.currentTimeMillis();
+ stopwatch.stop();
if (log.isDebugEnabled()) {
- log.debug("Finished calculating resource summary aggregate in " + (end - start) + " ms");
+ log.debug("Finished calculating resource summary aggregate for [scheduleId: " + scheduleId +
+ ", beginTime: " + beginTime + ", endTime: " + endTime + "] in " +
+ stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
}
}
}
@@ -283,12 +287,8 @@ public class MetricsServer {
}
public AggregateNumericMetric getSummaryAggregate(List<Integer> scheduleIds, long beginTime, long endTime) {
- long start = System.currentTimeMillis();
+ Stopwatch stopwatch = new Stopwatch().start();
try {
- if (log.isDebugEnabled()) {
- log.debug("Calculating group summary aggregate for [scheduleIds: [" + StringUtil.listToString(
- scheduleIds) + "], beginTime: " + beginTime + ", endTime: " + endTime + "]");
- }
DateTime begin = new DateTime(beginTime);
if (dateTimeService.isInRawDataRange(new DateTime(beginTime))) {
@@ -309,9 +309,11 @@ public class MetricsServer {
return calculateAggregate(metrics, beginTime);
} finally {
- long end = System.currentTimeMillis();
+ stopwatch.stop();
if (log.isDebugEnabled()) {
- log.debug("Finished calculating group summary aggregate in " + (end - start) + " ms");
+ log.debug("Finished calculatig group summary aggregate for [scheduleIds: " + scheduleIds +
+ ", beginTime: " + beginTime + ", endTime: " + endTime + "] in " +
+ stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
}
}
}
10 years, 4 months
[rhq] Branch 'release/jon3.2.x' - modules/enterprise
by mazz
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java | 44 ++++++++++
1 file changed, 44 insertions(+)
New commits:
commit 8d987e8cdf916fa97a18e70f0c25679d211c138f
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
(cherry picked from commit e4c0b12f83c3d51f111591e7fc7773125e655e17)
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;
10 years, 4 months
[rhq] 4 commits - modules/core modules/enterprise modules/plugins
by mazz
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,
10 years, 4 months
[rhq] .classpath pom.xml
by Heiko W. Rupp
.classpath | 2 +-
pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
New commits:
commit ed8a9215c0ebdaf60ede49b386398171c3dd8ebb
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Dec 9 13:54:15 2013 +0100
Bump the version of remoting
diff --git a/.classpath b/.classpath
index a334ae2..f8048fc 100644
--- a/.classpath
+++ b/.classpath
@@ -231,7 +231,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/i18nlog/i18nlog/1.0.10/i18nlog-1.0.10.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/gnu-getopt/getopt/1.0.13/getopt-1.0.13.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/commons-httpclient/commons-httpclient/3.0.1/commons-httpclient-3.0.1.jar" sourcepath="/M2_REPO/commons-httpclient/commons-httpclient/3.0.1/commons-httpclient-3.0.1-sources.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/remoting/jboss-remoting/2.5.4.SP4/jboss-remoting-2.5.4.SP4.jar" sourcepath="M2_REPO/org/jboss/remoting/jboss-remoting/2.5.4.SP4/jboss-remoting-2.5.4.SP4-sources.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/remoting/jboss-remoting/2.5.4.SP5/jboss-remoting-2.5.4.SP5.jar" sourcepath="M2_REPO/org/jboss/remoting/jboss-remoting/2.5.4.SP5/jboss-remoting-2.5.4.SP5-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/rss4j/rss4j/0.92-on.2/rss4j-0.92-on.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/ant/ant/1.8.4/ant-1.8.4.jar" sourcepath="M2_REPO/org/apache/ant/ant/1.8.4/ant-1.8.4-sources.jar"/>
diff --git a/pom.xml b/pom.xml
index cd099f6..77a3dcd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,7 +116,7 @@
<jboss-cache.version>1.4.1.SP9</jboss-cache.version>
<jboss-jmx.version>4.2.3.GA</jboss-jmx.version>
<jboss-common.version>1.2.1.GA</jboss-common.version> <!-- note this is the old commons we used, not the newer commons-core -->
- <jboss-remoting.version>2.5.4.SP4</jboss-remoting.version>
+ <jboss-remoting.version>2.5.4.SP5</jboss-remoting.version>
<jboss-serialization.version>1.0.3.GA</jboss-serialization.version>
<jboss-system.version>4.2.3.GA</jboss-system.version>
<jbosssx.version>4.2.3.GA</jbosssx.version>
10 years, 4 months