[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java | 2 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java | 7 +++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/UpdateExistingSchedulesWidget.java | 8 ++++++--
3 files changed, 13 insertions(+), 4 deletions(-)
New commits:
commit f362be20b579591491b59c4bfbbced1fa0394f5c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Sat Oct 30 12:21:38 2010 -0400
provide checkbox on metric templates view that allows user to choose whether or not the new template schedules should be applied to existing Resources
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java
index c038076..ed6ecd4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeNodeBuilder.java
@@ -36,6 +36,8 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
/**
+ * A helper class for {@link ResourceTypeTreeView}.
+ *
* @author Greg Hinkle
* @author John Mazzitelli
*/
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
index 43d51a2..ae4b755 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/ResourceTypeTreeView.java
@@ -55,6 +55,9 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTreeGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
+ * A tree view of all known ResourceTypes, which includes summaries of metric schedule and alert definition templates
+ * and allows the user to edit those templates.
+ *
* @author Greg Hinkle
* @author John Mazzitelli
*/
@@ -426,8 +429,8 @@ public class ResourceTypeTreeView extends LocatableVLayout implements Bookmarkab
if (record instanceof TreeNode) {
if (record instanceof ResourceTypeTreeNodeBuilder.ResourceTypeTreeNode) {
- String c = record.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_CATEGORY);
- switch (ResourceCategory.valueOf(c)) {
+ String categoryName = record.getAttribute(ResourceTypeTreeNodeBuilder.ATTRIB_CATEGORY);
+ switch (ResourceCategory.valueOf(categoryName)) {
case PLATFORM:
return "types/Platform_up_16.png";
case SERVER:
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/UpdateExistingSchedulesWidget.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/UpdateExistingSchedulesWidget.java
index 8ec63ae..3812cc0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/UpdateExistingSchedulesWidget.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/UpdateExistingSchedulesWidget.java
@@ -54,21 +54,25 @@ public class UpdateExistingSchedulesWidget extends LocatableHLayout implements T
DynamicForm form = new LocatableDynamicForm(this.getLocatorId());
form.setNumCols(3);
+
CheckboxItem checkboxItem = new CheckboxItem("updateExistingSchedules", "Update Existing Schedules");
checkboxItem.setDefaultValue(schedulesView.isUpdateExistingSchedules());
-
+ checkboxItem.setTooltip("Check this box to update the collection schedules for this metric on all existing "
+ + "Resources of this type. Otherwise, the template schedules will only be applied to Resources of this "
+ + "type that are added to inventory in the future.");
checkboxItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent changedEvent) {
boolean newValue = (Boolean)changedEvent.getValue();
schedulesView.setUpdateExistingSchedules(newValue);
}
});
+
form.setFields(checkboxItem);
addMember(form);
}
@Override
public void refresh(ListGrid listGrid) {
- return;
+ // When new data arrives, we want to keep the state of our checkbox the same, so nothing to do here.
}
}
13 years, 1 month
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java | 16 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java | 16 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/UpdateExistingSchedulesWidget.java | 74 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java | 35 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java | 16 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java | 15 +-
7 files changed, 143 insertions(+), 36 deletions(-)
New commits:
commit 0a0aa07d0e4cdf71b1dee4a7631bd70e50715072
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Oct 29 19:43:38 2010 -0400
add support to metric template view for specifying whether existing schedules should be updated
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
index bad1853..6747b39 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java
@@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasuremen
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
/**
- * A DataSource for reading and updating the default metric schedules for a particular ResourceType.
+ * A DataSource for reading and updating the default metric schedules ("metric templates") for a particular ResourceType.
*
* @author Ian Springer
*/
@@ -86,8 +86,10 @@ public class TemplateSchedulesDataSource extends AbstractMeasurementScheduleComp
@Override
protected void enableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ TemplateSchedulesView templateSchedulesView = (TemplateSchedulesView)measurementScheduleListView;
+ boolean updateExistingSchedules = templateSchedulesView.isUpdateExistingSchedules();
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
- this.measurementService.enableMeasurementTemplates(measurementDefinitionIds,
+ this.measurementService.enableSchedulesForResourceType(measurementDefinitionIds, updateExistingSchedules,
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable throwable) {
@@ -110,8 +112,10 @@ public class TemplateSchedulesDataSource extends AbstractMeasurementScheduleComp
@Override
protected void disableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) {
+ TemplateSchedulesView templateSchedulesView = (TemplateSchedulesView)measurementScheduleListView;
+ boolean updateExistingSchedules = templateSchedulesView.isUpdateExistingSchedules();
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
- this.measurementService.disableSchedulesForCompatibleGroup(this.resourceTypeId, measurementDefinitionIds,
+ this.measurementService.disableSchedulesForResourceType(measurementDefinitionIds, updateExistingSchedules,
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable throwable) {
@@ -135,9 +139,11 @@ public class TemplateSchedulesDataSource extends AbstractMeasurementScheduleComp
protected void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView,
int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames,
final long collectionInterval) {
+ TemplateSchedulesView templateSchedulesView = (TemplateSchedulesView)measurementScheduleListView;
+ boolean updateExistingSchedules = templateSchedulesView.isUpdateExistingSchedules();
final String s = (measurementDefinitionIds.length > 1) ? "s" : "";
- this.measurementService.updateMeasurementTemplates(measurementDefinitionIds, collectionInterval,
- new AsyncCallback<Void>() {
+ this.measurementService.updateSchedulesForResourceType(measurementDefinitionIds, collectionInterval,
+ updateExistingSchedules, new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable throwable) {
CoreGUI.getErrorHandler().handleError(
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
index 648ae40..71f2f49 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java
@@ -33,6 +33,8 @@ public class TemplateSchedulesView extends AbstractMeasurementScheduleListView {
private static final String[] EXCLUDED_FIELD_NAMES = new String[] { MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID };
+ private boolean updateExistingSchedules = true;
+
public TemplateSchedulesView(String locatorId, int resourceTypeId) {
super(locatorId, TITLE, new TemplateSchedulesDataSource(resourceTypeId), createCriteria(resourceTypeId),
EXCLUDED_FIELD_NAMES);
@@ -43,4 +45,18 @@ public class TemplateSchedulesView extends AbstractMeasurementScheduleListView {
criteria.addCriteria(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID, resourceTypeId);
return criteria;
}
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+ addExtraWidget(new UpdateExistingSchedulesWidget(this));
+ }
+
+ public boolean isUpdateExistingSchedules() {
+ return updateExistingSchedules;
+ }
+
+ public void setUpdateExistingSchedules(boolean updateExistingSchedules) {
+ this.updateExistingSchedules = updateExistingSchedules;
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/UpdateExistingSchedulesWidget.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/UpdateExistingSchedulesWidget.java
new file mode 100644
index 0000000..8ec63ae
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/UpdateExistingSchedulesWidget.java
@@ -0,0 +1,74 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * 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.admin.templates;
+
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.enterprise.gui.coregui.client.components.table.TableWidget;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+
+/**
+ * A table widget that provides a checkbox for selecting whether or not to update existing schedules when updating
+ * metric templates.
+ *
+ * @author Ian Springer
+ */
+public class UpdateExistingSchedulesWidget extends LocatableHLayout implements TableWidget {
+ private TemplateSchedulesView schedulesView;
+
+ public UpdateExistingSchedulesWidget(TemplateSchedulesView schedulesView) {
+ super(schedulesView.extendLocatorId("UpdateExistingSchedulesWidget"));
+ this.schedulesView = schedulesView;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ VLayout spacer = new VLayout();
+ spacer.setWidth(20);
+ addMember(spacer);
+
+ DynamicForm form = new LocatableDynamicForm(this.getLocatorId());
+ form.setNumCols(3);
+ CheckboxItem checkboxItem = new CheckboxItem("updateExistingSchedules", "Update Existing Schedules");
+ checkboxItem.setDefaultValue(schedulesView.isUpdateExistingSchedules());
+
+ checkboxItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent changedEvent) {
+ boolean newValue = (Boolean)changedEvent.getValue();
+ schedulesView.setUpdateExistingSchedules(newValue);
+ }
+ });
+ form.setFields(checkboxItem);
+ addMember(form);
+ }
+
+ @Override
+ public void refresh(ListGrid listGrid) {
+ return;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index 422c244..bf0f629 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -22,8 +22,11 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
@@ -75,6 +78,7 @@ public class DashboardsView extends LocatableVLayout implements BookmarkableView
private boolean editMode = false;
private List<Dashboard> dashboards;
+ private Map<String, Dashboard> dashboardsByName;
private DashboardView selectedDashboardView;
private Dashboard selectedDashboard;
@@ -112,6 +116,10 @@ public class DashboardsView extends LocatableVLayout implements BookmarkableView
private void updateDashboards(List<Dashboard> dashboards) {
removeMembers(getMembers());
this.dashboards = dashboards;
+ this.dashboardsByName = new HashMap(dashboards.size());
+ for (Dashboard dashboard: dashboards) {
+ this.dashboardsByName.put(dashboard.getName(), dashboard);
+ }
tabSet = new LocatableTabSet(getLocatorId());
@@ -189,7 +197,7 @@ public class DashboardsView extends LocatableVLayout implements BookmarkableView
protected Dashboard getDefaultDashboard() {
Dashboard dashboard = new Dashboard();
- dashboard.setName("Default Dashboard");
+ dashboard.setName("Default");
dashboard.setColumns(2);
dashboard.setColumnWidths("32%", "68%");
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND, "#F1F2F3"));
@@ -251,22 +259,17 @@ public class DashboardsView extends LocatableVLayout implements BookmarkableView
}
public void addNewDashboard() {
-
- Dashboard dashboard = new Dashboard();
- dashboard.setName("Dashboard");
-
- int i = 1;
- while (true) {
- boolean exists = false;
- for (Dashboard db : dashboards) {
- if (("Dashboard " + i).equals(db.getName()))
- exists = true;
- }
- if (!exists) {
- break;
+ int i = 0;
+ String availableDashboardName = null;
+ while (availableDashboardName == null) {
+ String candidateDashboardName = "Custom" + i++;
+ if (!this.dashboardsByName.containsKey(candidateDashboardName)) {
+ availableDashboardName = candidateDashboardName;
}
}
- dashboard.setName("Dashboard " + i);
+
+ Dashboard dashboard = new Dashboard();
+ dashboard.setName(availableDashboardName);
dashboard.setColumns(2);
dashboard.setColumnWidths("30%", "70%");
@@ -314,7 +317,7 @@ public class DashboardsView extends LocatableVLayout implements BookmarkableView
}
}
} else {
- com.allen_sauer.gwt.log.client.Log.info("WARN: While rendering DashboardsView tabSet is null.");
+ Log.info("WARN: While rendering DashboardsView, tabSet is null.");
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java
index ea64488..4c145b7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/MeasurementDataGWTService.java
@@ -80,11 +80,12 @@ public interface MeasurementDataGWTService extends RemoteService {
void updateSchedulesForCompatibleGroup(int resourceGroupId, int[] measurementDefinitionIds, long collectionInterval);
- void enableMeasurementTemplates(int[] measurementDefinitionIds);
+ void enableSchedulesForResourceType(int[] measurementDefinitionIds, boolean updateExistingSchedules);
- void disableMeasurementTemplates(int[] measurementDefinitionIds);
+ void disableSchedulesForResourceType(int[] measurementDefinitionIds, boolean updateExistingSchedules);
- void updateMeasurementTemplates(int[] measurementDefinitionIds, long collectionInterval);
+ void updateSchedulesForResourceType(int[] measurementDefinitionIds, long collectionInterval,
+ boolean updateExistingSchedules);
PageList<MeasurementDataTrait> findTraitsByCriteria(MeasurementDataTraitCriteria criteria);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
index 9073af2..0a83095 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/MeasurementDataGWTServiceImpl.java
@@ -199,25 +199,29 @@ public class MeasurementDataGWTServiceImpl extends AbstractGWTServiceImpl implem
}
}
- public void enableMeasurementTemplates(int[] measurementDefinitionIds) {
+ public void enableSchedulesForResourceType(int[] measurementDefinitionIds, boolean updateExistingSchedules) {
try {
- scheduleManager.enableMeasurementTemplates(getSessionSubject(), measurementDefinitionIds);
+ scheduleManager.updateDefaultCollectionIntervalForMeasurementDefinitions(getSessionSubject(),
+ measurementDefinitionIds, 0, updateExistingSchedules);
} catch (RuntimeException e) {
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
- public void disableMeasurementTemplates(int[] measurementDefinitionIds) {
+ public void disableSchedulesForResourceType(int[] measurementDefinitionIds, boolean updateExistingSchedules) {
try {
- scheduleManager.disableMeasurementTemplates(getSessionSubject(), measurementDefinitionIds);
+ scheduleManager.updateDefaultCollectionIntervalForMeasurementDefinitions(getSessionSubject(),
+ measurementDefinitionIds, -1, updateExistingSchedules);
} catch (RuntimeException e) {
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
- public void updateMeasurementTemplates(int[] measurementDefinitionIds, long collectionInterval) {
+ public void updateSchedulesForResourceType(int[] measurementDefinitionIds, long collectionInterval,
+ boolean updateExistingSchedules) {
try {
- scheduleManager.updateMeasurementTemplates(getSessionSubject(), measurementDefinitionIds, collectionInterval);
+ scheduleManager.updateDefaultCollectionIntervalForMeasurementDefinitions(getSessionSubject(),
+ measurementDefinitionIds, collectionInterval, updateExistingSchedules);
} catch (RuntimeException e) {
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
index ccd65bc..3dc8b05 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
@@ -332,13 +332,16 @@ public class MeasurementScheduleManagerBean implements MeasurementScheduleManage
}
/**
- * (Re-)Enables all collection schedules in the given measurement definition IDs and sets their collection
- * intervals. This only enables the "templates", it does not enable actual schedules unless updateExistingSchedules
- * is set to true.
+ * Updates the default enablement and/or collection intervals (i.e. metric templates) for the given measurement
+ * definitions. If updateExistingSchedules is true, the schedules for the corresponding metrics or all inventoried
+ * Resources are also updated. Otherwise, the updated templates will only affect Resources that added to
+ * inventory in the future.
*
* @param subject a valid subject that has Permission.MANAGE_SETTINGS
* @param measurementDefinitionIds The primary keys for the definitions
- * @param collectionInterval the new interval in millisconds for collection
+ * @param collectionInterval if > 0, enable the metric with this value as the the new collection
+ * interval, in milliseconds; if == 0, enable the metric with its current
+ * collection interval; if < 0, disable the metric
* @param updateExistingSchedules If true, then existing schedules for this definition will also be updated.
*/
@RequiredPermission(Permission.MANAGE_SETTINGS)
@@ -358,13 +361,13 @@ public class MeasurementScheduleManagerBean implements MeasurementScheduleManage
return;
}
- boolean enableDisable = (collectionInterval > 0);
+ boolean enable = (collectionInterval >= 0);
// batch the modifications to prevent the ORA error about IN clauses containing more than 1000 items
for (int batchIndex = 0; (batchIndex < measurementDefinitionIds.length); batchIndex += 1000) {
int[] batchIdArray = ArrayUtils.copyOfRange(measurementDefinitionIds, batchIndex, batchIndex + 1000);
- modifyDefaultCollectionIntervalForMeasurementDefinitions(subject, batchIdArray, enableDisable,
+ modifyDefaultCollectionIntervalForMeasurementDefinitions(subject, batchIdArray, enable,
collectionInterval, updateExistingSchedules);
}
}
13 years, 1 month
[rhq] 2 commits - modules/core
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 136 +++++-----
1 file changed, 73 insertions(+), 63 deletions(-)
New commits:
commit 7155896be74b82b2a9be7b1358103a4e2182fbcf
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Oct 29 16:52:44 2010 -0400
we need to remove the disabled resource's IDs from the callers set - removing resources from our internal resource set is useless
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 4c3b345..e483bb7 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
@@ -2449,7 +2449,7 @@ public class InventoryManager extends AgentService implements ContainerService,
Set<Resource> unknownResources = configuration.getServerServices().getDiscoveryServerService()
.getResources(unknownResourceIds, true);
- Set<Resource> toBeIgnored = new HashSet<Resource>();
+ Set<Integer> toBeIgnored = new HashSet<Integer>();
for (Resource unknownResource : unknownResources) {
ResourceType resourceType = pmm.getType(unknownResource.getResourceType());
@@ -2457,7 +2457,7 @@ public class InventoryManager extends AgentService implements ContainerService,
mergeResource(unknownResource);
syncSchedulesRecursively(unknownResource);
} else {
- toBeIgnored.add(unknownResource);
+ toBeIgnored.add(unknownResource.getId());
if (log.isDebugEnabled()) {
log.debug("During an inventory sync, the server gave us resource [" + unknownResource
+ "] but its type is disabled in the agent; ignoring it");
@@ -2465,7 +2465,7 @@ public class InventoryManager extends AgentService implements ContainerService,
}
}
- unknownResources.removeAll(toBeIgnored);
+ unknownResourceIds.removeAll(toBeIgnored);
}
return;
}
commit 6cfd66930f8cb270cca55f76d38591b01bd7776a
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Oct 29 16:51:36 2010 -0400
reformat - no coding changes here, just reformating
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 2e15f8e..4c3b345 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
@@ -243,19 +243,16 @@ public class InventoryManager extends AgentService implements ContainerService,
// inside EmbJopr).
if (configuration.isInsideAgent()) {
// After an initial delay (5s by default), periodically run an availability check (every 1m by default).
- availabilityThreadPoolExecutor.scheduleWithFixedDelay(availabilityExecutor,
- configuration.getAvailabilityScanInitialDelay(), configuration.getAvailabilityScanPeriod(),
- TimeUnit.SECONDS);
+ availabilityThreadPoolExecutor.scheduleWithFixedDelay(availabilityExecutor, configuration
+ .getAvailabilityScanInitialDelay(), configuration.getAvailabilityScanPeriod(), TimeUnit.SECONDS);
// After an initial delay (10s by default), periodically run a server discovery scan (every 15m by default).
- inventoryThreadPoolExecutor.scheduleWithFixedDelay(serverScanExecutor,
- configuration.getServerDiscoveryInitialDelay(), configuration.getServerDiscoveryPeriod(),
- TimeUnit.SECONDS);
+ inventoryThreadPoolExecutor.scheduleWithFixedDelay(serverScanExecutor, configuration
+ .getServerDiscoveryInitialDelay(), configuration.getServerDiscoveryPeriod(), TimeUnit.SECONDS);
// After an initial delay (20s by default), periodically run a service discovery scan (every 1d by default).
- inventoryThreadPoolExecutor.scheduleWithFixedDelay(serviceScanExecutor,
- configuration.getServiceDiscoveryInitialDelay(), configuration.getServiceDiscoveryPeriod(),
- TimeUnit.SECONDS);
+ inventoryThreadPoolExecutor.scheduleWithFixedDelay(serviceScanExecutor, configuration
+ .getServiceDiscoveryInitialDelay(), configuration.getServiceDiscoveryPeriod(), TimeUnit.SECONDS);
}
} finally {
inventoryLock.writeLock().unlock();
@@ -294,25 +291,26 @@ public class InventoryManager extends AgentService implements ContainerService,
* @throws Exception if the discovery component threw an exception
*/
public Set<DiscoveredResourceDetails> invokeDiscoveryComponent(ResourceContainer parentResourceContainer,
- ResourceDiscoveryComponent component, ResourceDiscoveryContext context) throws DiscoverySuspendedException, Exception {
+ ResourceDiscoveryComponent component, ResourceDiscoveryContext context) throws DiscoverySuspendedException,
+ Exception {
Resource parentResource = parentResourceContainer == null ? null : parentResourceContainer.getResource();
if (resourceUpgradeDelegate.hasUpgradeFailedInChildren(parentResource, context.getResourceType())) {
String message = "Discovery of [" + context.getResourceType() + "] has been suspended under "
- + (parentResource == null ? " the platform " : parentResource)
- + " because some of its siblings failed to upgrade.";
-
+ + (parentResource == null ? " the platform " : parentResource)
+ + " because some of its siblings failed to upgrade.";
+
log.debug(message);
-
+
throw new DiscoverySuspendedException(message);
}
long timeout = getDiscoveryComponentTimeout(context.getResourceType());
try {
- ResourceDiscoveryComponent proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(
- context.getResourceType(), component, timeout);
+ ResourceDiscoveryComponent proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(context
+ .getResourceType(), component, timeout);
Set<DiscoveredResourceDetails> results = proxy.discoverResources(context);
return results;
} catch (TimeoutException te) {
@@ -344,8 +342,8 @@ public class InventoryManager extends AgentService implements ContainerService,
long timeout = getDiscoveryComponentTimeout(context.getResourceType());
try {
- ManualAddFacet proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(
- context.getResourceType(), component, timeout, ManualAddFacet.class);
+ ManualAddFacet proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(context
+ .getResourceType(), component, timeout, ManualAddFacet.class);
DiscoveredResourceDetails result = proxy.discoverResource(pluginConfig, context);
return result;
} catch (TimeoutException te) {
@@ -384,8 +382,8 @@ public class InventoryManager extends AgentService implements ContainerService,
component, timeout, ClassLoaderFacet.class);
ResourceDiscoveryContext discoveryContext = new ResourceDiscoveryContext(resourceType, parentComponent,
- parentResourceContext, SystemInfoFactory.createSystemInfo(), null, null,
- this.configuration.getContainerName(), this.configuration.getPluginContainerDeployment());
+ 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.
@@ -600,8 +598,7 @@ public class InventoryManager extends AgentService implements ContainerService,
@NotNull
// TODO (ips): Perhaps refactor this so that it shares code with AvailablityExecutor.checkInventory().
- public
- Availability getCurrentAvailability(Resource resource) {
+ public Availability getCurrentAvailability(Resource resource) {
AvailabilityType availType = null; // i.e. UNKNOWN;
ResourceContainer resourceContainer = getResourceContainer(resource);
if (resourceContainer != null) {
@@ -674,8 +671,8 @@ public class InventoryManager extends AgentService implements ContainerService,
ResourceDiscoveryContext<ResourceComponent> discoveryContext = new ResourceDiscoveryContext<ResourceComponent>(
resourceType, parentResourceComponent, parentResourceContainer.getResourceContext(),
SystemInfoFactory.createSystemInfo(), new ArrayList<ProcessScanResult>(0),
- new ArrayList<Configuration>(0), this.configuration.getContainerName(),
- this.configuration.getPluginContainerDeployment());
+ new ArrayList<Configuration>(0), this.configuration.getContainerName(), this.configuration
+ .getPluginContainerDeployment());
// Ask the plugin's discovery component to find the new resource, throwing exceptions if it cannot be
// found at all.
@@ -705,8 +702,8 @@ public class InventoryManager extends AgentService implements ContainerService,
// Ask the plugin's discovery component to find the new resource, throwing exceptions if it cannot be
// found at all.
try {
- Set<DiscoveredResourceDetails> discoveredResources = invokeDiscoveryComponent(parentResourceContainer,
- discoveryComponent, discoveryContext);
+ Set<DiscoveredResourceDetails> discoveredResources = invokeDiscoveryComponent(
+ parentResourceContainer, discoveryComponent, discoveryContext);
if ((discoveredResources == null) || discoveredResources.isEmpty()) {
log.info("Plugin Error: During manual add, discovery component method ["
+ discoveryComponent.getClass().getName() + ".discoverResources()] returned "
@@ -719,11 +716,18 @@ public class InventoryManager extends AgentService implements ContainerService,
}
discoveredResourceDetails = discoveredResources.iterator().next();
} catch (DiscoverySuspendedException e) {
- String message = "The discovery class [" + discoveryComponent.getClass().getName() + "]" +
- " uses a legacy implementation of \"manual add\" functionality. Some of the child resources" +
- " with the resource type [" + resourceType + "] under the parent resource [" + parentResourceContainer.getResource() + "]" +
- " failed to upgrade, which makes it impossible to support the legacy manual-add implementation. Either upgrade the plugin [" +
- resourceType.getPlugin() + "] to successfully upgrade all resources or consider implementing the ManuallAdd facet.";
+ String message = "The discovery class ["
+ + discoveryComponent.getClass().getName()
+ + "]"
+ + " uses a legacy implementation of \"manual add\" functionality. Some of the child resources"
+ + " with the resource type ["
+ + resourceType
+ + "] under the parent resource ["
+ + parentResourceContainer.getResource()
+ + "]"
+ + " failed to upgrade, which makes it impossible to support the legacy manual-add implementation. Either upgrade the plugin ["
+ + resourceType.getPlugin()
+ + "] to successfully upgrade all resources or consider implementing the ManuallAdd facet.";
log.info(message);
throw new PluginContainerException(message, e);
}
@@ -869,7 +873,8 @@ public class InventoryManager extends AgentService implements ContainerService,
if ((this.platform != null) && (this.platform.getInventoryStatus() == InventoryStatus.NEW)
&& newPlatformWasDeletedRecently) {
// let's make sure we are registered; its probable that our platform was deleted and we need to re-register
- log.info("No committed resources to send in our availability report - the platform/agent was deleted, let's re-register again");
+ log
+ .info("No committed resources to send in our availability report - the platform/agent was deleted, let's re-register again");
registerWithServer();
newPlatformWasDeletedRecently = false; // we've tried to recover from our platform being deleted, let's not do it again
}
@@ -909,8 +914,8 @@ public class InventoryManager extends AgentService implements ContainerService,
log.debug("Availability report content: " + report.toString(log.isTraceEnabled()));
}
- boolean ok = configuration.getServerServices().getDiscoveryServerService()
- .mergeAvailabilityReport(report);
+ boolean ok = configuration.getServerServices().getDiscoveryServerService().mergeAvailabilityReport(
+ report);
if (!ok) {
// I guess I could immediately call executeAvailabilityScanImmediately and pass its results to
// mergeAvailabilityReport again right now, but what happens if we've queued up a bunch of
@@ -959,7 +964,8 @@ public class InventoryManager extends AgentService implements ContainerService,
if ((this.platform != null) && (this.platform.getInventoryStatus() == InventoryStatus.NEW)
&& newPlatformWasDeletedRecently) {
// let's make sure we are registered; its probable that our platform was deleted and we need to re-register
- log.info("The inventory report was invalid probably because the platform/Agent was deleted; let's re-register...");
+ log
+ .info("The inventory report was invalid probably because the platform/Agent was deleted; let's re-register...");
registerWithServer();
newPlatformWasDeletedRecently = false; // we've tried to recover from our platform being deleted, let's not do it again
}
@@ -1155,8 +1161,8 @@ public class InventoryManager extends AgentService implements ContainerService,
parent.removeChildResource(resource);
}
- PluginContainer.getInstance().getMeasurementManager()
- .unscheduleCollection(Collections.singleton(resource.getId()));
+ PluginContainer.getInstance().getMeasurementManager().unscheduleCollection(
+ Collections.singleton(resource.getId()));
if (this.resourceContainers.remove(resource.getUuid()) == null) {
if (log.isDebugEnabled()) {
@@ -1261,8 +1267,8 @@ public class InventoryManager extends AgentService implements ContainerService,
logMessage.append("description, ");
}
- logMessage.replace(logMessage.length() - 1, logMessage.length(), "to become [")
- .append(existingResource.toString()).append("]");
+ logMessage.replace(logMessage.length() - 1, logMessage.length(), "to become [").append(
+ existingResource.toString()).append("]");
log.info(logMessage.toString());
} else {
@@ -1493,8 +1499,8 @@ public class InventoryManager extends AgentService implements ContainerService,
log.warn("Cannot give activated resource its discovery component. Cause: " + e);
}
- ConfigurationUtility.normalizeConfiguration(resource.getPluginConfiguration(),
- type.getPluginConfigurationDefinition());
+ ConfigurationUtility.normalizeConfiguration(resource.getPluginConfiguration(), type
+ .getPluginConfigurationDefinition());
ResourceComponent parentComponent = null;
if (resource.getParentResource() != null) {
@@ -1861,7 +1867,8 @@ public class InventoryManager extends AgentService implements ContainerService,
}
} else {
// This is very strange - there are no platform types - we should never be missing the built-in platform plugin.
- log.error("Missing platform plugin(s) - falling back to dummy platform impl; this should only occur in tests!");
+ log
+ .error("Missing platform plugin(s) - falling back to dummy platform impl; this should only occur in tests!");
// TODO: Set sysprop (e.g. rhq.test.mode=true) in integration tests,
// and throw a runtime exception here if that sysprop is not set.
return getTestPlatform();
@@ -2181,8 +2188,8 @@ public class InventoryManager extends AgentService implements ContainerService,
try {
ResourceDiscoveryContext context = new ResourceDiscoveryContext(resourceType, parentComponent,
parentResourceContext, SystemInfoFactory.createSystemInfo(), processScanResults,
- Collections.EMPTY_LIST, this.configuration.getContainerName(),
- this.configuration.getPluginContainerDeployment());
+ Collections.EMPTY_LIST, this.configuration.getContainerName(), this.configuration
+ .getPluginContainerDeployment());
newResources = new HashSet<Resource>();
try {
Set<DiscoveredResourceDetails> discoveredResources = invokeDiscoveryComponent(parentContainer,
@@ -2202,14 +2209,15 @@ public class InventoryManager extends AgentService implements ContainerService,
+ discoveredResource.getResourceType().getName() + " but should have been "
+ resourceType.getName());
}
- if (null != pluginConfigObjects
- .put(discoveredResource.getPluginConfiguration(), discoveredResource)) {
- throw new IllegalStateException("The plugin component "
- + discoveryComponent.getClass().getName()
- + " returned multiple resources that point to the same plugin configuration object on the "
- + "resource type [" + resourceType + "]. This is not allowed, please use "
- + "ResoureDiscoveryContext.getDefaultPluginConfiguration() "
- + "for each discovered resource.");
+ if (null != pluginConfigObjects.put(discoveredResource.getPluginConfiguration(),
+ discoveredResource)) {
+ throw new IllegalStateException(
+ "The plugin component "
+ + discoveryComponent.getClass().getName()
+ + " returned multiple resources that point to the same plugin configuration object on the "
+ + "resource type [" + resourceType + "]. This is not allowed, please use "
+ + "ResoureDiscoveryContext.getDefaultPluginConfiguration() "
+ + "for each discovered resource.");
}
Resource newResource = InventoryManager.createNewResource(discoveredResource);
newResources.add(newResource);
@@ -2220,7 +2228,7 @@ public class InventoryManager extends AgentService implements ContainerService,
//but we can continue the discovery in the child resource types of the existing resources.
//we can therefore pretend that the discovery returned the existing resources so that
//we can recurse into their children up in the call-chain.
- for(Resource existingResource : parentResource.getChildResources()) {
+ for (Resource existingResource : parentResource.getChildResources()) {
if (resourceType.equals(existingResource.getResourceType())) {
newResources.add(existingResource);
}
@@ -2421,8 +2429,8 @@ public class InventoryManager extends AgentService implements ContainerService,
if (log.isDebugEnabled()) {
log.debug("Merging [" + modifiedResourceIds.size() + "] modified Resources into local inventory...");
}
- Set<Resource> modifiedResources = configuration.getServerServices().getDiscoveryServerService()
- .getResources(modifiedResourceIds, false);
+ Set<Resource> modifiedResources = configuration.getServerServices().getDiscoveryServerService().getResources(
+ modifiedResourceIds, false);
syncSchedules(modifiedResources); // RHQ-792, mtime is the indicator that schedules should be sync'ed too
for (Resource modifiedResource : modifiedResources) {
mergeResource(modifiedResource);
@@ -2683,12 +2691,14 @@ public class InventoryManager extends AgentService implements ContainerService,
+ "] wasn't started while upgrading.";
if (resource.getChildResources().isEmpty()) {
- log.info(message
- + " If this is the first time the plugin container starts up and has completely empty inventory, you can ignore this message.");
+ log
+ .info(message
+ + " If this is the first time the plugin container starts up and has completely empty inventory, you can ignore this message.");
} else {
- log.error(message
- + " This can potentially cause the discovery to find resources logically equivalent to already "
- + "existing resources if the corresponding plugins support upgrade for that particular resource type.");
+ log
+ .error(message
+ + " This can potentially cause the discovery to find resources logically equivalent to already "
+ + "existing resources if the corresponding plugins support upgrade for that particular resource type.");
}
}
} else {
13 years, 1 month
[rhq] Branch 'delete-agent-plugin' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy | 36 ++++++++++
1 file changed, 36 insertions(+)
New commits:
commit ce8a780c59148f8837b492f0d4d9542bb4997e20
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Oct 29 16:37:48 2010 -0400
Add tests to verify that package and package types get deleted
diff --git a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
index a92c639..421d28f 100644
--- a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
+++ b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
@@ -21,6 +21,7 @@ import org.rhq.core.domain.criteria.ResourceCriteria
import org.rhq.core.domain.resource.InventoryStatus
import org.testng.annotations.BeforeClass
import org.rhq.enterprise.server.bundle.TestBundleServerPluginService
+import org.rhq.core.domain.content.Package;
class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
@@ -310,6 +311,12 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
</operation>
<event name="serverCEvent" description="an entry was appended to a log file"/>
+
+ <content name="ServerC.Content" category="deployable">
+ <configuration>
+ <c:simple-property name="ServerC.Content.version"/>
+ </configuration>
+ </content>
</server>
<server name="ServerD">
@@ -324,6 +331,7 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
createResources(3, 'RemoveTypesPlugin', 'ServerC')
createBundle("test-bundle-1", "Test Bundle", "ServerC", "RemoveTypesPlugin")
+ createPackage('ServerC::test-package', 'ServerC', 'RemoveTypesPlugin')
def updatedDescriptor = """
<plugin name="RemoveTypesPlugin" displayName="Remove Types Plugin" package="org.rhq.plugins.test"
@@ -457,6 +465,24 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
assertEquals("The bundle type should have been deleted", 0, bundleTypes.size())
}
+ @Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
+ void deletePackages() {
+ def packages = entityManager.createQuery("from Package p where p.name = :name")
+ .setParameter("name", "ServerC::test-package")
+ .getResultList()
+
+ assertEquals "All packages should have been deleted", 0, packages.size()
+ }
+
+ @Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
+ void deletePackageTypes() {
+ def packageTypes = entityManager.createQuery("from PackageType p where p.name = :name")
+ .setParameter("name", "ServerC.Content")
+ .getResultList()
+
+ assertEquals "All package types should have been deleted", 0, packageTypes.size()
+ }
+
/**
* This method creates the plugin-related artifacts that are need to call
* ResourceMetadataManager.registerPlugin. It creates the PluginDescriptor object, and
@@ -583,6 +609,16 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
return bundle
}
+ def createPackage(packageName, resourceTypeName, pluginName) {
+ def subjectMgr = LookupUtil.subjectManager
+ def contentMgr = LookupUtil.contentManager
+
+ def packageTypes = contentMgr.findPackageTypes(subjectMgr.overlord, resourceTypeName, pluginName)
+ def pkg = new Package(packageName, packageTypes[0])
+
+ contentMgr.persistPackage(pkg)
+ }
+
def transaction(work) {
try {
transactionManager.begin()
13 years, 1 month
[rhq] etc/samples pom.xml
by Jay Shaughnessy
etc/samples/provisioning/sample-bundle/pom.xml | 1 +
pom.xml | 7 +++++++
2 files changed, 8 insertions(+)
New commits:
commit 619a4932fbe348057905cff266f70fe1de476e77
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Oct 29 16:08:27 2010 -0400
The assembly plugin now requires a non-empty <id>someId</id> element in
the assembly XML. But that value will, by default, be tacked on to the
final artifact name. In general we don't want that to happen because we
already specifiy <finalName> in the pom config. So, in the root pom change
the default to avoid tacking on the <id> value.
diff --git a/etc/samples/provisioning/sample-bundle/pom.xml b/etc/samples/provisioning/sample-bundle/pom.xml
index 6bd4a88..697b6c4 100644
--- a/etc/samples/provisioning/sample-bundle/pom.xml
+++ b/etc/samples/provisioning/sample-bundle/pom.xml
@@ -73,6 +73,7 @@
<descriptor>src/main/scripts/assembly.xml</descriptor>
</descriptors>
<finalName>${project.build.finalName}</finalName>
+ <appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
diff --git a/pom.xml b/pom.xml
index 06be211..82f2458 100644
--- a/pom.xml
+++ b/pom.xml
@@ -792,6 +792,13 @@
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </plugin>
+
</plugins>
</build>
13 years, 1 month
[rhq] Branch 'delete-agent-plugin' - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java | 31 ++
modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy | 118 +++++++---
2 files changed, 116 insertions(+), 33 deletions(-)
New commits:
commit aa3d4cd81b3854ca37f7235103807fedd6bde5d7
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Oct 29 14:59:29 2010 -0400
Add logic to delete bundles and bundle types
ResourceMetadataManagerBean lacks support for deleting content-related
stuff. With this commit, it now deletes bundles and bundle types that
are associated with the resource type being deleted. I have also added
tests to verify that bundles and bundle types are deleted.
I had to add some additional set up code to start the master (server)
plugin container. When I first wrote my test and a call to
BundleManagerBean, an exception was thrown complaining about the master
plugin contain not running.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
index ff81a6e..d02195b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java
@@ -56,6 +56,7 @@ import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
@@ -63,6 +64,7 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.criteria.BundleCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.event.EventDefinition;
import org.rhq.core.domain.measurement.MeasurementDefinition;
@@ -79,6 +81,7 @@ import org.rhq.core.util.jdbc.JDBCUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
+import org.rhq.enterprise.server.bundle.BundleManagerLocal;
import org.rhq.enterprise.server.configuration.metadata.ConfigurationDefinitionUpdateReport;
import org.rhq.enterprise.server.configuration.metadata.ConfigurationMetadataManagerLocal;
import org.rhq.enterprise.server.event.EventManagerLocal;
@@ -138,6 +141,9 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
@EJB
private ResourceMetadataManagerLocal resourceMetadataManager; // self
+ @EJB
+ private BundleManagerLocal bundleManager;
+
@SuppressWarnings("unchecked")
public List<Plugin> getAllPluginsById(List<Integer> pluginIds) {
if (pluginIds == null || pluginIds.size() == 0) {
@@ -591,6 +597,15 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
removeFromChildren(existingType);
entityManager.merge(existingType);
+ try {
+ deleteBundles(subject, existingType);
+ } catch (Exception e) {
+ throw new RuntimeException("Bundle deletion failed. Cannot finish deleting " + existingType, e);
+ }
+
+ entityManager.flush();
+ existingType = entityManager.find(existingType.getClass(), existingType.getId());
+
// Remove all compatible groups that are of the type.
List<ResourceGroup> compatGroups = existingType.getResourceGroups();
if (compatGroups != null) {
@@ -634,6 +649,22 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
entityManager.flush();
}
+ private void deleteBundles(Subject subject, ResourceType resourceType) throws Exception {
+ BundleType bundleType = resourceType.getBundleType();
+
+ if (bundleType == null) {
+ return;
+ }
+
+ BundleCriteria criteria = new BundleCriteria();
+ criteria.addFilterBundleTypeId(bundleType.getId());
+
+ List<Bundle> bundles = bundleManager.findBundlesByCriteria(subject, criteria);
+ for (Bundle bundle : bundles) {
+ bundleManager.deleteBundle(subject, bundle.getId());
+ }
+ }
+
private void removeFromParents(ResourceType typeToBeRemoved) {
// Wrap in new HashSet to avoid ConcurrentModificationExceptions.
Set<ResourceType> parentTypes = new HashSet<ResourceType>(typeToBeRemoved.getParentResourceTypes());
diff --git a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
index 584683c..a92c639 100644
--- a/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
+++ b/modules/enterprise/server/jar/src/test/groovy/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.groovy
@@ -19,11 +19,20 @@ import org.hibernate.Session
import org.rhq.core.domain.shared.ResourceBuilder
import org.rhq.core.domain.criteria.ResourceCriteria
import org.rhq.core.domain.resource.InventoryStatus
+import org.testng.annotations.BeforeClass
+import org.rhq.enterprise.server.bundle.TestBundleServerPluginService
class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
def plugins = []
+ @BeforeClass
+ void startMBeanServer() {
+ def bundleService = new TestBundleServerPluginService();
+ prepareCustomServerPluginService(bundleService)
+ bundleService.startMasterPluginContainerWithoutSchedulingJobs()
+ }
+
@AfterClass
void removePluginsFromDB() {
transaction {
@@ -286,6 +295,8 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
<subcategory name="ServerC.Category2"/>
</subcategories>
+ <bundle type="Test Bundle"/>
+
<process-scan name="scan1" query="process|basename|match=^java.*,arg|org.rhq.serverC1|match=.*"/>
<process-scan name="scan2" query="process|basename|match=^java.*,arg|org.rhq.serverC2|match=.*"/>
@@ -312,6 +323,7 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
createPlugin 'remove-types-plugin', '1.0', originalDescriptor
createResources(3, 'RemoveTypesPlugin', 'ServerC')
+ createBundle("test-bundle-1", "Test Bundle", "ServerC", "RemoveTypesPlugin")
def updatedDescriptor = """
<plugin name="RemoveTypesPlugin" displayName="Remove Types Plugin" package="org.rhq.plugins.test"
@@ -327,31 +339,6 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
createPlugin 'remove-types-plugin', '2.0', updatedDescriptor
}
- def createResources(Integer count, String pluginName, String resourceTypeName) {
- def resourceTypeMgr = LookupUtil.resourceTypeManager
- def resourceType = resourceTypeMgr.getResourceTypeByNameAndPlugin(resourceTypeName, pluginName)
-
- assertNotNull(
- "Cannot create resources. Unable to find resource type for [name: $resourceTypeName, plugin: $pluginName]",
- resourceType
- )
-
- def resources = []
- count.times {
- resources << new ResourceBuilder()
- .createServer()
- .withResourceType(resourceType)
- .withName("${resourceType.name}-$it")
- .withUuid("$resourceType.name:")
- .withRandomResourceKey("${resourceType.name}-$it")
- .build()
- }
-
- transaction {
- resources.each { resource -> entityManager.persist(resource) }
- }
- }
-
@Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
void deleteOperationDefsForRemovedType() {
def operationMgr = LookupUtil.operationManager
@@ -452,14 +439,22 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
}
}
- def transaction(work) {
- try {
- transactionManager.begin()
- work()
- transactionManager.commit()
- } catch (Throwable t) {
- transactionManager.rollback()
- }
+ @Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
+ void deleteBundles() {
+ def bundles = entityManager.createQuery("from Bundle b where b.bundleType.name = :name")
+ .setParameter("name", "Test Bundle")
+ .getResultList()
+
+ assertEquals("Failed to delete the bundles", 0, bundles.size())
+ }
+
+ @Test(dependsOnMethods = ['upgradePluginWithTypesRemoved'], groups = ['RemoveTypes'])
+ void deleteBundleTypes() {
+ def bundleTypes = entityManager.createQuery("from BundleType b where b.name = :name")
+ .setParameter("name", "Test Bundle")
+ .getResultList()
+
+ assertEquals("The bundle type should have been deleted", 0, bundleTypes.size())
}
/**
@@ -541,6 +536,63 @@ class ResourceMetadataManagerBeanTest extends AbstractEJB3Test {
return pluginDescriptor.ampsVersion
}
+ def createResources(Integer count, String pluginName, String resourceTypeName) {
+ def resourceTypeMgr = LookupUtil.resourceTypeManager
+ def resourceType = resourceTypeMgr.getResourceTypeByNameAndPlugin(resourceTypeName, pluginName)
+
+ assertNotNull(
+ "Cannot create resources. Unable to find resource type for [name: $resourceTypeName, plugin: $pluginName]",
+ resourceType
+ )
+
+ def resources = []
+ count.times {
+ resources << new ResourceBuilder()
+ .createServer()
+ .withResourceType(resourceType)
+ .withName("${resourceType.name}-$it")
+ .withUuid("$resourceType.name:")
+ .withRandomResourceKey("${resourceType.name}-$it")
+ .build()
+ }
+
+ transaction {
+ resources.each { resource -> entityManager.persist(resource) }
+ }
+ }
+
+ def createBundle(bundleName, bundleTypeName, resourceTypeName, pluginName) {
+ def subjectMgr = LookupUtil.subjectManager
+ def bundleMgr = LookupUtil.bundleManager
+ def resourceTypeMgr = LookupUtil.resourceTypeManager
+ def resourceType = resourceTypeMgr.getResourceTypeByNameAndPlugin(resourceTypeName, pluginName)
+
+ assertNotNull(
+ "Cannot create bundle. Unable to find resource type for [name: $resourceTypeName, plugin: $pluginName]",
+ resourceType
+ )
+
+ def bundleType = bundleMgr.getBundleType(subjectMgr.overlord, bundleTypeName)
+
+ assertNotNull("Cannot create bundle. Unable to find bundle type for [name: $bundleTypeName]")
+
+ def bundle = bundleMgr.createBundle(subjectMgr.overlord, bundleName, "test bundle: $bundleName", bundleType.id)
+
+ assertNotNull("Failed create bundle for [name: $bundleName]", bundle)
+
+ return bundle
+ }
+
+ def transaction(work) {
+ try {
+ transactionManager.begin()
+ work()
+ transactionManager.commit()
+ } catch (Throwable t) {
+ transactionManager.rollback()
+ }
+ }
+
void assertTypesPersisted(msg, types, plugin) {
def typesNotFound = []
def resourceTypeMgr = LookupUtil.resourceTypeManager
13 years, 1 month
[rhq] pom.xml
by ips
pom.xml | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
New commits:
commit ad1e25d6f625101ee196cb2aafaede67440d8315
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Oct 29 11:38:25 2010 -0400
clear up a bunch of mvn 3.0 warnings
diff --git a/pom.xml b/pom.xml
index aa3c441..06be211 100644
--- a/pom.xml
+++ b/pom.xml
@@ -252,13 +252,6 @@
</dependency>
<dependency>
- <groupId>org.jboss.jbossws</groupId>
- <artifactId>jbossws-native-dist</artifactId>
- <version>${jbossws-native-dist.version}</version>
- <type>zip</type>
- </dependency>
-
- <dependency>
<groupId>org.jboss.transaction</groupId>
<artifactId>jboss-jta</artifactId>
<version>${jboss-jta.version}</version>
@@ -1112,11 +1105,14 @@
<reporting>
<plugins>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
+ <version>2.2</version>
<inherited>true</inherited>
</plugin>
+
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
@@ -1129,14 +1125,17 @@
</configuration>
<inherited>true</inherited>
</plugin>
+
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
+ <version>2.0-beta-2</version>
</plugin>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.7</version>
<configuration>
<aggregate>true</aggregate>
<additionalJOption>-J-Xmx768m</additionalJOption>
@@ -1146,6 +1145,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.6</version>
</plugin>
<!--
<plugin>
@@ -1159,6 +1159,7 @@
<!-- must be last plugin in the list -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>dashboard-maven-plugin</artifactId>
+ <version>1.0.0-beta-1</version>
</plugin>
</plugins>
</reporting>
13 years, 1 month
[rhq] pom.xml
by ips
pom.xml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
New commits:
commit 669e236c9c60e94e4f52c6597bb103188d4a4921
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Oct 29 10:49:00 2010 -0400
downgrade Maven exec plugin from v1.2 to v1.1, since v1.2 appears to not work correctly
diff --git a/pom.xml b/pom.xml
index 5270296..aa3c441 100644
--- a/pom.xml
+++ b/pom.xml
@@ -575,8 +575,10 @@
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2</version>
+ <artifactId>exec-maven-plugin</artifactId>
+ <!-- NOTE: Version 1.2 of this plugin appears to be broken, so do not
+ upgrade to that version. -->
+ <version>1.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
13 years, 1 month
[rhq] etc/samples modules/enterprise modules/jopr
by mazz
etc/samples/provisioning/sample-bundle/src/main/scripts/assembly.xml | 2 +-
modules/enterprise/remoting/cli/src/main/scripts/rhq-client.assembly.xml | 2 +-
modules/enterprise/server/container/src/main/scripts/rhq-container.assembly.xml | 2 +-
modules/jopr/dist/agent/src/main/scripts/jopr-agent.assembly.xml | 2 +-
modules/jopr/dist/server/src/main/scripts/jopr-server.assembly.xml | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
New commits:
commit 503d56b32b819e099a451c1d26298760ec021330
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Oct 29 10:40:54 2010 -0400
looks like mvn requires a non-empty <id> field now in assembly.xml files
diff --git a/etc/samples/provisioning/sample-bundle/src/main/scripts/assembly.xml b/etc/samples/provisioning/sample-bundle/src/main/scripts/assembly.xml
index 942e5f9..f778b20 100644
--- a/etc/samples/provisioning/sample-bundle/src/main/scripts/assembly.xml
+++ b/etc/samples/provisioning/sample-bundle/src/main/scripts/assembly.xml
@@ -5,7 +5,7 @@
<assembly>
<!-- The id gets appended to the end of the zipfile name unless
it's an empty string, so make it an empty string. -->
- <id></id>
+ <id>sample-bundle</id>
<formats>
<format>zip</format>
</formats>
diff --git a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.assembly.xml b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.assembly.xml
index 5407e4d..eedf6ae 100644
--- a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.assembly.xml
+++ b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.assembly.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<assembly>
- <id></id>
+ <id>rhq-client</id>
<formats>
<format>zip</format>
</formats>
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.assembly.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.assembly.xml
index 82c7e1e..a6dbf98 100644
--- a/modules/enterprise/server/container/src/main/scripts/rhq-container.assembly.xml
+++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.assembly.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<assembly>
- <id></id>
+ <id>rhq-container</id>
<formats>
<format>zip</format>
</formats>
diff --git a/modules/jopr/dist/agent/src/main/scripts/jopr-agent.assembly.xml b/modules/jopr/dist/agent/src/main/scripts/jopr-agent.assembly.xml
index 36242d2..a77b0f9 100644
--- a/modules/jopr/dist/agent/src/main/scripts/jopr-agent.assembly.xml
+++ b/modules/jopr/dist/agent/src/main/scripts/jopr-agent.assembly.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<assembly>
- <id></id>
+ <id>jopr-agent</id>
<formats>
<format>zip</format>
</formats>
diff --git a/modules/jopr/dist/server/src/main/scripts/jopr-server.assembly.xml b/modules/jopr/dist/server/src/main/scripts/jopr-server.assembly.xml
index 8fb4063..d6d0506 100644
--- a/modules/jopr/dist/server/src/main/scripts/jopr-server.assembly.xml
+++ b/modules/jopr/dist/server/src/main/scripts/jopr-server.assembly.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<assembly>
- <id></id>
+ <id>jopr-server</id>
<formats>
<format>zip</format>
</formats>
13 years, 1 month
[rhq] Branch 'release-3.0.0' - modules/plugins
by ips
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
New commits:
commit aa672c81aeefcc66a17c4655044f9c2281f37c11
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Oct 29 10:31:47 2010 -0400
jboss-as-5 plugin: jboss-reflect.jar is required by some profileservice client calls and so should be included in the list of client jars returned by ApplicationServerDiscoveryComponent.getAdditionalClasspathUrls() (https://bugzilla.redhat.com/show_bug.cgi?id=647669)
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 5068f2d..bfd1174 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
@@ -104,7 +104,8 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
"common/lib/jboss-security-aspects.jar",
"lib/jboss-managed.jar",
"lib/jboss-metatype.jar",
- "lib/jboss-dependency.jar"
+ "lib/jboss-dependency.jar",
+ "lib/jboss-reflect.jar"
);
private static final List<String> AS6_CLIENT_JARS = new ArrayList<String>(CLIENT_JARS);
13 years, 1 month