modules/core/arquillian-integration/archive/pom.xml
| 6
modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginArchiveImpl.java
| 28 ++
modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginDescriptorContainer.java
| 16 +
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
| 105 ++++++++++
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
| 6
modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/SingleResourceDiscoveryComponent.java
| 30 ++
modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058DiscoveryComponent.java
| 51 ----
modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java
| 38 +++
modules/core/plugin-container-itest/src/test/resources/arquillian.xml
| 1
modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
| 5
modules/core/plugin-container-itest/src/test/resources/single-metric-rhq-plugin.xml
| 21 ++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
| 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
| 24 ++
13 files changed, 273 insertions(+), 60 deletions(-)
New commits:
commit b48676a8552e723f2fce366b00d438dbf2484693
Merge: 5e823b9 00c0ee0
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jun 29 17:48:02 2012 -0400
Merge branch 'master' of
ssh://git.fedorahosted.org/git/rhq/rhq.git
commit 5e823b969b8cc830432cfc2e055ed3292464c4d8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jun 29 17:47:26 2012 -0400
[BZ 834019] enhancement to the arquillian stuff so we can have code that can
templatize reusable plugin descriptors. this also has a reusable discovery component. This
includes LateMeasurementRescheduleTest that will hopefully, eventually test this BZ but
the actual test method is essentially a stub right now
diff --git a/modules/core/arquillian-integration/archive/pom.xml
b/modules/core/arquillian-integration/archive/pom.xml
index f92cc5e..edf6add 100644
--- a/modules/core/arquillian-integration/archive/pom.xml
+++ b/modules/core/arquillian-integration/archive/pom.xml
@@ -25,6 +25,12 @@
<dependency>
<groupId>org.rhq</groupId>
+ <artifactId>rhq-core-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
<artifactId>rhq-core-client-api</artifactId>
<version>${project.version}</version>
</dependency>
diff --git
a/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginArchiveImpl.java
b/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginArchiveImpl.java
index ed19397..3d31785 100644
---
a/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginArchiveImpl.java
+++
b/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginArchiveImpl.java
@@ -3,7 +3,9 @@
*/
package org.rhq.test.shrinkwrap;
+import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -41,6 +43,7 @@ import org.jboss.shrinkwrap.impl.base.container.ContainerBase;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
import org.rhq.core.clientapi.agent.metadata.PluginDependencyGraph;
+import org.rhq.core.util.stream.StreamUtil;
/**
* @author Lukas Krejci
@@ -122,6 +125,31 @@ public class RhqAgentPluginArchiveImpl extends
ContainerBase<RhqAgentPluginArchi
}
@Override
+ public RhqAgentPluginArchive setPluginDescriptorFromTemplate(String resourceName,
+ Map<String, String> replacementValues) throws IllegalArgumentException {
+
+ Validate.notNull(resourceName, "resourceName should be specified");
+ Validate.notNull(replacementValues, "replacementValues should be
specified");
+
+ // get the template text and replace all tokens with their replacement values
+ String templateXml = new String(StreamUtil.slurp(new
ClassLoaderAsset(resourceName).openStream()));
+ for (Map.Entry<String, String> entry : replacementValues.entrySet()) {
+ templateXml = templateXml.replace(entry.getKey(), entry.getValue());
+ }
+
+ // Make a new descriptor file with the new template content (with variables
replaced) in a tmp directory.
+ File newDescriptorFile;
+ try {
+ newDescriptorFile =
File.createTempFile(resourceName.replace(".xml", ""),
".xml");
+ StreamUtil.copy(new ByteArrayInputStream(templateXml.getBytes()), new
FileOutputStream(newDescriptorFile));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ return setPluginDescriptor(newDescriptorFile);
+ }
+
+ @Override
public RhqAgentPluginArchive setPluginDescriptor(String resourceName) throws
IllegalArgumentException {
Validate.notNull(resourceName, "ResourceName should be specified");
return setPluginDescriptor(new ClassLoaderAsset(resourceName));
diff --git
a/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginDescriptorContainer.java
b/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginDescriptorContainer.java
index 309b341..ff5bdf1 100644
---
a/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginDescriptorContainer.java
+++
b/modules/core/arquillian-integration/archive/src/main/java/org/rhq/test/shrinkwrap/RhqAgentPluginDescriptorContainer.java
@@ -7,6 +7,7 @@ import java.io.File;
import java.net.URL;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
@@ -36,6 +37,21 @@ public interface RhqAgentPluginDescriptorContainer<T extends
Archive<T>> {
ArchivePath getRequiredPluginsPath();
/**
+ * Sets the plugin descriptor using the plugin descriptor template resource, making
+ * a copy of that resource and replacing templatized variables in that file with
+ * replacement values that are passed into this method.
+ * The {@link ClassLoader} is used to obtain the plugin descriptor template resource,
but
+ * it is assumed to be a file on the file system.
+ *
+ * @param resourceName the name of the plugin descriptor template resource as
accessible by the class loader
+ * @param replacementValues map with keys of template replacement variable names with
their replacement values
+ * @return the archive itself
+ * @throws IllegalArgumentException if resourceName or replacementValues is null
+ */
+ T setPluginDescriptorFromTemplate(String resourceName, Map<String, String>
replacementValues)
+ throws IllegalArgumentException;
+
+ /**
* Sets the plugin descriptor using the resource name. The {@link ClassLoader} is
* used to obtain the resource.
*
diff --git
a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
new file mode 100644
index 0000000..518d5da
--- /dev/null
+++
b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/LateMeasurementRescheduleTest.java
@@ -0,0 +1,105 @@
+package org.rhq.core.pc.measurement;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Set;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.TargetsContainer;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.inventory.ResourceContainer;
+import org.rhq.plugins.test.SingleResourceDiscoveryComponent;
+import org.rhq.plugins.test.measurement.BZ834019ResourceComponent;
+import org.rhq.test.arquillian.AfterDiscovery;
+import org.rhq.test.arquillian.BeforeDiscovery;
+import org.rhq.test.arquillian.FakeServerInventory;
+import org.rhq.test.arquillian.MockingServerServices;
+import org.rhq.test.arquillian.ResourceComponentInstances;
+import org.rhq.test.arquillian.ResourceContainers;
+import org.rhq.test.arquillian.RunDiscovery;
+import org.rhq.test.shrinkwrap.RhqAgentPluginArchive;
+
+/**
+ * Test for BZ 834019.
+ */
+@RunDiscovery
+public class LateMeasurementRescheduleTest extends Arquillian {
+
+ @Deployment(name = "SingleMetricPlugin")
+ @TargetsContainer("connected-pc-with-metric-collection")
+ public static RhqAgentPluginArchive getTestPlugin() {
+ RhqAgentPluginArchive pluginJar = ShrinkWrap
+ .create(RhqAgentPluginArchive.class,
"single-metric-plugin-1.0.jar");
+ HashMap<String, String> replacements = new HashMap<String,
String>();
+ replacements.put("@@@discovery@@@",
SingleResourceDiscoveryComponent.class.getName());
+ replacements.put("@@@class@@@",
BZ834019ResourceComponent.class.getName());
+ return
pluginJar.setPluginDescriptorFromTemplate("single-metric-rhq-plugin.xml",
replacements).addClasses(
+ SingleResourceDiscoveryComponent.class, BZ834019ResourceComponent.class);
+ }
+
+ @ArquillianResource
+ private PluginContainer pluginContainer;
+
+ @ArquillianResource
+ public MockingServerServices serverServices;
+
+ private FakeServerInventory fakeServerInventory;
+ private FakeServerInventory.CompleteDiscoveryChecker discoveryCompleteChecker;
+
+ @ResourceContainers(plugin = "SingleMetricPlugin", resourceType =
"SingleMetricServer")
+ private Set<ResourceContainer> containers;
+
+ @ResourceComponentInstances(plugin = "SingleMetricPlugin", resourceType =
"SingleMetricServer")
+ private Set<BZ834019ResourceComponent> components;
+
+ @BeforeDiscovery(testMethods = "testBZ834019")
+ public void resetServerServices() throws Exception {
+ serverServices.resetMocks();
+ fakeServerInventory = new FakeServerInventory();
+ discoveryCompleteChecker =
fakeServerInventory.createAsyncDiscoveryCompletionChecker(1);
+
+ // autoimport everything
+
when(serverServices.getDiscoveryServerService().mergeInventoryReport(any(InventoryReport.class))).then(
+ fakeServerInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+
+ // set up the metric schedules using the metric metadata to determine default
intervals and enablement
+
when(serverServices.getDiscoveryServerService().postProcessNewlyCommittedResources(any(Set.class))).then(
+ fakeServerInventory.postProcessNewlyCommittedResources());
+ }
+
+ @AfterDiscovery
+ public void waitForAsyncDiscoveries() throws Exception {
+ if (discoveryCompleteChecker != null) {
+ discoveryCompleteChecker.waitForDiscoveryComplete(10000);
+ }
+ }
+
+ @Test(groups = "pc.itest.bz834019", priority = 20)
+ public void testBZ834019() throws Exception {
+ Assert.assertNotNull(pluginContainer);
+ Assert.assertTrue(pluginContainer.isStarted());
+
+ // make sure we have the resource container
+ Assert.assertEquals(containers.size(), 1, "missing container");
+
+ // make sure we have the resource component
+ Assert.assertEquals(components.size(), 1, "missing component");
+
+ assert containers.iterator().next().getResource().getInventoryStatus() ==
InventoryStatus.COMMITTED;
+
+ BZ834019ResourceComponent server = this.components.iterator().next();
+
+ // TODO do things to test BZ 834019
+ }
+}
diff --git
a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
index 8435114..d94e32f 100644
---
a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
+++
b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/measurement/ReadOnlyScheduleSetTest.java
@@ -19,7 +19,7 @@ import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.inventory.ResourceContainer;
-import org.rhq.plugins.test.measurement.BZ821058DiscoveryComponent;
+import org.rhq.plugins.test.SingleResourceDiscoveryComponent;
import org.rhq.plugins.test.measurement.BZ821058ResourceComponent;
import org.rhq.test.arquillian.AfterDiscovery;
import org.rhq.test.arquillian.BeforeDiscovery;
@@ -40,8 +40,8 @@ public class ReadOnlyScheduleSetTest extends Arquillian {
@TargetsContainer("connected-pc-with-metric-collection")
public static RhqAgentPluginArchive getTestPlugin() {
RhqAgentPluginArchive pluginJar = ShrinkWrap.create(RhqAgentPluginArchive.class,
"bz821058-plugin-1.0.jar");
- return
pluginJar.setPluginDescriptor("bz821058-rhq-plugin.xml").addClasses(BZ821058DiscoveryComponent.class,
- BZ821058ResourceComponent.class);
+ return
pluginJar.setPluginDescriptor("bz821058-rhq-plugin.xml").addClasses(
+ SingleResourceDiscoveryComponent.class, BZ821058ResourceComponent.class);
}
@ArquillianResource
diff --git
a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/SingleResourceDiscoveryComponent.java
b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/SingleResourceDiscoveryComponent.java
new file mode 100644
index 0000000..fde1f91
--- /dev/null
+++
b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/SingleResourceDiscoveryComponent.java
@@ -0,0 +1,30 @@
+package org.rhq.plugins.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+public class SingleResourceDiscoveryComponent implements
ResourceDiscoveryComponent<ResourceComponent<?>> {
+ @Override
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<ResourceComponent<?>> context)
+ throws InvalidPluginConfigurationException, Exception {
+
+ HashSet<DiscoveredResourceDetails> details = new
HashSet<DiscoveredResourceDetails>(1);
+ ResourceType rt = context.getResourceType();
+ String key = "SingleResourceKey";
+ String name = "SingleResourceName";
+ String version = "1";
+ Configuration pc = context.getDefaultPluginConfiguration();
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(rt, key, name,
version, null, pc, null);
+ details.add(resource);
+
+ return details;
+ }
+}
\ No newline at end of file
diff --git
a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058DiscoveryComponent.java
b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058DiscoveryComponent.java
deleted file mode 100644
index b9f49a4..0000000
---
a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ821058DiscoveryComponent.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2012 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 as published by
- * the Free Software Foundation version 2 of the License.
- *
- * 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 for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.plugins.test.measurement;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-
-public class BZ821058DiscoveryComponent implements
ResourceDiscoveryComponent<ResourceComponent<?>> {
-
- @Override
- public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<ResourceComponent<?>> context)
- throws InvalidPluginConfigurationException, Exception {
-
- HashSet<DiscoveredResourceDetails> details = new
HashSet<DiscoveredResourceDetails>(1);
- ResourceType rt = context.getResourceType();
- String key = "bz821058";
- String name = "bz821058";
- String version = "1";
- Configuration pc = context.getDefaultPluginConfiguration();
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(rt, key, name,
version, null, pc, null);
- details.add(resource);
-
- return details;
- }
-
-}
diff --git
a/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java
b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java
new file mode 100644
index 0000000..6a3a93d
--- /dev/null
+++
b/modules/core/plugin-container-itest/src/test/java/org/rhq/plugins/test/measurement/BZ834019ResourceComponent.java
@@ -0,0 +1,38 @@
+package org.rhq.plugins.test.measurement;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+
+public class BZ834019ResourceComponent implements
ResourceComponent<ResourceComponent<?>>, MeasurementFacet {
+
+ @Override
+ public AvailabilityType getAvailability() {
+ return AvailabilityType.UP;
+ }
+
+ @Override
+ public void start(ResourceContext<ResourceComponent<?>> context) throws
Exception {
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ @Override
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest>
metrics) throws Exception {
+ // TODO: do things to test BZ 834019
+ for (Iterator<MeasurementScheduleRequest> i = metrics.iterator();
i.hasNext();) {
+ MeasurementScheduleRequest metric = i.next();
+ report.addData(new MeasurementDataNumeric(metric, new Double(1.0)));
+ }
+ return;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/plugin-container-itest/src/test/resources/arquillian.xml
b/modules/core/plugin-container-itest/src/test/resources/arquillian.xml
index 92968b2..964e07e 100644
--- a/modules/core/plugin-container-itest/src/test/resources/arquillian.xml
+++ b/modules/core/plugin-container-itest/src/test/resources/arquillian.xml
@@ -10,6 +10,7 @@
<property name="insideAgent">true</property>
<property name="startManagementBean">false</property>
<property
name="measurementCollectionInitialDelay">10</property> <!-- start
collecting metrics after 10s -->
+ <property
name="measurementCollectionThreadPoolSize">1</property> <!-- make
testing easier by only having one thread collect -->
</configuration>
</container>
diff --git
a/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
b/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
index 730a656..c6adda6 100644
--- a/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
+++ b/modules/core/plugin-container-itest/src/test/resources/bz821058-rhq-plugin.xml
@@ -3,15 +3,14 @@
<plugin name="bz821058Plugin"
displayName="Plugin to test BZ 821058"
description="This will help test that measurement facet is given a read-only
schedule set."
- package="org.rhq.plugins.test.measurement"
version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
<server name="BZ821058Server"
- discovery="BZ821058DiscoveryComponent"
- class="BZ821058ResourceComponent">
+ discovery="org.rhq.plugins.test.SingleResourceDiscoveryComponent"
+
class="org.rhq.plugins.test.measurement.BZ821058ResourceComponent">
<metric property="metric1"
dataType="measurement"
diff --git
a/modules/core/plugin-container-itest/src/test/resources/single-metric-rhq-plugin.xml
b/modules/core/plugin-container-itest/src/test/resources/single-metric-rhq-plugin.xml
new file mode 100644
index 0000000..d67fafd
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/resources/single-metric-rhq-plugin.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin name="SingleMetricPlugin"
+ displayName="Plugin that has a single server with a single enabled
metric."
+ description="This will help test measurement collections by providing a
server with an enabled metric."
+ version="1.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <server name="SingleMetricServer"
+ discovery="@@@discovery@@@"
+ class="@@@class@@@">
+ <metric property="metric1"
+ dataType="measurement"
+ defaultOn="true"
+ displayType="summary"
+ defaultInterval="30000" />
+ </server>
+</plugin>
+
commit cd6c2fa4ce4f128f80145438499dbfc1223fac42
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jun 29 17:45:46 2012 -0400
[BZ 834019] the actual code fix to push out the new rescheduled metric - will later be
checking in test code to help test this
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
index ac13b06..e9303b4 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
@@ -88,7 +88,7 @@ public class MeasurementCollectorRunner implements
Callable<MeasurementReport>,
}
}
- this.measurementManager.reschedule(requests);
+ this.measurementManager.reschedule(requests, 31000L); // BZ 834019 -
go to the next collection interval plus 31s to skew it
return report;
}
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
index dc7d0ca..33895aa 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
@@ -526,11 +526,31 @@ public class MeasurementManager extends AgentService implements
MeasurementAgent
return nextScheduledSet;
}
+ /**
+ * Reschedules the given measurement schedules so the next collection occurs in the
future.
+ * The next collection will be pushed out by the number of seconds of the
schedule's collection
+ * interval.
+ *
+ * @param scheduledMeasurementInfos the schedules to reschedule
+ */
public synchronized void reschedule(Set<ScheduledMeasurementInfo>
scheduledMeasurementInfos) {
+ reschedule(scheduledMeasurementInfos, 0);
+ }
+
+ /**
+ * Reschedules the given measurement schedules so the next collection occurs in the
future.
+ * The next collection will be pushed out by the number of seconds of the
schedule's collection
+ * interval plus (or minus) the given adjustment (which is provided in
milliseconds).
+ *
+ * @param scheduledMeasurementInfos the schedules to reschedule
+ * @param adjustment the number of milliseconds to adjust the next collection time.
If 0, the
+ * next collection time will be the number of seconds in the future
as indicated
+ * by the schedule's interval.
+ */
+ public synchronized void reschedule(Set<ScheduledMeasurementInfo>
scheduledMeasurementInfos, long adjustment) {
for (ScheduledMeasurementInfo scheduledMeasurement : scheduledMeasurementInfos)
{
- // Iterate to next collection time
scheduledMeasurement.setNextCollection(scheduledMeasurement.getNextCollection()
- + scheduledMeasurement.getInterval());
+ + scheduledMeasurement.getInterval() + adjustment);
this.scheduledRequests.offer(scheduledMeasurement);
}
}