[rhq] modules/core
by mazz
modules/core/util/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
New commits:
commit 412f7ac30c6e395d56f86b3ab434452681d82277
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 31 10:19:26 2012 -0400
fix the versions to mimic the actual version strings in the distros
diff --git a/modules/core/util/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java b/modules/core/util/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
index 2e81763..6a390765 100644
--- a/modules/core/util/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
+++ b/modules/core/util/src/test/java/org/apache/maven/artifact/versioning/ComparableVersionTest.java
@@ -39,7 +39,6 @@ public class ComparableVersionTest {
RHQ_VERSIONS.add("4.4.0.RC1");
RHQ_VERSIONS.add("4.4.0.RC2");
RHQ_VERSIONS.add("4.4.0.GA");
- RHQ_VERSIONS.add("4.4.1.GA");
}
private static List<String> JON_VERSIONS = new ArrayList<String>();
@@ -52,7 +51,7 @@ public class ComparableVersionTest {
JON_VERSIONS.add("4.4.0.JON310BETA1");
JON_VERSIONS.add("4.4.0.JON310CR1");
JON_VERSIONS.add("4.4.0.JON310GA");
- JON_VERSIONS.add("4.4.1.JON311GA");
+ JON_VERSIONS.add("4.4.0.JON311GA");
}
public void testRHQVersions() {
11 years, 9 months
[rhq] Branch 'release/jon3.1.x' - modules/plugins
by snegrea
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit bb1765a555263daa7a4185461ed3b730b2a5246e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 31 08:42:20 2012 -0500
BZ 844217 - Use the correct name for the deployments directory (for bundles).
(cherry picked from commit 264bf23cb169b7c2fe73f1756138914752f4f2ee)
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
index a756dea..9d93300 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java
@@ -87,7 +87,7 @@ public class StandaloneASDiscovery extends BaseProcessDiscovery {
// Set deployment directory, which only exists for standalone servers
String baseDir = pluginConfig.getSimpleValue("baseDir");
if (baseDir != null) {
- File deployDir = new File(baseDir, "deployment");
+ File deployDir = new File(baseDir, "deployments");
pluginConfig.put(new PropertySimple("deployDir", deployDir.getPath()));
}
11 years, 9 months
[rhq] Branch 'feature/hadoop-plugin' - 2 commits - modules/plugins
by lkrejci
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopComponent.java | 45 ---
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopDiscovery.java | 64 -----
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceComponent.java | 124 +++-------
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java | 2
4 files changed, 50 insertions(+), 185 deletions(-)
New commits:
commit 89da8bf8ba91b32db9701cb0a6d7831d58d31516
Merge: 1733c4d 527bc2a
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jul 31 15:38:07 2012 +0200
more formatting and code cleanup before we do anything serious.
diff --cc modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopComponent.java
index 848d560,848d560..0000000
deleted file mode 100644,100644
--- a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopComponent.java
+++ /dev/null
diff --cc modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopDiscovery.java
index de8613a,de8613a..0000000
deleted file mode 100644,100644
--- a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopDiscovery.java
+++ /dev/null
commit 527bc2ae7a0a42af1a0ca2819b570c4333b5cabf
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jul 31 15:32:21 2012 +0200
formatting and general cleanup before we start doing anything serious.
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceComponent.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceComponent.java
index c0f060f..5cb3806 100644
--- a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceComponent.java
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceComponent.java
@@ -1,3 +1,21 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.plugins.hadoop;
@@ -10,68 +28,37 @@ import org.mc4j.ems.connection.bean.EmsBean;
import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationContext;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.JMXComponent;
import org.rhq.plugins.jmx.JMXServerComponent;
-public class HadoopServiceComponent extends JMXServerComponent implements JMXComponent, ResourceComponent
-, MeasurementFacet
-, OperationFacet
-{
- private final Log log = LogFactory.getLog(this.getClass());
-
- private ResourceContext context;
-
-
-
+public class HadoopServiceComponent extends JMXServerComponent<ResourceComponent<?>> implements
+ JMXComponent<ResourceComponent<?>>, MeasurementFacet, OperationFacet {
+
+ private static final Log LOG = LogFactory.getLog(HadoopServiceComponent.class);
/**
* Return availability of this resource
* @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
*/
+ @Override
public AvailabilityType getAvailability() {
- return AvailabilityType.UP; // Return UP until we know why context has no process info TODO
- //return context.getNativeProcess().isRunning() ? AvailabilityType.UP: AvailabilityType.DOWN;
- }
-
-
- /**
- * Start the resource connection
- * @see org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
- */
- public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
-
- Configuration conf = context.getPluginConfiguration();
- this.context = context;
- super.start(context);
- log.info("Started " + context.getResourceKey());
-
- }
-
-
- /**
- * Tear down the resource connection
- * @see org.rhq.core.pluginapi.inventory.ResourceComponent#stop()
- */
- public void stop() {
- super.stop();
-
+ return getResourceContext().getNativeProcess().isRunning() ? AvailabilityType.UP: AvailabilityType.DOWN;
}
@Override
public EmsConnection getEmsConnection() {
- EmsConnection conn = super.getEmsConnection(); // TODO: Customise this generated block
- log.info("EmsConnection is " + conn.toString());
+ EmsConnection conn = super.getEmsConnection(); // TODO: Customise this generated block
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("EmsConnection is " + conn.toString());
+ }
return conn;
}
@@ -80,38 +67,29 @@ public class HadoopServiceComponent extends JMXServerComponent implements JMXCom
* Gather measurement data
* @see org.rhq.core.pluginapi.measurement.MeasurementFacet#getValues(org.rhq.core.domain.measurement.MeasurementReport, java.util.Set)
*/
- public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
-
- for (MeasurementScheduleRequest req : metrics) {
- String property=req.getName();
- String props[] = property.split("\\|");
-
- EmsConnection conn = getEmsConnection();
- EmsBean bean = conn.getBean(props[0]);
- if (bean != null) {
- bean.refreshAttributes();
- EmsAttribute att = bean.getAttribute(props[1]);
- if (att!=null) {
- Long val = (Long) att.getValue(); // TODO check for real type
-
- MeasurementDataNumeric res = new MeasurementDataNumeric(req, Double.valueOf(val));
- report.addData(res);
- }
- else
- log.warn("Attribute " + props[1] + " not found");
- }
- else
- log.warn("MBean " + props[0] +" not found");
- }
- }
-
-
-
- public void startOperationFacet(OperationContext context) {
-
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+
+ for (MeasurementScheduleRequest req : metrics) {
+ String property = req.getName();
+ String props[] = property.split("\\|");
+
+ EmsConnection conn = getEmsConnection();
+ EmsBean bean = conn.getBean(props[0]);
+ if (bean != null) {
+ bean.refreshAttributes();
+ EmsAttribute att = bean.getAttribute(props[1]);
+ if (att != null) {
+ Long val = (Long) att.getValue(); // TODO check for real type
+
+ MeasurementDataNumeric res = new MeasurementDataNumeric(req, Double.valueOf(val));
+ report.addData(res);
+ } else
+ LOG.warn("Attribute " + props[1] + " not found");
+ } else
+ LOG.warn("MBean " + props[0] + " not found");
+ }
}
-
/**
* Invokes the passed operation on the managed resource
* @param name Name of the operation
@@ -129,8 +107,4 @@ public class HadoopServiceComponent extends JMXServerComponent implements JMXCom
return res;
}
-
-
-
-
}
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
index 41db515..f010976 100644
--- a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2012 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -44,6 +44,7 @@ import org.rhq.plugins.jmx.JMXDiscoveryComponent;
/**
* Discover individual hadoop processes
* @author Heiko W. Rupp
+ * @author Lukas Krejci
*/
public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<ResourceComponent<?>> {
@@ -51,36 +52,33 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<Resour
private static final String HADOOP_VERSION_MATCH = "hadoop-core-([0-9\\.]+)\\.jar";
private static final Pattern HADOOP_VERSION_PATTERN = Pattern.compile(HADOOP_VERSION_MATCH);
private static final String MAIN_CLASS_PROPERTY = "_mainClass";
-
+
public Set<DiscoveredResourceDetails> discoverResources(
- ResourceDiscoveryContext<ResourceComponent<?>> resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception {
+ ResourceDiscoveryContext<ResourceComponent<?>> resourceDiscoveryContext)
+ throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
- List<ProcessScanResult> parentProcessScans = resourceDiscoveryContext.getAutoDiscoveredProcesses();
+ List<ProcessScanResult> processScans = resourceDiscoveryContext.getAutoDiscoveredProcesses();
ResourceType resourceType = resourceDiscoveryContext.getResourceType();
String rtName = resourceType.getName();
- for (ProcessScanResult psr : parentProcessScans) {
-
+ for (ProcessScanResult psr : processScans) {
if (psr.getProcessScan().getName().equals(rtName)) {
String cwd = psr.getProcessInfo().getCurrentWorkingDirectory();
-
+
String version = getVersion(cwd);
Configuration pluginConfiguration = resourceDiscoveryContext.getDefaultPluginConfiguration();
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- resourceType, // ResourceType
- rtName+":"+cwd, // ResourceKey
- rtName, // resource name
- version, // Version
- "Hadoop " + rtName + " ( "+ cwd +" )", // description
- pluginConfiguration,
- psr.getProcessInfo() // process info
- );
-
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(resourceType, // ResourceType
+ rtName + ":" + cwd, // ResourceKey
+ rtName, // resource name
+ version, // Version
+ "Hadoop " + rtName + " ( " + cwd + " )", // description
+ pluginConfiguration, psr.getProcessInfo() // process info
+ );
/*
* We'll connect to the discovered VM on the local host, so set the jmx connection
@@ -88,12 +86,12 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<Resour
* anyway.
*/
pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY,
- pluginConfiguration.getSimpleValue(MAIN_CLASS_PROPERTY, null)));
+ pluginConfiguration.getSimpleValue(MAIN_CLASS_PROPERTY, null)));
pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
LocalVMTypeDescriptor.class.getName()));
log.debug("Discovered " + detail);
-
+
details.add(detail);
}
}
@@ -109,9 +107,9 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<Resour
*/
private String getVersion(String hadoopHomeDir) {
- File homeDir =new File(hadoopHomeDir);
+ File homeDir = new File(hadoopHomeDir);
if (homeDir.isDirectory() && homeDir.canRead()) {
- String[] foundCoreJars = homeDir.list(new FilenameFilter() {
+ String[] foundCoreJars = homeDir.list(new FilenameFilter() {
public boolean accept(File dir, String name) {
return HADOOP_VERSION_PATTERN.matcher(name).matches();
}
@@ -120,7 +118,7 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<Resour
if (foundCoreJars == null || foundCoreJars.length == 0) {
return null;
}
-
+
Matcher matcher = HADOOP_VERSION_PATTERN.matcher(foundCoreJars[0]);
if (matcher.matches()) {
return matcher.group(1);
@@ -132,5 +130,4 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<Resour
}
}
-
}
11 years, 9 months
[rhq] Branch 'feature/hadoop-plugin' - modules/plugins
by lkrejci
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java | 41 ++++------
1 file changed, 19 insertions(+), 22 deletions(-)
New commits:
commit 1733c4dd35f5e65cb7dbc3abfc43933dbddab9ac
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jul 31 15:26:09 2012 +0200
formatting
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
index 41db515..87007c8 100644
--- a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
@@ -44,6 +44,7 @@ import org.rhq.plugins.jmx.JMXDiscoveryComponent;
/**
* Discover individual hadoop processes
* @author Heiko W. Rupp
+ * @author Lukas Krejci
*/
public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<ResourceComponent<?>> {
@@ -51,36 +52,33 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<Resour
private static final String HADOOP_VERSION_MATCH = "hadoop-core-([0-9\\.]+)\\.jar";
private static final Pattern HADOOP_VERSION_PATTERN = Pattern.compile(HADOOP_VERSION_MATCH);
private static final String MAIN_CLASS_PROPERTY = "_mainClass";
-
+
public Set<DiscoveredResourceDetails> discoverResources(
- ResourceDiscoveryContext<ResourceComponent<?>> resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception {
+ ResourceDiscoveryContext<ResourceComponent<?>> resourceDiscoveryContext)
+ throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
- List<ProcessScanResult> parentProcessScans = resourceDiscoveryContext.getAutoDiscoveredProcesses();
+ List<ProcessScanResult> processScans = resourceDiscoveryContext.getAutoDiscoveredProcesses();
ResourceType resourceType = resourceDiscoveryContext.getResourceType();
String rtName = resourceType.getName();
- for (ProcessScanResult psr : parentProcessScans) {
-
+ for (ProcessScanResult psr : processScans) {
if (psr.getProcessScan().getName().equals(rtName)) {
String cwd = psr.getProcessInfo().getCurrentWorkingDirectory();
-
+
String version = getVersion(cwd);
Configuration pluginConfiguration = resourceDiscoveryContext.getDefaultPluginConfiguration();
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- resourceType, // ResourceType
- rtName+":"+cwd, // ResourceKey
- rtName, // resource name
- version, // Version
- "Hadoop " + rtName + " ( "+ cwd +" )", // description
- pluginConfiguration,
- psr.getProcessInfo() // process info
- );
-
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(resourceType, // ResourceType
+ rtName + ":" + cwd, // ResourceKey
+ rtName, // resource name
+ version, // Version
+ "Hadoop " + rtName + " ( " + cwd + " )", // description
+ pluginConfiguration, psr.getProcessInfo() // process info
+ );
/*
* We'll connect to the discovered VM on the local host, so set the jmx connection
@@ -88,12 +86,12 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<Resour
* anyway.
*/
pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY,
- pluginConfiguration.getSimpleValue(MAIN_CLASS_PROPERTY, null)));
+ pluginConfiguration.getSimpleValue(MAIN_CLASS_PROPERTY, null)));
pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
LocalVMTypeDescriptor.class.getName()));
log.debug("Discovered " + detail);
-
+
details.add(detail);
}
}
@@ -109,9 +107,9 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<Resour
*/
private String getVersion(String hadoopHomeDir) {
- File homeDir =new File(hadoopHomeDir);
+ File homeDir = new File(hadoopHomeDir);
if (homeDir.isDirectory() && homeDir.canRead()) {
- String[] foundCoreJars = homeDir.list(new FilenameFilter() {
+ String[] foundCoreJars = homeDir.list(new FilenameFilter() {
public boolean accept(File dir, String name) {
return HADOOP_VERSION_PATTERN.matcher(name).matches();
}
@@ -120,7 +118,7 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<Resour
if (foundCoreJars == null || foundCoreJars.length == 0) {
return null;
}
-
+
Matcher matcher = HADOOP_VERSION_PATTERN.matcher(foundCoreJars[0]);
if (matcher.matches()) {
return matcher.group(1);
@@ -132,5 +130,4 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<Resour
}
}
-
}
11 years, 9 months
[rhq] Branch 'feature/hadoop-plugin' - modules/plugins
by lkrejci
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java | 77 +++++-----
modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml | 30 +++
2 files changed, 68 insertions(+), 39 deletions(-)
New commits:
commit 51ce9762ce5fa59f4f7bbbc78da97e5ebc17307c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jul 31 14:53:16 2012 +0200
Making discovery and obtaining the JMX connection work,
basics of config properties we are going to support.
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
index bcc9af8..41db515 100644
--- a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
@@ -18,6 +18,8 @@
*/
package org.rhq.plugins.hadoop;
+import java.io.File;
+import java.io.FilenameFilter;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -26,8 +28,6 @@ import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor;
-import org.mc4j.ems.connection.support.metadata.J2SE5ConnectionTypeDescriptor;
import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
import org.rhq.core.domain.configuration.Configuration;
@@ -36,6 +36,7 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.jmx.JMXDiscoveryComponent;
@@ -44,19 +45,19 @@ import org.rhq.plugins.jmx.JMXDiscoveryComponent;
* Discover individual hadoop processes
* @author Heiko W. Rupp
*/
-public class HadoopServiceDiscovery implements ResourceDiscoveryComponent {
+public class HadoopServiceDiscovery implements ResourceDiscoveryComponent<ResourceComponent<?>> {
private final Log log = LogFactory.getLog(HadoopServiceDiscovery.class);
- private static final String HADOOP_VERSION_MATCH = ".*hadoop-([0-9\\.]+)-core.jar.*";
- private Pattern hadoopPattern = Pattern.compile(HADOOP_VERSION_MATCH);
-
+ private static final String HADOOP_VERSION_MATCH = "hadoop-core-([0-9\\.]+)\\.jar";
+ private static final Pattern HADOOP_VERSION_PATTERN = Pattern.compile(HADOOP_VERSION_MATCH);
+ private static final String MAIN_CLASS_PROPERTY = "_mainClass";
+
public Set<DiscoveredResourceDetails> discoverResources(
- ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception {
+ ResourceDiscoveryContext<ResourceComponent<?>> resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
- @SuppressWarnings("unchecked")
- List<ProcessScanResult> parentProcessScans = resourceDiscoveryContext.getParentResourceContext().getNativeProcessesForType();
+ List<ProcessScanResult> parentProcessScans = resourceDiscoveryContext.getAutoDiscoveredProcesses();
ResourceType resourceType = resourceDiscoveryContext.getResourceType();
String rtName = resourceType.getName();
@@ -65,17 +66,17 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent {
if (psr.getProcessScan().getName().equals(rtName)) {
- String[] commandLineArgs = psr.getProcessInfo().getCommandLine();
- String version = getVersion(commandLineArgs);
- String javaClazz = getClazzFromCommandLine(commandLineArgs);
+ String cwd = psr.getProcessInfo().getCurrentWorkingDirectory();
+
+ String version = getVersion(cwd);
Configuration pluginConfiguration = resourceDiscoveryContext.getDefaultPluginConfiguration();
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
resourceType, // ResourceType
- rtName+":"+psr.getProcessInfo().getCurrentWorkingDirectory(), // ResourceKey
+ rtName+":"+cwd, // ResourceKey
rtName, // resource name
version, // Version
- "Hadoop " + rtName + " ( "+ psr.getProcessInfo().getCurrentWorkingDirectory() +" )", // description
+ "Hadoop " + rtName + " ( "+ cwd +" )", // description
pluginConfiguration,
psr.getProcessInfo() // process info
);
@@ -87,11 +88,12 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent {
* anyway.
*/
pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY,
- javaClazz));
+ pluginConfiguration.getSimpleValue(MAIN_CLASS_PROPERTY, null)));
pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
LocalVMTypeDescriptor.class.getName()));
- log.info("Discovered " + detail);
+ log.debug("Discovered " + detail);
+
details.add(detail);
}
}
@@ -100,35 +102,34 @@ public class HadoopServiceDiscovery implements ResourceDiscoveryComponent {
}
/**
- * Get the full class name of the java class that 'jps -l' would list
- * @param commandLineArgs Command line args for the java executable
- * @return full class name for the server class
- */
- private String getClazzFromCommandLine(String[] commandLineArgs) {
- for (String line : commandLineArgs) {
- if (line.startsWith("org.apache.hadoop."))
- return line;
- }
- return "-not found-";
- }
-
- /**
* Get hadoop version
* from command line by looking at haoop-core-xx-core.jar
* @param commandLine Command line args for the java executable
* @return hdoop version string or null if it can not be determined
*/
- private String getVersion(String[] commandLine) {
-
- for (String line : commandLine) {
- Matcher m = hadoopPattern.matcher(line);
- if (m.matches()) {
- String result = m.group(1);
- return result;
+ private String getVersion(String hadoopHomeDir) {
+
+ File homeDir =new File(hadoopHomeDir);
+ if (homeDir.isDirectory() && homeDir.canRead()) {
+ String[] foundCoreJars = homeDir.list(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return HADOOP_VERSION_PATTERN.matcher(name).matches();
+ }
+ });
+
+ if (foundCoreJars == null || foundCoreJars.length == 0) {
+ return null;
}
+
+ Matcher matcher = HADOOP_VERSION_PATTERN.matcher(foundCoreJars[0]);
+ if (matcher.matches()) {
+ return matcher.group(1);
+ } else {
+ return null;
+ }
+ } else {
+ return null;
}
-
- return null;
}
diff --git a/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml
index efcdc33..334fcf5 100644
--- a/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml
@@ -6,7 +6,13 @@
<!-- NameNode (http://wiki.apache.org/hadoop/NameNode) -->
<server name="NameNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
- <process-scan name="NameNode" query="process|basename|match=^java.*,arg|*|match=.*proc_namenode.*"/>
+ <plugin-configuration>
+ <c:simple-property name="hadoop.home.dir" displayName="Home Directory" readOnly="true" />
+ <c:simple-property name="_mainClass" displayName="Main Class" readOnly="true" default="org.apache.hadoop.hdfs.server.namenode.NameNode" />
+ </plugin-configuration>
+
+ <process-scan name="NameNode"
+ query="process|basename|match=^java.*,arg|-Dproc_namenode|match=.*"/>
<metric property="Hadoop:service=NameNode,name=NameNodeInfo|NameDirStatuses" displayName="NameNode Storage"
dataType="trait" displayType="summary"/>
@@ -36,33 +42,55 @@
units="none"/>
<metric property="Hadoop:service=NameNode,name=NameNodeActivity|FilesCreated" displayName="Files Created"
units="none" measurementType="trendsup"/>
+
+ <resource-configuration>
+ <c:simple-property name="conf/core-site.xml:fs.default.name" displayName="Namenode URI" />
+ <c:simple-property name="conf/hdfs-site.xml:dfs.name.dir" displayName="Local Namespace and Logs Storage Directory" description="Path on the local filesystem where the NameNode stores the namespace and transactions logs persistently."/>
+ </resource-configuration>
</server>
<server name="SecondaryNameNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
+ <plugin-configuration>
+ <c:simple-property name="_mainClass" displayName="Main Class" readOnly="true" default="org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode" />
+ </plugin-configuration>
<process-scan name="SecondaryNameNode" query="process|basename|match=^java.*,arg|*|match=.*proc_secondarynamenode.*"/>
</server>
<!-- DataNode (http://wiki.apache.org/hadoop/DataNode) -->
<server name="DataNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
+ <plugin-configuration>
+ <c:simple-property name="_mainClass" displayName="Main Class" readOnly="true" default="org.apache.hadoop.hdfs.server.datanode.DataNode" />
+ </plugin-configuration>
+
<process-scan name="DataNode" query="process|basename|match=^java.*,arg|*|match=.*proc_datanode.*"/>
+
<metric property="Hadoop:service=DataNode,name=DataNode*|bytes_written" displayName="Bytes Writter"
measurementType="trendsup"/>
<metric property="Hadoop:service=DataNode,name=FSDatasetState*|Remaining" displayName="Remaining" units="bytes"/>
<metric property="Hadoop:service=DataNode,name=FSDatasetState*|Capacity" displayName="Capacity" units="bytes"/>
<metric property="Hadoop:service=DataNode,name=FSDatasetState*|StorageInfo" dataType="trait" displayType="summary"/>
<metric property="Hadoop:service=DataNode,name=RpcActivitForPort*|NumOpenConnections" displayName="Number of Open Connections"/>
+
+ <resource-configuration>
+ <c:simple-property name="conf/hdfs-site.xml:dfs.data.dir" displayName="Storage Directory" description="Comma separated list of paths on the local filesystem of a DataNode where it should store its blocks."/>
+ </resource-configuration>
</server>
<!-- JobTracker (http://wiki.apache.org/hadoop/JobTracker) -->
<server name="JobTracker" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
<plugin-configuration>
<c:simple-property name="baseObjectName" defaultValue="hadoop:service=JobTracker"/>
+ <c:simple-property name="_mainClass" displayName="Main Class" readOnly="true" default="org.apache.hadoop.mapred.JobTracker" />
</plugin-configuration>
<process-scan name="JobTracker" query="process|basename|match=^java.*,arg|*|match=.*proc_jobtracker.*"/>
</server>
<!-- TaskTracker (http://wiki.apache.org/hadoop/TaskTracker) -->
<server name="TaskTracker" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
+ <plugin-configuration>
+ <c:simple-property name="_mainClass" displayName="Main Class" readOnly="true" default="org.apache.hadoop.mapred.TaskTracker" />
+ </plugin-configuration>
+
<process-scan name="TaskTracker" query="process|basename|match=^java.*,arg|*|match=.*proc_tasktracker.*"/>
</server>
</plugin>
\ No newline at end of file
11 years, 9 months
[rhq] Branch 'feature/hadoop-plugin' - modules/plugins
by Jiri Kremser
modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml | 21 ++++------
1 file changed, 9 insertions(+), 12 deletions(-)
New commits:
commit 265d5abe6a6bf285b9d331e5ef560fc6a649876b
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Tue Jul 31 14:26:59 2012 +0200
Process scan strings now math the hadoop nodes
diff --git a/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml
index de3c6a9..efcdc33 100644
--- a/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml
@@ -5,9 +5,8 @@
<depends plugin="JMX" useClasses="true"/>
<!-- NameNode (http://wiki.apache.org/hadoop/NameNode) -->
- <server name="NameNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent" subCategory="Hadoop">
- <process-scan name="NameNode"
- query="process|basename|match=^java.*,arg|org.apache.hadoop.hdfs.server.namenode.NameNode|match=.*"/>
+ <server name="NameNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
+ <process-scan name="NameNode" query="process|basename|match=^java.*,arg|*|match=.*proc_namenode.*"/>
<metric property="Hadoop:service=NameNode,name=NameNodeInfo|NameDirStatuses" displayName="NameNode Storage"
dataType="trait" displayType="summary"/>
@@ -39,15 +38,13 @@
units="none" measurementType="trendsup"/>
</server>
- <server name="SecondaryNameNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent" subCategory="Hadoop">
- <process-scan name="SecondaryNameNode"
- query="process|basename|match=^java.*,arg|org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode|match=.*"/>
+ <server name="SecondaryNameNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
+ <process-scan name="SecondaryNameNode" query="process|basename|match=^java.*,arg|*|match=.*proc_secondarynamenode.*"/>
</server>
<!-- DataNode (http://wiki.apache.org/hadoop/DataNode) -->
<server name="DataNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
- <process-scan name="DataNode"
- query="process|basename|match=^java.*,arg|org.apache.hadoop.hdfs.server.datanode.DataNode|match=.*"/>
+ <process-scan name="DataNode" query="process|basename|match=^java.*,arg|*|match=.*proc_datanode.*"/>
<metric property="Hadoop:service=DataNode,name=DataNode*|bytes_written" displayName="Bytes Writter"
measurementType="trendsup"/>
<metric property="Hadoop:service=DataNode,name=FSDatasetState*|Remaining" displayName="Remaining" units="bytes"/>
@@ -57,15 +54,15 @@
</server>
<!-- JobTracker (http://wiki.apache.org/hadoop/JobTracker) -->
- <server name="JobTracker" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent" subCategory="Hadoop">
+ <server name="JobTracker" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
<plugin-configuration>
<c:simple-property name="baseObjectName" defaultValue="hadoop:service=JobTracker"/>
</plugin-configuration>
- <process-scan name="JobTracker" query="process|basename|match=^java.*,arg|org.apache.hadoop.mapred.JobTracker|match=.*"/>
+ <process-scan name="JobTracker" query="process|basename|match=^java.*,arg|*|match=.*proc_jobtracker.*"/>
</server>
<!-- TaskTracker (http://wiki.apache.org/hadoop/TaskTracker) -->
- <server name="TaskTracker" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent" subCategory="Hadoop">
- <process-scan name="TaskTracker" query="process|basename|match=^java.*,arg|org.apache.hadoop.mapred.TaskTracker|match=.*"/>
+ <server name="TaskTracker" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
+ <process-scan name="TaskTracker" query="process|basename|match=^java.*,arg|*|match=.*proc_tasktracker.*"/>
</server>
</plugin>
\ No newline at end of file
11 years, 9 months
[rhq] Branch 'release/jon3.1.x' - 2 commits - modules/plugins
by snegrea
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ThreadingComponent.java | 61 ++++++++++
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 16 +-
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java | 2
3 files changed, 73 insertions(+), 6 deletions(-)
New commits:
commit 0b0c1cb24c75493e83dec0f435da04641031a3d1
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 31 04:47:14 2012 -0500
BZ 837903 - remove thread ids from configuration and add an operation to retrieve them.
(cherry picked from commit e704b68d713a9bc956e826880d6fb0a93be322c9)
Conflicts:
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ThreadingComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ThreadingComponent.java
new file mode 100644
index 0000000..9080262
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ThreadingComponent.java
@@ -0,0 +1,61 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.List;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Component class for Threading within the runtime
+ * @author Heiko W. Rupp
+ */
+public class ThreadingComponent extends BaseComponent<ThreadingComponent> {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public OperationResult invokeOperation(String name,
+ Configuration parameters) throws Exception {
+
+ if (name.equals("get-all-thread-ids")) {
+ Operation op = new ReadAttribute(getAddress(), "all-thread-ids");
+ Result res = getASConnection().execute(op);
+ OperationResult operationResult;
+ if (res.isSuccess()) {
+ List<Long> ids = (List<Long>) res.getResult();
+ operationResult = new OperationResult(ids.toString());
+ } else {
+ operationResult = new OperationResult();
+ String errorMessage = "Got no result back";
+ if (!res.isSuccess()) {
+ errorMessage += ": " + res.getFailureDescription();
+ }
+ operationResult.setErrorMessage(errorMessage);
+ }
+ return operationResult;
+ }
+
+ return super.invokeOperation(name, parameters);
+ }
+}
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 34616c2..d46a3fb 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
@@ -7017,8 +7017,7 @@
<service name="Threading"
discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
+ class="ThreadingComponent">
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="type=threading"/>
@@ -7114,6 +7113,16 @@
</results>
</operation>
+ <operation name="get-all-thread-ids"
+ description="Get all live thread IDs. If a security manager is installed and the caller does not have ManagementPermission('monitor'), the result will be undefined."
+ displayName="Get All thread ids">
+
+ <results>
+ <c:simple-property name="operationResult"
+ description="List of thread ids"/>
+ </results>
+ </operation>
+
<metric property="thread-count" description="The current number of live threads including both daemon and non-daemon threads."/>
<metric property="peak-thread-count" description="The peak live thread count since the Java virtual machine started or peak was reset."/>
<metric property="total-started-thread-count" description="The total number of threads created and also started since the Java virtual machine started."/>
@@ -7123,9 +7132,6 @@
<resource-configuration>
<c:simple-property name="thread-contention-monitoring-enabled" required="false" type="boolean" readOnly="false" description="Whether thread contention monitoring is enabled."/>
<c:simple-property name="thread-cpu-time-enabled" required="false" type="boolean" readOnly="false" description="Whether thread CPU time measurement is enabled."/>
- <c:list-property name="all-thread-ids" description="All live thread IDs. If a security manager is installed and the caller does not have ManagementPermission('monitor'), the result will be undefined." readOnly="true">
- <c:simple-property name="all-thread-ids" readOnly="true"/>
- </c:list-property>
<c:simple-property name="thread-contention-monitoring-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine supports thread contention monitoring."/>
<c:simple-property name="thread-cpu-time-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine implementation supports CPU time measurement for any thread."/>
<c:simple-property name="current-thread-cpu-time-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine supports CPU time measurement for the current thread."/>
commit cf5db4a29b9c443abc7ea8691e2bdadedfbbf19a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jul 31 04:43:06 2012 -0500
Increase the wait time to allow all subresources to get committed to inventory.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java
index 5d64977..4136808 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/TemplatedResourcesTest.java
@@ -73,7 +73,7 @@ public class TemplatedResourcesTest extends AbstractJBossAS7PluginTest {
StandaloneServerComponentTest.RESOURCE_KEY);
inventoryManager.activateResource(server, platformContainer, false);
- Thread.sleep(20 * 1000L);
+ Thread.sleep(60 * 1000L);
for (ResourceData resourceData : testResourceData) {
ResourceType resourceType = new ResourceType(resourceData.resourceTypeName, PLUGIN_NAME,
11 years, 9 months
[rhq] modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java | 37 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java | 8 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java | 6 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties | 5 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 3
10 files changed, 51 insertions(+), 23 deletions(-)
New commits:
commit b49d9d3dd66056bee9fc58f8a4084f6f62487da4
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Mon Jul 30 20:51:25 2012 -0700
[BZ 733487 New SearchBar] Fixed bug with return key in search bar not properly sending search. Added i18n.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
index cf40099..5409248 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
@@ -138,32 +138,33 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
public void searchFocusHandler(FocusEvent event) {
Log.debug("focus in BasicSearchStrategy");
String searchExpression = searchBar.getSearchComboboxItem().getValueAsString();
- if (null != searchExpression && searchExpression.length() > 0) {
- getTabAwareSearchSuggestions(SearchSubsystem.RESOURCE,
- searchBar.getSearchComboboxItem().getValueAsString(), searchBar.getSearchComboboxItem()
- .getValueAsString().length());
- } else {
- getTabAwareSearchSuggestions(SearchSubsystem.RESOURCE, "", 0);
- }
+ doSearch(searchExpression);
}
+
+
@Override
public void searchKeyUpHandler(KeyUpEvent keyUpEvent) {
Log.debug("Keyup in BasicSearchStrategy: " + keyUpEvent.getKeyName());
String searchExpression = searchBar.getSearchComboboxItem().getValueAsString();
+ doSearch(searchExpression);
+
+ }
+
+ @Override
+ public void searchReturnKeyHandler(KeyUpEvent keyUpEvent) {
+ doSearch((String)keyUpEvent.getItem().getValue());
+ }
+
+ private void doSearch(String searchExpression) {
if (null != searchExpression && searchExpression.length() > 0) {
getTabAwareSearchSuggestions(SearchSubsystem.RESOURCE,
- searchBar.getSearchComboboxItem().getValueAsString(), searchBar.getSearchComboboxItem()
+ searchBar.getSearchComboboxItem().getValueAsString(), searchBar.getSearchComboboxItem()
.getValueAsString().length());
} else {
+ Log.debug("Empty Search expression");
getTabAwareSearchSuggestions(SearchSubsystem.RESOURCE, "", 0);
}
-
- }
-
- @Override
- public void searchReturnKeyHandler(KeyUpEvent keyUpEvent) {
- // Do nothing here; standard Table.TableFilter will handle normally
}
@Override
@@ -171,10 +172,11 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
return 25;
}
- private void getTabAwareSearchSuggestions(SearchSubsystem searchSubsystem, final String expression,
+ private void getTabAwareSearchSuggestions(final SearchSubsystem searchSubsystem, final String expression,
int caretPosition) {
if (expression.equals(lastExpression)) {
+ // short-circuit if we dont really need to do a search
Log.debug("search tab aware Suggestions: ignoring duplicate search for: " + expression);
return;
}
@@ -182,9 +184,11 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
final long suggestStart = System.currentTimeMillis();
+ Log.debug("Searching for: "+expression);
searchService.getTabAwareSuggestions(searchSubsystem, expression, caretPosition, null,
new AsyncCallback<List<SearchSuggestion>>() {
+ @Override
public void onSuccess(List<SearchSuggestion> results) {
ComboBoxItem comboBox = searchBar.getSearchComboboxItem();
@@ -235,8 +239,9 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
Log.debug(results.size() + " suggestions searches fetched in: " + suggestFetchTime + "ms");
}
+ @Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to retrieve search suggestion", caught);
+ CoreGUI.getErrorHandler().handleError(MSG.search_failed_to_retrieve_search_suggestion(), caught);
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java
index e793f9f..c22ccd8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/EnhancedSearchBar.java
@@ -71,10 +71,10 @@ public class EnhancedSearchBar extends ToolStrip {
private final SearchGWTServiceAsync searchService = GWTServiceLookup.getSearchService();
- private static final List IGNORED_KEYS;
+ private static final List<String> IGNORED_KEYS;
static {
- IGNORED_KEYS = new ArrayList(2);
+ IGNORED_KEYS = new ArrayList<String>(2);
IGNORED_KEYS.add("Arrow_Down");
IGNORED_KEYS.add("Arrow_Up");
}
@@ -253,13 +253,13 @@ public class EnhancedSearchBar extends ToolStrip {
@Override
public void onSuccess(Integer newSavedSearchId) {
currentSearchId = newSavedSearchId;
- Message message = new Message("Successfully Saved Search: " + name, Message.Severity.Info);
+ Message message = new Message(MSG.search_successfully_saved_search(name), Message.Severity.Info);
CoreGUI.getMessageCenter().notify(message);
}
@Override
public void onFailure(Throwable caught) {
- Message message = new Message("Failure to Save Search " + name, Message.Severity.Error);
+ Message message = new Message(MSG.search_failed_to_save_search(name), Message.Severity.Error);
CoreGUI.getMessageCenter().notify(message);
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java
index a04a000..9cdffbd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/FavoritesSearchStrategy.java
@@ -102,16 +102,18 @@ public class FavoritesSearchStrategy extends AbstractSearchStrategy {
Subject subject = UserSessionManager.getSessionSubject();
savedSearchCriteria.addFilterSubjectId(subject.getId());
savedSearchCriteria.setStrict(true);
- final long start = System.currentTimeMillis();
+ final long startTime = System.currentTimeMillis();
searchService.findSavedSearchesByCriteria(savedSearchCriteria, new AsyncCallback<List<SavedSearch>>() {
+ @Override
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.search_failed_to_retrieve_saved_search(), caught);
}
+ @Override
public void onSuccess(List<SavedSearch> result) {
- long fetchTime = System.currentTimeMillis() - start;
+ long fetchTime = System.currentTimeMillis() - startTime;
Log.debug(result.size() + " saved searches fetched in: " + fetchTime + "ms");
DataSource dataSource = new DataSource();
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 2e371d9..a558db1 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -413,8 +413,11 @@ filter_from_date = From
filter_to_date = To
group_tree_groupOfResourceType = Group of [{0}]
group_tree_partialClusterTooltip = {0} out of {1} group members have a ''{2}'' resource
+search_failed_to_save_search = Failed to Save Search: {0}
search_failed_to_retrieve_saved_search = Failed to retrieve saved search
+search_failed_to_retrieve_search_suggestion = Failed to retrieve search suggestion
search_name_your_search = name you search
+search_successfully_saved_search = Successfully Saved Search: {0}
util_ancestry_parentAncestry = Parent Ancestry for:
util_errorHandler_nullException = exception was null
util_monitoringRequestCallback_error_checkServerStatusFailure = Unable to determine login status - check Server status.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index 275fe4d..b146b3d 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -432,8 +432,11 @@ filter_from_date = Od
filter_to_date = Do
group_tree_groupOfResourceType = Skupina: [{0}]
group_tree_partialClusterTooltip = {0} z {1} členů skupiny má "{2}" zdroj
+##search_failed_to_save_search = Failed to Save Search: {0}
##search_failed_to_retrieve_saved_search = Failed to retrieve saved search
+##search_failed_to_retrieve_search_suggestion = Failed to retrieve search suggestion
##search_name_your_search = name you search
+##search_successfully_saved_search = Successfully Saved Search: {0}
util_ancestry_parentAncestry = Původ rodiče pro:
util_errorHandler_nullException = výjimka byla null
util_monitoringRequestCallback_error_checkServerStatusFailure = Nepodařilo se určit stav přihlašování - zkontrolujte stav serveru.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index ddd07fd..7b9effe 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -397,8 +397,11 @@ filter_from_date = Von
filter_to_date = Bis
##group_tree_groupOfResourceType = Group of [{0}]
group_tree_partialClusterTooltip = {0} der {1} Gruppenmitglieder haben eine ''{2}'' Ressource
+##search_failed_to_save_search = Failed to Save Search: {0}
##search_failed_to_retrieve_saved_search = Failed to retrieve saved search
+##search_failed_to_retrieve_search_suggestion = Failed to retrieve search suggestion
##search_name_your_search = name you search
+##search_successfully_saved_search = Successfully Saved Search: {0}
util_disambiguationReportDecorator_pluginSuffix = ({0} Plugin)
util_errorHandler_nullException = Exception war null
##util_monitoringRequestCallback_error_checkServerStatusFailure = Unable to determine login status - check Server status.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 6eb5212..b7c191e 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -410,8 +410,11 @@ filter_from_date = 開始
filter_to_date = 終了
##group_tree_groupOfResourceType = Group of [{0}]
group_tree_partialClusterTooltip = {1} の中の {0} グループメンバーが ''{2}'' リソースを持っています
+##search_failed_to_save_search = Failed to Save Search: {0}
##search_failed_to_retrieve_saved_search = Failed to retrieve saved search
+##search_failed_to_retrieve_search_suggestion = Failed to retrieve search suggestion
##search_name_your_search = name you search
+##search_successfully_saved_search = Successfully Saved Search: {0}
util_ancestry_parentAncestry = 親の先祖 :
util_disambiguationReportDecorator_pluginSuffix = ({0} プラグイン)
util_errorHandler_nullException = 例外は null でした
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 900b847..72b2f34 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -416,8 +416,11 @@ favorites_resources = Recursos Favoritos
##filter_to_date = To
##group_tree_groupOfResourceType = Group of [{0}]
group_tree_partialClusterTooltip = {0} out of {1} group members have a ''{2}'' resource
+##search_failed_to_save_search = Failed to Save Search: {0}
##search_failed_to_retrieve_saved_search = Failed to retrieve saved search
+##search_failed_to_retrieve_search_suggestion = Failed to retrieve search suggestion
##search_name_your_search = name you search
+##search_successfully_saved_search = Successfully Saved Search: {0}
util_ancestry_parentAncestry = Ancestral para:
util_errorHandler_nullException = Exce\u00E7\u00E3o nula
util_monitoringRequestCallback_error_checkServerStatusFailure = Imposs\u00EDvel verificar o status do login - verifique o status do Servidor.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index 43abe46..5a44858 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -403,8 +403,11 @@
#filter_from_date = From
#filter_to_date = To
#group_tree_partialClusterTooltip = {0} out of {1} group members have a ''{2}'' resource
+##search_failed_to_save_search = Failed to Save Search: {0}
##search_failed_to_retrieve_saved_search = Failed to retrieve saved search
-##search_name_your_search = name you search
+##search_failed_to_retrieve_search_suggestion = Failed to retrieve search suggestion
+##search_name_your_search = name you searci
+##search_successfully_saved_search = Successfully Saved Search: {0}
#util_ancestry_parentAncestry = Parent Ancestry for:
#util_errorHandler_nullException = exception was null
#util_monitoringRequestCallback_error_checkServerStatusFailure = Unable to determine login status - check Server status.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 9f3fd76..6ae9e47 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -405,8 +405,11 @@ favorites_resources = \u8d44\u6e90\u6536\u85cf\u5939
##filter_to_date = To
##group_tree_groupOfResourceType = Group of [{0}]
group_tree_partialClusterTooltip = \u9664\u53bb {1},{0}\u7684\u7ec4\u6210\u5458\u62e5\u6709 \u4e00\u4e2a''{2}''\u8d44\u6e90
+##search_failed_to_save_search = Failed to Save Search: {0}
##search_failed_to_retrieve_saved_search = Failed to retrieve saved search
+##search_failed_to_retrieve_search_suggestion = Failed to retrieve search suggestion
##search_name_your_search = name you search
+##search_successfully_saved_search = Successfully Saved Search: {0}
util_ancestry_parentAncestry = Parent Ancestry for:
util_errorHandler_nullException = \u5f02\u5e38\u662f null
util_monitoringRequestCallback_error_checkServerStatusFailure = \u65e0\u6cd5\u786e\u5b9a\u767b\u5f55\u72b6\u6001- \u68c0\u67e5\u670d\u52a1\u5668\u72b6\u6001.
11 years, 9 months
[rhq] modules/enterprise
by lkrejci
modules/enterprise/scripting/javascript/src/main/java/org/rhq/scripting/javascript/engine/RhinoScriptEngine.java | 29 ++++++++++
modules/enterprise/scripting/javascript/src/test/java/org/rhq/scripting/javascript/EngineTest.java | 26 ++++++++
2 files changed, 55 insertions(+)
New commits:
commit f4484a83507fa1f45ea18e5862dceb376efeda1c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jul 31 00:24:17 2012 +0200
[BZ 844495] - Fixing the inconsistency in the string handling introduced by
Rhino 1.7R4. The new version of Rhino introduced some performance
optimizations in the script concatenation which confused the script engine,
which is based on the previous versions of Rhino.
diff --git a/modules/enterprise/scripting/javascript/src/main/java/org/rhq/scripting/javascript/engine/RhinoScriptEngine.java b/modules/enterprise/scripting/javascript/src/main/java/org/rhq/scripting/javascript/engine/RhinoScriptEngine.java
index e8069a6..0475ecb 100644
--- a/modules/enterprise/scripting/javascript/src/main/java/org/rhq/scripting/javascript/engine/RhinoScriptEngine.java
+++ b/modules/enterprise/scripting/javascript/src/main/java/org/rhq/scripting/javascript/engine/RhinoScriptEngine.java
@@ -78,6 +78,7 @@ import javax.script.SimpleBindings;
import javax.script.SimpleScriptContext;
import org.mozilla.javascript.Callable;
+import org.mozilla.javascript.ConsString;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.Function;
@@ -90,6 +91,7 @@ import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.Synchronizer;
import org.mozilla.javascript.Undefined;
+import org.mozilla.javascript.WrapFactory;
import org.mozilla.javascript.Wrapper;
import org.mozilla.javascript.commonjs.module.RequireBuilder;
import org.mozilla.javascript.commonjs.module.provider.ModuleSourceProvider;
@@ -123,6 +125,8 @@ import org.rhq.scripting.javascript.engine.util.InterfaceImplementor;
* Modified to include the "require()" function by default.
* Modified to tighten the security of the script execution by running it in an
* AccessControlContext active at the time of the script engine creation.
+ * Modified to allow correct interoperability between Java and javascript string even
+ * if represented by the custom ConsString instance.
*
* @author Lukas Krejci
*/
@@ -167,7 +171,30 @@ public class RhinoScriptEngine extends AbstractScriptEngine
//LK - added support for CommonJS modules
private RequireBuilder requireBuilder;
+ //LK - custom wrap factory to overcome the difficulties comparing java strings with ConsString instances
+ // introduced by Rhino 1.7R4.
+ private static class CustomWrapFactory extends WrapFactory {
+
+ /**
+ * This behaves exactly the same as the super class' method except the fact that
+ * the ConsString is considered "primitive" and is not wrapped in any manner.
+ * <p>
+ * This is then consistent with the rest of Rhino that expects ConsString as a possible
+ * implementation of the string.
+ */
+ @Override
+ public Object wrap(Context cx, Scriptable scope, Object obj, Class<?> staticType) {
+ if (obj instanceof ConsString) {
+ return obj;
+ }
+
+ return super.wrap(cx, scope, obj, staticType);
+ }
+ }
+
+
//LK - make all the scripts run in an access control context
+ //LK - use a custom wrap factory to overcome the ConsString being mishandled when transferring from java to js and back
static {
ContextFactory.initGlobal(new ContextFactory() {
@Override
@@ -193,9 +220,11 @@ public class RhinoScriptEngine extends AbstractScriptEngine
}
}
+ @Override
protected Context makeContext() {
Context cx = super.makeContext();
cx.setOptimizationLevel(-1);
+ cx.setWrapFactory(new CustomWrapFactory());
return cx;
}
diff --git a/modules/enterprise/scripting/javascript/src/test/java/org/rhq/scripting/javascript/EngineTest.java b/modules/enterprise/scripting/javascript/src/test/java/org/rhq/scripting/javascript/EngineTest.java
index 7ccde17..6aa9355 100644
--- a/modules/enterprise/scripting/javascript/src/test/java/org/rhq/scripting/javascript/EngineTest.java
+++ b/modules/enterprise/scripting/javascript/src/test/java/org/rhq/scripting/javascript/EngineTest.java
@@ -78,6 +78,32 @@ public class EngineTest {
assertEquals(captureScriptOutput(script), output, "Unexpected functions found in modules");
}
+ public void stringHandlingConsistent() throws Exception {
+ String script = "var a = \"str\"\n"
+ + "var b = \"str\"\n"
+ + "var test1 = a + b\n"
+ + "var test2 = \"strstr\"\n"
+ + "var test3 = new java.lang.String(\"strstr\")\n";
+
+ ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
+
+ engine.eval(script);
+
+ //now do the tests with the initialized context
+
+ Object ret = engine.eval("test1 == test2");
+ assertEquals(ret, Boolean.TRUE, "Unexpected concatenated and javascript string comparison.");
+
+ ret = engine.eval("test1 == test3");
+ assertEquals(ret, Boolean.TRUE, "Unexpected concatenated and java string comparison.");
+
+ ret = engine.eval("test2 == test3");
+ assertEquals(ret, Boolean.TRUE, "Unexpected javascript and java string comparison.");
+
+ ret = engine.eval("java.lang.Integer.parseInt('1' + '2');");
+ assertEquals(ret, 12, "Engine failed to pass a concatenated string as a string parameter.");
+ }
+
private ScriptEngine getScriptEngine() {
ScriptEngineManager manager = new ScriptEngineManager();
return manager.getEngineByName("rhino-nonjdk");
11 years, 9 months
[rhq] Branch 'release/jon3.1.x' - modules/plugins
by snegrea
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 1 -
1 file changed, 1 deletion(-)
New commits:
commit 1095d809d84c44a8daf5e875ec4f7080e1b30239
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 30 17:01:22 2012 -0500
Fix a merge error that introduced unnecessary characters.
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 f42b583..34616c2 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
@@ -769,7 +769,6 @@
</resource-configuration>
'>
-=======
<!ENTITY loginModuleResourceConfig '
<resource-configuration>
<c:simple-property name="code" required="true" type="string" readOnly="true"
11 years, 9 months