[rhq] modules/enterprise
by Simeon Pinder
dev/null |binary
1 file changed
New commits:
commit 576244eef9c8abb91bd1f1ccfb6098a5f08e75fa
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Nov 3 10:45:30 2011 -0400
[BZ 746658] reverting RHQ-1415 as it lays down unsigned elements to file system which breaks signed builds for portal.war.
- Configuration has been completely rewritten in gwt so RHQ-1415 no longer occurs.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/classes/org/jboss/seam/el/SeamELResolver.class b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/classes/org/jboss/seam/el/SeamELResolver.class
deleted file mode 100644
index 9cf7ddf..0000000
Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/classes/org/jboss/seam/el/SeamELResolver.class and /dev/null differ
12 years, 7 months
[rhq] Branch 'release_jon3.x' - modules/enterprise
by John Sanda
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionDataSource.java | 6 ++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionsView.java | 8 ++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
New commits:
commit f51dc89b22f37762d277af23810405b6d1d5309c
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Nov 3 10:21:38 2011 -0400
[BZ 738404] Disable 'Detect Now' button for disabled definitons
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionDataSource.java
index 71ffeca..3bb7161 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionDataSource.java
@@ -68,6 +68,7 @@ public class DriftDefinitionDataSource extends RPCDataSource<DriftDefinitionComp
public static final String ATTR_DRIFT_HANDLING_MODE = "driftHandlingMode";
public static final String ATTR_BASE_DIR_STRING = "baseDirString";
public static final String ATTR_IS_ENABLED = "isEnabled";
+ public static final String ATTR_IS_ENABLED_ICON = "isEnabledIcon";
public static final String ATTR_EDIT = "edit";
public static final String ATTR_IS_PINNED = "isPinned";
public static final String ATTR_CHANGE_SET_CTIME = "changesetTime";
@@ -138,7 +139,7 @@ public class DriftDefinitionDataSource extends RPCDataSource<DriftDefinitionComp
changeSetTimeField.setCanSortClientOnly(true);
fields.add(changeSetTimeField);
- ListGridField enabledField = new ListGridField(ATTR_IS_ENABLED, MSG.common_title_enabled());
+ ListGridField enabledField = new ListGridField(ATTR_IS_ENABLED_ICON, MSG.common_title_enabled());
enabledField.setType(ListGridFieldType.IMAGE);
enabledField.setAlign(Alignment.CENTER);
fields.add(enabledField);
@@ -333,7 +334,8 @@ public class DriftDefinitionDataSource extends RPCDataSource<DriftDefinitionComp
record.setAttribute(ATTR_DRIFT_HANDLING_MODE, getDriftHandlingModeDisplayName(def.getDriftHandlingMode()));
record.setAttribute(ATTR_INTERVAL, String.valueOf(def.getInterval()));
record.setAttribute(ATTR_BASE_DIR_STRING, getBaseDirString(def.getBasedir()));
- record.setAttribute(ATTR_IS_ENABLED, ImageManager.getAvailabilityIcon(def.isEnabled()));
+ record.setAttribute(ATTR_IS_ENABLED, String.valueOf(def.isEnabled()));
+ record.setAttribute(ATTR_IS_ENABLED_ICON, ImageManager.getAvailabilityIcon(def.isEnabled()));
// fixed value, just the edit icon
record.setAttribute(ATTR_EDIT, ImageManager.getEditIcon());
record.setAttribute(ATTR_IS_PINNED, def.isPinned() ? ImageManager.getPinnedIcon() : ImageManager
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionsView.java
index f3e5d84..ca11132 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionsView.java
@@ -163,6 +163,14 @@ public class DriftDefinitionsView extends TableSection<DriftDefinitionDataSource
addTableAction("DetectNow", MSG.view_drift_button_detectNow(), null, new AbstractTableAction(
detectNowEnablement) {
+ @Override
+ public boolean isEnabled(ListGridRecord[] selection) {
+ if (selection.length == 0) {
+ return false;
+ }
+ return Boolean.valueOf(selection[0].getAttribute(DriftDefinitionDataSource.ATTR_IS_ENABLED));
+ }
+
public void executeAction(ListGridRecord[] selection, Object actionValue) {
detectDrift(selection); // will only ever be a single selection - see detectNowEnablement variable
}
12 years, 7 months
[rhq] modules/enterprise
by John Sanda
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionDataSource.java | 6 ++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionsView.java | 8 ++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
New commits:
commit fcc69d253f3951b374732afb365135c019933ecd
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Nov 3 10:21:38 2011 -0400
[BZ 738404] Disable 'Detect Now' button for disabled definitons
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionDataSource.java
index 71ffeca..3bb7161 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionDataSource.java
@@ -68,6 +68,7 @@ public class DriftDefinitionDataSource extends RPCDataSource<DriftDefinitionComp
public static final String ATTR_DRIFT_HANDLING_MODE = "driftHandlingMode";
public static final String ATTR_BASE_DIR_STRING = "baseDirString";
public static final String ATTR_IS_ENABLED = "isEnabled";
+ public static final String ATTR_IS_ENABLED_ICON = "isEnabledIcon";
public static final String ATTR_EDIT = "edit";
public static final String ATTR_IS_PINNED = "isPinned";
public static final String ATTR_CHANGE_SET_CTIME = "changesetTime";
@@ -138,7 +139,7 @@ public class DriftDefinitionDataSource extends RPCDataSource<DriftDefinitionComp
changeSetTimeField.setCanSortClientOnly(true);
fields.add(changeSetTimeField);
- ListGridField enabledField = new ListGridField(ATTR_IS_ENABLED, MSG.common_title_enabled());
+ ListGridField enabledField = new ListGridField(ATTR_IS_ENABLED_ICON, MSG.common_title_enabled());
enabledField.setType(ListGridFieldType.IMAGE);
enabledField.setAlign(Alignment.CENTER);
fields.add(enabledField);
@@ -333,7 +334,8 @@ public class DriftDefinitionDataSource extends RPCDataSource<DriftDefinitionComp
record.setAttribute(ATTR_DRIFT_HANDLING_MODE, getDriftHandlingModeDisplayName(def.getDriftHandlingMode()));
record.setAttribute(ATTR_INTERVAL, String.valueOf(def.getInterval()));
record.setAttribute(ATTR_BASE_DIR_STRING, getBaseDirString(def.getBasedir()));
- record.setAttribute(ATTR_IS_ENABLED, ImageManager.getAvailabilityIcon(def.isEnabled()));
+ record.setAttribute(ATTR_IS_ENABLED, String.valueOf(def.isEnabled()));
+ record.setAttribute(ATTR_IS_ENABLED_ICON, ImageManager.getAvailabilityIcon(def.isEnabled()));
// fixed value, just the edit icon
record.setAttribute(ATTR_EDIT, ImageManager.getEditIcon());
record.setAttribute(ATTR_IS_PINNED, def.isPinned() ? ImageManager.getPinnedIcon() : ImageManager
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionsView.java
index f3e5d84..ca11132 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDefinitionsView.java
@@ -163,6 +163,14 @@ public class DriftDefinitionsView extends TableSection<DriftDefinitionDataSource
addTableAction("DetectNow", MSG.view_drift_button_detectNow(), null, new AbstractTableAction(
detectNowEnablement) {
+ @Override
+ public boolean isEnabled(ListGridRecord[] selection) {
+ if (selection.length == 0) {
+ return false;
+ }
+ return Boolean.valueOf(selection[0].getAttribute(DriftDefinitionDataSource.ATTR_IS_ENABLED));
+ }
+
public void executeAction(ListGridRecord[] selection, Object actionValue) {
detectDrift(selection); // will only ever be a single selection - see detectNowEnablement variable
}
12 years, 7 months
[rhq] 2 commits - modules/plugins
by Heiko W. Rupp
modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java | 5 ++++-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)
New commits:
commit 2470ad0913d7adb6f776df50bb7b221267084a5f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Nov 3 12:34:08 2011 +0100
BZ 751016 - set content type,as as7 requires this now.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index cf5b100..13c9ae6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -98,6 +98,8 @@ public class ASConnection {
conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
+ conn.addRequestProperty("Content-Type","application/json");
+ conn.addRequestProperty("Accept","application/json");
OutputStream out = conn.getOutputStream();
String result = mapper.writeValueAsString(operation);
commit 6483d2d2a0e95678c7b5fffaa7343eaa155ccd62
Author: Elias Ross <genman(a)noderunner.net>
Date: Thu Nov 3 10:38:14 2011 +0100
BZ 750665 - fix a regex issue with formatMessage
diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java
index e4d9392..630b575 100644
--- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java
+++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java
@@ -25,6 +25,8 @@ import java.sql.Statement;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import java.util.regex.Matcher;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
@@ -58,7 +60,7 @@ public class CustomTableRowDiscoveryComponent implements ResourceDiscoveryCompon
if (resourceName == null) {
throw new InvalidPluginConfigurationException("The 'name' connection property has to be specified.");
}
-
+
statement = conn.createStatement();
resultSet = statement.executeQuery("SELECT * FROM " + table);
@@ -97,6 +99,7 @@ public class CustomTableRowDiscoveryComponent implements ResourceDiscoveryCompon
* @return the formatted text with variables replaced
*/
public static String formatMessage(String message, String key) {
+ key = Matcher.quoteReplacement(key);
message = message.replaceAll("\\{key\\}", key);
return message;
}
12 years, 7 months
[rhq] Branch 'release_jon3.x' - modules/plugins
by Heiko W. Rupp
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 2 ++
1 file changed, 2 insertions(+)
New commits:
commit b89b7e752ebf34c2d5de119e1cd1d404fc310d50
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Nov 3 12:38:17 2011 +0100
BZ 751016 - set content type,as as7 requires this now.(cherry picked from commit 0b363407c23241cb3323300b3aa91487c6f65669)
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index cf5b100..13c9ae6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -98,6 +98,8 @@ public class ASConnection {
conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
+ conn.addRequestProperty("Content-Type","application/json");
+ conn.addRequestProperty("Accept","application/json");
OutputStream out = conn.getOutputStream();
String result = mapper.writeValueAsString(operation);
12 years, 7 months
[rhq] Branch 'release_jon3.x' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 76 ++++++----
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 55 +++++++
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java | 16 +-
3 files changed, 117 insertions(+), 30 deletions(-)
New commits:
commit 0d520a33a83e85fd2ef57ab77b11dbfdddc023a9
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Nov 3 07:15:41 2011 -0400
[BZ 750886] drift detection needs to handle resource going back into compliance
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
index 9a66ac0..09bedef 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
@@ -261,8 +261,20 @@ public class DriftDetector implements Runnable {
}
if (deltaEntries.isEmpty()) {
- // If nothing has changed, there is no need to add/update any files
summary.setNewSnapshot(currentSnapshot);
+
+ // If nothing has changed, there is no need to add/update any files
+ // unless the definition is pinned in which case we need to reset
+ // the current snapshot to match the pinned snapshot. Note though
+ // that we increment the snapshot version in order to let the server
+ // know about the state change.
+ if (schedule.getDriftDefinition().isPinned()) {
+ currentSnapshot.delete();
+ File newSnapshot = updateCurrentSnapshot(schedule, snapshotEntries, newVersion);
+
+ updateDeltaSnapshot(summary, schedule, deltaEntries, newVersion, currentSnapshot, newSnapshot);
+ // TODO report back to the server that we are back in compliance
+ }
} else {
if (schedule.getDriftDefinition().isPinned() && newVersion > 1 &&
isSameAsPreviousChangeSet(deltaEntries, currentSnapshot)) {
@@ -271,35 +283,51 @@ public class DriftDetector implements Runnable {
return;
}
- File oldSnapshot = new File(currentSnapshot.getParentFile(), currentSnapshot.getName() + ".previous");
- copyFile(currentSnapshot, oldSnapshot);
- currentSnapshot.delete();
+ File oldSnapshot = backupAndDeleteCurrentSnapshot(currentSnapshot);
+ File newSnapshot = updateCurrentSnapshot(schedule, snapshotEntries, newVersion);
- Headers snapshotHeaders = createHeaders(schedule, COVERAGE, newVersion);
- File newSnapshot = changeSetMgr.findChangeSet(schedule.getResourceId(),
- schedule.getDriftDefinition().getName(), COVERAGE);
- ChangeSetWriter newSnapshotWriter = changeSetMgr.getChangeSetWriter(schedule.getResourceId(),
- snapshotHeaders);
+ updateDeltaSnapshot(summary, schedule, deltaEntries, newVersion, oldSnapshot, newSnapshot);
+ }
+ }
- for (FileEntry entry : snapshotEntries) {
- newSnapshotWriter.write(entry);
- }
- newSnapshotWriter.close();
- Headers deltaHeaders = createHeaders(schedule, DRIFT, newVersion);
+ private void updateDeltaSnapshot(DriftDetectionSummary summary, DriftDetectionSchedule schedule,
+ List<FileEntry> deltaEntries, int newVersion, File oldSnapshot, File newSnapshot)
+ throws IOException {
+ Headers deltaHeaders = createHeaders(schedule, DRIFT, newVersion);
+ File driftChangeSet = changeSetMgr.findChangeSet(schedule.getResourceId(),
+ schedule.getDriftDefinition().getName(), DRIFT);
+ ChangeSetWriter deltaWriter = changeSetMgr.getChangeSetWriter(driftChangeSet, deltaHeaders);
- File driftChangeSet = changeSetMgr.findChangeSet(schedule.getResourceId(),
- schedule.getDriftDefinition().getName(), DRIFT);
- ChangeSetWriter deltaWriter = changeSetMgr.getChangeSetWriter(driftChangeSet, deltaHeaders);
+ summary.setDriftChangeSet(driftChangeSet);
+ summary.setNewSnapshot(newSnapshot);
+ summary.setOldSnapshot(oldSnapshot);
- summary.setDriftChangeSet(driftChangeSet);
- summary.setNewSnapshot(newSnapshot);
- summary.setOldSnapshot(oldSnapshot);
+ for (FileEntry entry : deltaEntries) {
+ deltaWriter.write(entry);
+ }
+ deltaWriter.close();
+ }
- for (FileEntry entry : deltaEntries) {
- deltaWriter.write(entry);
- }
- deltaWriter.close();
+ private File backupAndDeleteCurrentSnapshot(File currentSnapshot) throws IOException {
+ File oldSnapshot = new File(currentSnapshot.getParentFile(), currentSnapshot.getName() + ".previous");
+ copyFile(currentSnapshot, oldSnapshot);
+ currentSnapshot.delete();
+ return oldSnapshot;
+ }
+
+ private File updateCurrentSnapshot(DriftDetectionSchedule schedule, List<FileEntry> snapshotEntries, int newVersion)
+ throws IOException {
+ Headers snapshotHeaders = createHeaders(schedule, COVERAGE, newVersion);
+ File newSnapshot = changeSetMgr.findChangeSet(schedule.getResourceId(),
+ schedule.getDriftDefinition().getName(), COVERAGE);
+ ChangeSetWriter newSnapshotWriter = changeSetMgr.getChangeSetWriter(schedule.getResourceId(),
+ snapshotHeaders);
+
+ for (FileEntry entry : snapshotEntries) {
+ newSnapshotWriter.write(entry);
}
+ newSnapshotWriter.close();
+ return newSnapshot;
}
private boolean isSameAsPreviousChangeSet(List<FileEntry> entries, File currentSnapsotFile) throws IOException {
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
index 983fbe3..c5cefdd 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
@@ -21,6 +21,7 @@ package org.rhq.core.pc.drift;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
+import static org.apache.commons.io.FileUtils.copyFile;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.touch;
import static org.rhq.common.drift.FileEntry.addedFileEntry;
@@ -48,6 +49,7 @@ import org.testng.annotations.Test;
import org.rhq.common.drift.ChangeSetReader;
import org.rhq.common.drift.ChangeSetReaderImpl;
import org.rhq.common.drift.ChangeSetWriter;
+import org.rhq.common.drift.ChangeSetWriterImpl;
import org.rhq.common.drift.FileEntry;
import org.rhq.common.drift.Headers;
import org.rhq.core.domain.drift.DriftDefinition;
@@ -865,6 +867,59 @@ public class DriftDetectorTest extends DriftTest {
}
+ @Test
+ public void detectWhenResourceComesBackIntoCompliance() throws Exception {
+ DriftDefinition driftDef = driftDefinition("back-into-compliance", resourceDir.getAbsolutePath());
+ driftDef.setPinned(true);
+
+ File confDir = mkdir(resourceDir, "conf");
+ File serverConf = createRandomFile(confDir, "server.conf");
+ String serverConfHash = sha256(serverConf);
+
+ Headers headers = createHeaders(driftDef, COVERAGE);
+
+ // generate the pinned snapshot which is version zero
+ File pinnedSnapshot = pinnedSnapshot(driftDef.getName());
+ ChangeSetWriter writer = new ChangeSetWriterImpl(pinnedSnapshot, headers);
+ writer.write(addedFileEntry("conf/server.conf", serverConfHash));
+ writer.close();
+
+ // generate the current snapshot file. we will take a shortcut here by
+ // just copying the pinned snapshot. We can do this since the current
+ // snapshot will be identical to the pinned snapshot after the current
+ // snapshot is first generated.
+ File currentSnapshot = changeSet(driftDef.getName(), COVERAGE);
+ copyFile(pinnedSnapshot, currentSnapshot);
+
+ // now generate some drift causing the resource to go out of compliance
+ File newServerConf = createRandomFile(confDir, "new_server.conf");
+ String newServerConfHash = sha256(newServerConf);
+
+ // do a drift detection run
+ DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId(), driftDef);
+ scheduleQueue.addSchedule(schedule);
+ // this run should produce version one
+ detector.run();
+
+ // now put the resource back into compliance
+ newServerConf.delete();
+
+ // do another drift detection run but first we have to delete the
+ // previous snapshot file otherwise the detection scan will not run.
+ previousSnapshot(driftDef.getName()).delete();
+ schedule.resetSchedule();
+ // this run should produce version two
+ detector.run();
+
+ // verify that that current snapshot has been updated to reflect that
+ // the resource is back in compliance.
+ List<FileEntry> entries = asList(addedFileEntry("conf/server.conf", serverConfHash));
+
+ assertHeaderEquals(currentSnapshot, createHeaders(driftDef, COVERAGE, 2));
+ assertFileEntriesMatch("The entries in the current snapshot should match those in the pinned snapshot " +
+ "once the resource has gone back into compliance.", entries, currentSnapshot);
+ }
+
private void assertHeaderEquals(File changeSet, Headers expected) throws Exception {
ChangeSetReader reader = new ChangeSetReaderImpl(new BufferedReader(new FileReader(changeSet)));
Headers actual = reader.getHeaders();
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
index ef0aa45..41b725b 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
@@ -19,6 +19,12 @@
package org.rhq.core.pc.drift;
+import static java.util.Arrays.asList;
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+import static org.apache.commons.io.IOUtils.write;
+import static org.apache.commons.io.IOUtils.writeLines;
+import static org.rhq.core.domain.drift.DriftConfigurationDefinition.BaseDirValueContext.fileSystem;
+
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@@ -35,12 +41,6 @@ import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftDefinition;
import org.rhq.core.util.MessageDigestGenerator;
-import static java.util.Arrays.asList;
-import static org.apache.commons.io.FileUtils.deleteDirectory;
-import static org.apache.commons.io.IOUtils.write;
-import static org.apache.commons.io.IOUtils.writeLines;
-import static org.rhq.core.domain.drift.DriftConfigurationDefinition.BaseDirValueContext.fileSystem;
-
/**
* A base test class that provides a framework for drift related tests. DriftTest sets up
* directories for change sets and for fake resources. Before each test method is run, a
@@ -191,6 +191,10 @@ public class DriftTest {
return changeSetMgr.findChangeSet(resourceId(), config, type);
}
+ protected File pinnedSnapshot(String definitionName) throws Exception {
+ return new File(changeSetDir(definitionName), "snapshot.pinned");
+ }
+
/**
* Returns the previous version snapshot file. This file is generated when an initial
* snapshot has already been generated and drift is subsequently detected.
12 years, 7 months
[rhq] modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 76 ++++++----
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 55 +++++++
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java | 16 +-
3 files changed, 117 insertions(+), 30 deletions(-)
New commits:
commit 098139720bb55945fc241fee337c403b2ce70adc
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Nov 3 07:15:41 2011 -0400
[BZ 750886] drift detection needs to handle resource going back into compliance
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
index 9a66ac0..09bedef 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
@@ -261,8 +261,20 @@ public class DriftDetector implements Runnable {
}
if (deltaEntries.isEmpty()) {
- // If nothing has changed, there is no need to add/update any files
summary.setNewSnapshot(currentSnapshot);
+
+ // If nothing has changed, there is no need to add/update any files
+ // unless the definition is pinned in which case we need to reset
+ // the current snapshot to match the pinned snapshot. Note though
+ // that we increment the snapshot version in order to let the server
+ // know about the state change.
+ if (schedule.getDriftDefinition().isPinned()) {
+ currentSnapshot.delete();
+ File newSnapshot = updateCurrentSnapshot(schedule, snapshotEntries, newVersion);
+
+ updateDeltaSnapshot(summary, schedule, deltaEntries, newVersion, currentSnapshot, newSnapshot);
+ // TODO report back to the server that we are back in compliance
+ }
} else {
if (schedule.getDriftDefinition().isPinned() && newVersion > 1 &&
isSameAsPreviousChangeSet(deltaEntries, currentSnapshot)) {
@@ -271,35 +283,51 @@ public class DriftDetector implements Runnable {
return;
}
- File oldSnapshot = new File(currentSnapshot.getParentFile(), currentSnapshot.getName() + ".previous");
- copyFile(currentSnapshot, oldSnapshot);
- currentSnapshot.delete();
+ File oldSnapshot = backupAndDeleteCurrentSnapshot(currentSnapshot);
+ File newSnapshot = updateCurrentSnapshot(schedule, snapshotEntries, newVersion);
- Headers snapshotHeaders = createHeaders(schedule, COVERAGE, newVersion);
- File newSnapshot = changeSetMgr.findChangeSet(schedule.getResourceId(),
- schedule.getDriftDefinition().getName(), COVERAGE);
- ChangeSetWriter newSnapshotWriter = changeSetMgr.getChangeSetWriter(schedule.getResourceId(),
- snapshotHeaders);
+ updateDeltaSnapshot(summary, schedule, deltaEntries, newVersion, oldSnapshot, newSnapshot);
+ }
+ }
- for (FileEntry entry : snapshotEntries) {
- newSnapshotWriter.write(entry);
- }
- newSnapshotWriter.close();
- Headers deltaHeaders = createHeaders(schedule, DRIFT, newVersion);
+ private void updateDeltaSnapshot(DriftDetectionSummary summary, DriftDetectionSchedule schedule,
+ List<FileEntry> deltaEntries, int newVersion, File oldSnapshot, File newSnapshot)
+ throws IOException {
+ Headers deltaHeaders = createHeaders(schedule, DRIFT, newVersion);
+ File driftChangeSet = changeSetMgr.findChangeSet(schedule.getResourceId(),
+ schedule.getDriftDefinition().getName(), DRIFT);
+ ChangeSetWriter deltaWriter = changeSetMgr.getChangeSetWriter(driftChangeSet, deltaHeaders);
- File driftChangeSet = changeSetMgr.findChangeSet(schedule.getResourceId(),
- schedule.getDriftDefinition().getName(), DRIFT);
- ChangeSetWriter deltaWriter = changeSetMgr.getChangeSetWriter(driftChangeSet, deltaHeaders);
+ summary.setDriftChangeSet(driftChangeSet);
+ summary.setNewSnapshot(newSnapshot);
+ summary.setOldSnapshot(oldSnapshot);
- summary.setDriftChangeSet(driftChangeSet);
- summary.setNewSnapshot(newSnapshot);
- summary.setOldSnapshot(oldSnapshot);
+ for (FileEntry entry : deltaEntries) {
+ deltaWriter.write(entry);
+ }
+ deltaWriter.close();
+ }
- for (FileEntry entry : deltaEntries) {
- deltaWriter.write(entry);
- }
- deltaWriter.close();
+ private File backupAndDeleteCurrentSnapshot(File currentSnapshot) throws IOException {
+ File oldSnapshot = new File(currentSnapshot.getParentFile(), currentSnapshot.getName() + ".previous");
+ copyFile(currentSnapshot, oldSnapshot);
+ currentSnapshot.delete();
+ return oldSnapshot;
+ }
+
+ private File updateCurrentSnapshot(DriftDetectionSchedule schedule, List<FileEntry> snapshotEntries, int newVersion)
+ throws IOException {
+ Headers snapshotHeaders = createHeaders(schedule, COVERAGE, newVersion);
+ File newSnapshot = changeSetMgr.findChangeSet(schedule.getResourceId(),
+ schedule.getDriftDefinition().getName(), COVERAGE);
+ ChangeSetWriter newSnapshotWriter = changeSetMgr.getChangeSetWriter(schedule.getResourceId(),
+ snapshotHeaders);
+
+ for (FileEntry entry : snapshotEntries) {
+ newSnapshotWriter.write(entry);
}
+ newSnapshotWriter.close();
+ return newSnapshot;
}
private boolean isSameAsPreviousChangeSet(List<FileEntry> entries, File currentSnapsotFile) throws IOException {
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
index 983fbe3..c5cefdd 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
@@ -21,6 +21,7 @@ package org.rhq.core.pc.drift;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
+import static org.apache.commons.io.FileUtils.copyFile;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.FileUtils.touch;
import static org.rhq.common.drift.FileEntry.addedFileEntry;
@@ -48,6 +49,7 @@ import org.testng.annotations.Test;
import org.rhq.common.drift.ChangeSetReader;
import org.rhq.common.drift.ChangeSetReaderImpl;
import org.rhq.common.drift.ChangeSetWriter;
+import org.rhq.common.drift.ChangeSetWriterImpl;
import org.rhq.common.drift.FileEntry;
import org.rhq.common.drift.Headers;
import org.rhq.core.domain.drift.DriftDefinition;
@@ -865,6 +867,59 @@ public class DriftDetectorTest extends DriftTest {
}
+ @Test
+ public void detectWhenResourceComesBackIntoCompliance() throws Exception {
+ DriftDefinition driftDef = driftDefinition("back-into-compliance", resourceDir.getAbsolutePath());
+ driftDef.setPinned(true);
+
+ File confDir = mkdir(resourceDir, "conf");
+ File serverConf = createRandomFile(confDir, "server.conf");
+ String serverConfHash = sha256(serverConf);
+
+ Headers headers = createHeaders(driftDef, COVERAGE);
+
+ // generate the pinned snapshot which is version zero
+ File pinnedSnapshot = pinnedSnapshot(driftDef.getName());
+ ChangeSetWriter writer = new ChangeSetWriterImpl(pinnedSnapshot, headers);
+ writer.write(addedFileEntry("conf/server.conf", serverConfHash));
+ writer.close();
+
+ // generate the current snapshot file. we will take a shortcut here by
+ // just copying the pinned snapshot. We can do this since the current
+ // snapshot will be identical to the pinned snapshot after the current
+ // snapshot is first generated.
+ File currentSnapshot = changeSet(driftDef.getName(), COVERAGE);
+ copyFile(pinnedSnapshot, currentSnapshot);
+
+ // now generate some drift causing the resource to go out of compliance
+ File newServerConf = createRandomFile(confDir, "new_server.conf");
+ String newServerConfHash = sha256(newServerConf);
+
+ // do a drift detection run
+ DriftDetectionSchedule schedule = new DriftDetectionSchedule(resourceId(), driftDef);
+ scheduleQueue.addSchedule(schedule);
+ // this run should produce version one
+ detector.run();
+
+ // now put the resource back into compliance
+ newServerConf.delete();
+
+ // do another drift detection run but first we have to delete the
+ // previous snapshot file otherwise the detection scan will not run.
+ previousSnapshot(driftDef.getName()).delete();
+ schedule.resetSchedule();
+ // this run should produce version two
+ detector.run();
+
+ // verify that that current snapshot has been updated to reflect that
+ // the resource is back in compliance.
+ List<FileEntry> entries = asList(addedFileEntry("conf/server.conf", serverConfHash));
+
+ assertHeaderEquals(currentSnapshot, createHeaders(driftDef, COVERAGE, 2));
+ assertFileEntriesMatch("The entries in the current snapshot should match those in the pinned snapshot " +
+ "once the resource has gone back into compliance.", entries, currentSnapshot);
+ }
+
private void assertHeaderEquals(File changeSet, Headers expected) throws Exception {
ChangeSetReader reader = new ChangeSetReaderImpl(new BufferedReader(new FileReader(changeSet)));
Headers actual = reader.getHeaders();
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
index ef0aa45..41b725b 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftTest.java
@@ -19,6 +19,12 @@
package org.rhq.core.pc.drift;
+import static java.util.Arrays.asList;
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+import static org.apache.commons.io.IOUtils.write;
+import static org.apache.commons.io.IOUtils.writeLines;
+import static org.rhq.core.domain.drift.DriftConfigurationDefinition.BaseDirValueContext.fileSystem;
+
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@@ -35,12 +41,6 @@ import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftDefinition;
import org.rhq.core.util.MessageDigestGenerator;
-import static java.util.Arrays.asList;
-import static org.apache.commons.io.FileUtils.deleteDirectory;
-import static org.apache.commons.io.IOUtils.write;
-import static org.apache.commons.io.IOUtils.writeLines;
-import static org.rhq.core.domain.drift.DriftConfigurationDefinition.BaseDirValueContext.fileSystem;
-
/**
* A base test class that provides a framework for drift related tests. DriftTest sets up
* directories for change sets and for fake resources. Before each test method is run, a
@@ -191,6 +191,10 @@ public class DriftTest {
return changeSetMgr.findChangeSet(resourceId(), config, type);
}
+ protected File pinnedSnapshot(String definitionName) throws Exception {
+ return new File(changeSetDir(definitionName), "snapshot.pinned");
+ }
+
/**
* Returns the previous version snapshot file. This file is generated when an initial
* snapshot has already been generated and drift is subsequently detected.
12 years, 7 months
[rhq] modules/core
by Heiko W. Rupp
modules/core/gui/pom.xml | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
New commits:
commit 402351743aa607e0af9e04f80cc70f8023f71f36
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Nov 3 10:05:32 2011 +0100
Add the deprecated repo of JBoss Nexus as it is needed for Hibernate.
diff --git a/modules/core/gui/pom.xml b/modules/core/gui/pom.xml
index e2b1d14..72b7bf8 100644
--- a/modules/core/gui/pom.xml
+++ b/modules/core/gui/pom.xml
@@ -39,7 +39,7 @@
<version>${project.version}</version>
<scope>provided</scope> <!-- by ${rhq.earName} -->
</dependency>
-
+
<dependency>
<groupId>${rhq.groupId}</groupId>
<artifactId>rhq-core-domain</artifactId>
@@ -53,7 +53,7 @@
<version>${project.version}</version>
<scope>provided</scope> <!-- by ${rhq.earName} -->
</dependency>
-
+
<!-- 3rd Party Deps -->
<!-- needed for referenced domain entities that use Hibernate annotations (due to JDK5 bug) -->
@@ -132,7 +132,7 @@
</dependency>
<!-- == Seam Related Dependencies ================ -->
-
+
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam</artifactId>
@@ -206,4 +206,15 @@
</profiles>
+ <repositories>
+ <repository>
+ <id>jboss-deprecated-items-group</id>
+ <name>JBoss Public Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
</project>
12 years, 7 months
[rhq] modules/enterprise
by Heiko W. Rupp
modules/enterprise/gui/coregui/pom.xml | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
New commits:
commit 5fff4e722ed1fa8ea5eb2d3be48cc393732e7579
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Nov 2 21:53:51 2011 +0100
Add the deprecated repo of JBoss Nexus as it is needed for Hibernate.
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index cecb704..b8a1f59 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -6,7 +6,7 @@
<groupId>org.rhq</groupId>
<artifactId>rhq-parent</artifactId>
<version>4.3.0-SNAPSHOT</version>
- <relativePath>../../../../pom.xml</relativePath>
+ <relativePath>../../../../pom.xml</relativePath>
</parent>
<groupId>org.rhq</groupId>
@@ -31,7 +31,7 @@
in your settings.xml -->
<gwt-plugin.extraJvmArgs>-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=256M</gwt-plugin.extraJvmArgs>
<gwt-plugin.localWorkers>2</gwt-plugin.localWorkers>
-
+
<coreGuiParams />
<coreGuiRunTarget>'http://localhost:7080/coregui/CoreGUI.html${coreGuiParams}'</coreGuiRunTarget>
@@ -61,10 +61,10 @@
-->
<gwt.userAgent>ie6,ie8,gecko1_8,safari,opera</gwt.userAgent>
- <!-- Change this to "true" via the mvn command line or your ~/.m2/settings.xml to speed
+ <!-- Change this to "true" via the mvn command line or your ~/.m2/settings.xml to speed
up gwt compilation. -->
<gwt.draftCompile>false</gwt.draftCompile>
-
+
<!-- Comma-separated list of the locales that should be included during GWT compilation. The specified locales
should each have two corresponding message bundle properties files under
src/main/resources/org/rhq/enterprise/gui/coregui/client/. For example, the "ja" locale has
@@ -101,7 +101,7 @@
<!-- by rhq.ear -->
</dependency>
-
+
<!-- =============== 3rd Party Deps =============== -->
<dependency>
@@ -252,7 +252,7 @@
<targetPath>${project.build.directory}/generated-sources/gwt</targetPath>
<directory>src/main/resources</directory>
<filtering>true</filtering>
- </resource>
+ </resource>
<resource>
<directory>src/main/java</directory>
<includes>
@@ -282,7 +282,7 @@
<debugSuspend>false</debugSuspend>
<servicePattern>**/gwt/*GWTService.java</servicePattern>
<i18nMessagesBundle>org.rhq.enterprise.gui.coregui.client.Messages</i18nMessagesBundle>
- <i18nConstantsWithLookupBundle>org.rhq.enterprise.gui.coregui.client.MessageConstants</i18nConstantsWithLookupBundle>
+ <i18nConstantsWithLookupBundle>org.rhq.enterprise.gui.coregui.client.MessageConstants</i18nConstantsWithLookupBundle>
<compileSourcesArtifact>org.rhq:rhq-core-domain</compileSourcesArtifact>
<style>DETAILED</style>
</configuration>
@@ -304,7 +304,7 @@
</goals>
<configuration>
<module>org.rhq.enterprise.gui.coregui.CoreGUI</module>
- </configuration>
+ </configuration>
</execution>
</executions>
</plugin>
@@ -476,7 +476,7 @@
</activation>
<properties>
<coreGuiRunTarget>http://localhost:7080/coregui/CoreGUI.html${coreGuiParams}</coreGuiRunTarget>
- </properties>
+ </properties>
</profile>
<profile>
@@ -494,7 +494,7 @@
</plugins>
</build>
</profile>
-
+
</profiles>
@@ -516,6 +516,16 @@
<enabled>false</enabled>
</snapshots>
</repository>
+
+ <repository>
+ <id>jboss-deprecated-items-group</id>
+ <name>JBoss Public Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+
</repositories>
</project>
12 years, 7 months
[rhq] Branch 'release_jon3.x' - etc/samples modules/core modules/plugins
by mazz
etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml | 5 -
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/MetricsMetadataParser.java | 48 +++++-----
modules/core/client-api/src/main/resources/rhq-plugin.xsd | 20 ++--
modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml | 1
4 files changed, 38 insertions(+), 36 deletions(-)
New commits:
commit 727d01bb4c1bbaf96ba14f90070ea2a60c4a7a3b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Nov 2 11:38:09 2011 -0400
[BZ 741331] change default intervals
diff --git a/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml b/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
index 2547af7..4f4966d 100644
--- a/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
+++ b/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
@@ -97,10 +97,7 @@
-->
<metric property="MeasurementName"
displayName="The Measurement Name"
- description="Describes what this measurement is actually telling you"
- defaultOn="true"
- defaultInterval="300000"
- category="performance" />
+ description="Describes what this measurement is actually telling you" />
<!--
CHANGE: Resource configuration properties are used to configure resources themselves, as compared to the plugin
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/MetricsMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/MetricsMetadataParser.java
index 77ecd37..c5e294f 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/MetricsMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/MetricsMetadataParser.java
@@ -44,11 +44,12 @@ import org.rhq.core.domain.util.StringUtils;
* @author Greg Hinkle
*/
public class MetricsMetadataParser {
- private static final long MIN_1 = 1L * 60 * 1000L;
- private static final long MIN_10 = 10L * MIN_1;
- private static final long MIN_20 = 20L * MIN_1;
- private static final long MIN_30 = 30L * MIN_1;
- private static final long MIN_60 = 60L * MIN_1;
+ private static final long MINUTE_1 = 1L * 60 * 1000L;
+ private static final long MINUTE_10 = 10L * MINUTE_1;
+ private static final long MINUTE_20 = 20L * MINUTE_1;
+ private static final long MINUTE_30 = 30L * MINUTE_1;
+ private static final long HOUR_1 = 60L * MINUTE_1;
+ private static final long HOUR_24 = HOUR_1 * 24;
public static final long MINIMUM_INTERVAL = MeasurementSchedule.MINIMUM_INTERVAL;
@@ -59,24 +60,24 @@ public class MetricsMetadataParser {
DataType dataType = DataType.valueOf(metricDescriptor.getDataType().toUpperCase());
DisplayType displayType = DisplayType.valueOf(metricDescriptor.getDisplayType().toUpperCase());
- long collectionInterval = MIN_30;
+ long collectionInterval = MINUTE_30;
MeasurementUnits units = getMeasurementUnits(metricDescriptor.getUnits(), dataType);
switch (dataType) {
case MEASUREMENT: {
switch (resourceType.getCategory()) {
case PLATFORM: {
- collectionInterval = MIN_10;
+ collectionInterval = MINUTE_10;
break;
}
case SERVER: {
- collectionInterval = MIN_20;
+ collectionInterval = MINUTE_10;
break;
}
case SERVICE: {
- collectionInterval = MIN_30;
+ collectionInterval = MINUTE_20;
break;
}
}
@@ -88,12 +89,12 @@ public class MetricsMetadataParser {
}
case TRAIT: {
- collectionInterval = (displayType == DisplayType.SUMMARY) ? MIN_30 : MIN_60;
+ collectionInterval = HOUR_24; // BZ 741331 no difference between summary and detail
break;
}
case CALLTIME: {
- collectionInterval = MIN_10;
+ collectionInterval = MINUTE_10;
if (units != MeasurementUnits.MILLISECONDS) {
throw new IllegalStateException("Units must always be set to 'milliseconds' for call-time metrics.");
}
@@ -110,10 +111,10 @@ public class MetricsMetadataParser {
(metricDescriptor.getDefaultInterval() == null) ? collectionInterval : metricDescriptor
.getDefaultInterval().longValue());
- definition = new MeasurementDefinition(metricDescriptor.getProperty(), MeasurementCategory
- .valueOf(metricDescriptor.getCategory().toUpperCase()), getMeasurementUnits(metricDescriptor.getUnits(),
- dataType), dataType, NumericType.valueOf(metricDescriptor.getMeasurementType().toUpperCase()),
- metricDescriptor.isDefaultOn(), collectionInterval, displayType);
+ definition = new MeasurementDefinition(metricDescriptor.getProperty(),
+ MeasurementCategory.valueOf(metricDescriptor.getCategory().toUpperCase()), getMeasurementUnits(
+ metricDescriptor.getUnits(), dataType), dataType, NumericType.valueOf(metricDescriptor
+ .getMeasurementType().toUpperCase()), metricDescriptor.isDefaultOn(), collectionInterval, displayType);
if (metricDescriptor.getDisplayName() != null) {
definition.setDisplayName(metricDescriptor.getDisplayName());
@@ -129,19 +130,22 @@ public class MetricsMetadataParser {
definition.setDestinationType(metricDescriptor.getDestinationType());
// Make sure that all summary properties are on by default.
- // BZ 741331 - we no longer want to imply any metric should be on by default
- // let the plugin writer tell us explicitly if it should be on by default
- // if (definition.getDisplayType() == DisplayType.SUMMARY) {
- // definition.setDefaultOn(true);
- // }
+ // It is assumed that if a plugin developer marks a metric as "summary" (which
+ // shows the metric's graph within the graph page of the UI) then he doesn't want
+ // to show an empty graph by default. Therefore, a summary metric will always be
+ // enabled by default. You can't say a metric is a "summary" metric but with
+ // defaultOn="false". The defaultOn will be overridden here and will be set to true.
+ if (definition.getDisplayType() == DisplayType.SUMMARY) {
+ definition.setDefaultOn(true);
+ }
if ((definition.getNumericType() == NumericType.TRENDSUP)
|| (definition.getNumericType() == NumericType.TRENDSDOWN)) {
ArrayList<MeasurementDefinition> definitions = new ArrayList<MeasurementDefinition>();
MeasurementDefinition perMinuteMetric = new MeasurementDefinition(definition);
- // Default to applying defaultOn, SUMMARY type, etc. to the per-minute version of the metric,
- // so only the per-minute, and not the raw, is enabled by default.
+ // Disable the raw metric since that is usually what the user will want. Typically,
+ // the user will only care about the per-minute metric.
definition.setDisplayType(DisplayType.DETAIL);
definition.setDefaultOn(false);
diff --git a/modules/core/client-api/src/main/resources/rhq-plugin.xsd b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
index 927d0d7..df31a44 100644
--- a/modules/core/client-api/src/main/resources/rhq-plugin.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
@@ -202,16 +202,16 @@
<xs:annotation>
<xs:documentation>
The default collection interval, in milliseconds. The metric is not necessarily
- enabled by default - see the defaultOn attribute for that. The minimum allowed
- value is 30000 (30 seconds). If unspecified, the default collection interval is
- set according to the Resource category, metric data type, and metric display
- type, as follows:
+ enabled by default - see the defaultOn and displayType attributes for that.
+ The minimum allowed value is 30000 (30 seconds).
+ If unspecified, the default collection interval is set according to the
+ resource type category, metric data type, and metric display type, as follows:
- platform numeric metrics: summary - 1m, detail - 2m
- server numeric metrics: summary - 5m, detail - 10m
- service numeric metrics: summary - 10m, detail - 20m
- traits: summary - 10m, detail - 30m
- call-time metrics: 1m
+ Platform numeric metrics: summary - 10m, detail - 20m
+ Server numeric metrics: summary - 10m, detail - 20m
+ Service numeric metrics: summary - 20m, detail - 40m
+ All Traits: summary and detail - 24 hours
+ Calltime metrics: 10m
</xs:documentation>
</xs:annotation>
<xs:simpleType>
@@ -225,6 +225,8 @@
<xs:documentation>
If true, this metric will get collected as soon as possible.
If false, a user must explicitly tell the plugin to collect this metric.
+ This is only used for metrics with a displayType of "detail". All
+ "summary" metrics are enabled by default, regardless of this value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
diff --git a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
index 69cbf8a..ee83f0c 100644
--- a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
@@ -196,7 +196,6 @@
displayName="Agent Home Directory"
dataType="trait"
displayType="detail"
- defaultInterval="86400000"
description="The directory where the agent is installed" />
<metric property="NumberAgentRestarts"
12 years, 7 months