[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 95a2fea597a1a828352e84452c21690ff91f39cf
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jun 30 00:31:18 2011 -0400
Do not store path name of basedir directory entry
I was previously storing the name of the base dir in the directory when
it included files which was resulting in the name getting appending to
the path twice when reading the change set file.
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 524843b..5d1ae5d 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
@@ -73,7 +73,7 @@ public class DriftDetector implements Runnable {
private String relativePath(File basedir, File file) {
if (basedir.equals(file)) {
- return basedir.getName();
+ return ".";
}
return file.getAbsolutePath().substring(basedir.getAbsolutePath().length() + 1);
}
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java | 1
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java | 164 +++++++---
2 files changed, 125 insertions(+), 40 deletions(-)
New commits:
commit b61193a4fb2594e4fcdc1a7b4ed59077c7914f75
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jun 29 22:39:53 2011 -0400
Fixing infinite loop bug in DriftFilesSender
Adding another test for the bug and refactoring the tests adding helper
methods.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java
index e7cf34c..589cc0b 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java
@@ -82,6 +82,7 @@ public class DriftFilesSender implements Runnable {
return new File(dir, fileEntry.getFile());
}
}
+ dirEntry = reader.readDirectoryEntry();
}
return null;
}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java
index 6a5eb71..53233e5 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftFilesSenderTest.java
@@ -1,16 +1,9 @@
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.FileUtils.touch;
-import static org.apache.commons.io.IOUtils.writeLines;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
+import java.util.ArrayList;
import java.util.List;
import org.testng.annotations.BeforeClass;
@@ -20,6 +13,14 @@ import org.testng.annotations.Test;
import org.rhq.common.drift.Headers;
import org.rhq.core.domain.drift.DriftFile;
+import static java.util.Arrays.asList;
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+import static org.apache.commons.io.FileUtils.touch;
+import static org.apache.commons.io.IOUtils.writeLines;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
public class DriftFilesSenderTest {
File changeSetsDir;
@@ -38,11 +39,8 @@ public class DriftFilesSenderTest {
deleteDirectory(basedir);
basedir.mkdir();
- changeSetsDir = new File(basedir, "changesets");
- changeSetsDir.mkdir();
-
- resourcesDir = new File(basedir, "resources");
- resourcesDir.mkdir();
+ changeSetsDir = mkdir(basedir, "changesets");
+ resourcesDir = mkdir(basedir, "resources");
}
@BeforeMethod
@@ -51,48 +49,134 @@ public class DriftFilesSenderTest {
}
@Test
- public void sendFiles() throws Exception {
- String driftConfigName = "test";
+ public void sendFilesInOneDirectory() throws Exception {
+ String driftConfigName = "single-directory-test";
- File server1Dir = new File(resourcesDir, "server-1");
- server1Dir.mkdir();
-
- File confDir = new File(server1Dir, "conf");
- confDir.mkdir();
-
- touch(new File(confDir, "server.conf"));
+ File server1Dir = mkdir(resourcesDir, "server-1");
+ File confDir = mkdir(server1Dir, "conf");
+ touch(new File(confDir, "server-1.conf"));
+ touch(new File(confDir, "server-2.conf"));
int resourceId = 1;
+ File changeSetDir = createChangeSetDir(resourceId, driftConfigName);
+
+ // Each item in changeSet is listed by the line it will appear in the actual file
+ // in an attemp to make it more self-documenting.
+ writeChangeSet(changeSetDir, asList(
+ driftConfigName,
+ server1Dir.getAbsolutePath(),
+ COVERAGE.code(),
+ "conf 2",
+ "2e345df 0 server-1.conf A",
+ "a5d8c3e 0 server-2.conf A",
+ ""
+ ));
+
+ DriftFilesSender sender = new DriftFilesSender();
+ sender.setDriftClient(new DriftClientTestStub());
+ sender.setChangeSetManager(changeSetMgr);
+ sender.setResourceId(resourceId);
+ sender.setDriftFiles(driftFiles("2e345df", "a5d8c3e"));
+ sender.setHeaders(new Headers(driftConfigName, server1Dir.getAbsolutePath(), COVERAGE));
+ sender.run();
- File changeSetDir = new File(new File(changeSetsDir, Integer.toString(resourceId)), driftConfigName);
- changeSetDir.mkdirs();
+ File contentDir = mkdir(changeSetDir, "content");
- List<String> changeSet = asList(driftConfigName, server1Dir.getAbsolutePath(), COVERAGE.code(), "conf 1",
- "2e345df 0 server.conf A", "");
- BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(changeSetDir,
- "changeset.txt")));
- writeLines(changeSet, "\n", stream);
- stream.close();
+ assertEquals(contentDir.list().length, 2, "Expected to find two files in " + contentDir.getAbsolutePath());
+ assertFileCopiedToContentDir(contentDir, "2e345df");
+ assertFileCopiedToContentDir(contentDir, "a5d8c3e");
+ }
- Headers headers = new Headers(driftConfigName, server1Dir.getAbsolutePath(), COVERAGE);
- List<DriftFile> driftFiles = asList(new DriftFile("2e345df"));
+ @Test
+ public void sendFilesInMultipleDirectories() throws Exception {
+ String driftConfigName = "multiple-directories-test";
+
+ File server2Dir = mkdir(resourcesDir, "server-2");
+ File confDir = mkdir(server2Dir, "conf");
+ File libDir = mkdir(server2Dir, "lib");
+ touch(new File(confDir, "server-1.conf"));
+ touch(new File(confDir, "server-2.conf"));
+ touch(new File(libDir, "server-1.jar"));
+ touch(new File(libDir, "server-2.jar"));
+
+ int resourceId = 2;
+ File changeSetDir = createChangeSetDir(resourceId, driftConfigName);
+
+ // Each item in changeSet is listed by the line it will appear in the actual file
+ // in an attemp to make it more self-documenting.
+ writeChangeSet(changeSetDir, asList(
+ driftConfigName,
+ server2Dir.getAbsolutePath(),
+ COVERAGE.code(),
+ "conf 2",
+ "2e345df 0 server-1.conf A",
+ "a5d8c3e 0 server-2.conf A",
+ "",
+ "lib 2",
+ "91d4abb 0 server-1.jar A",
+ "92c4abb 0 server-2.jar A",
+ ""
+ ));
DriftFilesSender sender = new DriftFilesSender();
sender.setDriftClient(new DriftClientTestStub());
sender.setChangeSetManager(changeSetMgr);
sender.setResourceId(resourceId);
- sender.setDriftFiles(driftFiles);
- sender.setHeaders(headers);
+ // Note that the order of the drift files is random. When the server sends a request
+ // for files we cannot assume that the files will be in any particular order.
+ sender.setDriftFiles(driftFiles("2e345df", "91d4abb", "a5d8c3e", "92c4abb"));
+ sender.setHeaders(new Headers(driftConfigName, server2Dir.getAbsolutePath(), COVERAGE));
sender.run();
- File contentDir = new File(changeSetDir, "content");
- contentDir.mkdir();
+ File contentDir = mkdir(changeSetDir, "content");
+
+ assertEquals(contentDir.list().length, 4, "Expected to find four files in " + contentDir.getAbsolutePath());
+ assertFileCopiedToContentDir(contentDir, "2e345df");
+ assertFileCopiedToContentDir(contentDir, "a5d8c3e");
+ assertFileCopiedToContentDir(contentDir, "91d4abb");
+ assertFileCopiedToContentDir(contentDir, "92c4abb");
+ }
+
+ /**
+ * This method only verifies that a file having a particular hash or SHA-256 has been
+ * copied to the specified content directory.
+ *
+ * @param contentDir The directory to which the file should have been copied
+ *
+ * @param fileHash The file hash which is expected to be the name of the file in the
+ * content directory.
+ */
+ void assertFileCopiedToContentDir(File contentDir, String fileHash) {
+ File file = new File(contentDir, fileHash);
+ assertTrue(file.exists(), "Expected to find file named " + file.getName() + " in content directory " +
+ contentDir.getPath() + ". The SHA-256 hash should be used as the file name.");
+ }
+
+ File mkdir(File parent, String name) {
+ File dir = new File(parent, name);
+ dir.mkdirs();
+ return dir;
+ }
+
+ File createChangeSetDir(int resourceId, String driftConfigName) {
+ File dir = new File(new File(changeSetsDir, Integer.toString(resourceId)), driftConfigName);
+ dir.mkdirs();
+ return dir;
+ }
- File content = new File(contentDir, "2e345df");
+ void writeChangeSet(File changeSetDir, List<String> changeSet) throws Exception {
+ BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(changeSetDir,
+ "changeset.txt")));
+ writeLines(changeSet, "\n", stream);
+ stream.close();
+ }
- assertEquals(contentDir.list().length, 1, "Expected to find one file in " + contentDir.getAbsolutePath());
- assertTrue(content.exists(), "Expected to find file named " + content.getName() + " in content directory. "
- + "SHA-256 hashes should be used as file names");
+ List<DriftFile> driftFiles(String... hashes) {
+ List<DriftFile> files = new ArrayList<DriftFile>();
+ for (String hash : hashes) {
+ files.add(new DriftFile(hash));
+ }
+ return files;
}
}
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by mazz
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 165 +++++++---
1 file changed, 131 insertions(+), 34 deletions(-)
New commits:
commit 28e8cc561764726c7e97e7f7ceacde54a3681e51
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 29 17:40:18 2011 -0400
db upgrade for the new static config def for drift. postgres worked, and I think I got oracle upgrade steps, but I did not test it on oracle
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index d34a247..57c100c 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3445,60 +3445,157 @@
</schemaSpec>
<schemaSpec version="2.111">
+ <!-- BUILD THE STATIC CONFIG DEFINITION FOR DRIFT CONFIGURATION -->
+
+ <!-- db agnostic insert the config def row -->
<schema-directSQL>
<statement desc="Creating global drift configuration definition">
- INSERT INTO rhq_config_def (id, name, description)
- VALUES (1, 'GLOBAL_DRIFT_CONFIG_DEF', 'The drift configuration definition')
+ INSERT INTO rhq_config_def (id, name, description, config_format)
+ VALUES (1, 'GLOBAL_DRIFT_CONFIG_DEF', 'The drift configuration definition', 'STRUCTURED')
</statement>
- <statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type, order_index, dtype, config_def_id)
- VALUES (1, 'name', 'Drift Configuration Name', 'The drift configuration name', true, 'STRING', 0, 'property', 1)
+ </schema-directSQL>
+
+ <!-- db specific inserts to add the property defs -->
+ <!-- POSTGRES -->
+ <schema-directSQL>
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (1, 'name', 'Drift Configuration Name', 1, 'The drift configuration name', 'true', 'false', 'true', 0, 'property', 'STRING', 'false')
</statement>
- <statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type, default_value, order_index, dtype, config_def_id)
- VALUES (2, 'enabled', 'Enabled', 'Enables or disables drift detection for this configuration', true, 'BOOLEAN', 'false', 1, 'property', 1)
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value, default_value)
+ VALUES (2, 'enabled', 'Enabled', 1, 'Enables or disables the drift configuration' , 'true', 'false', 'true', 1, 'property', 'BOOLEAN', 'false', 'false')
</statement>
- <statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type, order_index, dtype, config_def_id)
- VALUES (3, 'basedir', 'Base Directory', 'The base directory from which files will be monitored for drift.', true, 'STRING', 2, 'property', 1)
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, description, required, readonly, summary, order_index, dtype)
+ VALUES (3, 'basedir', 'Base Directory', 1, 'The root directory from which snapshots will be generated during drift monitoring.', 'true', 'false', 'true', 2, 'map')
</statement>
- <statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type, order_index, dtype, default_value, config_def_id)
- VALUES (4, 'interval', 'Interval', 'The interval, in seconds, between drift detection scans for this configuration. Default is thirty minutes.', false, 'LONG', 3, 'property', '1800', 1)
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (4, 'valueContext', 'Value Context', 3, 'Identifies where the named value can be found.', 'true', 'false', 'true', 0, 'property', 'STRING', 'false')
</statement>
- <statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, description, order_index, config_def_id)
- VALUES (5, 'includes', 'Includes', 'list', 'A set of patterns that specify files and/or directories to include.', 4, 1)
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (5, 'valueName', 'Value Name', 3, 'The name of the value as found in the context', 'true', 'false', 'true', 1, 'property', 'STRING', 'false')
</statement>
- <statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, parent_list_definition_id)
- VALUES (6, 'include', 'Include', 'map', 4)
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value, default_value)
+ VALUES (6, 'interval', 'Interval', 1, 'The frequency in seconds in which drift monitoring should run. Defaults to 1800 seconds (i.e. 30 minutes)', 'false', 'false', 'true', 3, 'property', 'LONG', 'false', '1800')
</statement>
- <statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type, order_index, dtype, parent_map_definition_id)
- VALUES (7, 'path', 'Path', 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.', 'STRING', 0, 'property', 5)
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, readonly, summary, order_index, dtype)
+ VALUES (8, 'include', 'Include', 'A pattern that specifies a file or directory to include.', 'true', 'false', 'true', 0, 'map')
</statement>
- <statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type, order_index, dtype, parent_map_definition_id)
- VALUES (8, 'pattern', 'Pattern', 'Pathname pattern that must match for the items in the directory path to be included.', 'STRING', 1, 'property', 5)
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, parent_list_definition_id, description, required, readonly, summary, order_index, dtype)
+ VALUES (7, 'includes', 'Includes', 1, 8, 'A set of patterns that specify files and/or directories to include.', 'false', 'false', 'true', 4, 'list')
+ </statement>
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (9, 'path', 'Path', 8, 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.', 'true', 'false', 'true', 0, 'property', 'STRING', 'false')
+ </statement>
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (10, 'pattern', 'Pattern', 8, 'Pathname pattern that must match for the items in the directory path to be included.', 'false', 'false', 'true', 1, 'property', 'STRING', 'false')
+ </statement>
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, readonly, summary, order_index, dtype)
+ VALUES (12, 'exclude', 'Exclude', 'A pattern that specifies a file or directory to exclude.', 'true', 'false', 'true', 0, 'map')
</statement>
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, parent_list_definition_id, description, required, readonly, summary, order_index, dtype)
+ VALUES (11, 'excludes', 'Excludes', 1, 12, 'A set of patterns that specify files and/or directories to exclude.', 'false', 'false', 'true', 5, 'list')
+ </statement>
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (13, 'path', 'Path', 12, 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.', 'true', 'false', 'true', 0, 'property', 'STRING', 'false')
+ </statement>
+ <statement targetDBVendor="postgresql">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (14, 'pattern', 'Pattern', 12, 'Pathname pattern that must match for the items in the directory path to be excluded.', 'false', 'false', 'true', 1, 'property', 'STRING', 'false')
+ </statement>
+ </schema-directSQL>
+
+ <!-- ORACLE -->
+ <schema-directSQL>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (1, 'name', 'Drift Configuration Name', 1, 'The drift configuration name', 1, 0, 1, 0, 'property', 'STRING', 0)
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value, default_value)
+ VALUES (2, 'enabled', 'Enabled', 1, 'Enables or disables the drift configuration' , 1, 0, 1, 1, 'property', 'BOOLEAN', 0, 'false')
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, description, required, readonly, summary, order_index, dtype)
+ VALUES (3, 'basedir', 'Base Directory', 1, 'The root directory from which snapshots will be generated during drift monitoring.', 1, 0, 1, 2, 'map')
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (4, 'valueContext', 'Value Context', 3, 'Identifies where the named value can be found.', 1, 0, 1, 0, 'property', 'STRING', 0)
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (5, 'valueName', 'Value Name', 3, 'The name of the value as found in the context', 1, 0, 1, 1, 'property', 'STRING', 0)
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value, default_value)
+ VALUES (6, 'interval', 'Interval', 1, 'The frequency in seconds in which drift monitoring should run. Defaults to 1800 seconds (i.e. 30 minutes)', 0, 0, 1, 3, 'property', 'LONG', 0, '1800')
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, readonly, summary, order_index, dtype)
+ VALUES (8, 'include', 'Include', 'A pattern that specifies a file or directory to include.', 1, 0, 1, 0, 'map')
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, parent_list_definition_id, description, required, readonly, summary, order_index, dtype)
+ VALUES (7, 'includes', 'Includes', 1, 8, 'A set of patterns that specify files and/or directories to include.', 0, 0, 1, 4, 'list')
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (9, 'path', 'Path', 8, 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.', 1, 0, 1, 0, 'property', 'STRING', 0)
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (10, 'pattern', 'Pattern', 8, 'Pathname pattern that must match for the items in the directory path to be included.', 0, 0, 1, 1, 'property', 'STRING', 0)
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, readonly, summary, order_index, dtype)
+ VALUES (12, 'exclude', 'Exclude', 'A pattern that specifies a file or directory to exclude.', 1, 0, 1, 0, 'map')
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, config_def_id, parent_list_definition_id, description, required, readonly, summary, order_index, dtype)
+ VALUES (11, 'excludes', 'Excludes', 1, 12, 'A set of patterns that specify files and/or directories to exclude.', 0, 0, 1, 5, 'list')
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (13, 'path', 'Path', 12, 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.', 1, 0, 1, 0, 'property', 'STRING', 0)
+ </statement>
+ <statement targetDBVendor="oracle">
+ INSERT INTO rhq_config_prop_def (id, name, display_name, parent_map_definition_id, description, required, readonly, summary, order_index, dtype, simple_type, allow_custom_enum_value)
+ VALUES (14, 'pattern', 'Pattern', 12, 'Pathname pattern that must match for the items in the directory path to be excluded.', 0, 0, 1, 1, 'property', 'STRING', 0)
+ </statement>
+ </schema-directSQL>
+
+ <!-- db agnostic inserts to add the enum values -->
+ <schema-directSQL>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, description, order_index, config_def_id)
- VALUES (9, 'excludes', 'Excludes', 'list', 'A set of patterns that specify files and/or directories to exclude.', 5, 1)
+ INSERT INTO rhq_conf_prop_def_enum (id, name, string_value, order_index, property_def_id)
+ VALUES (1, 'pluginConfiguration', 'pluginConfiguration', 0, 4)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, parent_list_definition_id)
- VALUES (10, 'exclude', 'Exclude', 'map', 8)
+ INSERT INTO rhq_conf_prop_def_enum (id, name, string_value, order_index, property_def_id)
+ VALUES (2, 'resourceConfiguration', 'resourceConfiguration', 1, 4)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type, order_index, dtype, parent_map_definition_id)
- VALUES (11, 'path', 'Path', 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.', 'STRING', 0, 'property', 9)
+ INSERT INTO rhq_conf_prop_def_enum (id, name, string_value, order_index, property_def_id)
+ VALUES (3, 'measurementTrait', 'measurementTrait', 2, 4)
</statement>
<statement>
- INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type, order_index, dtype, parent_map_definition_id)
- VALUES (12, 'pattern', 'Pattern', 'Pathname pattern that must match for the items in the directory path to be excluded.', 'STRING', 1, 'property', 9)
+ INSERT INTO rhq_conf_prop_def_enum (id, name, string_value, order_index, property_def_id)
+ VALUES (4, 'fileSystem', 'fileSystem', 3, 4)
</statement>
</schema-directSQL>
+
</schemaSpec>
<schemaSpec version="2.112">
12 years, 10 months
[rhq] Branch 'drift' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
New commits:
commit 1d737967890284806c129f67d00fa36fb6214097
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jun 29 17:15:57 2011 -0400
Adding REQUIRES_NEW to SLSB methods called from MDBs to avoid 2PC-related errors
I do not fully understand these errors but reading
http://management-platform.blogspot.com/2008/11/transaction-recovery-in-j...
should provide some background.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 089d5df..bb28468 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -75,6 +75,8 @@ import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
@Stateless
public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
private final Log log = LogFactory.getLog(this.getClass());
@@ -101,6 +103,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
private EntityManager entityManager;
@Override
+ @TransactionAttribute(REQUIRES_NEW)
public void addChangeSet(int resourceId, long zipSize, InputStream zipStream) throws Exception {
Connection connection = factory.createConnection();
@@ -112,6 +115,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
+ @TransactionAttribute(REQUIRES_NEW)
public void addFiles(int resourceId, long zipSize, InputStream zipStream) throws Exception {
Connection connection = factory.createConnection();
@@ -123,6 +127,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
+ @TransactionAttribute(REQUIRES_NEW)
public void storeChangeSet(final int resourceId, File changeSetZip) throws Exception {
Resource resource = entityManager.find(Resource.class, resourceId);
if (null == resource) {
@@ -239,7 +244,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
- @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @TransactionAttribute(REQUIRES_NEW)
public void persistDriftFileData(DriftFile driftFile, InputStream data) throws Exception {
DriftFileContent df = entityManager.find(DriftFileContent.class, driftFile.getHashId());
12 years, 10 months
[rhq] Branch 'as7plugin' - 2 commits - modules/plugins
by Heiko W. Rupp
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 18 +--
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java | 8 -
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 35 +++---
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java | 11 ++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java | 3
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 55 ++++++++--
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java | 16 +-
7 files changed, 103 insertions(+), 43 deletions(-)
New commits:
commit d6aa39205a8b3cd0da96237d9b9dfbb54e1d5687
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 29 22:36:14 2011 +0200
Fix detection of mod_cluster subsystem.
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 41c5c58..870ad38 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
@@ -177,28 +177,6 @@
<c:simple-property name="path" default="profile" readOnly="true"/>
</plugin-configuration>
- <service name="ModCluster"
- class="BaseComponent"
- discovery="SubsystemDiscovery"
- description="Mod_cluster support">
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="subsystem=modcluster"/>
- </plugin-configuration>
-
- <operation name="list-proxies" description="Read the list of httpd contected to the nodes.">
- </operation>
-
- <operation name="validate-address" description="Read the list of httpd contected to the nodes.">
- </operation>
-
- <resource-configuration>
- <c:simple-property name="advertise-socket" displayName="Advertise Socket" type="string">
- <c:option-source target="configuration" expression="socket-binding=name:type=SocketBindingGroup"/>
- </c:simple-property>
- </resource-configuration>
- </service>
-
</server>
<server name="ServerGroup"
@@ -1376,6 +1354,36 @@ working area for individual server instances</li></ul>"/>
</service>
</server>
+ <server name="ModCluster"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ description="Mod_cluster support"
+ singleton="true"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/> <!-- FAKE as "runs inside Profile" only does not work -->
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=modcluster"/>
+ </plugin-configuration>
+
+ <operation name="list-proxies" description="Read the list of httpd connected to the nodes.">
+ </operation>
+
+ <operation name="validate-address" >
+ </operation>
+
+ <resource-configuration>
+ <c:simple-property name="advertise-socket" displayName="Advertise Socket" type="string">
+ <c:option-source target="configuration" expression="socket-binding=name:type=SocketBindingGroup"/>
+ </c:simple-property>
+ </resource-configuration>
+ </server>
+
+
<service name="NetworkInterface"
discovery="SubsystemDiscovery"
class="BaseComponent"
commit 403973e67dae1cfd79a6591c815f7715a38c4537
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 29 22:01:09 2011 +0200
Change upload code because of a bug in the server (AS7-1145), add a property to enable json logging.
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 f2bb47f..d89f4c4 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
@@ -43,21 +43,27 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
*/
public class ASConnection {
+ public static final String MANAGEMENT = "/management";
+// public static final String MANAGEMENT = "/domain-api"; // Old one - leave it here for the moment for tests.
private final Log log = LogFactory.getLog(ASConnection.class);
URL url;
String urlString;
private ObjectMapper mapper;
- boolean verbose = true; // This is a variable on purpose, so devs can switch it on in the debugger
+ public static boolean verbose = false; // This is a variable on purpose, so devs can switch it on in the debugger or in the agent
public ASConnection(String host, int port) {
try {
- url = new URL("http",host,port,"/management");
+ url = new URL("http",host,port, MANAGEMENT);
urlString = url.toString();
+
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e.getMessage());
}
+ // read system property "as7plugin.verbose"
+ verbose = Boolean.getBoolean("as7plugin.verbose");
+
mapper = new ObjectMapper();
}
@@ -107,8 +113,7 @@ public class ASConnection {
String result = mapper.writeValueAsString(operation);
if (verbose) {
- System.out.println("Json to send: " + result);
- System.out.flush();
+ log.info("Json to send: " + result);
}
mapper.writeValue(out, operation);
@@ -141,8 +146,7 @@ public class ASConnection {
ObjectMapper om2 = new ObjectMapper();
om2.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
String tmp = om2.writeValueAsString(operationResult);
- System.out.println(tmp);
- System.out.flush();
+ log.info(tmp);
}
}
else {
@@ -156,8 +160,6 @@ public class ASConnection {
}
else {
log.error("IS was null and code was " + responseCode);
- if (verbose)
- System.err.println("IS was null and code was " + responseCode);
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
index d876c80..3ab7c3c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -51,7 +51,7 @@ public class ASUploadConnection {
private static final String POST_REQUEST_METHOD = "POST";
- private static final String UPLOAD_URL_PATH = "/management/add-content";
+ private static final String UPLOAD_URL_PATH = ASConnection.MANAGEMENT + "/add-content";
private final Log log = LogFactory.getLog(ASUploadConnection.class);
@@ -96,7 +96,7 @@ public class ASUploadConnection {
os.flush();
int code = connection.getResponseCode();
- System.err.println("Response code " + code);
+ log.info("Response code for file upload: " + code);
if (code==500)
is = connection.getErrorStream();
else
@@ -116,10 +116,10 @@ public class ASUploadConnection {
if (s!=null)
tree = mapper.readTree(s);
else
- System.out.println("- no result received from InputStream -");
+ log.warn("- no result received from InputStream -");
}
else
- System.out.println("- no InputStream available -");
+ log.warn("- no InputStream available -");
} catch (IOException e) {
e.printStackTrace(); // TODO: Customise this generated block
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index a51a96a..2ac49d0 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -80,6 +80,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
String key;
String host;
int port;
+ private boolean verbose = ASConnection.verbose;
/**
* Return availability of this resource
@@ -305,7 +306,9 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName, details.getKey(), out);
JsonNode uploadResult = uploadConnection.finishUpload();
- System.out.println(uploadResult);
+ if (verbose)
+ log.info(uploadResult);
+
if (ASConnection.isErrorReply(uploadResult)) {
report.setStatus(CreateResourceStatus.FAILURE);
report.setErrorMessage(ASConnection.getFailureDescription(uploadResult));
@@ -319,7 +322,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
fileName=fileName.substring("C:\\fakepath\\".length());
}
- log.info("Deploying [" + fileName + "] ...");
+ boolean toServerGroup = context.getResourceKey().contains("server-group=");
+ log.info("Deploying [" + fileName + "] to domain only= " + !toServerGroup + " ...");
String tmpName = fileName; // TODO figure out the tmp-name biz with the AS guys
@@ -338,15 +342,22 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
step1.addAdditionalProperty("name", tmpName);
step1.addAdditionalProperty("runtime-name", fileName);
- CompositeOperation cop = new CompositeOperation();
- cop.addStep(step1);
String resourceKey;
-
+ JsonNode result ;
/*
* We need to check here if this is an upload to /deployment only
* or if this should be deployed to a server group too
*/
- if (context.getResourceKey().contains("server-group=")) {
+
+ if (!toServerGroup) {
+
+ result = connection.executeRaw(step1);
+ resourceKey = addressToPath(step1.getAddress());
+
+ }
+ else {
+ CompositeOperation cop = new CompositeOperation();
+ cop.addStep(step1);
List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>();
serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
@@ -359,19 +370,13 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
cop.addStep(step3);
resourceKey = addressToPath(serverGroupAddress);
- }
- else {
-/*
- List<PROPERTY_VALUE> address = step1.getAddress();
- Operation step3 = new Operation("deploy",address);
- cop.addStep(step3);
-*/
+ if (verbose)
+ log.info("Deploy operation: " + cop);
- resourceKey = addressToPath(step1.getAddress());
+ result = connection.executeRaw(cop);
}
- JsonNode result = connection.executeRaw(cop);
if (ASConnection.isErrorReply(result)) {
String failureDescription = ASConnection.getFailureDescription(result);
report.setErrorMessage(failureDescription);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
index 3f57a06..3946dbe 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -98,6 +98,9 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
}
config.put(new PropertySimple("socket-binding-port-offset",serverInfo.portOffset));
+ String path = "host=" + hostName + ",server-config=" + serverInfo.name;
+ config.put(new PropertySimple("path",path));
+
// TODO this fails for the downed servers.
@@ -241,6 +244,14 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
boolean autoStart;
int portOffset;
String bindingGroup;
+
+ @Override
+ public String toString() {
+ return "ServerInfo{" +
+ "name='" + name + '\'' +
+ ", group='" + group + '\'' +
+ '}';
+ }
}
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index a3ab676..60fc615 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -101,7 +101,8 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
if (cpath.contains("="))
path += "," + cpath;
- System.out.println("total path: [" + path + "]");
+ if (Boolean.getBoolean("as7plugin.verbose"))
+ log.info("total path: [" + path + "]");
JsonNode json ;
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 76d1bcf..41c5c58 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
@@ -169,14 +169,38 @@
<server name="Profile"
- description="One profile in a domain"
+ description="One profile in a domain. Profiles are assigned to server groups."
discovery="SubsystemDiscovery"
class="BaseComponent">
<plugin-configuration>
<c:simple-property name="path" default="profile" readOnly="true"/>
</plugin-configuration>
+
+ <service name="ModCluster"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ description="Mod_cluster support">
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=modcluster"/>
+ </plugin-configuration>
+
+ <operation name="list-proxies" description="Read the list of httpd contected to the nodes.">
+ </operation>
+
+ <operation name="validate-address" description="Read the list of httpd contected to the nodes.">
+ </operation>
+
+ <resource-configuration>
+ <c:simple-property name="advertise-socket" displayName="Advertise Socket" type="string">
+ <c:option-source target="configuration" expression="socket-binding=name:type=SocketBindingGroup"/>
+ </c:simple-property>
+ </resource-configuration>
+ </service>
+
</server>
+
<server name="ServerGroup"
description="Server groups on this domain"
discovery="SubsystemDiscovery"
@@ -190,8 +214,12 @@
<resource-configuration>
- <c:simple-property name="profile" />
- <c:simple-property name="socket-binding-group"/>
+ <c:simple-property name="profile" description="The profile name" required="true"/>
+ <c:simple-property name="socket-binding-group" readOnly="false" required="true">
+ <c:option-source target="resource" expression="type=SocketBindingGroup"/>
+ </c:simple-property>
+ <c:simple-property name="socket-binding-port-offset" required="false" defaultValue="0" type="integer"
+ description="The default offset to be added to the port values given by the socket binding group."/>
<c:simple-property name="jvm" required="false"/>
</resource-configuration>
@@ -236,7 +264,9 @@
<operation name="domain-deployment:promote" displayName="Deploy to Server-Group" description="Deploy this deployment to a server group">
<parameters>
- <c:simple-property name="server-group" required="true" description="Server group to deploy to" type="string"/>
+ <c:simple-property name="server-group" required="true" description="Server group to deploy to" type="string">
+ <c:option-source target="resource" expression="type=ServerGroup" />
+ </c:simple-property>
<c:simple-property name="enabled" required="true" default="true" description="Should the deployment be enabled on the server group?" type="boolean"/>
</parameters>
<results>
@@ -327,6 +357,7 @@
<c:simple-property name="group" readOnly="true" displayName="Server Group" description="Server Group this instance belongs to."/>
<c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindngs to use"/>
<c:simple-property name="socket-binding-port-offset" readOnly="true" displayName="Port Offset" type="integer" default="0" description="Offset to the base ports"/>
+ <c:simple-property name="path" readOnly="true" />
&logSources;
</plugin-configuration>
@@ -351,7 +382,8 @@
</results>
</operation>
-
+ <metric property="status" dataType="trait" displayName="Server state" description="Detailed server state"
+ displayType="summary"/>
</server>
@@ -1387,8 +1419,8 @@ working area for individual server instances</li></ul>"/>
<c:simple-property name="interface" description="Name of the interface to which the socket should be bound, or, for multicast sockets, the interface on which it should listen. This should be one of the declared interfaces." required="false"/>
<c:simple-property name="port" description="Number of the port to which the socket should be bound." type="integer"/>
<c:simple-property name="fixed-port" description="Whether the port value should remain fixed even if numeric offsets are applied to the other sockets in the socket group." type="boolean"/>
- <c:simple-property name="multicast-address" description="Multicast address on which the socket should receive multicast traffic. If unspecified, the socket will not be configured to receive multicast." />
- <c:simple-property name="multicast-port" description="Port on which the socket should receive multicast traffic. Must be configured if 'multicast-address' is configured." type="integer"/>
+ <c:simple-property name="multicast-address" description="Multicast address on which the socket should receive multicast traffic. If unspecified, the socket will not be configured to receive multicast." required="false"/>
+ <c:simple-property name="multicast-port" description="Port on which the socket should receive multicast traffic. Must be configured if 'multicast-address' is configured." type="integer" required="false"/>
</c:map-property>
</c:list-property>
</resource-configuration>
@@ -1420,5 +1452,4 @@ working area for individual server instances</li></ul>"/>
</service>
-
</plugin>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index b0d68ee..e18193d 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -41,7 +41,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* the UPLOAD_FILE must point to a valid archive in the resources directory.
* @author Heiko W. Rupp
*/
-@Test(enabled = true) // TODO add an "integration test profile" that is able to fire the server before running the test
+@Test(enabled = UploadAndDeployTest.isEnabled) // TODO add an "integration test profile" that is able to fire the server before running the test
public class UploadAndDeployTest {
static final String TEST_WAR = "test.war";
@@ -49,8 +49,10 @@ public class UploadAndDeployTest {
private static final String DC_HOST = "localhost";
private static final int DC_HTTP_PORT = 9990;
+ protected static final boolean isEnabled = false;
- @Test(timeOut = 60*1000L, enabled=true)
+
+ @Test(timeOut = 60*1000L, enabled=isEnabled)
public void testUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -62,7 +64,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L, enabled=true)
+ @Test(timeOut = 60*1000L, enabled=isEnabled)
public void testDoubleUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -75,7 +77,7 @@ public class UploadAndDeployTest {
assert bytes_value.equals("7jgpMVmynfxpqp8UDleKLmtgbrA=");
}
- @Test(timeOut = 60*1000L,enabled=true)
+ @Test(timeOut = 60*1000L,enabled=isEnabled)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -155,7 +157,7 @@ public class UploadAndDeployTest {
}
// Test for AS7-853
- @Test(timeOut = 60*1000L,enabled = true)
+ @Test(timeOut = 60*1000L,enabled = isEnabled)
public void testUploadIndividualSteps2() throws Exception {
String bytes_value = prepare();
@@ -229,7 +231,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L,enabled = true)
+ @Test(timeOut = 60*1000L,enabled = isEnabled)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
@@ -295,7 +297,7 @@ public class UploadAndDeployTest {
* Test uploading to domain only, but not to a server group
* @throws Exception
*/
- @Test(timeOut = 60*1000L,enabled = true)
+ @Test(timeOut = 60*1000L,enabled = isEnabled)
public void testUploadComposite2() throws Exception {
String bytes_value = prepare();
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java | 8 --------
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 10 ++++++----
2 files changed, 6 insertions(+), 12 deletions(-)
New commits:
commit 180a7eb872e0c09b61da70eef8a756676d262334
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jun 29 16:24:05 2011 -0400
Fixing failing test
Test method broke as a result of the changes to the basedir property in
DriftConfiguration. It is no longer stored as a simple property and the
test was creating a config using a simple property for the basedir.
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
index 997e65f..2cb74a2 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
@@ -67,14 +67,6 @@ public class ChangeSetManagerImplTest {
assertReaderOpenedOnChangeSet(reader, asList("server/conf", "1"));
}
- DriftConfiguration driftConfiguration(String name, String basedir) {
- Configuration config = new Configuration();
- config.put(new PropertySimple("name", name));
- config.put(new PropertySimple("basedir", basedir));
-
- return new DriftConfiguration(config);
- }
-
/**
* Verifies that a {@link ChangeSetReader} has been opened on the expected change set.
* This method first verifies that the reader is not null. It then reads the first
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 dfed1e2..b5f9bd2 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
@@ -3,6 +3,7 @@ package org.rhq.core.pc.drift;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.IOUtils.readLines;
import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
+import static org.rhq.core.domain.drift.DriftConfigurationDefinition.BaseDirValueContext.fileSystem;
import static org.testng.Assert.assertEquals;
import static org.unitils.thirdparty.org.apache.commons.io.FileUtils.touch;
@@ -24,6 +25,7 @@ import org.rhq.common.drift.DirectoryEntry;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.drift.DriftConfiguration;
+import org.rhq.core.domain.drift.DriftConfigurationDefinition;
import org.rhq.test.JMockTest;
public class DriftDetectorTest extends JMockTest {
@@ -93,11 +95,11 @@ public class DriftDetectorTest extends JMockTest {
}
DriftConfiguration driftConfiguration(String name, String basedir) {
- Configuration config = new Configuration();
- config.put(new PropertySimple("name", name));
- config.put(new PropertySimple("basedir", basedir));
+ DriftConfiguration config = new DriftConfiguration(new Configuration());
+ config.setName(name);
+ config.setBasedir(config.new BaseDirectory(fileSystem, basedir));
- return new DriftConfiguration(config);
+ return config;
}
void assertHeaderEquals(List<String> lines, String... expected) {
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java | 2 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 17 +++++-----
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 10 ++---
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java | 11 +++++-
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 5 ++
5 files changed, 29 insertions(+), 16 deletions(-)
New commits:
commit a9daca687758ff427c3afb293bb63ed917ea8ece
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jun 29 16:02:51 2011 -0400
Avoiding NPE when calculating the basedir
The resource is needed in order to calculate the basedir, but the
resource field attached to the DriftConfiguration object is not set.
That will likely go away any way so now the resource id is also passed
into DriftManager.getAbsoluteBaseDirectory.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java
index f2bbb04..aca1a2f 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java
@@ -14,6 +14,6 @@ public interface DriftClient {
void sendChangeSetContentToServer(int resourceId, String driftConfigurationName, File contentDir);
- File getAbsoluteBaseDirectory(DriftConfiguration driftConfiguration);
+ File getAbsoluteBaseDirectory(int resourceId, DriftConfiguration driftConfiguration);
}
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 364bfc2..524843b 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
@@ -50,15 +50,16 @@ public class DriftDetector implements Runnable {
}
DriftConfiguration driftConfig = schedule.getDriftConfiguration();
+ int resourceId = schedule.getResourceId();
try {
// TODO add logic to determine if there is an existing changeset
// if there is no previous changeset then we need to generate the initial
// coverage changeset
ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(schedule.getResourceId(),
- new Headers(driftConfig.getName(), basedir(driftConfig), COVERAGE));
+ new Headers(driftConfig.getName(), basedir(resourceId, driftConfig), COVERAGE));
- DirectoryScanner scanner = new DirectoryScanner(schedule.getDriftConfiguration(), writer);
+ DirectoryScanner scanner = new DirectoryScanner(resourceId, driftConfig, writer);
scanner.scan();
} catch (IOException e) {
// TODO Call ChangeSetManager here to rollback any thing that was written to disk.
@@ -81,30 +82,32 @@ public class DriftDetector implements Runnable {
return digestGenerator.calcDigestString(file);
}
- private String basedir(DriftConfiguration driftConfig) {
- return driftClient.getAbsoluteBaseDirectory(driftConfig).getAbsolutePath();
+ private String basedir(int resourceId, DriftConfiguration driftConfig) {
+ return driftClient.getAbsoluteBaseDirectory(resourceId, driftConfig).getAbsolutePath();
}
// TODO Do not use DirectoryWalker
// Want to do the file scan iteratively to keep memory overhead as low as possible.
private class DirectoryScanner extends DirectoryWalker {
+ int resourceId;
DriftConfiguration driftConfig;
ChangeSetWriter writer;
Stack<DirectoryEntry> stack = new Stack<DirectoryEntry>();
- public DirectoryScanner(DriftConfiguration driftConfig, ChangeSetWriter writer) {
+ public DirectoryScanner(int resourceId, DriftConfiguration driftConfig, ChangeSetWriter writer) {
+ this.resourceId = resourceId;
this.driftConfig = driftConfig;
this.writer = writer;
}
public void scan() throws IOException {
- walk(new File(basedir(driftConfig)), EMPTY_LIST);
+ walk(new File(basedir(resourceId, driftConfig)), EMPTY_LIST);
}
@Override
protected void handleDirectoryStart(File directory, int depth, Collection results) throws IOException {
- stack.push(new DirectoryEntry(relativePath(new File(basedir(driftConfig)), directory)));
+ stack.push(new DirectoryEntry(relativePath(new File(basedir(resourceId, driftConfig)), directory)));
}
@Override
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index 7837392..f252c08 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -181,19 +181,19 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
/**
* Given a drift configuration, this examines the config and its associated resource to determine where exactly
* the base directory is that should be monitoried.
- *
+ *
+ * @param resourceId The id of the resource to which the config belongs
* @param driftConfiguration describes what is to be monitored for drift
*
* @return absolute directory location where the drift configuration base directory is referring
*/
@Override
- public File getAbsoluteBaseDirectory(DriftConfiguration driftConfiguration) {
+ public File getAbsoluteBaseDirectory(int resourceId, DriftConfiguration driftConfiguration) {
// get the resource entity stored in our local inventory
InventoryManager im = getInventoryManager();
- Resource resource = driftConfiguration.getResource();
- ResourceContainer container = im.getResourceContainer(resource);
- resource = container.getResource();
+ ResourceContainer container = im.getResourceContainer(resourceId);
+ Resource resource = container.getResource();
// find out the type of base location that is specified by the drift config
DriftConfiguration.BaseDirectory baseDir = driftConfiguration.getBasedir();
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java
index 36e255a..013aaef 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java
@@ -5,6 +5,9 @@ import java.io.File;
import org.rhq.core.domain.drift.DriftConfiguration;
class DriftClientTestStub implements DriftClient {
+
+ private File basedir;
+
@Override
public void sendChangeSetToServer(int resourceId, DriftConfiguration driftConfiguration) {
}
@@ -14,7 +17,11 @@ class DriftClientTestStub implements DriftClient {
}
@Override
- public File getAbsoluteBaseDirectory(DriftConfiguration driftConfiguration) {
- return null;
+ public File getAbsoluteBaseDirectory(int resourceId, DriftConfiguration driftConfiguration) {
+ return basedir;
+ }
+
+ public void setBaseDir(File basedir) {
+ this.basedir = basedir;
}
}
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 89fa721..dfed1e2 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
@@ -73,8 +73,11 @@ public class DriftDetectorTest extends JMockTest {
scheduleQueue.enqueue(schedule);
+ DriftClientTestStub driftClient = new DriftClientTestStub();
+ driftClient.setBaseDir(server1Dir);
+
DriftDetector detector = new DriftDetector();
- detector.setDriftClient(new DriftClientTestStub());
+ detector.setDriftClient(driftClient);
detector.setChangeSetManager(changeSetMgr);
detector.setScheduleQueue(scheduleQueue);
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java | 51 ---------
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 55 ----------
modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java | 45 ++++++++
3 files changed, 47 insertions(+), 104 deletions(-)
New commits:
commit 8046ab22ea95aefadb5fd0dd507b5aaf77a274c0
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 29 15:52:17 2011 -0400
refactor the getTraitValue since both drift and bundle managers need it
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
index 29afab5..d240606 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@ -25,7 +25,6 @@ package org.rhq.core.pc.bundle;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -54,10 +53,6 @@ import org.rhq.core.domain.bundle.ResourceTypeBundleConfiguration;
import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory.Status;
import org.rhq.core.domain.bundle.ResourceTypeBundleConfiguration.BundleDestinationBaseDirectory;
import org.rhq.core.domain.content.PackageVersion;
-import org.rhq.core.domain.measurement.DataType;
-import org.rhq.core.domain.measurement.MeasurementData;
-import org.rhq.core.domain.measurement.MeasurementDataRequest;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pc.ContainerService;
@@ -495,7 +490,7 @@ public class BundleManager extends AgentService implements BundleAgentService, B
break;
}
case measurementTrait: {
- baseLocation = getTraitValue(container, destBaseDirValueName);
+ baseLocation = getMeasurementManager().getTraitValue(container, destBaseDirValueName);
if (baseLocation == null) {
throw new IllegalArgumentException("Cannot obtain trait [" + destBaseDirName + "] for resource ["
+ resource.getName() + "]");
@@ -521,50 +516,6 @@ public class BundleManager extends AgentService implements BundleAgentService, B
}
/**
- * Given the name of a trait, this will find the value of that trait for the given resource.
- *
- * @param resource the resource whose trait value is to be obtained
- * @param traitName the name of the trait whose value is to be obtained
- *
- * @return the value of the trait, or <code>null</code> if unknown
- */
- private String getTraitValue(ResourceContainer container, String traitName) {
- Integer traitScheduleId = null;
- Set<MeasurementScheduleRequest> schedules = container.getMeasurementSchedule();
- for (MeasurementScheduleRequest schedule : schedules) {
- if (schedule.getName().equals(traitName)) {
- if (schedule.getDataType() != DataType.TRAIT) {
- throw new IllegalArgumentException("Measurement named [" + traitName + "] for resource ["
- + container.getResource().getName() + "] is not a trait, it is of type ["
- + schedule.getDataType() + "]");
- }
- traitScheduleId = Integer.valueOf(schedule.getScheduleId());
- }
- }
- if (traitScheduleId == null) {
- throw new IllegalArgumentException("There is no trait [" + traitName + "] for resource ["
- + container.getResource().getName() + "]");
- }
-
- MeasurementManager mm = getMeasurementManager();
- String traitValue = mm.getCachedTraitValue(traitScheduleId.intValue());
- if (traitValue == null) {
- // the trait hasn't been collected yet, so it isn't cached. We need to get its live value
- List<MeasurementDataRequest> requests = new ArrayList<MeasurementDataRequest>();
- requests.add(new MeasurementDataRequest(traitName, DataType.TRAIT));
- Set<MeasurementData> dataset = mm.getRealTimeMeasurementValue(container.getResource().getId(), requests);
- if (dataset != null && dataset.size() == 1) {
- Object value = dataset.iterator().next().getValue();
- if (value != null) {
- traitValue = value.toString();
- }
- }
- }
-
- return traitValue;
- }
-
- /**
* If this manager can talk to a server-side {@link BundleServerService}, a proxy to that service is returned.
*
* @return the server-side proxy; <code>null</code> if this manager doesn't have a server to talk to
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index 015d307..7837392 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -6,9 +6,7 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -20,10 +18,6 @@ import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.clientapi.server.drift.DriftServerService;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
-import org.rhq.core.domain.measurement.DataType;
-import org.rhq.core.domain.measurement.MeasurementData;
-import org.rhq.core.domain.measurement.MeasurementDataRequest;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.pc.ContainerService;
import org.rhq.core.pc.PluginContainer;
@@ -235,7 +229,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
break;
}
case measurementTrait: {
- baseLocation = getTraitValue(container, baseDirValueName);
+ baseLocation = getMeasurementManager().getTraitValue(container, baseDirValueName);
if (baseLocation == null) {
throw new IllegalArgumentException("Cannot obtain trait [" + baseDirValueName + "] for resource ["
+ resource.getName() + "]");
@@ -259,53 +253,6 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
}
/**
- * Given the name of a trait, this will find the value of that trait for the given resource.
- *
- * @param resource the resource whose trait value is to be obtained
- * @param traitName the name of the trait whose value is to be obtained
- *
- * @return the value of the trait, or <code>null</code> if unknown
- *
- * TODO: this is taken directly from BundleManager. We should refactor this and the one
- * in BundleManager to a single place, perhaps MeasurementManager.
- */
- private String getTraitValue(ResourceContainer container, String traitName) {
- Integer traitScheduleId = null;
- Set<MeasurementScheduleRequest> schedules = container.getMeasurementSchedule();
- for (MeasurementScheduleRequest schedule : schedules) {
- if (schedule.getName().equals(traitName)) {
- if (schedule.getDataType() != DataType.TRAIT) {
- throw new IllegalArgumentException("Measurement named [" + traitName + "] for resource ["
- + container.getResource().getName() + "] is not a trait, it is of type ["
- + schedule.getDataType() + "]");
- }
- traitScheduleId = Integer.valueOf(schedule.getScheduleId());
- }
- }
- if (traitScheduleId == null) {
- throw new IllegalArgumentException("There is no trait [" + traitName + "] for resource ["
- + container.getResource().getName() + "]");
- }
-
- MeasurementManager mm = getMeasurementManager();
- String traitValue = mm.getCachedTraitValue(traitScheduleId.intValue());
- if (traitValue == null) {
- // the trait hasn't been collected yet, so it isn't cached. We need to get its live value
- List<MeasurementDataRequest> requests = new ArrayList<MeasurementDataRequest>();
- requests.add(new MeasurementDataRequest(traitName, DataType.TRAIT));
- Set<MeasurementData> dataset = mm.getRealTimeMeasurementValue(container.getResource().getId(), requests);
- if (dataset != null && dataset.size() == 1) {
- Object value = dataset.iterator().next().getValue();
- if (value != null) {
- traitValue = value.toString();
- }
- }
- }
-
- return traitValue;
- }
-
- /**
* Returns the manager that can provide data on the inventory. This is a separate protected method
* so we can extend our manger class to have a mock manager for testing.
*
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 88bc4e6..44b7d4a 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
@@ -23,6 +23,7 @@
package org.rhq.core.pc.measurement;
import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -44,6 +45,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.clientapi.agent.measurement.MeasurementAgentService;
+import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementDataRequest;
@@ -553,6 +555,49 @@ public class MeasurementManager extends AgentService implements MeasurementAgent
return results;
}
+ /**
+ * Given the name of a trait, this will find the value of that trait for the given resource.
+ *
+ * @param resource the resource whose trait value is to be obtained
+ * @param traitName the name of the trait whose value is to be obtained
+ *
+ * @return the value of the trait, or <code>null</code> if unknown
+ */
+ public String getTraitValue(ResourceContainer container, String traitName) {
+ Integer traitScheduleId = null;
+ Set<MeasurementScheduleRequest> schedules = container.getMeasurementSchedule();
+ for (MeasurementScheduleRequest schedule : schedules) {
+ if (schedule.getName().equals(traitName)) {
+ if (schedule.getDataType() != DataType.TRAIT) {
+ throw new IllegalArgumentException("Measurement named [" + traitName + "] for resource ["
+ + container.getResource().getName() + "] is not a trait, it is of type ["
+ + schedule.getDataType() + "]");
+ }
+ traitScheduleId = Integer.valueOf(schedule.getScheduleId());
+ }
+ }
+ if (traitScheduleId == null) {
+ throw new IllegalArgumentException("There is no trait [" + traitName + "] for resource ["
+ + container.getResource().getName() + "]");
+ }
+
+ String traitValue = getCachedTraitValue(traitScheduleId.intValue());
+ if (traitValue == null) {
+ // the trait hasn't been collected yet, so it isn't cached. We need to get its live value
+ List<MeasurementDataRequest> requests = new ArrayList<MeasurementDataRequest>();
+ requests.add(new MeasurementDataRequest(traitName, DataType.TRAIT));
+ Set<MeasurementData> dataset = getRealTimeMeasurementValue(container.getResource().getId(), requests);
+ if (dataset != null && dataset.size() == 1) {
+ Object value = dataset.iterator().next().getValue();
+ if (value != null) {
+ traitValue = value.toString();
+ }
+ }
+ }
+
+ return traitValue;
+ }
+
// -- MBean monitoring methods
public long getMeasurementsCollected() {
12 years, 10 months
[rhq] Branch 'drift' - modules/core modules/enterprise
by mazz
modules/core/dbutils/src/main/scripts/dbsetup/config-data.xml | 52 +-
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java | 4
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftConfigurationDefinitionTest.java | 176 ++++------
3 files changed, 122 insertions(+), 110 deletions(-)
New commits:
commit 79af18d0466ee2e99f8315deabaa92f237736ab3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 29 15:43:10 2011 -0400
fix some typos in the def constants in order to get the unit test to pass - good thing I have these tests :)
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/config-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/config-data.xml
index 089cd64..904e10b 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/config-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/config-data.xml
@@ -67,15 +67,15 @@
allow_custom_enum_value="false"
default_value="1800" />
- <data id="7" name="includes" display_name="Includes" config_def_id="1"
- description="A set of patterns that specify files and/or directories to include."
- required="false"
- readonly="false"
- summary="true"
- order_index="4"
- dtype="list" />
-
- <data id="8" name="include" display_name="Include" parent_list_definition_id="7"
+ <!-- the JPA mapping is weird here - we insert the child row first, then the parent.
+ This is because the child row does not specify any config_def_id OR parent_list_definition_id.
+ All relationship references are null.
+ The parent list will point its parent_list_definition_id to this map row's ID and is why
+ we need to put the child row in first, so it exists for the parent to refer to.
+ You do this to indicate it is the parent to this child row and this child row denotes
+ the parent list's member definition
+ -->
+ <data id="8" name="include" display_name="Include"
description="A pattern that specifies a file or directory to include."
required="true"
readonly="false"
@@ -83,6 +83,14 @@
order_index="0"
dtype="map" />
+ <data id="7" name="includes" display_name="Includes" config_def_id="1" parent_list_definition_id="8"
+ description="A set of patterns that specify files and/or directories to include."
+ required="false"
+ readonly="false"
+ summary="true"
+ order_index="4"
+ dtype="list" />
+
<data id="9" name="path" display_name="Path" parent_map_definition_id="8"
description="A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration."
required="true"
@@ -103,7 +111,23 @@
simple_type="STRING"
allow_custom_enum_value="false" />
- <data id="11" name="excludes" display_name="Excludes" config_def_id="1"
+ <!-- the JPA mapping is weird here - we insert the child row first, then the parent.
+ This is because the child row does not specify any config_def_id OR parent_list_definition_id.
+ All relationship references are null.
+ The parent list will point its parent_list_definition_id to this map row's ID and is why
+ we need to put the child row in first, so it exists for the parent to refer to.
+ You do this to indicate it is the parent to this child row and this child row denotes
+ the parent list's member definition
+ -->
+ <data id="12" name="exclude" display_name="Exclude"
+ description="A pattern that specifies a file or directory to exclude."
+ required="true"
+ readonly="false"
+ summary="true"
+ order_index="0"
+ dtype="map" />
+
+ <data id="11" name="excludes" display_name="Excludes" config_def_id="1" parent_list_definition_id="12"
description="A set of patterns that specify files and/or directories to exclude."
required="false"
readonly="false"
@@ -111,14 +135,6 @@
order_index="5"
dtype="list" />
- <data id="12" name="exclude" display_name="Exclude" parent_list_definition_id="11"
- description="A pattern that specifies a files or directory to exclude."
- required="true"
- readonly="false"
- summary="true"
- order_index="0"
- dtype="map" />
-
<data id="13" name="path" display_name="Path" parent_map_definition_id="12"
description="A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration."
required="true"
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java
index 3090601..bdf677d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftConfigurationDefinition.java
@@ -241,7 +241,7 @@ public class DriftConfigurationDefinition implements Serializable {
private static PropertyDefinitionMap createInclude() {
String name = PROP_INCLUDES_INCLUDE;
- String description = "A set of patterns that specify files and/or directories to include.";
+ String description = "A pattern that specifies a file or directory to include.";
boolean required = true;
PropertyDefinitionSimple path = createIncludePath();
@@ -307,7 +307,7 @@ public class DriftConfigurationDefinition implements Serializable {
private static PropertyDefinitionMap createExclude() {
String name = PROP_EXCLUDES_EXCLUDE;
- String description = "A set of patterns that specify files and/or directories to exclude.";
+ String description = "A pattern that specifies a file or directory to exclude.";
boolean required = true;
PropertyDefinitionSimple path = createExcludePath();
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftConfigurationDefinitionTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftConfigurationDefinitionTest.java
index 525a46c..6388292 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftConfigurationDefinitionTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftConfigurationDefinitionTest.java
@@ -37,101 +37,97 @@ import org.rhq.enterprise.server.test.AbstractEJB3Test;
public class DriftConfigurationDefinitionTest extends AbstractEJB3Test {
public void testDriftConfigurationDefinition() throws Throwable {
+ ConfigurationDefinition def;
+ ConfigurationDefinition defDATABASE;
+
getTransactionManager().begin();
try {
- ConfigurationDefinition def = DriftConfigurationDefinition.getInstance();
- ConfigurationDefinition defDATABASE = getEntityManager().find(ConfigurationDefinition.class, def.getId());
-
- assert defDATABASE.getId() == def.getId();
- assert defDATABASE.getPropertyDefinitions().size() == def.getPropertyDefinitions().size();
-
- PropertyDefinitionSimple simpleDATABASE;
- PropertyDefinitionSimple simple;
- PropertyDefinitionMap mapDATABASE;
- PropertyDefinitionMap map;
- PropertyDefinitionList listDATABASE;
- PropertyDefinitionList list;
-
- // NAME
- simpleDATABASE = defDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_NAME);
- simple = def.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_NAME);
- assertSimpleProperty(simpleDATABASE, simple);
-
- // ENABLED
- simpleDATABASE = defDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_ENABLED);
- simple = def.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_ENABLED);
- assertSimpleProperty(simpleDATABASE, simple);
-
- // INTERVAL
- simpleDATABASE = defDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_INTERVAL);
- simple = def.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_INTERVAL);
- assertSimpleProperty(simpleDATABASE, simple);
-
- // BASEDIR
- mapDATABASE = defDATABASE.getPropertyDefinitionMap(DriftConfigurationDefinition.PROP_BASEDIR);
- map = def.getPropertyDefinitionMap(DriftConfigurationDefinition.PROP_BASEDIR);
- assertMapProperty(mapDATABASE, map);
-
- // BASEDIR VALUECONTEXT (implicitly also tests the enums)
- simpleDATABASE = mapDATABASE
- .getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT);
- simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT);
- assertSimpleProperty(simpleDATABASE, simple);
-
- // BASEDIR VALUENAME
- simpleDATABASE = mapDATABASE
- .getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME);
- simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME);
- assertSimpleProperty(simpleDATABASE, simple);
-
- // INCLUDES
- listDATABASE = defDATABASE.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_INCLUDES);
- list = def.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_INCLUDES);
- assertListProperty(listDATABASE, list);
-
- // INCLUDES INCLUDE
- /*
- PropertyDefinitionMap deleteme = getEntityManager().find(PropertyDefinitionMap.class, 8);
-
- mapDATABASE = (PropertyDefinitionMap) listDATABASE.getMemberDefinition();
- map = (PropertyDefinitionMap) list.getMemberDefinition();
- assertMapProperty(mapDATABASE, map);
-
- // INCLUDES INCLUDE PATH
- simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
- simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
- assertSimpleProperty(simpleDATABASE, simple);
-
- // INCLUDES INCLUDE PATTERN
- simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
- simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
- assertSimpleProperty(simpleDATABASE, simple);
- */
-
- // EXCLUDES
- listDATABASE = defDATABASE.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_EXCLUDES);
- list = def.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_EXCLUDES);
- assertListProperty(listDATABASE, list);
-
- /*
- // EXCLUDES EXCLUDE
- mapDATABASE = (PropertyDefinitionMap) listDATABASE.getMemberDefinition();
- map = (PropertyDefinitionMap) list.getMemberDefinition();
- assertMapProperty(mapDATABASE, map);
-
- // EXCLUDES EXCLUDE PATH
- simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
- simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
- assertSimpleProperty(simpleDATABASE, simple);
-
- // EXCLUDES EXCLUDE PATTERN
- simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
- simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
- assertSimpleProperty(simpleDATABASE, simple);
- */
+ def = DriftConfigurationDefinition.getInstance();
+ defDATABASE = getEntityManager().find(ConfigurationDefinition.class, def.getId());
} finally {
getTransactionManager().rollback();
}
+
+ assert defDATABASE.getId() == def.getId();
+ assert defDATABASE.getPropertyDefinitions().size() == def.getPropertyDefinitions().size();
+
+ PropertyDefinitionSimple simpleDATABASE;
+ PropertyDefinitionSimple simple;
+ PropertyDefinitionMap mapDATABASE;
+ PropertyDefinitionMap map;
+ PropertyDefinitionList listDATABASE;
+ PropertyDefinitionList list;
+
+ // NAME
+ simpleDATABASE = defDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_NAME);
+ simple = def.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_NAME);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // ENABLED
+ simpleDATABASE = defDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_ENABLED);
+ simple = def.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_ENABLED);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // INTERVAL
+ simpleDATABASE = defDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_INTERVAL);
+ simple = def.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_INTERVAL);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // BASEDIR
+ mapDATABASE = defDATABASE.getPropertyDefinitionMap(DriftConfigurationDefinition.PROP_BASEDIR);
+ map = def.getPropertyDefinitionMap(DriftConfigurationDefinition.PROP_BASEDIR);
+ assertMapProperty(mapDATABASE, map);
+
+ // BASEDIR VALUECONTEXT (implicitly also tests the enums)
+ simpleDATABASE = mapDATABASE
+ .getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // BASEDIR VALUENAME
+ simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // INCLUDES
+ listDATABASE = defDATABASE.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_INCLUDES);
+ list = def.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_INCLUDES);
+ assertListProperty(listDATABASE, list);
+
+ // INCLUDES INCLUDE
+ mapDATABASE = (PropertyDefinitionMap) listDATABASE.getMemberDefinition();
+ map = (PropertyDefinitionMap) list.getMemberDefinition();
+ assertMapProperty(mapDATABASE, map);
+
+ // INCLUDES INCLUDE PATH
+ simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // INCLUDES INCLUDE PATTERN
+ simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // EXCLUDES
+ listDATABASE = defDATABASE.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_EXCLUDES);
+ list = def.getPropertyDefinitionList(DriftConfigurationDefinition.PROP_EXCLUDES);
+ assertListProperty(listDATABASE, list);
+
+ // EXCLUDES EXCLUDE
+ mapDATABASE = (PropertyDefinitionMap) listDATABASE.getMemberDefinition();
+ map = (PropertyDefinitionMap) list.getMemberDefinition();
+ assertMapProperty(mapDATABASE, map);
+
+ // EXCLUDES EXCLUDE PATH
+ simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATH);
+ assertSimpleProperty(simpleDATABASE, simple);
+
+ // EXCLUDES EXCLUDE PATTERN
+ simpleDATABASE = mapDATABASE.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
+ simple = map.getPropertyDefinitionSimple(DriftConfigurationDefinition.PROP_PATTERN);
+ assertSimpleProperty(simpleDATABASE, simple);
}
private void assertListProperty(PropertyDefinitionList listDb, PropertyDefinitionList list) throws Throwable {
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java | 2 ++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 10 +++++++---
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 1 +
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java | 5 +++++
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 2 +-
5 files changed, 16 insertions(+), 4 deletions(-)
New commits:
commit eece962f72452c6128c4768d6aa1b318b1b2caea
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jun 29 15:39:53 2011 -0400
Fixing compiler errors for getting basedir value by context
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java
index 114c365..f2bbb04 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftClient.java
@@ -14,4 +14,6 @@ public interface DriftClient {
void sendChangeSetContentToServer(int resourceId, String driftConfigurationName, File contentDir);
+ File getAbsoluteBaseDirectory(DriftConfiguration driftConfiguration);
+
}
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 6c31e7f..364bfc2 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
@@ -56,7 +56,7 @@ public class DriftDetector implements Runnable {
// if there is no previous changeset then we need to generate the initial
// coverage changeset
ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(schedule.getResourceId(),
- new Headers(driftConfig.getName(), driftConfig.getBasedir(), COVERAGE));
+ new Headers(driftConfig.getName(), basedir(driftConfig), COVERAGE));
DirectoryScanner scanner = new DirectoryScanner(schedule.getDriftConfiguration(), writer);
scanner.scan();
@@ -81,6 +81,10 @@ public class DriftDetector implements Runnable {
return digestGenerator.calcDigestString(file);
}
+ private String basedir(DriftConfiguration driftConfig) {
+ return driftClient.getAbsoluteBaseDirectory(driftConfig).getAbsolutePath();
+ }
+
// TODO Do not use DirectoryWalker
// Want to do the file scan iteratively to keep memory overhead as low as possible.
private class DirectoryScanner extends DirectoryWalker {
@@ -95,12 +99,12 @@ public class DriftDetector implements Runnable {
}
public void scan() throws IOException {
- walk(new File(driftConfig.getBasedir()), EMPTY_LIST);
+ walk(new File(basedir(driftConfig)), EMPTY_LIST);
}
@Override
protected void handleDirectoryStart(File directory, int depth, Collection results) throws IOException {
- stack.push(new DirectoryEntry(relativePath(new File(driftConfig.getBasedir()), directory)));
+ stack.push(new DirectoryEntry(relativePath(new File(basedir(driftConfig)), directory)));
}
@Override
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index cffea1c..015d307 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -192,6 +192,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
*
* @return absolute directory location where the drift configuration base directory is referring
*/
+ @Override
public File getAbsoluteBaseDirectory(DriftConfiguration driftConfiguration) {
// get the resource entity stored in our local inventory
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java
index d6e5d45..36e255a 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftClientTestStub.java
@@ -12,4 +12,9 @@ class DriftClientTestStub implements DriftClient {
@Override
public void sendChangeSetContentToServer(int resourceId, String driftConfigurationName, File contentDir) {
}
+
+ @Override
+ public File getAbsoluteBaseDirectory(DriftConfiguration driftConfiguration) {
+ return null;
+ }
}
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 605b275..89fa721 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
@@ -85,7 +85,7 @@ public class DriftDetectorTest extends JMockTest {
List<String> lines = readLines(new BufferedInputStream(new FileInputStream(changeSet)));
- assertHeaderEquals(lines, driftConfig.getName(), driftConfig.getBasedir(), COVERAGE.code());
+ assertHeaderEquals(lines, driftConfig.getName(), driftConfig.getBasedir().getValueName(), COVERAGE.code());
assertThatChangeSetDoesNotContainEmptyDirs(changeSet);
}
12 years, 10 months