[rhq] Branch 'release-3.0.0' - modules/core
by ips
modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java | 15 ++++++++++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java | 7 +++-
2 files changed, 20 insertions(+), 2 deletions(-)
New commits:
commit 0a244b73f60b25b78ebc9378407e35867cf9e10c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Sep 20 14:58:44 2010 -0400
only ask discovery components for additional classpath URLs (i.e. client jars) if per-resource classloaders are enabled in the plugin container config
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java
index aec2353..ffaae5e 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/ClassLoaderManager.java
@@ -463,6 +463,21 @@ public class ClassLoaderManager {
return new HashMap<CanonicalResourceKey, ClassLoader>(this.resourceClassLoaders);
}
+ /**
+ * Returns <code>true</code> if this manager will create instances of classloaders for those
+ * individual Resources that require it, or <code>false</code> if this manager will never create
+ * individual classloaders for Resources (i.e. {@link #obtainResourceClassLoader(Resource, ResourceContainer, List)}
+ * will always just return plugin classloaders).
+ *
+ * @return <code>true</code> if this manager will create instances of classloaders for those
+ * individual Resources that require it, or <code>false</code> if this manager will never create
+ * individual classloaders for Resources (i.e. {@link #obtainResourceClassLoader(Resource, ResourceContainer, List)}
+ * will always just return plugin classloaders)
+ */
+ public boolean isCreateResourceClassLoaders() {
+ return this.createResourceClassLoaders;
+ }
+
private Set<ClassLoader> getUniquePluginClassLoaders() {
HashSet<ClassLoader> uniqueClassLoaders = new HashSet<ClassLoader>(this.pluginClassLoaders.values());
return uniqueClassLoaders;
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java
index 4176353..ca8eef6 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java
@@ -23,6 +23,7 @@
package org.rhq.core.pc.plugin;
import java.net.URL;
+import java.util.Collections;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -174,14 +175,16 @@ public class PluginComponentFactory implements ContainerService {
+ parentResource);
}
} else if (resource.equals(inventoryMgr.getPlatform())) {
- // the given resource is our top platform resource, just use its plugin classloader
+ // the given resource is our top platform resource - just use its plugin classloader
return classLoaderMgr.obtainPluginClassLoader(resourceType.getPlugin());
} else {
throw new PluginContainerException("Missing parent resource for resource=" + resource);
}
// get the classloader the resource should use
- List<URL> additionalJars = askDiscoveryComponentForAdditionalClasspathUrls(resource, parentContainer);
+ List<URL> additionalJars = (classLoaderMgr.isCreateResourceClassLoaders()) ?
+ askDiscoveryComponentForAdditionalClasspathUrls(resource, parentContainer) :
+ Collections.<URL>emptyList();
ClassLoader cl = classLoaderMgr.obtainResourceClassLoader(resource, parentContainer, additionalJars);
return cl;
} catch (Throwable t) {
13 years, 9 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
New commits:
commit a63b4bcd0ea05090acac14797f9e06d31e00c6b7
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 20 14:16:36 2010 -0400
use WIPE animation - seems to work faster than the FADE
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index a1303a1..0e3a899 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -224,7 +224,7 @@ public abstract class TableSection extends Table implements BookmarkableView {
protected void switchToDetailsView() {
Canvas contents = getTableContents();
if (contents != null) {
- contents.animateHide(AnimationEffect.FADE, new AnimationCallback() {
+ contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
@Override
public void execute(boolean b) {
detailsView.setWidth100();
@@ -232,7 +232,7 @@ public abstract class TableSection extends Table implements BookmarkableView {
detailsHolder.addMember(new BackButton(extendLocatorId("BackButton"), "Back to List", basePath));
detailsHolder.addMember(detailsView);
- detailsHolder.animateShow(AnimationEffect.FADE);
+ detailsHolder.animateShow(AnimationEffect.WIPE);
}
});
}
@@ -246,18 +246,18 @@ public abstract class TableSection extends Table implements BookmarkableView {
if (contents != null) {
if (detailsHolder != null && detailsHolder.isVisible()) {
- detailsHolder.animateHide(AnimationEffect.FADE, new AnimationCallback() {
+ detailsHolder.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
@Override
public void execute(boolean b) {
for (Canvas child : detailsHolder.getMembers()) {
child.destroy();
}
- contents.animateShow(AnimationEffect.FADE);
+ contents.animateShow(AnimationEffect.WIPE);
}
});
} else {
- contents.animateShow(AnimationEffect.FADE);
+ contents.animateShow(AnimationEffect.WIPE);
}
}
}
13 years, 9 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java | 90 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 227 +++++++++-
2 files changed, 287 insertions(+), 30 deletions(-)
New commits:
commit 665349f2a221a7aed276f67197ca9289fba322b2
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 20 13:05:03 2010 -0400
bz 535756 add the ability to create calltime conditions to an alert definition
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java
index 098e92a..14cb2c2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java
@@ -54,17 +54,40 @@ public class AlertFormatUtility {
break;
}
case THRESHOLD: {
- str.append("Metric Value Exceeds Threshold");
- str.append(" [");
- str.append(condition.getName());
- str.append(" ");
- str.append(condition.getComparator());
- str.append(" ");
double value = condition.getThreshold();
MeasurementUnits units = condition.getMeasurementDefinition().getUnits();
String formatted = MeasurementConverterClient.format(value, units, true);
- str.append(formatted);
- str.append("]");
+
+ if (condition.getOption() == null) {
+ str.append("Metric Value Exceeds Threshold");
+ str.append(" [");
+ str.append(condition.getName());
+ str.append(" ");
+ str.append(condition.getComparator());
+ str.append(" ");
+ str.append(formatted);
+ str.append("]");
+ } else {
+ // this is a calltime threshold condition
+ // the name of the metric is only obtainable by querying for the name from the meas def ID
+ // but since most times (all the time?) there is only one calltime metric per resource,
+ // not showing the metric name probably isn't detrimental
+ str.append("Calltime Value Exceeds Threshold");
+ str.append(" [");
+ str.append(condition.getOption()); // MIN, MAX, AVG (never null)
+ str.append(" ");
+ str.append(condition.getComparator()); // <, >, =
+ str.append(" ");
+ str.append(condition.getThreshold());
+ str.append("]");
+ if (condition.getName() != null && condition.getName().length() > 0) {
+ str.append(" ");
+ str.append("with call destination matching");
+ str.append(" '");
+ str.append(condition.getName());
+ str.append("'");
+ }
+ }
break;
}
case BASELINE: {
@@ -86,10 +109,39 @@ public class AlertFormatUtility {
break;
}
case CHANGE: {
- str.append("Metric Value Change");
- str.append(" [");
- str.append(condition.getName());
- str.append("]");
+ if (condition.getOption() == null) {
+ str.append("Metric Value Change");
+ str.append(" [");
+ str.append(condition.getName());
+ str.append("]");
+ } else {
+ // this is a calltime change condition
+ // the name of the metric is only obtainable by querying for the name from the meas def ID
+ // but since most times (all the time?) there is only one calltime metric per resource,
+ // not showing the metric name probably isn't detrimental
+ str.append("Calltime Value Changes");
+ str.append(" [");
+ str.append(condition.getOption()); // MIN, MAX, AVG (never null)
+ str.append(" ");
+ str.append(getCalltimeChangeComparator(condition.getComparator())); // LO, HI, CH
+ str.append(" ");
+ str.append("by at least");
+ str.append(" ");
+
+ double value = condition.getThreshold();
+ MeasurementUnits units = MeasurementUnits.PERCENTAGE;
+ String formatted = MeasurementConverterClient.format(value, units, true);
+ str.append(formatted);
+
+ str.append("]");
+ if (condition.getName() != null && condition.getName().length() > 0) {
+ str.append(" ");
+ str.append("with call destination matching");
+ str.append(" '");
+ str.append(condition.getName());
+ str.append("'");
+ }
+ }
break;
}
case TRAIT: {
@@ -122,9 +174,9 @@ public class AlertFormatUtility {
if (condition.getOption() != null && condition.getOption().length() > 0) {
str.append(" ");
str.append("matching");
- str.append(" [");
+ str.append(" '");
str.append(condition.getOption());
- str.append("]");
+ str.append("'");
}
break;
}
@@ -136,6 +188,16 @@ public class AlertFormatUtility {
return str.toString();
}
+ private static String getCalltimeChangeComparator(String comparator) {
+ if ("HI".equals(comparator)) {
+ return "Grows";
+ } else if ("LO".equals(comparator)) {
+ return "Shrinks";
+ } else { // CH
+ return "Changes";
+ }
+ }
+
public static String getAlertRecoveryInfo(Alert alert) {
String recoveryInfo;
AlertDefinition recoveryAlertDefinition = alert.getRecoveryAlertDefinition();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 7e81a0e..3fcc64e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -58,6 +58,11 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class NewConditionEditor extends LocatableDynamicForm {
+ // these aren't "real" calltime condition categories (not real AlertConditionCategory enums)
+ // but we need these values for the drop down menu selections
+ private static final String ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE = "calltime-change";
+ private static final String ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD = "calltime-threshold";
+
private static final String AVAILABILITY_ITEMNAME = "availability";
private static final String THRESHOLD_METRIC_ITEMNAME = "thresholdMetric";
private static final String THRESHOLD_COMPARATOR_ITEMNAME = "thresholdComparator";
@@ -67,6 +72,16 @@ public class NewConditionEditor extends LocatableDynamicForm {
private static final String BASELINE_PERCENTAGE_ITEMNAME = "baselinePercentage";
private static final String BASELINE_SELECTION_ITEMNAME = "baselineSelection";
private static final String CHANGE_METRIC_ITEMNAME = "changeMetric";
+ private static final String CALLTIME_THRESHOLD_METRIC_ITEMNAME = "calltimeThresholdMetric";
+ private static final String CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME = "calltimeThresholdMinMaxAvgSelection";
+ private static final String CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME = "calltimeThresholdComparator";
+ private static final String CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME = "calltimeThresholdAbsoluteValue";
+ private static final String CALLTIME_THRESHOLD_REGEX_ITEMNAME = "calltimeThresholdRegex";
+ private static final String CALLTIME_CHANGE_METRIC_ITEMNAME = "calltimeChangeMetric";
+ private static final String CALLTIME_CHANGE_MINMAXAVG_ITEMNAME = "calltimeChangeMinMaxAvgSelection";
+ private static final String CALLTIME_CHANGE_COMPARATOR_ITEMNAME = "calltimeChangeComparator";
+ private static final String CALLTIME_CHANGE_PERCENTAGE_ITEMNAME = "calltimeChangePercentageValue";
+ private static final String CALLTIME_CHANGE_REGEX_ITEMNAME = "calltimeChangeRegex";
private static final String TRAIT_METRIC_ITEMNAME = "trait";
private static final String OPERATION_NAME_ITEMNAME = "operation";
private static final String OPERATION_RESULTS_ITEMNAME = "operationResults";
@@ -76,6 +91,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem conditionTypeSelectItem;
private HashSet<AlertCondition> conditions; // the new condition we create goes into this set
private boolean supportsMetrics = false;
+ private boolean supportsCalltimeMetrics = false;
private boolean supportsTraits = false;
private boolean supportsOperations = false;
private boolean supportsEvents = false;
@@ -101,6 +117,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
this.supportsMetrics = true;
break;
}
+ case CALLTIME: {
+ this.supportsCalltimeMetrics = true;
+ break;
+ }
case TRAIT: {
this.supportsTraits = true;
break;
@@ -132,6 +152,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
condTypes.put(AlertConditionCategory.BASELINE.name(), "Measurement Baseline Threshold");
condTypes.put(AlertConditionCategory.CHANGE.name(), "Measurement Value Change");
}
+ if (supportsCalltimeMetrics) {
+ condTypes.put(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD, "Calltime Value Threshold");
+ condTypes.put(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE, "Calltime Value Change");
+ }
if (supportsTraits) {
condTypes.put(AlertConditionCategory.TRAIT.name(), "Trait Value Change");
}
@@ -176,6 +200,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
formItems.addAll(buildMetricBaselineFormItems());
formItems.addAll(buildMetricChangeFormItems());
}
+ if (supportsCalltimeMetrics) {
+ formItems.addAll(buildCalltimeThresholdFormItems());
+ formItems.addAll(buildCalltimeChangeFormItems());
+ }
if (supportsTraits) {
formItems.addAll(buildTraitChangeFormItems());
}
@@ -194,8 +222,20 @@ public class NewConditionEditor extends LocatableDynamicForm {
};
private void saveNewCondition() {
- AlertConditionCategory category;
- category = AlertConditionCategory.valueOf(conditionTypeSelectItem.getValue().toString());
+ final boolean calltimeCategory;
+ final AlertConditionCategory category;
+
+ String selectedCategory = conditionTypeSelectItem.getValue().toString();
+ if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD)) {
+ calltimeCategory = true;
+ category = AlertConditionCategory.THRESHOLD;
+ } else if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE)) {
+ calltimeCategory = true;
+ category = AlertConditionCategory.CHANGE;
+ } else {
+ calltimeCategory = false;
+ category = AlertConditionCategory.valueOf(selectedCategory);
+ }
AlertCondition newCondition = new AlertCondition();
newCondition.setCategory(category);
@@ -211,12 +251,21 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
case THRESHOLD: {
- MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME));
- newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
- newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME)));
- newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME));
- newCondition.setOption(null);
- newCondition.setMeasurementDefinition(measDef);
+ if (!calltimeCategory) {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME)));
+ newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME));
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ } else {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_THRESHOLD_METRIC_ITEMNAME));
+ newCondition.setName(getValueAsString(CALLTIME_THRESHOLD_REGEX_ITEMNAME));
+ newCondition.setThreshold(Double.valueOf(getValueAsString(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME)));
+ newCondition.setComparator(getValueAsString(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME));
+ newCondition.setOption(getValueAsString(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME));
+ newCondition.setMeasurementDefinition(measDef);
+ }
break;
}
@@ -231,12 +280,22 @@ public class NewConditionEditor extends LocatableDynamicForm {
}
case CHANGE: {
- MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME));
- newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
- newCondition.setComparator(null);
- newCondition.setThreshold(null);
- newCondition.setOption(null);
- newCondition.setMeasurementDefinition(measDef);
+ if (!calltimeCategory) {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME));
+ newCondition.setName(measDef.getDisplayName()); // TODO should not use display name
+ newCondition.setComparator(null);
+ newCondition.setThreshold(null);
+ newCondition.setOption(null);
+ newCondition.setMeasurementDefinition(measDef);
+ } else {
+ MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_CHANGE_METRIC_ITEMNAME));
+ newCondition.setName(getValueAsString(CALLTIME_CHANGE_REGEX_ITEMNAME));
+ newCondition
+ .setThreshold(Double.valueOf(getValueAsString(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME)) / 100.0);
+ newCondition.setComparator(getValueAsString(CALLTIME_CHANGE_COMPARATOR_ITEMNAME));
+ newCondition.setOption(getValueAsString(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME));
+ newCondition.setMeasurementDefinition(measDef);
+ }
break;
}
@@ -360,6 +419,97 @@ public class NewConditionEditor extends LocatableDynamicForm {
return formItems;
}
+ private ArrayList<FormItem> buildCalltimeThresholdFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD);
+
+ String helpStr = "Specify the calltime threshold value that, when violated, triggers the condition. The value you specify is an absolute value with an optional units specifier. You also must specify which calltime limit to compare the value with (minimum, maximum or average calltime value).";
+ StaticTextItem helpItem = buildHelpTextItem("calltimeThresholdHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ formItems.add(buildCalltimeMetricDropDownMenu(CALLTIME_THRESHOLD_METRIC_ITEMNAME, ifFunc));
+
+ SelectItem minMaxAvgSelection = new SelectItem(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME, "Calltime Limit");
+ LinkedHashMap<String, String> limits = new LinkedHashMap<String, String>(3);
+ limits.put("MIN", "Minimum");
+ limits.put("AVG", "Average");
+ limits.put("MAX", "Maximum");
+ minMaxAvgSelection.setTooltip("The calltime limit value that is to be compared with the given value");
+ minMaxAvgSelection.setValueMap(limits);
+ minMaxAvgSelection.setDefaultValue("AVG");
+ minMaxAvgSelection.setWrapTitle(false);
+ minMaxAvgSelection.setWidth("*");
+ minMaxAvgSelection.setRedrawOnChange(true);
+ minMaxAvgSelection.setShowIfCondition(ifFunc);
+ formItems.add(minMaxAvgSelection);
+
+ formItems.add(buildComparatorDropDownMenu(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME, ifFunc));
+ TextItem absoluteValue = new TextItem(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME, "Calltime Value");
+ absoluteValue.setWrapTitle(false);
+ absoluteValue.setRequired(true);
+ absoluteValue
+ .setTooltip("The threshold value of the metric that will trigger the condition when compared using the selected comparator.");
+ absoluteValue.setShowIfCondition(ifFunc);
+ formItems.add(absoluteValue);
+
+ TextItem regex = new TextItem(CALLTIME_THRESHOLD_REGEX_ITEMNAME, "Regular Expression");
+ regex.setRequired(false);
+ regex
+ .setTooltip("If specified, this is a regular expression that must match a call destination in order to trigger the condition.");
+ regex.setWrapTitle(false);
+ regex.setShowIfCondition(ifFunc);
+ formItems.add(regex);
+
+ return formItems;
+ }
+
+ private ArrayList<FormItem> buildCalltimeChangeFormItems() {
+ ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+ ShowIfCategoryFunction ifFunc = new ShowIfCategoryFunction(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE);
+
+ String helpStr = "Specify the calltime value that, when changed at least a specified amount, triggers the condition. You must specify which calltime limit to check (minimum, maximum or average calltime value) and the percentage of change that must occur.";
+ StaticTextItem helpItem = buildHelpTextItem("calltimeChangeHelp", helpStr, ifFunc);
+ formItems.add(helpItem);
+
+ formItems.add(buildCalltimeMetricDropDownMenu(CALLTIME_CHANGE_METRIC_ITEMNAME, ifFunc));
+
+ SelectItem minMaxAvgSelection = new SelectItem(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME, "Calltime Limit");
+ LinkedHashMap<String, String> limits = new LinkedHashMap<String, String>(3);
+ limits.put("MIN", "Minimum");
+ limits.put("AVG", "Average");
+ limits.put("MAX", "Maximum");
+ minMaxAvgSelection.setTooltip("The calltime limit value that is to be checked for change");
+ minMaxAvgSelection.setValueMap(limits);
+ minMaxAvgSelection.setDefaultValue("AVG");
+ minMaxAvgSelection.setWrapTitle(false);
+ minMaxAvgSelection.setWidth("*");
+ minMaxAvgSelection.setRedrawOnChange(true);
+ minMaxAvgSelection.setShowIfCondition(ifFunc);
+ formItems.add(minMaxAvgSelection);
+
+ formItems.add(buildCalltimeComparatorDropDownMenu(CALLTIME_CHANGE_COMPARATOR_ITEMNAME, ifFunc));
+
+ TextItem percentage = new TextItem(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME, "Percentage Change");
+ percentage.setWrapTitle(false);
+ percentage.setRequired(true);
+ percentage
+ .setTooltip("A collected calltime value will trigger this condition when it differs by at least this percentage of the selected calltime limit value");
+ percentage.setShowIfCondition(ifFunc);
+ formItems.add(percentage);
+
+ TextItem regex = new TextItem(CALLTIME_CHANGE_REGEX_ITEMNAME, "Regular Expression");
+ regex.setRequired(false);
+ regex
+ .setTooltip("If specified, this is a regular expression that must match a call destination in order to trigger the condition.");
+ regex.setWrapTitle(false);
+ regex.setShowIfCondition(ifFunc);
+ formItems.add(regex);
+
+ return formItems;
+ }
+
private ArrayList<FormItem> buildTraitChangeFormItems() {
ArrayList<FormItem> formItems = new ArrayList<FormItem>();
@@ -510,9 +660,27 @@ public class NewConditionEditor extends LocatableDynamicForm {
return metricSelection;
}
+ private SelectItem buildCalltimeMetricDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
+
+ LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String, String>();
+ for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ if (def.getDataType() == DataType.CALLTIME) {
+ metricsMap.put(def.getName(), def.getDisplayName());
+ }
+ }
+
+ SelectItem metricSelection = new SelectItem(itemName, "Metric");
+ metricSelection.setValueMap(metricsMap);
+ metricSelection.setDefaultValue(metricsMap.keySet().iterator().next()); // just use the first one
+ metricSelection.setWidth("*");
+ metricSelection.setRedrawOnChange(true);
+ metricSelection.setShowIfCondition(ifFunc);
+ return metricSelection;
+ }
+
private SelectItem buildComparatorDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
- LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>();
+ LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>(3);
comparators.put("<", "< (Less than)");
comparators.put("=", "= (Equal to)");
comparators.put(">", "> (Greater than)");
@@ -525,6 +693,21 @@ public class NewConditionEditor extends LocatableDynamicForm {
return comparatorSelection;
}
+ private SelectItem buildCalltimeComparatorDropDownMenu(String itemName, FormItemIfFunction ifFunc) {
+
+ LinkedHashMap<String, String> comparators = new LinkedHashMap<String, String>(3);
+ comparators.put("LO", "Shrinks");
+ comparators.put("CH", "Changes");
+ comparators.put("HI", "Grows");
+
+ SelectItem comparatorSelection = new SelectItem(itemName, "Comparator");
+ comparatorSelection.setValueMap(comparators);
+ comparatorSelection.setDefaultValue("CH");
+ comparatorSelection.setTooltip("How a collected calltime value should be compared to the given calltime limit");
+ comparatorSelection.setShowIfCondition(ifFunc);
+ return comparatorSelection;
+ }
+
private StaticTextItem buildHelpTextItem(String itemName, String helpText, FormItemIfFunction ifFunc) {
StaticTextItem help = new StaticTextItem(itemName);
help.setShowTitle(false);
@@ -548,13 +731,25 @@ public class NewConditionEditor extends LocatableDynamicForm {
private class ShowIfCategoryFunction implements FormItemIfFunction {
private final AlertConditionCategory category;
+ private final String calltimeCategory;
public ShowIfCategoryFunction(AlertConditionCategory category) {
this.category = category;
+ this.calltimeCategory = null;
+ }
+
+ public ShowIfCategoryFunction(String calltimeCategory) {
+ this.category = null;
+ this.calltimeCategory = calltimeCategory;
}
public boolean execute(FormItem item, Object value, DynamicForm form) {
- return category.name().equals(form.getValue("conditionType").toString());
+ String conditionTypeString = form.getValue("conditionType").toString();
+ if (category != null) {
+ return category.name().equals(conditionTypeString);
+ } else {
+ return calltimeCategory.equals(conditionTypeString);
+ }
}
}
}
13 years, 9 months
[rhq] modules/core
by mazz
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java | 20 ++++++----
1 file changed, 13 insertions(+), 7 deletions(-)
New commits:
commit d4a02cc3c2fb7e999fede59f3813357e6b0e79ec
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Sep 20 09:19:34 2010 -0400
add more javadocs to explain what the fields are for calltime alert conditions
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
index 3218d9d..640648b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertCondition.java
@@ -390,6 +390,8 @@ public class AlertCondition implements Serializable {
* THRESHOLD: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
* BASELINE: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
* CHANGE: the name of the metric (TODO: today its the display name, very bad for i18n purposes)
+ * OR (for calltime alert conditions only) this will be the optional regular expression condition
+ * (which may be null)
* TRAIT: the name of the trait (TODO: today its the display name, very bad for i18n purposes)
* CONTROL: the name of the operation (not its display name)
* EVENT: the level of event to compare with (DEBUG, INFO, WARN, ERROR, FATAL)
@@ -405,11 +407,14 @@ public class AlertCondition implements Serializable {
}
/**
- * One of these comparators: "<", ">" or "=".
- * This will be null if the condition does not compare values. Only THRESHOLD
- * and BASELINE condition categories use comparators; other types of conditions
- * will return <code>null</code>.
+ * Will be one of these comparators: "<", ">" or "=" but only for THRESHOLD
+ * and BASELINE condition categories. For calltime alert conditions (i.e. category
+ * CHANGE for calltime metric definitions), comparator will be one of these
+ * comparators: "HI", "LO", "CH" (where "CH" means "change").
*
+ * Other types of conditions will return <code>null</code> (i.e. this will be
+ * null if the condition does not compare values).
+ *
* @return comparator string
*/
public String getComparator() {
@@ -422,7 +427,8 @@ public class AlertCondition implements Serializable {
/**
* Returns the threshold to compare a measurement value to see if the condition is true.
- * This is only valid for conditions of category THRESHOLD and BASELINE. All other
+ * This is only valid for conditions of category THRESHOLD, BASELINE and CHANGE (but
+ * only where CHANGE is for a calltime metric alert condition). All other
* condition types will return <code>null</code>.
*
* @return threshold value or null
@@ -438,9 +444,9 @@ public class AlertCondition implements Serializable {
/**
* The option string is optional and its semantics differ based on the category of this condition:
* AVAILABILITY: the {@link AvailabilityType} to trigger off of (DOWN or UP)
- * THRESHOLD: n/a
+ * THRESHOLD: for calltime metric conditions, one of "MIN, "MAX", "AVG" - all others are n/a
* BASELINE: one of "min", "max" or "mean" - indicates what the threshold is compared to (min/max/avg baseline value)
- * CHANGE: n/a
+ * CHANGE: for calltime metric conditions, one of "MIN, "MAX", "AVG" - all others are n/a
* TRAIT: n/a
* CONTROL: the {@link OperationRequestStatus} name (SUCCESS, FAILURE, etc).
* EVENT: the regular expression of the message to match (which may be empty string if not specified)
13 years, 9 months
[rhq] modules/enterprise
by fdrabek
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
New commits:
commit 24ba99780531d2f187528d7b555d79fab807467b
Author: Filip Drabek <fdrabek(a)dhcp-lab-136.englab.brq.redhat.com>
Date: Mon Sep 20 13:47:47 2010 +0200
BZ - 617603,617649,617653 - permission checks.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index cb17046..d4451bc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -985,7 +985,7 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
// make sure the user has the proper permissions to do this
Resource resource = doomedRequest.getResource();
- if (!authorizationManager.hasResourcePermission(subject, Permission.CONFIGURE_WRITE, resource.getId())) {
+ if (!authorizationManager.hasResourcePermission(subject, Permission.MODIFY_RESOURCE, resource.getId())) {
throw new PermissionException("User [" + subject.getName()
+ "] does not have permission to purge a configuration update audit trail for resource [" + resource
+ "]");
@@ -1909,10 +1909,10 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
public int deleteGroupResourceConfigurationUpdates(Subject subject, Integer resourceGroupId,
Integer[] groupResourceConfigurationUpdateIds) {
- if (authorizationManager.hasGroupPermission(subject, Permission.CONFIGURE_WRITE, resourceGroupId) == false) {
+ if (authorizationManager.hasGroupPermission(subject, Permission.MODIFY_RESOURCE, resourceGroupId) == false) {
log.error(subject + " attempted to delete " + groupResourceConfigurationUpdateIds.length
+ " group resource configuration updates for ResourceGroup[id" + resourceGroupId
- + "], but did not have the " + Permission.CONFIGURE_WRITE.name() + " permission for this group");
+ + "], but did not have the " + Permission.MODIFY_RESOURCE.name() + " permission for this group");
return 0;
}
@@ -1983,7 +1983,7 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
GroupPluginConfigurationUpdate update = getGroupPluginConfigurationById(configurationUpdateId);
int groupId = update.getGroup().getId();
- if (authorizationManager.hasGroupPermission(subject, Permission.CONFIGURE_READ, groupId) == false) {
+ if (authorizationManager.hasGroupPermission(subject, Permission.MODIFY_RESOURCE, groupId) == false) {
throw new PermissionException("User[" + subject.getName()
+ "] does not have permission to view group resourceConfiguration[id=" + configurationUpdateId + "]");
}
13 years, 9 months
[rhq] Branch 'perftest' - 2 commits - modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java | 81 +++++++++-
1 file changed, 73 insertions(+), 8 deletions(-)
New commits:
commit 988b64b3c57d2e493c088cd6f9b6de492b4b4e18
Merge: fd6e467... 0fa40ba...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Sep 20 12:36:10 2010 +0200
Merge branch 'perftest' of ssh://git.fedorahosted.org/git/rhq/rhq into perftest
commit fd6e4675561cbe9a5b1718c40f9ee654edd716fe
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Sep 20 12:11:27 2010 +0200
Enable back some tests.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
index 288cf69..00193d5 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
@@ -68,6 +68,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
private Agent theAgent;
private Resource theResource;
private ResourceType theResourceType;
+ private List<Resource> additionalResources;
private Availability availability1;
private Availability availability2;
private Availability availability3;
@@ -81,6 +82,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
this.resourceAvailabilityManager = LookupUtil.getResourceAvailabilityManager();
this.resourceManager = LookupUtil.getResourceManager();
this.overlord = LookupUtil.getSubjectManager().getOverlord();
+ additionalResources = new ArrayList<Resource>();
} catch (Throwable t) {
// Catch RuntimeExceptions and Errors and dump their stack trace, because Surefire will completely swallow them
// and throw a cryptic NPE (see http://jira.codehaus.org/browse/SUREFIRE-157)!
@@ -100,6 +102,19 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
theResource = null;
}
+ if (additionalResources!=null) {
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+
+ for (Resource res : additionalResources) {
+ Resource res2 = em.find(Resource.class, res.getId());
+ resourceManager.uninventoryResource(overlord, res2.getId());
+ resourceManager.uninventoryResourceAsyncWork(overlord, res2.getId());
+
+ }
+ getTransactionManager().commit();
+ }
+
if (theResourceType != null) {
getTransactionManager().begin();
EntityManager em = getEntityManager();
@@ -121,6 +136,55 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
@SuppressWarnings("unchecked")
@Test(enabled = true)
+ public void testInsertPastAvailabilities() throws Exception {
+ Date now = new Date();
+ Date middle = new Date(now.getTime() - 30000); // 30s ago
+ Date then = new Date(now.getTime() - 60000); // 60s ago
+
+ EntityManager em = beginTx();
+
+ try {
+ setupResource(em);
+ commitAndClose(em);
+
+ Availability aThen = new Availability(theResource, then, AvailabilityType.UP);
+ aThen.setEndTime(middle);
+
+ Availability aMiddle = new Availability(theResource, middle, AvailabilityType.DOWN);
+ aMiddle.setEndTime(now);
+
+ Availability aNow = new Availability(theResource, now, AvailabilityType.UP);
+
+ /*
+ * Simulate a report (aMiddle) that came in late (e.g. because of sorting
+ * issues on the agent or because of a network blip anyway. Expectation is
+ * that it gets just inserted in the middle.
+ */
+ persistAvailability(aThen);
+ persistAvailability(aNow);
+ persistAvailability(aMiddle);
+
+ em = beginTx();
+ Query q = em.createNamedQuery(Availability.FIND_BY_RESOURCE);
+ q.setParameter("resourceId", theResource.getId());
+ List<Availability> avails = q.getResultList();
+
+ assert avails.size()==2 : "Did not get 2 availabilities but " + avails.size(); // TODO Wrong assumption ?
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ } finally {
+ if (em != null) {
+ getTransactionManager().rollback();
+ em.close();
+ }
+ }
+ }
+
+
+ @SuppressWarnings("unchecked")
+ @Test(enabled = true)
public void testPurgeAvailabilities() throws Exception {
Date now = new Date();
Date middle = new Date(now.getTime() - 30000); // 30s ago
@@ -186,7 +250,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = ENABLE_TESTS)
+ @Test(enabled = true)
public void testGetAvailabilities() throws Exception {
EntityManager em = beginTx();
@@ -321,7 +385,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = ENABLE_TESTS)
+ @Test(enabled = true)
public void testSetAllAgentResourceAvailabilities() throws Exception {
EntityManager em = beginTx();
@@ -352,7 +416,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = ENABLE_TESTS)
+ @Test(enabled = true)
public void testAgentBackfillNewResource() throws Exception {
EntityManager em = beginTx();
@@ -572,7 +636,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = ENABLE_TESTS)
+ @Test(enabled = true)
public void testAgentOldReport() throws Exception {
EntityManager em = beginTx();
@@ -660,7 +724,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = ENABLE_TESTS)
+ @Test(enabled = true)
public void testAgentOldReport2() throws Exception {
EntityManager em = beginTx();
@@ -720,7 +784,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = ENABLE_TESTS)
+ @Test(enabled = true)
public void testGetAvailabilities2() throws Exception {
EntityManager em = beginTx();
@@ -808,7 +872,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
*
* @throws Exception in case of error
*/
- @Test(enabled = ENABLE_TESTS)
+ @Test(enabled = true)
public void testMergeReport() throws Exception {
EntityManager em = beginTx();
@@ -880,7 +944,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
}
}
- @Test(enabled = ENABLE_TESTS)
+ @Test(enabled = true)
public void testMergeReportPerformance() throws Exception {
EntityManager em = beginTx();
List<Resource> allResources = new ArrayList<Resource>();
@@ -1085,6 +1149,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
newResource.setAgent(theAgent);
parentResource.addChildResource(newResource);
em.persist(newResource);
+ additionalResources.add(newResource);
return newResource;
}
13 years, 9 months
[rhq] Branch 'nagios' - modules/plugins
by Heiko W. Rupp
modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorDiscovery.java | 30 +++++++---
1 file changed, 22 insertions(+), 8 deletions(-)
New commits:
commit 66b41a0096182b70463e2414efd5dc3ebdceac72
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Sep 20 12:28:20 2010 +0200
Allow for autodiscovery of NagiosMonitor (server) types while RHQ UI is in rework.
diff --git a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorDiscovery.java b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorDiscovery.java
index fc592fa..594faac 100644
--- a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorDiscovery.java
+++ b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorDiscovery.java
@@ -33,7 +33,6 @@ import org.rhq.core.pluginapi.inventory.ManualAddFacet;
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.nagios.NagiosMonitorComponent;
import org.rhq.plugins.nagios.network.NetworkConnection;
import org.rhq.plugins.nagios.reply.LqlReply;
import org.rhq.plugins.nagios.request.LqlResourceTypeRequest;
@@ -56,17 +55,13 @@ public class NagiosMonitorDiscovery implements ResourceDiscoveryComponent, Manua
public DiscoveredResourceDetails discoverResource(Configuration configuration,
ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException {
- String nagiosHost = configuration.getSimpleValue("nagiosHost", NagiosMonitorComponent.DEFAULT_NAGIOSIP);
- String nagiosPort = configuration.getSimpleValue("nagiosPort", NagiosMonitorComponent.DEFAULT_NAGIOSPORT);
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(),
- "nagios@" + nagiosHost + ":" + nagiosPort, "Nagios@" + nagiosHost + ":" + nagiosPort, null,
- "Nagios server @ " + nagiosHost + ":" + nagiosPort, configuration, null);
+ DiscoveredResourceDetails detail = createNagiosMonitorServerDetail(configuration, resourceDiscoveryContext);
log.info("Adding NagiosMonitor " + detail);
return detail;
}
+
/**
* Don run the auto-discovery for the services below the NagiosMonitor server type.
*/
@@ -75,9 +70,16 @@ public class NagiosMonitorDiscovery implements ResourceDiscoveryComponent, Manua
// If we have no parent, it means the NagiosMonitoring server type is not yet up.
ResourceComponent tmpComponent = discoveryContext.getParentResourceComponent();
- if (tmpComponent == null || !(tmpComponent instanceof NagiosMonitorComponent))
+ if (tmpComponent == null || !(tmpComponent instanceof NagiosMonitorComponent)) {
+
+ // Temporarily allow autodiscovery of NagiosMonitor server type, while RHQ 4 ui work is going on
+ discoveredResources.add(
+ createNagiosMonitorServerDetail(discoveryContext.getDefaultPluginConfiguration(),discoveryContext));
return discoveredResources;
+ }
+
+
NagiosMonitorComponent parentComponent = (NagiosMonitorComponent) tmpComponent;
String nagiosHost = parentComponent.getNagiosHost();
int nagiosPort = parentComponent.getNagiosPort();
@@ -109,6 +111,18 @@ public class NagiosMonitorDiscovery implements ResourceDiscoveryComponent, Manua
return discoveredResources;
}
+ private DiscoveredResourceDetails createNagiosMonitorServerDetail(Configuration configuration,
+ ResourceDiscoveryContext resourceDiscoveryContext) {
+ String nagiosHost = configuration.getSimpleValue("nagiosHost", NagiosMonitorComponent.DEFAULT_NAGIOSIP);
+ String nagiosPort = configuration.getSimpleValue("nagiosPort", NagiosMonitorComponent.DEFAULT_NAGIOSPORT);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(),
+ "nagios@" + nagiosHost + ":" + nagiosPort, "Nagios@" + nagiosHost + ":" + nagiosPort, null,
+ "Nagios server @ " + nagiosHost + ":" + nagiosPort, configuration, null);
+ return detail;
+ }
+
+
/**
* Don't run the auto-discovery of this "nagios" server type,
* as we probably won't have one on each platform. Rather have the admin
13 years, 9 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java | 23 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 38 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 111 ++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java | 129 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java | 45 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java | 50 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java | 17 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java | 64 +++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java | 45 +--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java | 45 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java | 26 +-
17 files changed, 420 insertions(+), 209 deletions(-)
New commits:
commit c7986f9c539a6f93002eb02a846692ed09ddcc10
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Sep 17 17:44:30 2010 -0400
Work on Group CRUD
- Group category now determined on the fly, a la group def calculation,
by group membership. This means a manually group can change category
in its lifetime by editing the membership. That may be less important
than the fact that it simplifies initial creation and users really
only have to care about adding members.
- Added basic support for mixed-group tree/detail view. Just enough to
get us moving.
- Added Inventory->Membership subtab for changing group members.
- Changed ResourceManagerLocal.ensureMembershipMatches() to .setMembership()
The name is cleaner and in line with naming for a series of new
calls that simply syncs associated data to be the set passed in. Also,
optionally can reset the group's category based on the membership change.
- A couple of locatorId fixes in touched files
-
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
index c4a4bca..333427f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGroupGWTService.java
@@ -34,23 +34,26 @@ import org.rhq.core.domain.util.PageList;
@RemoteServiceRelativePath("ResourceGroupGWTService")
public interface ResourceGroupGWTService extends RemoteService {
- PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria);
+ GroupDefinition createGroupDefinition(GroupDefinition groupDefinition);
- PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria);
+ ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds);
- PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria);
+ void deleteGroupDefinitions(int[] groupDefinitionIds);
- void ensureMembershipMatches(int groupId, int[] resourceIds);
+ void deleteResourceGroups(int[] groupIds);
- ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds);
+ PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria);
- void deleteResourceGroups(int[] groupIds);
+ PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria);
- void updateResourceGroup(ResourceGroup group);
+ PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria);
+
+ void setMembership(int groupId, int[] resourceIds, boolean setType);
void updateGroupDefinition(GroupDefinition groupDefinition);
- void deleteGroupDefinitions(int[] groupDefinitionIds);
+ void updateResourceGroup(ResourceGroup group);
- GroupDefinition createGroupDefinition(GroupDefinition groupDefinition);
-}
+ void updateResourceGroup(ResourceGroup group, boolean updateMembership);
+
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 128dff8..6603a00 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -45,6 +45,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
import org.rhq.enterprise.gui.coregui.client.inventory.common.event.EventCompositeHistoryView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.ResourceGroupMembershipView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.OverviewView;
@@ -52,10 +53,9 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchVi
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/**
- * Right panel of the group view.
+ * Be able to view members as a resource list, or edit members via selector.
*
- * @author Greg Hinkle
- * @author Ian Springer
+ * @author Jay Shaughnessy
*/
public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<ResourceGroupComposite, ResourceGroupTitleBar> {
private static final String BASE_VIEW_PATH = "ResourceGroup";
@@ -83,6 +83,7 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
private SubTab monitorCallTime;
private SubTab inventoryMembers;
private SubTab inventoryConn;
+ private SubTab inventoryMembership;
private SubTab opHistory;
private SubTab opSched;
private SubTab alertHistory;
@@ -91,12 +92,24 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
private SubTab configHistory;
private SubTab eventHistory;
+ private String currentTab;
+ private String currentSubTab;
+
public ResourceGroupDetailView(String locatorId) {
super(locatorId, BASE_VIEW_PATH);
}
@Override
public Integer getSelectedItemId() {
+ // if moving from membership subtab then re-load the detail view as the membership and
+ // group type may have changed.
+ if (this.inventoryTab.getTitle().equals(currentTab)
+ && this.inventoryMembership.getTitle().equals(currentSubTab)) {
+ this.currentTab = null;
+ this.currentSubTab = null;
+ this.groupId = null;
+ }
+
return this.groupId;
}
@@ -130,7 +143,8 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
"/images/icons/Inventory_grey_16.png");
inventoryMembers = new SubTab(inventoryTab.extendLocatorId("Members"), "Members", null);
inventoryConn = new SubTab(inventoryTab.extendLocatorId("ConnectionSettings"), "Connection Settings", null);
- inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn);
+ inventoryMembership = new SubTab(inventoryTab.extendLocatorId("Membership"), "Membership", null);
+ inventoryTab.registerSubTabs(this.inventoryMembers, this.inventoryConn, this.inventoryMembership);
tabs.add(inventoryTab);
operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), "Operations",
@@ -184,9 +198,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
this.monitorSched.setCanvas(new SchedulesView(this.monitoringTab.extendLocatorId("SchedulesView"), groupId));
this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/group/monitor/response-plain.xhtml?groupId=" + groupId));
- this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(groupId));
+ this.inventoryMembers.setCanvas(ResourceSearchView.getMembersOf(this.inventoryTab
+ .extendLocatorId("MembersView"), groupId));
// TODO: Uncomment this once the group config component is done.
//this.inventoryConn.setCanvas(new GroupPluginConfigurationEditView(this.group.getId(), this.group.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin));
+ this.inventoryMembership.setCanvas(new ResourceGroupMembershipView(this.inventoryTab
+ .extendLocatorId("MembershipView"), groupId));
this.opHistory.setCanvas(new FullHTMLPane("/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId="
+ groupId));
@@ -290,6 +307,9 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
});
}
});
+ } else {
+ updateTabContent(groupComposite);
+ selectTab(getTabName(), getSubTabName(), viewPath);
}
}
@@ -305,4 +325,12 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
}
return false;
}
+
+ @Override
+ public void selectTab(String tabTitle, String subtabTitle, ViewPath viewPath) {
+ currentTab = tabTitle;
+ currentSubTab = subtabTitle;
+ super.selectTab(tabTitle, subtabTitle, viewPath);
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
index aa2ee61..ba57920 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java
@@ -43,6 +43,7 @@ import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ClusterKey;
+import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ClusterFlyweight;
import org.rhq.core.domain.resource.group.composite.ClusterKeyFlyweight;
@@ -89,14 +90,11 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
treeGrid.setSortField("name");
treeGrid.setShowHeader(false);
-
addMember(this.treeGrid);
-
contextMenu = new ResourceGroupTreeContextMenu();
treeGrid.setContextMenu(contextMenu);
-
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
@Override
public void onSelectionChanged(SelectionEvent selectionEvent) {
@@ -141,17 +139,29 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
criteria.fetchResourceType(true);
GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria,
- new AsyncCallback<PageList<ResourceGroup>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load group", caught);
- }
-
- @Override
- public void onSuccess(PageList<ResourceGroup> result) {
- ResourceGroup group = result.get(0);
- ResourceGroupTreeView.this.selectedGroup = group;
+ new AsyncCallback<PageList<ResourceGroup>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load group", caught);
+ }
+ @Override
+ public void onSuccess(PageList<ResourceGroup> result) {
+ ResourceGroup group = result.get(0);
+ ResourceGroupTreeView.this.selectedGroup = group;
+
+ if (GroupCategory.MIXED == group.getGroupCategory()) {
+ ResourceGroupTreeView.this.rootResourceGroup = group;
+ ResourceGroupTreeView.this.rootGroupId = rootResourceGroup.getId();
+ TreeNode fakeRoot = new TreeNode("fakeRootNode");
+ TreeNode rootNode = new TreeNode(rootResourceGroup.getName());
+ rootNode.setID(String.valueOf(rootResourceGroup.getId())); //getClusterKey().toString());
+ fakeRoot.setChildren(new TreeNode[] { rootNode });
+ Tree tree = new Tree();
+ tree.setRoot(fakeRoot);
+ treeGrid.setData(tree);
+ treeGrid.markForRedraw();
+ } else {
if (group.getClusterResourceGroup() == null) {
ResourceGroupTreeView.this.rootResourceGroup = group;
// This is a straight up group
@@ -164,12 +174,12 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
loadGroup(rootGroup.getId());
}
-
}
- });
- }
+ }
+ });
+ }
private void loadGroup(int groupId) {
@@ -193,19 +203,17 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
treeGrid.selectRecord(selectedNode);
}
-
} else {
this.rootGroupId = groupId;
- GWTServiceLookup.getClusterService().getClusterTree(groupId,
- new AsyncCallback<ClusterFlyweight>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load tree", caught);
- }
+ GWTServiceLookup.getClusterService().getClusterTree(groupId, new AsyncCallback<ClusterFlyweight>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load tree", caught);
+ }
- public void onSuccess(ClusterFlyweight result) {
- loadTreeTypes(result);
- }
- });
+ public void onSuccess(ClusterFlyweight result) {
+ loadTreeTypes(result);
+ }
+ });
}
}
@@ -215,60 +223,54 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
typeIds.add(this.rootResourceGroup.getResourceType().getId());
getTreeTypes(root, typeIds);
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- typeIds.toArray(new Integer[typeIds.size()]),
- new ResourceTypeRepository.TypesLoadedCallback() {
- @Override
- public void onTypesLoaded(HashMap<Integer, ResourceType> types) {
- ResourceGroupTreeView.this.typeMap = types;
- loadTree(root);
- }
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(typeIds.toArray(new Integer[typeIds.size()]),
+ new ResourceTypeRepository.TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(HashMap<Integer, ResourceType> types) {
+ ResourceGroupTreeView.this.typeMap = types;
+ loadTree(root);
}
- );
+ });
}
-
private void selectClusterGroup(ClusterKey key) {
GWTServiceLookup.getClusterService().createAutoClusterBackingGroup(key, true,
- new AsyncCallback<ResourceGroup>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to create or update auto cluster group", caught);
- }
+ new AsyncCallback<ResourceGroup>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to create or update auto cluster group", caught);
+ }
- @Override
- public void onSuccess(ResourceGroup result) {
- int groupId = result.getId();
- History.newItem("ResourceGroup/" + groupId);
- }
- });
+ @Override
+ public void onSuccess(ResourceGroup result) {
+ int groupId = result.getId();
+ History.newItem("ResourceGroup/" + groupId);
+ }
+ });
}
private void loadTree(ClusterFlyweight root) {
TreeNode fakeRoot = new TreeNode("fakeRootNode");
-
TreeNode rootNode = new TreeNode(rootResourceGroup.getName());
rootNode.setID(String.valueOf(root.getGroupId())); //getClusterKey().toString());
+
ResourceType rootResourceType = typeMap.get(rootResourceGroup.getResourceType().getId());
rootNode.setAttribute("resourceType", rootResourceType);
String icon = "types/" + rootResourceType.getCategory().getDisplayName() + "_up_16.png";
rootNode.setIcon(icon);
- fakeRoot.setChildren(new TreeNode[]{rootNode});
+ fakeRoot.setChildren(new TreeNode[] { rootNode });
ClusterKey rootKey = new ClusterKey(root.getGroupId());
loadTree(rootNode, root, rootKey);
-
-
Tree tree = new Tree();
tree.setRoot(fakeRoot);
-
treeGrid.setData(tree);
treeGrid.markForRedraw();
}
@@ -286,7 +288,8 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
TreeNode node = new TreeNode(child.getName());
ClusterKeyFlyweight keyFlyweight = child.getClusterKey();
- ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(), keyFlyweight.getResourceKey());
+ ClusterKey key = new ClusterKey(parentKey, keyFlyweight.getResourceTypeId(), keyFlyweight
+ .getResourceKey());
ResourceType type = this.typeMap.get(keyFlyweight.getResourceTypeId());
@@ -294,7 +297,6 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
node.setIcon(icon);
-
node.setID(key.getKey());
node.setAttribute("key", key);
node.setAttribute("resourceType", type);
@@ -317,7 +319,6 @@ public class ResourceGroupTreeView extends VLayout implements BookmarkableView {
setSelectedGroup(groupId);
}
-
private void getTreeTypes(ClusterFlyweight clusterFlyweight, Set<Integer> typeIds) {
if (clusterFlyweight.getClusterKey() != null) {
typeIds.add(clusterFlyweight.getClusterKey().getResourceTypeId());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java
new file mode 100644
index 0000000..e08b57d
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupMembershipView.java
@@ -0,0 +1,129 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.client.inventory.groups.detail.inventory;
+
+import java.util.HashSet;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.LayoutSpacer;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class ResourceGroupMembershipView extends LocatableVLayout {
+
+ private int resourceGroupId;
+ private ResourceGroup resourceGroup;
+ private ResourceGroupResourceSelector selector;
+
+ public ResourceGroupMembershipView(String locatorId, int resourceGroupId) {
+ super(locatorId);
+
+ this.resourceGroupId = resourceGroupId;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ build();
+ }
+
+ public void build() {
+ ToolStrip toolStrip = new ToolStrip();
+ toolStrip.setWidth100();
+
+ toolStrip.addMember(new LayoutSpacer());
+
+ IButton saveButton = new LocatableIButton(this.extendLocatorId("Save"), "Save");
+ saveButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ save();
+ }
+ });
+
+ toolStrip.addMember(saveButton);
+ this.addMember(toolStrip);
+
+ ResourceGroupCriteria c = new ResourceGroupCriteria();
+ c.addFilterId(this.resourceGroupId);
+ c.fetchExplicitResources(true);
+ GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(c,
+ new AsyncCallback<PageList<ResourceGroup>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to fetch Resource Group", caught);
+ }
+
+ public void onSuccess(PageList<ResourceGroup> result) {
+ ResourceGroupMembershipView.this.resourceGroup = result.get(0);
+ ResourceGroupMembershipView.this.selector = new ResourceGroupResourceSelector(
+ ResourceGroupMembershipView.this.getLocatorId(), ResourceGroupMembershipView.this.resourceGroup
+ .getExplicitResources());
+ ResourceGroupMembershipView.this.selector.setOverflow(Overflow.AUTO);
+
+ addMember(ResourceGroupMembershipView.this.selector);
+ }
+ });
+ }
+
+ private void save() {
+ int[] resourceIds = getSelectedResourceIds();
+
+ GWTServiceLookup.getResourceGroupService().setMembership(this.resourceGroup.getId(), resourceIds, true,
+ new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to update configuration", caught);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Group membership updated for ["
+ + ResourceGroupMembershipView.this.resourceGroup.getName() + "]", Message.Severity.Info));
+ CoreGUI.refresh();
+ }
+ });
+ }
+
+ private int[] getSelectedResourceIds() {
+ int[] selection = new int[this.selector.getSelection().size()];
+ HashSet<Integer> selectedIds = this.selector.getSelection();
+ int i = 0;
+ for (Integer id : selectedIds) {
+ selection[i++] = id;
+ }
+
+ return selection;
+ }
+
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
new file mode 100644
index 0000000..6bc96fb
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory;
+
+import java.util.Collection;
+
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class ResourceGroupResourceSelector extends ResourceSelector {
+
+ public ResourceGroupResourceSelector(String locatorId, Collection<Resource> resources) {
+ super(locatorId);
+ if (null != resources) {
+ ListGridRecord[] data = (new ResourceDatasource()).buildRecords(resources);
+ setAssigned(data);
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java
index 41aff20..2c3f364 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/OverviewView.java
@@ -91,7 +91,7 @@ public class OverviewView extends LocatableVLayout {
return;
}
group.setName(newName);
- OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() {
+ OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
"Failed to change name of Resource group with id " + group.getId() + " from \""
@@ -141,7 +141,7 @@ public class OverviewView extends LocatableVLayout {
return;
}
group.setDescription(newDescription);
- OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() {
+ OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
"Failed to change description of Resource group with id " + group.getId() + " from \""
@@ -177,7 +177,7 @@ public class OverviewView extends LocatableVLayout {
return;
}
group.setLocation(newLocation);
- OverviewView.this.resourceGroupService.updateResourceGroup(group, new AsyncCallback<Void>() {
+ OverviewView.this.resourceGroupService.updateResourceGroup(group, false, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
"Failed to change location of Resource group with id " + group.getId() + " from \""
@@ -224,7 +224,8 @@ public class OverviewView extends LocatableVLayout {
StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition", "Group Definition");
GroupDefinition groupDefinition = group.getGroupDefinition();
String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId());
- groupDefinitionItem.setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinition.getName() + "</a>");
+ groupDefinitionItem
+ .setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinition.getName() + "</a>");
formItems.add(groupDefinitionItem);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java
index f06f6ae..6b4664a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateStep.java
@@ -22,22 +22,16 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.wizard;
-import java.util.LinkedHashMap;
-
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.ValuesManager;
import com.smartgwt.client.widgets.form.fields.AutoFitTextAreaItem;
import com.smartgwt.client.widgets.form.fields.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.IPickTreeItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.enterprise.gui.coregui.client.components.form.RadioGroupWithComponentsItem;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypePluginTreeDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
@@ -68,42 +62,14 @@ public class GroupCreateStep extends AbstractWizardStep {
CheckboxItem recursive = new CheckboxItem("recursive", "Recursive");
- LinkedHashMap<String, Canvas> options = new LinkedHashMap<String, Canvas>();
- options.put("Mixed", null);
-
- IPickTreeItem typeSelectItem = new IPickTreeItem("type", "Type");
- typeSelectItem.setDataSource(new ResourceTypePluginTreeDataSource());
- typeSelectItem.setValueField("id");
- typeSelectItem.setCanSelectParentItems(true);
- typeSelectItem.setLoadDataOnDemand(false);
- typeSelectItem.setEmptyMenuMessage("Loading...");
- typeSelectItem.setShowIcons(true);
-
- DynamicForm form2 = new LocatableDynamicForm("TypeTree");
- form2.setValuesManager(form.getValuesManager());
- form2.setFields(typeSelectItem);
- options.put("Compatible", form2);
-
- RadioGroupWithComponentsItem kind = new RadioGroupWithComponentsItem("groupType", "Group Type", options,
- form);
- kind.setValue("Mixed");
- form.setFields(name, description, location, recursive, kind);
-
+ form.setFields(name, description, location, recursive);
}
+
return form;
}
public boolean nextPage() {
- boolean valid = form.validate();
- if (valid) {
- RadioGroupWithComponentsItem kind = (RadioGroupWithComponentsItem) form.getField("groupType");
- if ("Compatible".equals(kind.getSelected())) {
- DynamicForm form2 = (DynamicForm) kind.getSelectedComponent();
- valid = (null != form2.getValue("type"));
- }
- }
-
- return valid;
+ return form.validate();
}
public String getName() {
@@ -116,16 +82,6 @@ public class GroupCreateStep extends AbstractWizardStep {
group.setLocation(form.getValueAsString("location"));
group.setRecursive(form.getValue("recursive") != null ? true : false);
- RadioGroupWithComponentsItem kind = (RadioGroupWithComponentsItem) form.getField("groupType");
- if ("Compatible".equals(kind.getSelected())) {
- DynamicForm form2 = (DynamicForm) kind.getSelectedComponent();
- if (null != form2.getValue("type")) {
- ResourceType rt = new ResourceType();
- rt.setId(Integer.parseInt(form2.getValueAsString("type")));
- group.setResourceType(rt);
- }
- }
-
return group;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
index a55b334..fbbf71e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
@@ -28,7 +28,6 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.IButton;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
@@ -67,23 +66,11 @@ public class GroupCreateWizard extends AbstractWizard {
}
public String getSubtitle() {
- return null; // TODO: Implement this method.
+ return null;
}
public List<IButton> getCustomButtons(int step) {
- return null; // TODO: Implement this method.
- }
-
- /**
- * @return only the rt id is set
- */
- public ResourceType getCompatibleGroupResourceType() {
- ResourceGroup rg = createStep.getGroup();
- ResourceType rt = null;
- if (null != rg) {
- rt = rg.getResourceType();
- }
- return rt;
+ return null;
}
public void cancel() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java
index 3a3048d..2e3e9c7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupMembersStep.java
@@ -26,7 +26,6 @@ import java.util.HashSet;
import com.smartgwt.client.widgets.Canvas;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
@@ -37,18 +36,14 @@ public class GroupMembersStep extends AbstractWizardStep {
private GroupCreateWizard wizard = null;
private ResourceSelector selector = null;
- private ResourceType requireType = null;
public GroupMembersStep(GroupCreateWizard wizard) {
this.wizard = wizard;
}
public Canvas getCanvas() {
- ResourceType rt = wizard.getCompatibleGroupResourceType();
- if ((selector == null) || (rt != requireType)) {
+ if (selector == null) {
selector = new ResourceSelector(getName());
- requireType = rt;
- selector.setRequireType(rt);
}
return selector;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
index faa406e..ed442b2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/InventoryView.java
@@ -57,8 +57,8 @@ public class InventoryView extends LocatableHLayout implements BookmarkableView
private static final String SECTION_GROUPS = "Groups";
private static final String SECTION_RESOURCES = "Resources";
- private static final String SUBSECTION_RESOURCE_INVENTORY = "Resource Inventory";
- private static final String SUBSECTION_GROUP_INVENTORY = "Group Inventory";
+ private static final String SUBSECTION_RESOURCE_INVENTORY = "Resources";
+ private static final String SUBSECTION_GROUP_INVENTORY = "Groups";
private static final String SUBSECTION_SAVED_SEARCHES = "Saved Searches";
private static final String PAGE_ADQ = "Discovery Manager";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 9817819..71f1996 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -182,14 +182,13 @@ public class ResourceSearchView extends Table {
// -------- Static Utility loaders ------------
- public static ResourceSearchView getChildrenOf(int resourceId) {
- return new ResourceSearchView("ResourceSearchChildren", new Criteria("parentId", String.valueOf(resourceId)),
+ public static ResourceSearchView getChildrenOf(String locatorId, int resourceId) {
+ return new ResourceSearchView(locatorId, new Criteria("parentId", String.valueOf(resourceId)),
"Child Resources");
}
- public static ResourceSearchView getMembersOf(int groupId) {
- return new ResourceSearchView("ResourceSearchMemberOf", new Criteria("groupId", String.valueOf(groupId)),
- "Member Resources");
+ public static ResourceSearchView getMembersOf(String locatorId, int groupId) {
+ return new ResourceSearchView(locatorId, new Criteria("groupId", String.valueOf(groupId)), "Member Resources");
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 2edb50f..e80be32 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -207,7 +207,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
this.monitorCallTime.setCanvas(new FullHTMLPane("/rhq/resource/monitor/response-plain.xhtml?id="
+ resource.getId()));
- this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(resource.getId()));
+ this.inventoryChildren.setCanvas(ResourceSearchView.getChildrenOf(this.extendLocatorId("Children"), resource
+ .getId()));
this.inventoryConn.setCanvas(new PluginConfigurationEditView(this.extendLocatorId("PluginConfig"), resource));
// comment out GWT-based operation history until...
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
index e9f773d..b1ad07f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java
@@ -49,8 +49,8 @@ public class ResourceSelector extends AbstractSelector<Resource> {
private ResourceType requireType;
- public ResourceSelector(String id) {
- super(id);
+ public ResourceSelector(String locatorId) {
+ super(locatorId);
}
public ResourceType getRequireType() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
index b2ec813..b9642d6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGroupGWTServiceImpl.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria;
import org.rhq.core.domain.resource.group.GroupDefinition;
@@ -36,34 +37,57 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implements ResourceGroupGWTService {
+ private static final long serialVersionUID = 1L;
+
private ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
private GroupDefinitionManagerLocal definitionManager = LookupUtil.getGroupDefinitionManager();
public PageList<ResourceGroup> findResourceGroupsByCriteria(ResourceGroupCriteria criteria) {
- return SerialUtility.prepare(groupManager.findResourceGroupsByCriteria(getSessionSubject(), criteria),
- "ResourceGroupService.findResourceGroupsByCriteria");
+ try {
+ PageList<ResourceGroup> groups = groupManager.findResourceGroupsByCriteria(getSessionSubject(), criteria);
+ return SerialUtility.prepare(groups, "ResourceGroupService.findResourceGroupsByCriteria");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
public PageList<ResourceGroupComposite> findResourceGroupCompositesByCriteria(ResourceGroupCriteria criteria) {
- return SerialUtility.prepare(groupManager.findResourceGroupCompositesByCriteria(getSessionSubject(), criteria),
- "ResourceGroupService.findResourceGroupCompositesByCriteria");
+ try {
+ PageList<ResourceGroupComposite> composites = groupManager.findResourceGroupCompositesByCriteria(
+ getSessionSubject(), criteria);
+ return SerialUtility.prepare(composites, "ResourceGroupService.findResourceGroupCompositesByCriteria");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
public PageList<GroupDefinition> findGroupDefinitionsByCriteria(ResourceGroupDefinitionCriteria criteria) {
- return SerialUtility.prepare(definitionManager.findGroupDefinitionsByCriteria(getSessionSubject(), criteria),
- "ResourceGroupService.findGroupDefinitionsByCriteria");
+ try {
+ PageList<GroupDefinition> definitions = definitionManager.findGroupDefinitionsByCriteria(
+ getSessionSubject(), criteria);
+ return SerialUtility.prepare(definitions, "ResourceGroupService.findGroupDefinitionsByCriteria");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
- public void ensureMembershipMatches(int groupId, int[] resourceIds) {
- groupManager.ensureMembershipMatches(getSessionSubject(), groupId, resourceIds);
+ public void setMembership(int groupId, int[] resourceIds, boolean setType) {
+ try {
+ groupManager.setMembership(getSessionSubject(), groupId, resourceIds, setType);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
public ResourceGroup createResourceGroup(ResourceGroup group, int[] resourceIds) {
- group = groupManager.createResourceGroup(getSessionSubject(), group);
-
- ensureMembershipMatches(group.getId(), resourceIds);
-
- return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup");
+ try {
+ Subject user = getSessionSubject();
+ group = groupManager.createResourceGroup(user, group);
+ groupManager.setMembership(user, group.getId(), resourceIds, true);
+ return SerialUtility.prepare(group, "ResourceGroupService.createResourceGroup");
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
public void deleteResourceGroups(int[] groupIds) {
@@ -75,7 +99,19 @@ public class ResourceGroupGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
public void updateResourceGroup(ResourceGroup group) {
- groupManager.updateResourceGroup(getSessionSubject(), group);
+ try {
+ groupManager.updateResourceGroup(getSessionSubject(), group);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
+ }
+
+ public void updateResourceGroup(ResourceGroup group, boolean updateMembership) {
+ try {
+ groupManager.updateResourceGroup(getSessionSubject(), group, null, updateMembership);
+ } catch (Throwable t) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(t));
+ }
}
public GroupDefinition createGroupDefinition(GroupDefinition groupDefinition) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
index 10611fa..4aaf7ca 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/cluster/ClusterManagerBean.java
@@ -48,7 +48,6 @@ import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.resource.group.ResourceGroupAlreadyExistsException;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
-import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
/**
*
@@ -139,9 +138,9 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
try {
// You are allowed to cause the creation of an auto cluster backing group as long as you can
// view the parent group. (That check was done above)
- resourceGroupManager.ensureMembershipMatches(subjectManager.getOverlord(), autoClusterBackingGroup
- .getId(), resourceIds);
- } catch (ResourceGroupUpdateException e) {
+ resourceGroupManager.setMembership(subjectManager.getOverlord(), autoClusterBackingGroup.getId(),
+ resourceIds, false);
+ } catch (Exception e) {
log.error("Could not add resources to group:" + e);
}
}
@@ -177,11 +176,10 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
}
public ClusterFlyweight getClusterTree(Subject subject, int groupId) {
- Query query = entityManager.createQuery(
- "SELECT r.id, r.resourceType.id, r.parentResource.id, r.resourceKey, r.name, " +
- "(SELECT count(r2) FROM Resource r2 join r2.explicitGroups g2 WHERE g2.id = :groupId and r2.id = r.id) " +
- "FROM Resource r join r.implicitGroups g " +
- "WHERE g.id = :groupId");
+ Query query = entityManager
+ .createQuery("SELECT r.id, r.resourceType.id, r.parentResource.id, r.resourceKey, r.name, "
+ + "(SELECT count(r2) FROM Resource r2 join r2.explicitGroups g2 WHERE g2.id = :groupId and r2.id = r.id) "
+ + "FROM Resource r join r.implicitGroups g " + "WHERE g.id = :groupId");
query.setParameter("groupId", groupId);
List<Object[]> rs = query.getResultList();
@@ -203,7 +201,6 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
}
}
-
ClusterFlyweight key = new ClusterFlyweight(groupId);
buildTree(groupId, key, explicitResources, dataMap);
@@ -211,7 +208,8 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
return key;
}
- private void buildTree(int groupId, ClusterFlyweight parent, Set<Integer> parentIds, Map<Integer,List<Object[]>> data) {
+ private void buildTree(int groupId, ClusterFlyweight parent, Set<Integer> parentIds,
+ Map<Integer, List<Object[]>> data) {
for (Integer parentId : parentIds) {
@@ -219,32 +217,29 @@ public class ClusterManagerBean implements ClusterManagerLocal, ClusterManagerRe
Map<ClusterKeyFlyweight, Set<Integer>> members = new HashMap<ClusterKeyFlyweight, Set<Integer>>();
if (data.get(parentId) != null) {
- for (Object[] child : data.get(parentId)) {
- ClusterKeyFlyweight n = new ClusterKeyFlyweight((Integer)child[1], (String)child[3]);
+ for (Object[] child : data.get(parentId)) {
+ ClusterKeyFlyweight n = new ClusterKeyFlyweight((Integer) child[1], (String) child[3]);
ClusterFlyweight flyweight = children.get(n);
- Set<Integer> memberList = members.get(n);
- if (flyweight == null) {
- flyweight = new ClusterFlyweight(n);
- children.put(n, flyweight);
- memberList = new HashSet<Integer>();
- members.put(n, memberList);
+ Set<Integer> memberList = members.get(n);
+ if (flyweight == null) {
+ flyweight = new ClusterFlyweight(n);
+ children.put(n, flyweight);
+ memberList = new HashSet<Integer>();
+ members.put(n, memberList);
+ }
+ flyweight.addResource((String) child[4]);
+ memberList.add((Integer) child[0]);
}
- flyweight.addResource((String)child[4]);
- memberList.add((Integer) child[0]);
- }
}
parent.setChildren(new ArrayList<ClusterFlyweight>(children.values()));
-
for (ClusterFlyweight child : children.values()) {
buildTree(groupId, child, members.get(child.getClusterKey()), data);
}
}
}
-
-
private String getClusterKeyQuery(ClusterKey clusterKey) {
if (null == clusterKey)
return null;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
index 04dd614..28ae218 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
@@ -171,8 +171,19 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
}
@RequiredPermission(Permission.MANAGE_INVENTORY)
- public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType)
+ public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group) throws ResourceGroupUpdateException {
+ return updateResourceGroup(subject, group, null, true);
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group, RecursivityChangeType changeType)
throws ResourceGroupUpdateException {
+ return updateResourceGroup(subject, group, null, true);
+ }
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType,
+ boolean updateMembership) throws ResourceGroupUpdateException {
int groupId = group.getId();
ResourceGroup attachedGroup = entityManager.find(ResourceGroup.class, groupId);
@@ -198,6 +209,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
}
}
+ if (!updateMembership) {
+ group.setExplicitResources(attachedGroup.getExplicitResources());
+ group.setImplicitResources(attachedGroup.getImplicitResources());
+ }
+
group.setMtime(System.currentTimeMillis());
group.setModifiedBy(user.getName());
@@ -320,7 +336,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
try {
operationManager.unscheduleGroupOperation(overlord, schedule.getJobId().toString(), group.getId());
} catch (UnscheduleException e) {
- log.warn("Failed to unschedule job [" + schedule + "] for a group being deleted [" + group + "]", e);
+ log
+ .warn("Failed to unschedule job [" + schedule + "] for a group being deleted [" + group + "]",
+ e);
}
}
} catch (Exception e) {
@@ -759,8 +777,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
* to this method, we can just do simple RHQ_RESOURCE_GROUP_RES_IMP_MAP table insertions
*/
String insertImplicitQueryString = JDBCUtil.transformQueryForMultipleInParameters(
- ResourceGroup.QUERY_NATIVE_ADD_RESOURCES_TO_GROUP_IMPLICIT, "@@RESOURCE_IDS@@",
- resourceIdsToAdd.size());
+ ResourceGroup.QUERY_NATIVE_ADD_RESOURCES_TO_GROUP_IMPLICIT, "@@RESOURCE_IDS@@", resourceIdsToAdd
+ .size());
insertImplicitStatement = conn.prepareStatement(insertImplicitQueryString);
insertImplicitStatement.setInt(1, implicitRecursiveGroupId);
JDBCUtil.bindNTimes(insertImplicitStatement, ArrayUtils.unwrapCollection(resourceIdsToAdd), 2);
@@ -822,9 +840,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
ResourceGroup group = getResourceGroupById(subject, groupId, category);
Set<Resource> res = group.getExplicitResources();
if (res != null && res.size() > 0) {
- List<Resource> resources = PersistenceUtility.getHibernateSession(entityManager)
- .createFilter(res, "where this.inventoryStatus = :inventoryStatus")
- .setParameter("inventoryStatus", InventoryStatus.COMMITTED).list();
+ List<Resource> resources = PersistenceUtility.getHibernateSession(entityManager).createFilter(res,
+ "where this.inventoryStatus = :inventoryStatus").setParameter("inventoryStatus",
+ InventoryStatus.COMMITTED).list();
return resources;
} else {
@@ -1278,7 +1296,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
return groupIds;
}
- public void ensureMembershipMatches(Subject subject, int groupId, int[] resourceIds) {
+ public void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType)
+ throws ResourceGroupDeleteException {
//throws ResourceGroupUpdateException {
List<Integer> currentMembers = resourceManager.findExplicitResourceIdsByResourceGroup(groupId);
@@ -1293,6 +1312,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
if (extraMembers.size() > 0) {
removeResourcesFromGroup(subject, groupId, ArrayUtils.unwrapCollection(extraMembers));
}
+
+ // As a result of the membership change ensure that the group type is set correctly.
+ if (setType) {
+ setResourceType(groupId);
+ }
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -1402,11 +1426,6 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
: RecursivityChangeType.RemovedRecursion);
}
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group) throws ResourceGroupUpdateException {
- return updateResourceGroup(subject, group, null);
- }
-
@SuppressWarnings("unchecked")
public PageList<ResourceGroup> findResourceGroupsByCriteria(Subject subject, ResourceGroupCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
index 2919879..45f7cc4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerLocal.java
@@ -42,9 +42,6 @@ import org.rhq.core.domain.util.PageList;
@Local
public interface ResourceGroupManagerLocal {
- ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType)
- throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException;
-
ResourceGroup getResourceGroupById(Subject user, int id, GroupCategory category)
throws ResourceGroupNotFoundException;
@@ -108,10 +105,30 @@ public interface ResourceGroupManagerLocal {
List<Integer> findDeletedResourceGroupIds(int[] groupIds);
- void ensureMembershipMatches(Subject subject, int groupId, int[] resourceIds) throws ResourceGroupUpdateException;
+ /**
+ * This method ensures that the explicit group membership is set to the specified resources. Members
+ * will be added or removed as necessary. Make sure you pass the correct value for the <setType>
+ * parameter.
+ *
+ * @param subject
+ * @param groupId
+ * @param resourceIds
+ * @param setType Set to false if the specified resourceIds will not alter the group type (compatible or
+ * mixed). Set true to have the group type (re)set automatically, based on the new group membership.
+ * @throws ResourceGroupUpdateException
+ * @throws ResourceGroupDeleteException
+ */
+ void setMembership(Subject subject, int groupId, int[] resourceIds, boolean setType)
+ throws ResourceGroupUpdateException, ResourceGroupDeleteException;
void uninventoryMembers(Subject subject, int groupId);
+ ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType)
+ throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException;
+
+ ResourceGroup updateResourceGroup(Subject user, ResourceGroup group, RecursivityChangeType changeType,
+ boolean updateMembership) throws ResourceGroupAlreadyExistsException, ResourceGroupUpdateException;
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// The following are shared with the Remote Interface
@@ -141,5 +158,4 @@ public interface ResourceGroupManagerLocal {
ResourceGroup updateResourceGroup(Subject subject, ResourceGroup group);
PageList<ResourceGroup> findResourceGroupsByCriteria(Subject subject, ResourceGroupCriteria criteria);
-
}
\ No newline at end of file
13 years, 9 months
[rhq] 2 commits - modules/common modules/core modules/enterprise modules/plugins
by ips
modules/common/jboss-as/pom.xml | 6
modules/common/jboss-as/src/main/java/org/jboss/on/common/jbossas/JmxConnectionHelper.java | 262 +++++++++
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java | 6
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java | 5
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java | 2
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 103 ++-
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java | 3
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProperties.java | 4
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JmxConnectionHelper.java | 264 ----------
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 15
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java | 8
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossProperties.java | 2
13 files changed, 373 insertions(+), 314 deletions(-)
New commits:
commit 19cc4a49d4041a3dcfdf4cb05bff2ab0b56edec1
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Sep 17 17:40:48 2010 -0400
add support to as5 plugin for managing AS 6.0 M4 and later (https://bugzilla.redhat.com/show_bug.cgi?id=619240); add support to as5 plugin for discovering and managing AS instances with non-standard lib dirs, e.g. jboss.lib.url (https://bugzilla.redhat.com/show_bug.cgi?id=635158); move JmxConnectionHelper to jboss-as-common module
diff --git a/modules/common/jboss-as/pom.xml b/modules/common/jboss-as/pom.xml
index d69311c..b60da0b 100644
--- a/modules/common/jboss-as/pom.xml
+++ b/modules/common/jboss-as/pom.xml
@@ -45,6 +45,12 @@
</dependency>
<dependency>
+ <groupId>mc4j</groupId>
+ <artifactId>org-mc4j-ems</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ </dependency>
+
+ <dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rhq-core-plugin-api</artifactId>
<version>${project.version}</version>
diff --git a/modules/common/jboss-as/src/main/java/org/jboss/on/common/jbossas/JmxConnectionHelper.java b/modules/common/jboss-as/src/main/java/org/jboss/on/common/jbossas/JmxConnectionHelper.java
new file mode 100644
index 0000000..dc57a78
--- /dev/null
+++ b/modules/common/jboss-as/src/main/java/org/jboss/on/common/jbossas/JmxConnectionHelper.java
@@ -0,0 +1,262 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 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.jboss.on.common.jbossas;
+
+import java.io.File;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mc4j.ems.connection.ConnectionFactory;
+import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.settings.ConnectionSettings;
+import org.mc4j.ems.connection.support.ConnectionProvider;
+import org.mc4j.ems.connection.support.metadata.ConnectionTypeDescriptor;
+import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+
+/**
+ * Shared helper class to connect to a remote JMX server.
+ *
+ * @author Heiko W. Rupp
+ */
+public class JmxConnectionHelper {
+ public static final String CONNECTOR_DESCRIPTOR_TYPE = "connectorDescriptorType";
+ public static final String CONNECTOR_ADDRESS = "connectorAddress";
+ public static final String CONNECTOR_PRINCIPAL = "connectorPrincipal";
+ public static final String CONNECTOR_CREDENTIALS = "connectorCredentials";
+ public static final String JBOSS_HOME_DIR = "jbossHomeDir";
+
+ private static final Log log = LogFactory.getLog(JmxConnectionHelper.class);
+
+ private static EmsConnection connection;
+ private static Configuration configuration;
+
+ private static final String JNP_DISABLE_DISCOVERY_JNP_INIT_PROP = "jnp.disableDiscovery";
+
+ /**
+ * This is the timeout for the initial connection to the MBeanServer that is made by the AS ResourceComponent's
+ * start method.
+ */
+ private static final int JNP_TIMEOUT = 30 * 1000; // 30 seconds
+ /**
+ * This is the timeout for MBean attribute gets/sets and operations invoked on the remote MBeanServer.
+ * NOTE: This timeout comes into play if the JBossAS instance has gone down since the original JNP connection was made.
+ */
+ private static final int JNP_SO_TIMEOUT = 15 * 1000; // 15 seconds
+
+ /**
+ * Controls the dampening of connection error stack traces in an attempt to control spam to the log file. Each time
+ * a connection error is encountered, this will be incremented. When the connection is finally established, this
+ * will be reset to zero.
+ */
+ private static int consecutiveConnectionErrors;
+
+ private boolean copyConnectionLibraries;
+ private File tmpDir;
+
+ /**
+ * Constructs a new connection helper.
+ *
+ * @param copyConnectionLibraries whether to copy the libraries need for the connection so that
+ * the ems classloader doesn't block the application access to them.
+ * @param tmpDir the temporary directory to use when copying the libraries
+ */
+ public JmxConnectionHelper(boolean copyConnectionLibraries, File tmpDir) {
+ this.copyConnectionLibraries = copyConnectionLibraries;
+ this.tmpDir = tmpDir;
+ }
+
+ /**
+ * Obtain an EmsConnection for the passed connection properties. The properties will be retained.
+ * To create a connection with different properties, use this method again with a different set
+ * of properties.
+ * @param config Configuration properties for this connection
+ * @return an EmsConnection or null in case of failure
+ * @see #getEmsConnection()
+ */
+ public EmsConnection getEmsConnection(Configuration config) {
+ EmsConnection emsConnection = null;
+ configuration = config;
+
+ try {
+ emsConnection = loadConnection(config, copyConnectionLibraries, tmpDir);
+ } catch (Exception e) {
+ log.error("Component attempting to access a connection that could not be loaded");
+ }
+
+ return emsConnection;
+ }
+
+ /**
+ * Obtain an EmsConnection. This will only work if the connection properties have passed
+ * before via a call to {@link #getEmsConnection(Configuration)}
+ * @return an EmsConnection or null in case of failure
+ * @see #getEmsConnection(org.rhq.core.domain.configuration.Configuration)
+ */
+ public EmsConnection getEmsConnection() {
+ EmsConnection emsConnection = null;
+ if (configuration == null) {
+ throw new RuntimeException("No configuration set");
+ }
+
+ try {
+ emsConnection = loadConnection(configuration, copyConnectionLibraries, tmpDir);
+ } catch (Exception e) {
+ log.error("Component attempting to access a connection that could not be loaded");
+ }
+
+ return emsConnection;
+ }
+
+ /**
+ * This is the preferred way to use a connection from within this class; methods should not access the connection
+ * property directly as it may not have been instantiated if the connection could not be made.
+ * <p/>
+ * <p>If the connection has already been established, return the object reference to it. If not, attempt to make a
+ * live connection to the JMX server.</p>
+ * <p/>
+ * <p>If the connection could not be made in the start(org.rhq.core.pluginapi.inventory.ResourceContext) method,
+ * this method will effectively try to load the connection on each attempt to use it. As such, multiple threads may
+ * attempt to access the connection through this means at a time. Therefore, the method has been made synchronized
+ * on instances of the class.</p>
+ * <p/>
+ * <p>If any errors are encountered, this method will log the error, taking into account logic to prevent spamming
+ * the log file. Calling methods should take care to not redundantly log the exception thrown by this method.</p>
+ *
+ * @param pluginConfig
+ * @return live connection to the JMX server; this will not be <code>null</code>
+ * @throws Exception if there are any issues at all connecting to the server
+ */
+ private static synchronized EmsConnection loadConnection(Configuration pluginConfig,
+ boolean copyConnectionLibraries, File tmpDir) throws Exception {
+ if (connection == null) {
+ try {
+ //Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
+
+ ConnectionSettings connectionSettings = new ConnectionSettings();
+
+ String connectionTypeDescriptorClass = pluginConfig.getSimple(CONNECTOR_DESCRIPTOR_TYPE)
+ .getStringValue();
+ PropertySimple serverUrl = pluginConfig.getSimple(CONNECTOR_ADDRESS);
+
+ connectionSettings.initializeConnectionType((ConnectionTypeDescriptor) Class.forName(
+ connectionTypeDescriptorClass).newInstance());
+ // if not provided use the default serverUrl
+ if (null != serverUrl) {
+ connectionSettings.setServerUrl(serverUrl.getStringValue());
+ }
+
+ connectionSettings.setPrincipal(pluginConfig.getSimpleValue(CONNECTOR_PRINCIPAL, null));
+ connectionSettings.setCredentials(pluginConfig.getSimpleValue(CONNECTOR_CREDENTIALS, null));
+ connectionSettings.setLibraryURI(pluginConfig.getSimpleValue(JBOSS_HOME_DIR, null));
+
+ if (connectionSettings.getAdvancedProperties() == null) {
+ connectionSettings.setAdvancedProperties(new Properties());
+ }
+
+ connectionSettings.getAdvancedProperties().setProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER, "true");
+ connectionSettings.getAdvancedProperties().setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, "true");
+
+ // Make sure the timeout always happens, even if the JBoss server is hung.
+ connectionSettings.getAdvancedProperties().setProperty("jnp.timeout", String.valueOf(JNP_TIMEOUT));
+ connectionSettings.getAdvancedProperties().setProperty("jnp.sotimeout", String.valueOf(JNP_SO_TIMEOUT));
+
+ // TODO (ips): Remove this?
+ connectionSettings.getAdvancedProperties().setProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER,
+ Boolean.TRUE.toString());
+
+ if (copyConnectionLibraries) {
+ // Tell EMS to make copies of jar files so that the ems classloader doesn't lock
+ // application files (making us unable to update them) Bug: JBNADM-670
+ connectionSettings.getControlProperties().setProperty(ConnectionFactory.COPY_JARS_TO_TEMP,
+ String.valueOf(Boolean.TRUE));
+ }
+
+ // Tell EMS to use the plugin's temp dir, so the PC will be able to clean it up and so an access control
+ // policy can easily be defined for the dir. EMS will use this for connection libraries (i.e. client
+ // jars) if COPY_JARS control prop is true, but it will also use it for the ems-mpl jar no matter what,
+ // so we need to always set it.
+ connectionSettings.getControlProperties().setProperty(ConnectionFactory.JAR_TEMP_DIR,
+ tmpDir.getAbsolutePath());
+
+ connectionSettings.getAdvancedProperties().setProperty(InternalVMTypeDescriptor.DEFAULT_DOMAIN_SEARCH,
+ "jboss");
+
+ ConnectionFactory connectionFactory = new ConnectionFactory();
+ connectionFactory.discoverServerClasses(connectionSettings);
+
+ ConnectionProvider connectionProvider = connectionFactory.getConnectionProvider(connectionSettings);
+ connection = connectionProvider.connect();
+
+ connection.loadSynchronous(false); // this loads all the MBeans
+
+ consecutiveConnectionErrors = 0;
+
+ if (log.isDebugEnabled())
+ log.debug("Successfully made connection to the remote server instance");
+ } catch (Exception e) {
+
+ // The connection will be established even in the case that the principal cannot be authenticated,
+ // but the connection will not work. That failure seems to come from the call to loadSynchronous after
+ // the connection is established. If we get to this point that an exception was thrown, close any
+ // connection that was made and null it out so we can try to establish it again.
+ if (connection != null) {
+ if (log.isDebugEnabled())
+ log.debug("Connection created but an exception was thrown. Closing the connection.", e);
+ connection.close();
+ connection = null;
+ }
+
+ // Since the connection is attempted each time it's used, failure to connect could result in log
+ // file spamming. Log it once for every 10 consecutive times it's encountered.
+ if (consecutiveConnectionErrors % 10 == 0) {
+ log.warn("Could not establish connection to the instance [" + (consecutiveConnectionErrors + 1)
+ + "] times.", e);
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Could not connect to the instance for resource ", e);
+
+ consecutiveConnectionErrors++;
+
+ throw e;
+ }
+ }
+
+ return connection;
+ }
+
+ /**
+ * If necessary attempt to close the EMS connection, then set this.connection null. Synchronized ensure we play
+ * well with loadConnection.
+ */
+ public synchronized void closeConnection() {
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (Exception e) {
+ log.error("Error closing EMS connection: " + e);
+ }
+ connection = null;
+ }
+ }
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index 720d1ab..361ac15 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -353,8 +353,13 @@ public class InventoryManager extends AgentService implements ContainerService,
parentResourceContext, SystemInfoFactory.createSystemInfo(), null, null, this.configuration
.getContainerName(), this.configuration.getPluginContainerDeployment());
+ // Configurations are not immutable, so clone the plugin config, so the plugin will not be able to change the
+ // actual PC-managed plugin config.
+ Configuration pluginConfigClone = resource.getPluginConfiguration().deepCopy(false);
+ // TODO (ips): Clone the ResourceType too for the same reason.
+
DiscoveredResourceDetails details = new DiscoveredResourceDetails(resourceType, resource.getResourceKey(),
- resource.getName(), resource.getVersion(), resource.getDescription(), resource.getPluginConfiguration(),
+ resource.getName(), resource.getVersion(), resource.getDescription(), pluginConfigClone,
null); // TODO: I have a feeling we'll need process info, how to get it??
List<URL> results = proxy.getAdditionalClasspathUrls(discoveryContext, details);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java
index bef5806..f8ac5a1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java
@@ -75,9 +75,10 @@ public class UpdateCollectionIntervalWidget extends LocatableHLayout implements
refresh(UpdateCollectionIntervalWidget.this.schedulesView.getListGrid());
}
});
+ // Specify a null title so no label is rendered to the left of the combo box.
SelectItem unitsItem = new SelectItem("units", null);
- unitsItem.setValueMap("seconds", "minutes", "hours");
- unitsItem.setDefaultValue("seconds");
+ unitsItem.setValueMap("second(s)", "minute(s)", "hour(s)");
+ unitsItem.setDefaultValue("second(s)");
unitsItem.setShowTitle(false);
this.form.setFields(intervalItem, unitsItem);
addMember(this.form);
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
index 6b5dfa4..855791a 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
@@ -47,6 +47,7 @@ import org.jboss.managed.api.ManagedComponent;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.on.common.jbossas.JBPMWorkflowManager;
import org.jboss.on.common.jbossas.JBossASPaths;
+import org.jboss.on.common.jbossas.JmxConnectionHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -88,7 +89,6 @@ import org.rhq.plugins.jbossas5.connection.ProfileServiceConnectionProvider;
import org.rhq.plugins.jbossas5.connection.RemoteProfileServiceConnectionProvider;
import org.rhq.plugins.jbossas5.helper.CreateChildResourceFacetDelegate;
import org.rhq.plugins.jbossas5.helper.JBossAS5ConnectionTypeDescriptor;
-import org.rhq.plugins.jbossas5.helper.JmxConnectionHelper;
import org.rhq.plugins.jbossas5.helper.InPluginControlActionFacade;
import org.rhq.plugins.jbossas5.util.ManagedComponentUtils;
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
index 94cad13..1eb9df6 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
@@ -1,6 +1,6 @@
/*
* Jopr Management Platform
-* Copyright (C) 2005-2009 Red Hat, Inc.
+* Copyright (C) 2005-2010 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -24,10 +24,11 @@ package org.rhq.plugins.jbossas5;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
import java.net.InetAddress;
+import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -66,9 +67,10 @@ import org.rhq.plugins.jbossas5.helper.JBossInstanceInfo;
import org.rhq.plugins.jbossas5.helper.JBossProductType;
import org.rhq.plugins.jbossas5.helper.JBossProperties;
import org.rhq.plugins.jbossas5.util.JnpConfig;
+import org.rhq.plugins.jbossas5.util.ResourceComponentUtils;
/**
- * A Resource discovery component for JBoss AS Server Resources, which include the following:
+ * A Resource discovery component for JBoss application server Resources, which include the following:
*
* JBoss AS, 5.2.0.Beta1 and later
* JBoss EAP, 5.0.0.Beta and later
@@ -78,6 +80,7 @@ import org.rhq.plugins.jbossas5.util.JnpConfig;
* @author Ian Springer
* @author Mark Spritzler
*/
+@SuppressWarnings({"UnusedDeclaration"})
public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryComponent, ClassLoaderFacet,
ManualAddFacet {
private static final String CHANGE_ME = "***CHANGE_ME***";
@@ -87,7 +90,8 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
private static final String LOCALHOST = "127.0.0.1";
private static final String JAVA_HOME_ENV_VAR = "JAVA_HOME";
- private static final Map<JBossProductType, ComparableVersion> MINIMUM_PRODUCT_VERSIONS = new HashMap(3);
+ private static final Map<JBossProductType, ComparableVersion> MINIMUM_PRODUCT_VERSIONS =
+ new HashMap<JBossProductType, ComparableVersion>(4);
static {
MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.AS, new ComparableVersion("5.2.0.Beta1"));
MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.EAP, new ComparableVersion("5.0.0.Beta"));
@@ -95,19 +99,23 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.SOA, new ComparableVersion("5.0.0.Beta"));
}
- private static final List<String> CLIENT_JARS = Arrays.asList(
+ private static final String[] CLIENT_JAR_URLS = new String[] {
// NOTE: The jbossall-client.jar aggregates a whole bunch of other jars from the client dir via its
// MANIFEST.MF Class-Path.
- "client/jbossall-client.jar", "client/trove.jar", "client/javassist.jar",
- "common/lib/jboss-security-aspects.jar", "lib/jboss-managed.jar", "lib/jboss-metatype.jar",
- "lib/jboss-dependency.jar");
-
- private static final List<String> AS6_CLIENT_JARS = new ArrayList<String>(CLIENT_JARS);
- static {
- // The below jars are required for JBoss AS 6.0 M1, M2, and M3.
- AS6_CLIENT_JARS.add("lib/jboss-classpool.jar");
- AS6_CLIENT_JARS.add("lib/jboss-classpool-scoped.jar");
- }
+ "%clientUrl%/jbossall-client.jar", //
+ "%clientUrl%/trove.jar", //
+ "%clientUrl%/javassist.jar", //
+ "%commonLibUrl%/jboss-security-aspects.jar", //
+ "%libUrl%/jboss-managed.jar", //
+ "%libUrl%/jboss-metatype.jar", //
+ "%libUrl%/jboss-dependency.jar", //
+ // AS 6.0 M1 and later
+ "%libUrl%/jboss-classpool.jar", //
+ "%libUrl%/jboss-classpool-scoped.jar", //
+ // AS 6.0 M4 and later
+ "%commonLibUrl%/jboss-as-profileservice.jar", //
+ "%libUrl%/jboss-profileservice-spi.jar" //
+ };
private final Log log = LogFactory.getLog(this.getClass());
@@ -149,34 +157,63 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
public List<URL> getAdditionalClasspathUrls(ResourceDiscoveryContext context, DiscoveredResourceDetails details)
throws Exception {
Configuration pluginConfig = details.getPluginConfiguration();
- String homeDir = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.HOME_DIR)
- .getStringValue();
+ setValuesForUnsetClientJarUrlProperties(pluginConfig);
+
+ List<URL> clientJarUrls = new ArrayList<URL>();
+ for (String clientJarUrlString : CLIENT_JAR_URLS) {
+ // Substitute values in for any templated plugin config props.
+ clientJarUrlString = ResourceComponentUtils.replacePropertyExpressionsInTemplate(clientJarUrlString,
+ pluginConfig);
+ URL clientJarUrl = new URL(clientJarUrlString);
+ if (isReadable(clientJarUrl)) {
+ clientJarUrls.add(clientJarUrl);
+ } else {
+ log.warn("Client JAR [" + clientJarUrl + "] does not exist or is not readable (note, this JAR "
+ + " may not be required for some app server versions).");
+ }
+ }
- List<URL> clientJars = new ArrayList<URL>();
+ return clientJarUrls;
+ }
- for (String jarFileName : getClientJars(pluginConfig)) {
- File clientJar = new File(homeDir, jarFileName);
- if (!clientJar.exists()) {
- throw new FileNotFoundException("Cannot find [" + clientJar + "] - unable to manage server.");
+ private boolean isReadable(URL url) {
+ try {
+ InputStream inputStream = url.openStream();
+ try {
+ inputStream.close();
}
- if (!clientJar.canRead()) {
- throw new IOException("Cannot read [" + clientJar + "] - unable to manage server.");
+ catch (IOException e) {
+ log.error("Failed to close input stream for URL [" + url + "].", e);
}
- clientJars.add(clientJar.toURI().toURL());
+ return true;
+ }
+ catch (IOException e) {
+ return false;
}
-
- return clientJars;
}
- private List<String> getClientJars(Configuration pluginConfig) throws IOException {
- PropertySimple jbossHomeDir = pluginConfig.getSimple("homeDir");
- JBossInstallationInfo installationInfo = new JBossInstallationInfo(new File(jbossHomeDir.getStringValue()));
+ private void setValuesForUnsetClientJarUrlProperties(Configuration pluginConfig) throws MalformedURLException {
+ String homeDir = pluginConfig.getSimple(ApplicationServerPluginConfigurationProperties.HOME_DIR)
+ .getStringValue();
+ URL homeUrl = new File(homeDir).toURI().toURL();
+
+ String clientUrlString = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.CLIENT_URL, null);
+ if (clientUrlString == null) {
+ URL clientUrl = new URL(homeUrl, "client");
+ pluginConfig.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.CLIENT_URL, clientUrl));
+ }
- if (installationInfo.getMajorVersion().equals("6")) {
- return AS6_CLIENT_JARS;
+ String libUrlString = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.LIB_URL, null);
+ if (libUrlString == null) {
+ URL libUrl = new URL(homeUrl, "lib");
+ pluginConfig.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.LIB_URL, libUrl));
}
- return CLIENT_JARS;
+ String commonLibUrlString = pluginConfig.getSimpleValue(ApplicationServerPluginConfigurationProperties.COMMON_LIB_URL, null);
+ if (commonLibUrlString == null) {
+ URL commonLibUrl = new URL(homeUrl, "common/lib");
+ pluginConfig.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.COMMON_LIB_URL, commonLibUrl));
+ }
}
private Set<DiscoveredResourceDetails> discoverExternalJBossAsProcesses(ResourceDiscoveryContext discoveryContext) {
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java
index c87a82f..3489fd4 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerPluginConfigurationProperties.java
@@ -31,6 +31,9 @@ public class ApplicationServerPluginConfigurationProperties {
public static final String PRINCIPAL = "principal";
public static final String CREDENTIALS = "credentials";
public static final String HOME_DIR = "homeDir";
+ public static final String CLIENT_URL = "clientUrl";
+ public static final String LIB_URL = "libUrl";
+ public static final String COMMON_LIB_URL = "commonLibUrl";
public static final String SERVER_HOME_DIR = "serverHomeDir";
public static final String JAVA_HOME = "javaHome";
public static final String BIND_ADDRESS = "bindAddress";
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProperties.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProperties.java
index 4c88d99..7fa6360 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProperties.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProperties.java
@@ -23,7 +23,8 @@
package org.rhq.plugins.jbossas5.helper;
/**
- * The properties that are used by the JBossAS micro-kernel during bootstrap (see http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProperties).
+ * The properties that are used by the JBossAS micro-kernel during bootstrap
+ * (see http://community.jboss.org/wiki/JBossProperties).
*
* @author Ian Springer
*/
@@ -44,6 +45,7 @@ public abstract class JBossProperties {
public static final String HOME_URL = "jboss.home.url";
public static final String LIB_URL = "jboss.lib.url";
public static final String PATCH_URL = "jboss.patch.url";
+ public static final String COMMON_LIB_URL = "jboss.common.lib.url";
/**
* The configuration name of the server - default 'default' for AS, or 'production' for EAP or SOA
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JmxConnectionHelper.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JmxConnectionHelper.java
deleted file mode 100644
index c07254a..0000000
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JmxConnectionHelper.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 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.jbossas5.helper;
-
-import java.io.File;
-import java.util.Properties;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.mc4j.ems.connection.ConnectionFactory;
-import org.mc4j.ems.connection.EmsConnection;
-import org.mc4j.ems.connection.settings.ConnectionSettings;
-import org.mc4j.ems.connection.support.ConnectionProvider;
-import org.mc4j.ems.connection.support.metadata.ConnectionTypeDescriptor;
-import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-
-/**
- * Shared helper class to connect to a remote server
- *
- * @author Heiko W. Rupp
- */
-public class JmxConnectionHelper {
-
- public static final String CONNECTOR_DESCRIPTOR_TYPE = "connectorDescriptorType";
- public static final String CONNECTOR_ADDRESS = "connectorAddress";
- public static final String CONNECTOR_PRINCIPAL = "connectorPrincipal";
- public static final String CONNECTOR_CREDENTIALS = "connectorCredentials";
- public static final String JBOSS_HOME_DIR = "jbossHomeDir";
-
- private static final Log log = LogFactory.getLog(JmxConnectionHelper.class);
-
- private static EmsConnection connection;
- private static Configuration configuration;
-
- private static final String JNP_DISABLE_DISCOVERY_JNP_INIT_PROP = "jnp.disableDiscovery";
-
- /**
- * This is the timeout for the initial connection to the MBeanServer that is made by
- * {@link org.rhq.plugins.jbossas5.ApplicationServerComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)}.
- */
- private static final int JNP_TIMEOUT = 30 * 1000; // 30 seconds
- /**
- * This is the timeout for MBean attribute gets/sets and operations invoked on the remote MBeanServer.
- * NOTE: This timeout comes into play if the JBossAS instance has gone down since the original JNP connection was made.
- */
- private static final int JNP_SO_TIMEOUT = 15 * 1000; // 15 seconds
-
- /**
- * Controls the dampening of connection error stack traces in an attempt to control spam to the log file. Each time
- * a connection error is encountered, this will be incremented. When the connection is finally established, this
- * will be reset to zero.
- */
- private static int consecutiveConnectionErrors;
-
- private boolean copyConnectionLibraries;
- private File tmpDir;
-
- /**
- * Constructs a new connection helper.
- *
- * @param copyConnectionLibraries whether to copy the libraries need for the connection so that
- * the ems classloader doesn't block the application access to them.
- * @param tmpDir the temporary directory to use when copying the libraries
- */
- public JmxConnectionHelper(boolean copyConnectionLibraries, File tmpDir) {
- this.copyConnectionLibraries = copyConnectionLibraries;
- this.tmpDir = tmpDir;
- }
-
- /**
- * Obtain an EmsConnection for the passed connection properties. The properties will be retained.
- * To create a connection with different properties, use this method again with a different set
- * of properties.
- * @param config Configuration properties for this connection
- * @return an EmsConnection or null in case of failure
- * @see #getEmsConnection()
- */
- public EmsConnection getEmsConnection(Configuration config) {
- EmsConnection emsConnection = null;
- configuration = config;
-
- try {
- emsConnection = loadConnection(config, copyConnectionLibraries, tmpDir);
- } catch (Exception e) {
- log.error("Component attempting to access a connection that could not be loaded");
- }
-
- return emsConnection;
- }
-
- /**
- * Obtain an EmsConnection. This will only work if the connection properties have passed
- * before via a call to {@link #getEmsConnection(Configuration)}
- * @return an EmsConnection or null in case of failure
- * @see #getEmsConnection(org.rhq.core.domain.configuration.Configuration)
- */
- public EmsConnection getEmsConnection() {
- EmsConnection emsConnection = null;
- if (configuration == null) {
- throw new RuntimeException("No configuration set");
- }
-
- try {
- emsConnection = loadConnection(configuration, copyConnectionLibraries, tmpDir);
- } catch (Exception e) {
- log.error("Component attempting to access a connection that could not be loaded");
- }
-
- return emsConnection;
- }
-
- /**
- * This is the preferred way to use a connection from within this class; methods should not access the connection
- * property directly as it may not have been instantiated if the connection could not be made.
- * <p/>
- * <p>If the connection has already been established, return the object reference to it. If not, attempt to make a
- * live connection to the JMX server.</p>
- * <p/>
- * <p>If the connection could not be made in the start(org.rhq.core.pluginapi.inventory.ResourceContext) method,
- * this method will effectively try to load the connection on each attempt to use it. As such, multiple threads may
- * attempt to access the connection through this means at a time. Therefore, the method has been made synchronized
- * on instances of the class.</p>
- * <p/>
- * <p>If any errors are encountered, this method will log the error, taking into account logic to prevent spamming
- * the log file. Calling methods should take care to not redundantly log the exception thrown by this method.</p>
- *
- * @param pluginConfig
- * @return live connection to the JMX server; this will not be <code>null</code>
- * @throws Exception if there are any issues at all connecting to the server
- */
- private static synchronized EmsConnection loadConnection(Configuration pluginConfig,
- boolean copyConnectionLibraries, File tmpDir) throws Exception {
- if (connection == null) {
- try {
- //Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
-
- ConnectionSettings connectionSettings = new ConnectionSettings();
-
- String connectionTypeDescriptorClass = pluginConfig.getSimple(CONNECTOR_DESCRIPTOR_TYPE)
- .getStringValue();
- PropertySimple serverUrl = pluginConfig.getSimple(CONNECTOR_ADDRESS);
-
- connectionSettings.initializeConnectionType((ConnectionTypeDescriptor) Class.forName(
- connectionTypeDescriptorClass).newInstance());
- // if not provided use the default serverUrl
- if (null != serverUrl) {
- connectionSettings.setServerUrl(serverUrl.getStringValue());
- }
-
- connectionSettings.setPrincipal(pluginConfig.getSimpleValue(CONNECTOR_PRINCIPAL, null));
- connectionSettings.setCredentials(pluginConfig.getSimpleValue(CONNECTOR_CREDENTIALS, null));
- connectionSettings.setLibraryURI(pluginConfig.getSimpleValue(JBOSS_HOME_DIR, null));
-
- if (connectionSettings.getAdvancedProperties() == null) {
- connectionSettings.setAdvancedProperties(new Properties());
- }
-
- connectionSettings.getAdvancedProperties().setProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER, "true");
- connectionSettings.getAdvancedProperties().setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, "true");
-
- // Make sure the timeout always happens, even if the JBoss server is hung.
- connectionSettings.getAdvancedProperties().setProperty("jnp.timeout", String.valueOf(JNP_TIMEOUT));
- connectionSettings.getAdvancedProperties().setProperty("jnp.sotimeout", String.valueOf(JNP_SO_TIMEOUT));
-
- // TODO (ips): Remove this?
- connectionSettings.getAdvancedProperties().setProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER,
- Boolean.TRUE.toString());
-
- if (copyConnectionLibraries) {
- // Tell EMS to make copies of jar files so that the ems classloader doesn't lock
- // application files (making us unable to update them) Bug: JBNADM-670
- connectionSettings.getControlProperties().setProperty(ConnectionFactory.COPY_JARS_TO_TEMP,
- String.valueOf(Boolean.TRUE));
- }
-
- // Tell EMS to use the plugin's temp dir, so the PC will be able to clean it up and so an access control
- // policy can easily be defined for the dir. EMS will use this for connection libraries (i.e. client
- // jars) if COPY_JARS control prop is true, but it will also use it for the ems-mpl jar no matter what,
- // so we need to always set it.
- connectionSettings.getControlProperties().setProperty(ConnectionFactory.JAR_TEMP_DIR,
- tmpDir.getAbsolutePath());
-
- connectionSettings.getAdvancedProperties().setProperty(InternalVMTypeDescriptor.DEFAULT_DOMAIN_SEARCH,
- "jboss");
-
- ConnectionFactory connectionFactory = new ConnectionFactory();
- connectionFactory.discoverServerClasses(connectionSettings);
-
- ConnectionProvider connectionProvider = connectionFactory.getConnectionProvider(connectionSettings);
- connection = connectionProvider.connect();
-
- connection.loadSynchronous(false); // this loads all the MBeans
-
- consecutiveConnectionErrors = 0;
-
- if (log.isDebugEnabled())
- log.debug("Successfully made connection to the remote server instance");
- } catch (Exception e) {
-
- // The connection will be established even in the case that the principal cannot be authenticated,
- // but the connection will not work. That failure seems to come from the call to loadSynchronous after
- // the connection is established. If we get to this point that an exception was thrown, close any
- // connection that was made and null it out so we can try to establish it again.
- if (connection != null) {
- if (log.isDebugEnabled())
- log.debug("Connection created but an exception was thrown. Closing the connection.", e);
- connection.close();
- connection = null;
- }
-
- // Since the connection is attempted each time it's used, failure to connect could result in log
- // file spamming. Log it once for every 10 consecutive times it's encountered.
- if (consecutiveConnectionErrors % 10 == 0) {
- log.warn("Could not establish connection to the instance [" + (consecutiveConnectionErrors + 1)
- + "] times.", e);
- }
-
- if (log.isDebugEnabled())
- log.debug("Could not connect to the instance for resource ", e);
-
- consecutiveConnectionErrors++;
-
- throw e;
- }
- }
-
- return connection;
- }
-
- /**
- * If necessary attempt to close the EMS connection, then set this.connection null. Synchronized ensure we play
- * well with loadConnection.
- */
- public synchronized void closeConnection() {
- if (connection != null) {
- try {
- connection.close();
- } catch (Exception e) {
- log.error("Error closing EMS connection: " + e);
- }
- connection = null;
- }
- }
-
-}
diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
index ea8ff2d..47ca3e0 100644
--- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
@@ -972,8 +972,17 @@
description="The name of the server configuration (e.g. minimal, default, or all);
if not specified, it will default to the last path component of {serverHomeDir}."
default="default"/>
+ <c:simple-property name="clientUrl" required="false"
+ description="The URL of the server's client JAR library directory;
+ if not specified, it will default to {homeDir}/client."/>
+ <c:simple-property name="libUrl" required="false"
+ description="The URL of the server's main JAR library directory;
+ if not specified, it will default to {homeDir}/lib."/>
+ <c:simple-property name="commonLibUrl" required="false"
+ description="The URL of the server's common JAR library directory;
+ if not specified, it will default to {homeDir}/common/lib."/>
</c:group>
- <c:group name="control" displayName="Operations">
+ <c:group name="control" displayName="Operations">
<c:simple-property name="scriptPrefix" displayName="Script Prefix" type="string" required="false"
description="A prefix applied to script execution commands. Typically a sudo
for applicable platforms. The prefix is applied verbatim. As such, a
@@ -1011,7 +1020,7 @@
to 'shutdown script'."/>
</c:group>
- <c:group name="advanced" displayName="Advanced" hiddenByDefault="true">
+ <c:group name="advanced" displayName="Advanced" hiddenByDefault="true">
<c:simple-property name="shutdownMBeanName" displayName="Shutdown MBean Name"
default="jboss.system:type=Server"
description="Name of the MBean to use when shutting down this server through JMX."/>
@@ -1029,7 +1038,7 @@
<c:simple-property name="childJmxServerName" displayName="JBoss AS JVM Name" default="JVM"
readOnly="true" required="false"
description="The name of the JBoss AS JVM resource."/>
- </c:group>
+ </c:group>
<c:group name="events">
<c:list-property name="logEventSources">
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
index 5fac37b..8e967ae 100644
--- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
+++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java
@@ -115,7 +115,7 @@ import org.rhq.plugins.jmx.JMXDiscoveryComponent;
import org.rhq.plugins.jmx.ObjectNameQueryUtility;
/**
-* Supports JBoss 3.2.3 through 4.2.x
+* Resource component for managing JBoss AS 3.2.3 through 4.2.x, and JBoss EAP and SOA-P 4.x.
*
* @author Greg Hinkle
* @author John Mazzitelli
@@ -156,10 +156,6 @@ public class JBossASServerComponent implements MeasurementFacet, OperationFacet,
private static final String RESOURCE_TYPE_WAR = "Web Application (WAR)";
private static final String RESOURCE_TYPE_SAR = "Service Archive (SAR)"; // Not yet used
- // The following constants reference the exact name of the package types as defined in the plugin descriptor
- private static final String PACKAGE_TYPE_PATCH = "cumulativePatch";
- private static final String PACKAGE_TYPE_LIBRARY = "library";
-
private static final String JNP_DISABLE_DISCOVERY_JNP_INIT_PROP = "jnp.disableDiscovery";
private static final String DISTRIBUTED_REPLICANT_MANAGER_MBEAN_NAME_TEMPLATE = "jboss:partitionName=%partitionName%,service=DistributedReplicantManager";
@@ -1070,6 +1066,8 @@ public class JBossASServerComponent implements MeasurementFacet, OperationFacet,
*
* @throws Exception if there are any issues at all connecting to the server
*/
+ // TODO (ips): Refactor this method to use the JmxConnectionHelper class from the jboss-as-common module, which is
+ // what the jboss-as-5 plugin uses.
private synchronized EmsConnection loadConnection() throws Exception {
if (this.connection == null) {
try {
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossProperties.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossProperties.java
index 7cfb2b2..680898f 100644
--- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossProperties.java
+++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossProperties.java
@@ -24,7 +24,7 @@ package org.rhq.plugins.jbossas.helper;
/**
* The properties that are used by the JBossAS micro-kernel during bootstrap
- * (see http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProperties).
+ * (see http://community.jboss.org/wiki/JBossProperties).
*
* @author Ian Springer
*/
commit 03d5f59b902515e77f998600875130d476cff61d
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Sep 16 18:42:13 2010 -0400
misc minor
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java
index 4181721..f5350fd 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/DiscoveredResourceDetails.java
@@ -44,13 +44,13 @@ import org.rhq.core.system.ProcessInfo;
* @author John Mazzitelli
*/
public class DiscoveredResourceDetails {
- private final Log log = LogFactory.getLog(this.getClass());
-
private static final int RESOURCE_KEY_MAX_LENGTH = 500;
private static final int RESOURCE_NAME_MAX_LENGTH = 500;
private static final int RESOURCE_VERSION_MAX_LENGTH = 100;
private static final int RESOURCE_DESCRIPTION_MAX_LENGTH = 1000;
+ private final Log log = LogFactory.getLog(this.getClass());
+
private ResourceType resourceType;
private String resourceKey;
private String resourceName;
@@ -289,7 +289,7 @@ public class DiscoveredResourceDetails {
@Override
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append("key=");
buf.append(getResourceKey());
13 years, 9 months
[rhq] Branch 'perftest' - modules/helpers
by lkrejci
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Exporter.java | 7 +--
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Entity.java | 20 +++++++++-
2 files changed, 22 insertions(+), 5 deletions(-)
New commits:
commit 0fa40ba83da0b957c789fdecc8400e27f2dbfe64
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Sep 17 16:54:48 2010 +0200
Adding the concept of a "root" entity in the export. Only the root entities are passed to the EntityRelationshipFilter as the ones to be included while the rest of the entities in the ExportConfiguration are merely there to further restrict the exported data.
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Exporter.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Exporter.java
index 45df4ac..869f87a 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Exporter.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/Exporter.java
@@ -66,8 +66,6 @@ public class Exporter {
public static void run(ExportConfiguration config, IDataSetConsumer consumer) throws Exception {
IDatabaseConnection connection = DbUnitUtil.getConnection(config.getSettings());
try {
- //get the list of the entities to load from the settings.
- //empty = all tables
Map<Entity, String> entityQueries = getEntityQueries(config);
Map<Class<?>, Set<ColumnValues>> pksToLoad = new HashMap<Class<?>, Set<ColumnValues>>();
@@ -146,8 +144,9 @@ public class Exporter {
Map<Entity, String> ret = new HashMap<Entity, String>();
for (Entity e : config.getEntities()) {
- String sql = e.getFilter();
- ret.put(e, sql);
+ if (e.isRoot()) {
+ ret.put(e, e.getFilter());
+ }
}
return ret;
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Entity.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Entity.java
index cc2ef96..17c4c79 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Entity.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/config/Entity.java
@@ -45,6 +45,9 @@ public class Entity {
@XmlAttribute
private Boolean includeAllFields;
+ @XmlAttribute
+ private Boolean root;
+
@XmlElement(name = "rel")
private Set<Relationship> relationships = new HashSet<Relationship>();
@@ -89,7 +92,22 @@ public class Entity {
}
/**
- * @return the SQL statement that returns the primary keys to be considered.
+ * @return true if this entity is to be considered the root of the exported hierarchy.
+ * The root entities are considered the base of the exported entity graph. All other non-root
+ * entities only contain additional configuration for given resources should they appear
+ * in the entity dependency graph as a dependency or dependent of some of the root entities.
+ */
+ public boolean isRoot() {
+ return root == null ? false : root;
+ }
+
+ public void setRoot(boolean root) {
+ this.root = root;
+ }
+
+ /**
+ * @return the SQL statement that returns the primary keys to be considered. Setting this
+ * property only makes sense for {@link #isRoot() root} entities.
*/
public String getFilter() {
return filter;
13 years, 9 months