[rhq] Branch 'mtho11/d3-charts2' - 2 commits - modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java | 214 +++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java | 31 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java | 171 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/HasD3JsniChart.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java | 35 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricLineGraph.java | 246 ++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricNvd3BarChartGraph.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java | 84 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java | 33 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java | 80 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3GraphView.java | 253 ----------
13 files changed, 659 insertions(+), 523 deletions(-)
New commits:
commit 2d714af85454bfca2a5efaffa37a670348a24c91
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Jan 30 10:43:38 2013 -0800
Charting - Fix Dashboard chart make AbstractGraph not inherit MetricGraphData. Major refactor.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
index b61d6b0..ea9edd3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
@@ -18,6 +18,12 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
@@ -31,45 +37,62 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.AvailabilityCriteria;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.measurement.Availability;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.lookup.ResourceLookupComboBoxItem;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData;
import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricStackedBarGraph;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricD3GraphView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricD3Graph;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceScheduledMetricDatasource;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.Log;
+import org.rhq.enterprise.gui.coregui.client.util.async.Command;
+import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch;
+import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
/**
* @author Greg Hinkle
* @author Jay Shaughnessy
*/
-public class ResourceGraphPortlet extends ResourceMetricD3GraphView implements CustomSettingsPortlet {
+public class ResourceGraphPortlet extends ResourceMetricD3Graph implements CustomSettingsPortlet {
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "ResourceMetric";
// A default displayed, persisted name for the portlet
public static final String NAME = MSG.view_portlet_defaultName_resourceMetric();
-
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
-
public static final String CFG_RESOURCE_ID = "resourceId";
public static final String CFG_DEFINITION_ID = "definitionId";
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
public ResourceGraphPortlet(String locatorId) {
super(locatorId);
+ isPortalGraph = true;
//setChartHeight("100%");
setOverflow(Overflow.HIDDEN);
- MetricStackedBarGraph chart = new MetricStackedBarGraph();
- setJsniChart(chart);
+ setGraph(new MetricStackedBarGraph(new MetricGraphData()));
}
@Override
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ Log.debug("\n\n\nPortlet Configure !!");
if (null == this.portletWindow && null != portletWindow) {
this.portletWindow = portletWindow;
@@ -81,27 +104,153 @@ public class ResourceGraphPortlet extends ResourceMetricD3GraphView implements C
if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
PropertySimple resourceIdProperty = storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
- if (resourceIdProperty!=null) {
- Integer entityId = resourceIdProperty.getIntegerValue();
- if (entityId != null)
- if(metricGraphData == null){
- this.metricGraphData = new MetricGraphData();
- }
- metricGraphData.setEntityId(entityId);
- getJsniChart().setEntityId(entityId);
-
- }
PropertySimple measurementDefIdProperty = storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
- if (measurementDefIdProperty!=null) {
+ if (resourceIdProperty != null && measurementDefIdProperty != null) {
+ final Integer entityId = resourceIdProperty.getIntegerValue();
+ final Integer measurementDefId = measurementDefIdProperty.getIntegerValue();
+ //this.metricGraphData = new MetricGraphData();
+ graph.getMetricGraphData().setDefinitionId(measurementDefId);
+ graph.getMetricGraphData().setEntityId(entityId);
+
+ if (entityId != null && measurementDefId != null) {
+
+ queryResource(entityId, measurementDefId);
+ }
- Integer measurementDefId = measurementDefIdProperty.getIntegerValue();
- if (measurementDefId!=null)
- metricGraphData.setDefinitionId(measurementDefId);
- getJsniChart().setDefinitionId(measurementDefId);
}
}
}
+ private void queryResource(Integer entityId, final Integer measurementDefId) {
+ final long startTime = System.currentTimeMillis();
+
+ ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+
+ ResourceCriteria resourceCriteria = new ResourceCriteria();
+ resourceCriteria.addFilterId(entityId);
+ resourceService.findResourcesByCriteria(resourceCriteria, new AsyncCallback<PageList<Resource>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(), caught);
+ }
+
+ @Override
+ public void onSuccess(PageList<Resource> result) {
+ if (result.isEmpty()) {
+ return;
+ }
+ // only concerned with first resource since this is a query by id
+ final Resource resource = result.get(0);
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ typesSet.add(resource.getResourceType().getId());
+ HashSet<String> ancestries = new HashSet<String>();
+ ancestries.add(resource.getAncestry());
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ typesSet.toArray(new Integer[typesSet.size()]),
+ EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
+ new ResourceTypeRepository.TypesLoadedCallback() {
+
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ ResourceType type = types.get(resource.getResourceType().getId());
+ Log.debug("MeasurementDefs.size(): " + type.getMetricDefinitions().size());
+ for (final MeasurementDefinition def : type.getMetricDefinitions()) {
+ if (def.getId() == measurementDefId) {
+ Log.debug("Found portlet measurement definition !" + def);
+
+ getJsniChart().setEntityId(resource.getId());
+ getJsniChart().setDefinition(def);
+ queryMetricsDataForDashboardGraphs(resource.getId(), def);
+ break;
+ }
+ }
+ }
+ });
+ }
+ });
+ }
+
+ private void queryMetricsDataForDashboardGraphs(final Integer entityId, final MeasurementDefinition def) {
+ final long startTime = System.currentTimeMillis();
+
+ // setting up a deferred Command to execute after all resource queries have completed (successfully or unsuccessfully)
+ // we know there are exactly 2 resources
+ final CountDownLatch countDownLatch = CountDownLatch.create(2, new Command() {
+ @Override
+ /**
+ * Satisfied only after ALL of the metric queries AND availability have completed
+ */
+ public void execute() {
+ Log.debug("Time for Dashboard async query: " + (System.currentTimeMillis() - startTime));
+ drawGraph();
+ //redraw();
+ }
+ });
+
+ queryAvailability(entityId, countDownLatch);
+ queryMeasurementsAndMetricData(entityId, countDownLatch);
+ // now the countDown latch will run sometime asynchronously after BOTH the previous 2 queries have executed
+ }
+
+ private void queryAvailability(final Integer entityId, final CountDownLatch countDownLatch) {
+
+ final long startTime = System.currentTimeMillis();
+
+ // now return the availability
+ AvailabilityCriteria c = new AvailabilityCriteria();
+ c.addFilterResourceId(entityId);
+ c.addFilterInitialAvailability(false);
+ c.addSortStartTime(PageOrdering.ASC);
+ GWTServiceLookup.getAvailabilityService().findAvailabilityByCriteria(c,
+ new AsyncCallback<PageList<Availability>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_availability_loadFailed(), caught);
+ countDownLatch.countDown();
+ }
+
+ @Override
+ public void onSuccess(PageList<Availability> availList) {
+ Log.debug("\nSuccessfully queried Dashboard availability in: "
+ + (System.currentTimeMillis() - startTime) + " ms.");
+ PageList<Availability> downAvailList = new PageList<Availability>();
+ for (Availability availability : availList) {
+ if (availability.getAvailabilityType().equals(AvailabilityType.DOWN)
+ || availability.getAvailabilityType().equals(AvailabilityType.DISABLED)) {
+ downAvailList.add(availability);
+ }
+ }
+ graph.getMetricGraphData().setAvailabilityDownList(downAvailList);
+ countDownLatch.countDown();
+ }
+ });
+ }
+
+ private void queryMeasurementsAndMetricData(final Integer entityId, final CountDownLatch countDownLatch) {
+ final long startTime = System.currentTimeMillis();
+ //
+ GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(entityId,
+ new int[] { graph.getMetricGraphData().getDefinitionId() }, 8, MeasurementUtils.UNIT_HOURS, 60,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_loadFailed(), caught);
+ countDownLatch.countDown();
+ }
+
+ @Override
+ public void onSuccess(final List<List<MeasurementDataNumericHighLowComposite>> measurementData) {
+ Log.debug("\nSuccessfully queried Dashboard Metric data in: "
+ + (System.currentTimeMillis() - startTime) + " ms.");
+ graph.getMetricGraphData().setMetricData(measurementData.get(0));
+ countDownLatch.countDown();
+ }
+ });
+ }
+
@Override
public Canvas getHelpCanvas() {
return new HTMLFlow(MSG.view_portlet_help_graph());
@@ -112,7 +261,7 @@ public class ResourceGraphPortlet extends ResourceMetricD3GraphView implements C
DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
PropertySimple simple = storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
- if (simple == null || simple.getIntegerValue()==null) {
+ if (simple == null || simple.getIntegerValue() == null) {
removeMembers(getMembers());
addMember(new Label("<i>" + MSG.view_portlet_configure_needed() + "</i>"));
} else {
@@ -161,12 +310,12 @@ public class ResourceGraphPortlet extends ResourceMetricD3GraphView implements C
if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
Integer integerValue = storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID).getIntegerValue();
- if (integerValue!=null) {
+ if (integerValue != null) {
form.setValue(CFG_RESOURCE_ID, integerValue);
}
PropertySimple propertySimple = storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
- if (propertySimple!=null && propertySimple.getIntegerValue()!=null) {
+ if (propertySimple != null && propertySimple.getIntegerValue() != null) {
form.setValue(CFG_DEFINITION_ID, propertySimple.getIntegerValue());
}
}
@@ -199,19 +348,18 @@ public class ResourceGraphPortlet extends ResourceMetricD3GraphView implements C
DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
PropertySimple simple = storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
- if (simple == null || simple.getIntegerValue()==null) {
+ if (simple == null || simple.getIntegerValue() == null) {
addMember(new Label("<i>" + MSG.view_portlet_configure_needed() + "</i>"));
} else {
- metricGraphData.setEntityId(simple.getIntegerValue());
+ graph.getMetricGraphData().setEntityId(simple.getIntegerValue());
PropertySimple simpleDefId = storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
- Log.debug("EntityId from portal config: "+simple.getIntegerValue());
- Log.debug("DefintionId from portal config: "+simpleDefId.getIntegerValue());
- metricGraphData.setDefinitionId(simpleDefId.getIntegerValue());
- renderGraph();
+ Log.debug("EntityId from portal config: " + simple.getIntegerValue());
+ Log.debug("DefintionId from portal config: " + simpleDefId.getIntegerValue());
+ graph.getMetricGraphData().setDefinitionId(simpleDefId.getIntegerValue());
+ drawGraph();
}
}
-
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java
index 6396b61..7ccbd60 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java
@@ -26,6 +26,7 @@ import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import org.rhq.enterprise.gui.coregui.client.IconEnum;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph;
import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData;
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
@@ -42,9 +43,8 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*/
public abstract class AbstractMetricD3GraphView extends LocatableVLayout {
-
protected HTMLFlow resourceTitle;
- protected MetricGraphData metricGraphData;
+ protected AbstractGraph graph;
private Integer chartHeight;
@@ -53,14 +53,13 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout {
}
- public AbstractMetricD3GraphView(String locatorId, MetricGraphData metricGraphData){
+ public AbstractMetricD3GraphView(String locatorId, AbstractGraph graph){
this(locatorId);
- this.metricGraphData = metricGraphData;
+ this.graph = graph;
setHeight100();
setWidth100();
}
- protected abstract void renderGraph();
protected HTMLFlow getEntityTitle(){
return resourceTitle;
@@ -72,14 +71,14 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout {
protected void onDraw() {
super.onDraw();
removeMembers(getMembers());
- renderGraph();
+ drawGraph();
}
@Override
public void parentResized() {
super.parentResized();
removeMembers(getMembers());
- renderGraph();
+ drawGraph();
}
/**
@@ -90,7 +89,7 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout {
*
*/
protected void drawGraph() {
- Log.debug("drawGraph marker in AbstractMetricD3GraphView for: " + metricGraphData.getChartId());
+ Log.debug("drawGraph marker in AbstractMetricD3GraphView for: " + graph.getMetricGraphData().getChartId());
// HLayout titleHLayout = new LocatableHLayout(extendLocatorId("HTitle"));
//
@@ -112,7 +111,7 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout {
// addMember(titleHLayout);
StringBuilder divAndSvgDefs = new StringBuilder();
- divAndSvgDefs.append("<div id=\"rChart-" + metricGraphData.getChartId() + "\" ><svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" style=\"height:"+getChartHeight()+"px;\">");
+ divAndSvgDefs.append("<div id=\"rChart-" + graph.getMetricGraphData().getChartId() + "\" ><svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" style=\"height:"+getChartHeight()+"px;\">");
divAndSvgDefs.append(getSvgDefs());
divAndSvgDefs.append("</svg></div>");
HTMLFlow graph = new HTMLFlow(divAndSvgDefs.toString());
@@ -151,6 +150,14 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout {
"</defs>";
}
+ public AbstractGraph getGraph() {
+ return graph;
+ }
+
+ public void setGraph(AbstractGraph graph) {
+ this.graph = graph;
+ }
+
public abstract void drawJsniChart();
private Img createLiveGraphImage() {
@@ -167,11 +174,11 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout {
}
public void setChartHeight(Integer height) {
- metricGraphData.setChartHeight(height);
+ graph.getMetricGraphData().setChartHeight(height);
}
public Integer getChartHeight() {
- return metricGraphData.getChartHeight();
+ return graph.getMetricGraphData().getChartHeight();
}
/**
@@ -180,7 +187,7 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout {
* @param metricGraphData
*/
public void setMetricGraphData(MetricGraphData metricGraphData) {
- this.metricGraphData = metricGraphData;
+ graph.setMetricGraphData(metricGraphData);
}
protected boolean supportsLiveGraphViewDialog() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java
new file mode 100644
index 0000000..ff13fab
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java
@@ -0,0 +1,171 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.common.charttype;
+
+import java.util.List;
+
+import org.rhq.core.domain.measurement.Availability;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
+import org.rhq.core.domain.util.PageList;
+
+/**
+ * Common Graph capability.
+ * The MetricGraphData delegate is wrapped for JSNI access via d3 charts.
+ *
+ * @author Mike Thompson
+ */
+public abstract class AbstractGraph implements HasD3JsniChart {
+
+ private MetricGraphData metricGraphData;
+
+ public MetricGraphData getMetricGraphData() {
+ return metricGraphData;
+ }
+
+ public void setMetricGraphData(MetricGraphData metricGraphData) {
+ this.metricGraphData = metricGraphData;
+ }
+
+ public int getEntityId() {
+ return metricGraphData.getEntityId();
+ }
+
+ @Override
+ public void setEntityId(int entityId) {
+ metricGraphData.setEntityId(entityId);
+ }
+
+ public String getEntityName() {
+ return metricGraphData.getEntityName();
+ }
+
+ public int getDefinitionId() {
+ return metricGraphData.getDefinitionId();
+ }
+
+ @Override
+ public void setDefinitionId(int definitionId) {
+ metricGraphData.setDefinitionId(definitionId);
+ }
+
+ public MeasurementDefinition getDefinition() {
+ return metricGraphData.getDefinition();
+ }
+
+ @Override
+ public void setDefinition(MeasurementDefinition definition) {
+ metricGraphData.setDefinition(definition);
+ }
+
+ public String getChartId() {
+ return metricGraphData.getChartId();
+ }
+
+ public List<MeasurementDataNumericHighLowComposite> getMetricData() {
+ return metricGraphData.getMetricData();
+ }
+
+ public void setMetricData(List<MeasurementDataNumericHighLowComposite> metricData) {
+ metricGraphData.setMetricData(metricData);
+ }
+
+ public void setAvailabilityDownList(PageList<Availability> availabilityDownList) {
+ metricGraphData.setAvailabilityDownList(availabilityDownList);
+ }
+
+ public void setMeasurementOOBCompositeList(PageList<MeasurementOOBComposite> measurementOOBCompositeList) {
+ metricGraphData.setMeasurementOOBCompositeList(measurementOOBCompositeList);
+ }
+
+ public String getChartTitleMinLabel() {
+ return metricGraphData.getChartTitleMinLabel();
+ }
+
+ public String getChartTitleAvgLabel() {
+ return metricGraphData.getChartTitleAvgLabel();
+ }
+
+ public String getChartTitlePeakLabel() {
+ return metricGraphData.getChartTitlePeakLabel();
+ }
+
+ public String getChartDateLabel() {
+ return metricGraphData.getChartDateLabel();
+ }
+
+ public String getChartDownLabel() {
+ return metricGraphData.getChartDownLabel();
+ }
+
+ public String getChartTimeLabel() {
+ return metricGraphData.getChartTimeLabel();
+ }
+
+ public String getChartUnknownLabel() {
+ return metricGraphData.getChartUnknownLabel();
+ }
+
+ public String getChartHoverStartLabel() {
+ return metricGraphData.getChartHoverStartLabel();
+ }
+
+ public String getChartHoverEndLabel() {
+ return metricGraphData.getChartHoverEndLabel();
+ }
+
+ public String getChartHoverPeriodLabel() {
+ return metricGraphData.getChartHoverPeriodLabel();
+ }
+
+ public String getChartHoverBarLabel() {
+ return metricGraphData.getChartHoverBarLabel();
+ }
+
+ public Integer getChartHeight() {
+ return metricGraphData.getChartHeight();
+ }
+
+ public void setChartHeight(Integer chartHeight) {
+ metricGraphData.setChartHeight(chartHeight);
+ }
+
+ public String getYAxisTitle() {
+ return metricGraphData.getYAxisTitle();
+ }
+
+ public String getYAxisUnits() {
+ return metricGraphData.getYAxisUnits();
+ }
+
+ public String getXAxisTitle() {
+ return metricGraphData.getXAxisTitle();
+ }
+
+ public String getJsonMetrics() {
+ return metricGraphData.getJsonMetrics();
+ }
+
+ public boolean shouldDisplayDayOfWeekInXAxisLabel() {
+ return metricGraphData.shouldDisplayDayOfWeekInXAxisLabel();
+ }
+
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/HasD3JsniChart.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/HasD3JsniChart.java
index 8fe4b32..6bd0d7e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/HasD3JsniChart.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/HasD3JsniChart.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.common.charttype;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+
/**
* Defines GWT JSNI charting capability. Indicator of a class producing
* d3 (javascript) charts. Allows us to quickly find, in a standard
@@ -31,5 +33,6 @@ public interface HasD3JsniChart
void drawJsniChart();
void setEntityId(int entityId) ;
void setDefinitionId(int definitionId) ;
+ void setDefinition(MeasurementDefinition measurementDefinition) ;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java
index e8c2523..6deb6e4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java
@@ -79,15 +79,12 @@ public class MetricGraphData implements JsonMetricProducer {
}
/**
- * Constructor for the dashboard case when it as a saved configuration.
+ *
* @param entityId
- * @param measurementDefId
+ * @param entityName
+ * @param def
+ * @param metricData
*/
- public MetricGraphData(int entityId, int measurementDefId) {
- setEntityId(entityId);
- setDefinitionId(measurementDefId);
- }
-
public MetricGraphData(int entityId, String entityName, MeasurementDefinition def,
List<MeasurementDataNumericHighLowComposite> metricData) {
this.entityName = entityName;
@@ -97,13 +94,23 @@ public class MetricGraphData implements JsonMetricProducer {
this.metricData = metricData;
}
+ public MetricGraphData(int entityId, String entityName, MeasurementDefinition measurementDef, List<MeasurementDataNumericHighLowComposite> metrics, PageList<Availability> downAvailList, PageList<MeasurementOOBComposite> measurementOOBCompositeList) {
+ this.entityName = entityName;
+ setEntityId(entityId);
+ setDefinitionId(measurementDef.getId());
+ this.definition = measurementDef;
+ this.metricData = metrics;
+ this.availabilityDownList = downAvailList;
+ this.measurementOOBCompositeList = measurementOOBCompositeList;
+ }
+
public int getEntityId() {
return this.entityId;
}
public void setEntityId(int entityId) {
this.entityId = entityId;
- this.definition = null;
+ //this.definition = null;
}
public String getEntityName() {
@@ -116,7 +123,7 @@ public class MetricGraphData implements JsonMetricProducer {
public void setDefinitionId(int definitionId) {
this.definitionId = definitionId;
- this.definition = null;
+ //this.definition = null;
}
public MeasurementDefinition getDefinition() {
@@ -139,17 +146,14 @@ public class MetricGraphData implements JsonMetricProducer {
this.metricData = metricData;
}
- public PageList<Availability> getAvailabilityDownList() {
- return availabilityDownList;
- }
public void setAvailabilityDownList(PageList<Availability> availabilityDownList) {
this.availabilityDownList = availabilityDownList;
}
- public PageList<MeasurementOOBComposite> getMeasurementOOBCompositeList() {
- return measurementOOBCompositeList;
- }
+// public PageList<MeasurementOOBComposite> getMeasurementOOBCompositeList() {
+// return measurementOOBCompositeList;
+// }
public void setMeasurementOOBCompositeList(PageList<MeasurementOOBComposite> measurementOOBCompositeList) {
this.measurementOOBCompositeList = measurementOOBCompositeList;
@@ -213,6 +217,7 @@ public class MetricGraphData implements JsonMetricProducer {
}
public String getYAxisTitle() {
+
if (null != definition.getDisplayName() && definition.getDisplayName().length() > 55) {
return definition.getDisplayName().substring(0, 55) + "...";
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricLineGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricLineGraph.java
index 15c4a2b..6057620 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricLineGraph.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricLineGraph.java
@@ -23,145 +23,133 @@ package org.rhq.enterprise.gui.coregui.client.inventory.common.charttype;
*
* @author Mike Thompson
*/
-public final class MetricLineGraph extends MetricGraphData implements HasD3JsniChart
-{
- /**
- * Constructor for dashboard portlet view as chart definition and data are deferred to later
- * in the portlet configuration.
- *
- * @param locatorId
- */
- public MetricLineGraph(String locatorId) {
- //super(locatorId);
- }
-
+public final class MetricLineGraph extends AbstractGraph {
/**
* General constructor for stacked bar graph when you have all the data needed to
* produce the graph. (This is true for all cases but the dashboard portlet).
*/
- public MetricLineGraph(MetricGraphData metricGraphData){
- super(metricGraphData.getEntityId(), metricGraphData.getEntityName(),metricGraphData.getDefinition(),metricGraphData.getMetricData());
+ public MetricLineGraph(MetricGraphData metricGraphData) {
+ setMetricGraphData(metricGraphData);
}
-
/**
* The magic JSNI to draw the charts with d3.
*/
public native void drawJsniChart() /*-{
- console.log("Draw Metric Line jsni chart");
- var global = this,
- chartId = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartId()(),
- chartHandle = "#rChart-"+chartId,
- chartSelection = chartHandle + " svg",
- json = eval(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getJsonMetrics()()),
- yAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisTitle()(),
- yAxisUnits = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisUnits()(),
- xAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getXAxisTitle()();
-
- console.log("chart id: "+chartSelection );
- console.log(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getJsonMetrics()());
-
- //var jsonData = eval([{ x:1352204720548, high:0.016642348035599646, low:0.016642348035599646, y:0.016642348035599646},{ x:1352211680548, high:12.000200003333388, low:0.0, y:3.500050000833347},{ x:1352211920548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352212160548, high:5.0, low:1.999966667222213, y:2.750000000277778},{ x:1352212400548, high:4.0, low:2.0, y:2.5000083334722243},{ x:1352212640548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352212880548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352213120548, high:3.000050000833347, low:1.999966667222213, y:2.2500041672916677},{ x:1352213360548, high:4.0, low:1.999966667222213, y:2.7499916668055535},{ x:1352213600548, high:2.000033333888898, low:1.999966667222213, y:2.000008333750002},{ x:1352213840548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352214080548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352214320548, high:4.0, low:2.0,
y:2.5},{ x:1352214560548, high:3.0, low:1.999966667222213, y:2.250000000833347},{ x:1352214800548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352215040548, high:4.0, low:2.0, y:2.5},{ x:1352215280548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352215520548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352215760548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352216000548, high:4.0, low:2.0, y:2.5},{ x:1352216240548, high:2.000066668888963, low:1.999966667222213, y:2.000008334027794},{ x:1352216480548, high:3.0, low:1.999966667222213, y:2.2499916668055535}]);
-
-
- function draw(data){
- "use strict";
-
- var margin = {top: 10, right: 5, bottom: 30, left: 70},
- width = 400 - margin.left - margin.right,
- height = 150 - margin.top - margin.bottom;
-
- var timeScale = $wnd.d3.time.scale()
- .range([0, width])
- .domain($wnd.d3.extent(data, function(d) { return d.x; }));
-
- var yScale = $wnd.d3.scale.linear()
- .rangeRound([height, 0])
- .domain([$wnd.d3.min(data.map(function(x) {return x.low;})), $wnd.d3.max(data.map(function(x){return x.high;}))]);
-
- var xAxis = $wnd.d3.svg.axis()
- .scale(timeScale)
- .ticks(5)
- .orient("bottom");
-
- var yAxis = $wnd.d3.svg.axis()
- .scale(yScale)
- .ticks(5)
- .orient("left");
-
- var interpolation = "basis";
-
- var line = $wnd.d3.svg.line()
- .interpolate(interpolation)
- .x(function(d) { return timeScale(d.x); })
- .y(function(d) { return yScale(+d.y); });
-
- var highLine = $wnd.d3.svg.line()
- .interpolate(interpolation)
- .x(function(d) { return timeScale(d.x); })
- .y(function(d) { return yScale(+d.high); });
-
- var lowLine = $wnd.d3.svg.line()
- .interpolate(interpolation)
- .x(function(d) { return timeScale(d.x); })
- .y(function(d) { return yScale(+d.low); });
-
- var svg = $wnd.d3.select(chartSelection).append("g")
- .attr("width", width + margin.left + margin.right)
- .attr("height", height + margin.top + margin.bottom)
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
-
- svg.append("g")
- .attr("class", "x axis")
- .attr("transform", "translate(0," + height + ")")
- .call(xAxis);
-
-
- svg.append("g")
- .attr("class", "y axis")
- .call(yAxis)
- .append("text")
- .attr("transform", "rotate(-90)")
- .attr("y", -60)
- .attr("dy", ".71em")
- .style("text-anchor", "end")
- .text(yAxisUnits === "NONE" ? "" : yAxisUnits);
-
- console.log("finished axes");
-
- svg.append("path")
- .datum(data)
- .attr("class", "line")
- .attr("fill", "none")
- .attr("stroke", "steelblue")
- .attr("stroke-width", "2")
- .attr("d", line);
-
- svg.append("path")
- .datum(data)
- .attr("class", "highLine")
- .attr("fill", "none")
- .attr("stroke", "red")
- .attr("stroke-width", "1.5")
- //.attr("stroke-dasharray", "20,10,5,5,5,10")
- .attr("stroke-dasharray", "5,5")
- .attr("stroke-opacity", ".3")
- .attr("d", highLine);
-
- svg.append("path")
- .datum(data)
- .attr("class", "lowLine")
- .attr("fill", "none")
- .attr("stroke", "blue")
- .attr("stroke-width", "1.5")
- .attr("stroke-dasharray", "5,5")
- .attr("stroke-opacity", ".3")
- .attr("d", lowLine);
-
- console.log("finished paths");
- }(data);
-
- }-*/;
+ console.log("Draw Metric Line jsni chart");
+ var global = this,
+ chartId = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartId()(),
+ chartHandle = "#rChart-"+chartId,
+ chartSelection = chartHandle + " svg",
+ json = eval(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getJsonMetrics()()),
+ yAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisTitle()(),
+ yAxisUnits = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisUnits()(),
+ xAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getXAxisTitle()();
+
+ console.log("chart id: "+chartSelection );
+ console.log(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getJsonMetrics()());
+
+ //var jsonData = eval([{ x:1352204720548, high:0.016642348035599646, low:0.016642348035599646, y:0.016642348035599646},{ x:1352211680548, high:12.000200003333388, low:0.0, y:3.500050000833347},{ x:1352211920548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352212160548, high:5.0, low:1.999966667222213, y:2.750000000277778},{ x:1352212400548, high:4.0, low:2.0, y:2.5000083334722243},{ x:1352212640548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352212880548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352213120548, high:3.000050000833347, low:1.999966667222213, y:2.2500041672916677},{ x:1352213360548, high:4.0, low:1.999966667222213, y:2.7499916668055535},{ x:1352213600548, high:2.000033333888898, low:1.999966667222213, y:2.000008333750002},{ x:1352213840548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352214080548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352214320548, high:4.0, low:2.0, y
:2.5},{ x:1352214560548, high:3.0, low:1.999966667222213, y:2.250000000833347},{ x:1352214800548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352215040548, high:4.0, low:2.0, y:2.5},{ x:1352215280548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352215520548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352215760548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352216000548, high:4.0, low:2.0, y:2.5},{ x:1352216240548, high:2.000066668888963, low:1.999966667222213, y:2.000008334027794},{ x:1352216480548, high:3.0, low:1.999966667222213, y:2.2499916668055535}]);
+
+
+ function draw(data){
+ "use strict";
+
+ var margin = {top: 10, right: 5, bottom: 30, left: 70},
+ width = 400 - margin.left - margin.right,
+ height = 150 - margin.top - margin.bottom;
+
+ var timeScale = $wnd.d3.time.scale()
+ .range([0, width])
+ .domain($wnd.d3.extent(data, function(d) { return d.x; }));
+
+ var yScale = $wnd.d3.scale.linear()
+ .rangeRound([height, 0])
+ .domain([$wnd.d3.min(data.map(function(x) {return x.low;})), $wnd.d3.max(data.map(function(x){return x.high;}))]);
+
+ var xAxis = $wnd.d3.svg.axis()
+ .scale(timeScale)
+ .ticks(5)
+ .orient("bottom");
+
+ var yAxis = $wnd.d3.svg.axis()
+ .scale(yScale)
+ .ticks(5)
+ .orient("left");
+
+ var interpolation = "basis";
+
+ var line = $wnd.d3.svg.line()
+ .interpolate(interpolation)
+ .x(function(d) { return timeScale(d.x); })
+ .y(function(d) { return yScale(+d.y); });
+
+ var highLine = $wnd.d3.svg.line()
+ .interpolate(interpolation)
+ .x(function(d) { return timeScale(d.x); })
+ .y(function(d) { return yScale(+d.high); });
+
+ var lowLine = $wnd.d3.svg.line()
+ .interpolate(interpolation)
+ .x(function(d) { return timeScale(d.x); })
+ .y(function(d) { return yScale(+d.low); });
+
+ var svg = $wnd.d3.select(chartSelection).append("g")
+ .attr("width", width + margin.left + margin.right)
+ .attr("height", height + margin.top + margin.bottom)
+ .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
+
+ svg.append("g")
+ .attr("class", "x axis")
+ .attr("transform", "translate(0," + height + ")")
+ .call(xAxis);
+
+
+ svg.append("g")
+ .attr("class", "y axis")
+ .call(yAxis)
+ .append("text")
+ .attr("transform", "rotate(-90)")
+ .attr("y", -60)
+ .attr("dy", ".71em")
+ .style("text-anchor", "end")
+ .text(yAxisUnits === "NONE" ? "" : yAxisUnits);
+
+ console.log("finished axes");
+
+ svg.append("path")
+ .datum(data)
+ .attr("class", "line")
+ .attr("fill", "none")
+ .attr("stroke", "steelblue")
+ .attr("stroke-width", "2")
+ .attr("d", line);
+
+ svg.append("path")
+ .datum(data)
+ .attr("class", "highLine")
+ .attr("fill", "none")
+ .attr("stroke", "red")
+ .attr("stroke-width", "1.5")
+ //.attr("stroke-dasharray", "20,10,5,5,5,10")
+ .attr("stroke-dasharray", "5,5")
+ .attr("stroke-opacity", ".3")
+ .attr("d", highLine);
+
+ svg.append("path")
+ .datum(data)
+ .attr("class", "lowLine")
+ .attr("fill", "none")
+ .attr("stroke", "blue")
+ .attr("stroke-width", "1.5")
+ .attr("stroke-dasharray", "5,5")
+ .attr("stroke-opacity", ".3")
+ .attr("d", lowLine);
+
+ console.log("finished paths");
+ }(data);
+
+ }-*/;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricNvd3BarChartGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricNvd3BarChartGraph.java
index 8c2dd04..d84bb92 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricNvd3BarChartGraph.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricNvd3BarChartGraph.java
@@ -23,25 +23,14 @@ package org.rhq.enterprise.gui.coregui.client.inventory.common.charttype;
*
* @author Mike Thompson
*/
-public final class MetricNvd3BarChartGraph extends MetricGraphData implements HasD3JsniChart
+public final class MetricNvd3BarChartGraph extends AbstractGraph
{
-
- /**
- * Constructor for dashboard portlet view as chart definition and data are deferred to later
- * in the portlet configuration.
- * @param locatorId
- */
- public MetricNvd3BarChartGraph(String locatorId) {
- //super(locatorId);
- }
-
/**
* General constructor for stacked bar graph when you have all the data needed to
* produce the graph. (This is true for all cases but the dashboard portlet).
*/
public MetricNvd3BarChartGraph(MetricGraphData metricGraphData){
- super(metricGraphData.getEntityId(), metricGraphData.getEntityName(), metricGraphData.getDefinition(),metricGraphData.getMetricData());
-
+ setMetricGraphData(metricGraphData);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java
index 20d52b5..33998f8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java
@@ -23,21 +23,14 @@ package org.rhq.enterprise.gui.coregui.client.inventory.common.charttype;
*
* @author Mike Thompson
*/
-public final class MetricStackedBarGraph extends MetricGraphData implements HasD3JsniChart {
- /**
- * Constructor for dashboard portlet view as chart definition and data are deferred to later in the portlet
- * configuration.
- */
- public MetricStackedBarGraph() {
- //super(locatorId);
- }
+public final class MetricStackedBarGraph extends AbstractGraph {
/**
* General constructor for stacked bar graph when you have all the data needed to produce the graph. (This is true
* for all cases but the dashboard portlet).
*/
public MetricStackedBarGraph(MetricGraphData metricGraphData) {
- super(metricGraphData.getEntityId(), metricGraphData.getEntityName(), metricGraphData.getDefinition(), metricGraphData.getMetricData());
+ setMetricGraphData(metricGraphData);
}
@@ -50,29 +43,26 @@ public final class MetricStackedBarGraph extends MetricGraphData implements HasD
console.log("Draw Stacked Bar jsni chart");
var global = this;
- // json metrics data for testing purposes
- //var jsonMetrics = [{ x:1352204720548, high:0.016642348035599646, low:0.016642348035599646, y:0.016642348035599646},{ x:1352211680548, high:12.000200003333388, low:0.0, y:3.500050000833347},{ x:1352211920548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352212160548, high:5.0, low:1.999966667222213, y:2.750000000277778},{ x:1352212400548, high:4.0, low:2.0, y:2.5000083334722243},{ x:1352212640548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352212880548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352213120548, high:3.000050000833347, low:1.999966667222213, y:2.2500041672916677},{ x:1352213360548, high:4.0, low:1.999966667222213, y:2.7499916668055535},{ x:1352213600548, high:2.000033333888898, low:1.999966667222213, y:2.000008333750002},{ x:1352213840548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352214080548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352214320548, high:4.0, low:2.0, y:
2.5},{ x:1352214560548, high:3.0, low:1.999966667222213, y:2.250000000833347},{ x:1352214800548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352215040548, high:4.0, low:2.0, y:2.5},{ x:1352215280548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352215520548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352215760548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352216000548, high:4.0, low:2.0, y:2.5},{ x:1352216240548, high:2.000066668888963, low:1.999966667222213, y:2.000008334027794},{ x:1352216480548, high:3.0, low:1.999966667222213, y:2.2499916668055535}];
-
// create a chartContext object (from rhq.js) with the data required to render to a chart
// this same data could be passed to different chart types
- // This way, we are decoupled from the dependency on globals and JSNI.
- var chartContext = new $wnd.ChartContext(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartId()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartHeight()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getJsonMetrics()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getXAxisTitle()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisTitle()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisUnits()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartTitleMinLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartTitleAvgLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartTitlePeakLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartDateLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartTimeLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartDownLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartUnknownLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartHoverStartLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartHoverEndLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartHoverPeriodLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartHoverBarLabel()()
+ // This way, we are decoupled from the dependency on globals and JSNI and kept all the java interaction right here.
+ var chartContext = new $wnd.ChartContext(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartId()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHeight()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getJsonMetrics()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getXAxisTitle()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getYAxisTitle()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getYAxisUnits()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartTitleMinLabel()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartTitleAvgLabel()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartTitlePeakLabel()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartDateLabel()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartTimeLabel()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartDownLabel()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartUnknownLabel()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHoverStartLabel()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHoverEndLabel()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHoverPeriodLabel()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHoverBarLabel()()
);
@@ -465,9 +455,9 @@ public final class MetricStackedBarGraph extends MetricGraphData implements HasD
var minuteBarThreshold = 4,
firstDate = this.__data__[0].x,
secondDate = this.__data__[1].x,
- barDateDiffInMinutues = (secondDate - firstDate)/ (60000);
+ barDateDiffInMinutes = (secondDate - firstDate)/ (60000);
- if(barDateDiffInMinutues > minuteBarThreshold){
+ if(barDateDiffInMinutes > minuteBarThreshold){
// on a bar avg line if the value is undefined then use the last defined value
if(d.y == undefined){
if(i >= 1){
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
index b911476..f7e9eae 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
@@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.components.measurement.UserPreferen
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData;
import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricStackedBarGraph;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricD3GraphView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricD3Graph;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -145,7 +145,7 @@ public class D3GroupGraphListView extends LocatableVLayout {
MetricGraphData metricGraphData = new MetricGraphData(resourceGroup.getId(), resourceGroup.getName(),
measurementDefinition, data);
MetricStackedBarGraph graph = new MetricStackedBarGraph(metricGraphData);
- ResourceMetricD3GraphView graphView = new ResourceMetricD3GraphView(extendLocatorId(measurementDefinition.getName()),metricGraphData, graph);
+ ResourceMetricD3Graph graphView = new ResourceMetricD3Graph(extendLocatorId(measurementDefinition.getName()), graph);
graphView.setWidth("95%");
graphView.setHeight(250);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java
index 0fde8d9..904ce6a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph;
import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.HasD3JsniChart;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -51,32 +52,30 @@ public class ResourceGroupMetricD3GraphView extends AbstractMetricD3GraphView {
* Defines the jsniChart type like area, line, etc...
*
*/
- private HasD3JsniChart jsniChart;
+ //private HasD3JsniChart jsniChart;
- public ResourceGroupMetricD3GraphView(String locatorId){
- super(locatorId);
- //setChartHeight("150px");
- }
+// public ResourceGroupMetricD3GraphView(String locatorId){
+// super(locatorId);
+// //setChartHeight("150px");
+// }
- public ResourceGroupMetricD3GraphView(String locatorId, MetricGraphData metricGraphData, HasD3JsniChart jsniChart) {
+ public ResourceGroupMetricD3GraphView(String locatorId, AbstractGraph graph) {
//super(locatorId, entityId, entityName, def, data);
- super(locatorId,metricGraphData);
- this.jsniChart = jsniChart;
+ super(locatorId,graph);
//setChartHeight("150px");
}
- @Override
protected void renderGraph() {
- if (null == metricGraphData.getDefinition()) {
+ if (null == graph.getMetricGraphData().getDefinition()) {
ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
ResourceCriteria resourceCriteria = new ResourceCriteria();
- resourceCriteria.addFilterId(metricGraphData.getEntityId());
+ resourceCriteria.addFilterId(graph.getMetricGraphData().getEntityId());
resourceService.findResourcesByCriteria(resourceCriteria, new AsyncCallback<PageList<Resource>>() {
@Override
public void onFailure(Throwable caught) {
@@ -112,11 +111,11 @@ public class ResourceGroupMetricD3GraphView extends AbstractMetricD3GraphView {
ResourceType type = types.get(resource.getResourceType().getId());
for (MeasurementDefinition def : type.getMetricDefinitions()) {
- if (def.getId() == metricGraphData.getDefinitionId()) {
- metricGraphData.setDefinition(def);
+ if (def.getId() == graph.getMetricGraphData().getDefinitionId()) {
+ graph.getMetricGraphData().setDefinition(def);
- GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(metricGraphData.getEntityId(),
- new int[] { metricGraphData.getDefinitionId() }, 8, MeasurementUtils.UNIT_HOURS, 60,
+ GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(graph.getMetricGraphData().getEntityId(),
+ new int[] { graph.getMetricGraphData().getDefinitionId() }, 8, MeasurementUtils.UNIT_HOURS, 60,
new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
@Override
public void onFailure(Throwable caught) {
@@ -127,7 +126,7 @@ public class ResourceGroupMetricD3GraphView extends AbstractMetricD3GraphView {
@Override
public void onSuccess(
List<List<MeasurementDataNumericHighLowComposite>> result) {
- metricGraphData.setMetricData(result.get(0));
+ graph.getMetricGraphData().setMetricData(result.get(0));
drawGraph();
}
@@ -152,7 +151,7 @@ public class ResourceGroupMetricD3GraphView extends AbstractMetricD3GraphView {
*/
public void drawJsniChart()
{
- jsniChart.drawJsniChart();
+ graph.drawJsniChart();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java
index 7c65f3b..9302529 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java
@@ -133,7 +133,7 @@ public class D3GraphListView extends LocatableVLayout {
* Build whatever graph (summary or not) by grabbing the MeasurementDefinitions
* that are defined for the resource and then querying the metric and availability data.
*/
- public void buildGraphs() {
+ private void buildGraphs() {
final long startTimer = System.currentTimeMillis();
List<Long> startEndList = measurementRangeEditor.getBeginEndTimes();
final long startTime = startEndList.get(0);
@@ -218,7 +218,7 @@ public class D3GraphListView extends LocatableVLayout {
@Override
public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> metrics) {
metricsDataList = metrics;
- Log.debug("Metric graph data queried in: "
+ Log.debug("Regular Metric graph data queried in: "
+ (System.currentTimeMillis() - startTimer + " ms."));
countDownLatch.countDown();
@@ -351,14 +351,13 @@ public class D3GraphListView extends LocatableVLayout {
private void buildSingleGraph(PageList<Availability> downAvailList,
PageList<MeasurementOOBComposite> measurementOOBCompositeList, MeasurementDefinition measurementDefinition,
List<MeasurementDataNumericHighLowComposite> data, int height) {
+
MetricGraphData metricGraphData = new MetricGraphData(resource.getId(), resource.getName(),
- measurementDefinition, data);
+ measurementDefinition, data, downAvailList, measurementOOBCompositeList);
MetricStackedBarGraph graph = new MetricStackedBarGraph(metricGraphData);
- graph.setAvailabilityDownList(downAvailList);
- graph.setMeasurementOOBCompositeList(measurementOOBCompositeList);
- ResourceMetricD3GraphView graphView = new ResourceMetricD3GraphView(
- extendLocatorId(measurementDefinition.getName()), metricGraphData, graph);
+ ResourceMetricD3Graph graphView = new ResourceMetricD3Graph(
+ extendLocatorId(measurementDefinition.getName()), graph);
graphView.setWidth("95%");
graphView.setHeight(height);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java
new file mode 100644
index 0000000..0fc84ad
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java
@@ -0,0 +1,80 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
+
+import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMetricD3GraphView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.HasD3JsniChart;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData;
+import org.rhq.enterprise.gui.coregui.client.util.Log;
+
+public class ResourceMetricD3Graph extends AbstractMetricD3GraphView {
+
+ protected boolean isPortalGraph = false;
+ /**
+ * Defines the jsniChart type like area, line, etc...
+ *
+ */
+ //private HasD3JsniChart jsniChart;
+
+ /**
+ * This constructor is for the use case in the Dashboard where we dont actually
+ * have a entity or measurement yet.
+ * @param locatorId
+ */
+ public ResourceMetricD3Graph(String locatorId) {
+ super(locatorId);
+ //setChartHeight("150px");
+ }
+
+ public ResourceMetricD3Graph(String locatorId, AbstractGraph graph) {
+
+ super(locatorId, graph);
+ //this.jsniChart = jsniChart;
+ //setChartHeight("150px");
+ }
+
+
+ @Override
+ protected boolean supportsLiveGraphViewDialog() {
+ return true;
+ }
+
+ @Override
+ /**
+ * Delegate the call to rendering the JSNI chart.
+ * This way the chart type can be swapped out at any time.
+ */
+ public void drawJsniChart() {
+ graph.drawJsniChart();
+ }
+
+ public HasD3JsniChart getJsniChart() {
+ return graph;
+ }
+
+// public void setJsniChart(HasD3JsniChart jsniChart) {
+// this.graph = jsniChart;
+// }
+
+ @Override
+ protected void displayLiveGraphViewDialog() {
+ LiveGraphD3View.displayAsDialog(getLocatorId(), graph.getMetricGraphData().getEntityId(), graph.getMetricGraphData().getDefinition());
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3GraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3GraphView.java
deleted file mode 100644
index 90b5338..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3GraphView.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
-
-import java.util.List;
-
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Map;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-
-import org.rhq.core.domain.criteria.AvailabilityCriteria;
-import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.measurement.Availability;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.HasD3JsniChart;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMetricD3GraphView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.Log;
-import org.rhq.enterprise.gui.coregui.client.util.async.Command;
-import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch;
-import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
-
-
-public class ResourceMetricD3GraphView extends AbstractMetricD3GraphView
-{
- /**
- * Defines the jsniChart type like area, line, etc...
- *
- */
- private HasD3JsniChart jsniChart;
-
- /**
- * This constructor is for the use case in the Dashboard where we dont actually
- * have a entity or measurement yet.
- * @param locatorId
- */
- public ResourceMetricD3GraphView(String locatorId){
- super(locatorId);
- //setChartHeight("150px");
- }
-
-
-
- public ResourceMetricD3GraphView(String locatorId, MetricGraphData metricGraphData, HasD3JsniChart jsniChart ) {
-
- super(locatorId, metricGraphData);
- this.jsniChart = jsniChart;
- //setChartHeight("150px");
- }
-
-
- @Override
- /**
- * Render the graph by determining if we need to load definition for
- * the dashboard graph (which will be empty, all other graph types
- * will have the definition already defined and we can just render the graph).
- */
- protected void renderGraph() {
- boolean isDashboardGraph = (null == metricGraphData.getDefinition());
- if (isDashboardGraph) {
- Log.debug("Chart path for: dashboard metrics");
- queryMetricsDataForDashboardGraphs();
- } else {
- Log.debug("Chart path for: non-dashboard metrics");
- drawGraph();
- }
- }
-
- private void queryMetricsDataForDashboardGraphs(){
- Log.debug(" ** RenderGraph Dashboard Portlet path");
- final long startTime = System.currentTimeMillis();
-
- ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
-
- ResourceCriteria resourceCriteria = new ResourceCriteria();
- resourceCriteria.addFilterId(metricGraphData.getEntityId());
- resourceService.findResourcesByCriteria(resourceCriteria, new AsyncCallback<PageList<Resource>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(), caught);
- }
-
- @Override
- public void onSuccess(PageList<Resource> result) {
- if (result.isEmpty()) {
- return;
- }
- // only concerned with first resource since this is a query by id
- final Resource firstResource = result.get(0);
-
- // setting up a deferred Command to execute after all resource queries have completed (successfully or unsuccessfully)
- // we know there are exactly 2 resources
- final CountDownLatch countDownLatch = CountDownLatch.create(2,
- new Command() {
- @Override
- /**
- * Satisfied only after ALL of the metric queries AND availability have completed
- */
- public void execute() {
- Log.debug("Time for async query: "+(System.currentTimeMillis() - startTime));
- drawGraph();
- //redraw();
- }
- });
-
- queryAvailability(firstResource, countDownLatch);
- queryMeasurementsAndMetricData(firstResource, countDownLatch);
- // now the countDown latch will run sometime asynchronously after BOTH the previous 2 queries have executed
- }
- });
- }
-
- private void queryAvailability(final Resource resource, final CountDownLatch countDownLatch){
-
- final long startTime = System.currentTimeMillis();
-
- // now return the availability
- AvailabilityCriteria c = new AvailabilityCriteria();
- c.addFilterResourceId(resource.getId());
- c.addFilterInitialAvailability(false);
- c.addSortStartTime(PageOrdering.ASC);
- GWTServiceLookup.getAvailabilityService().findAvailabilityByCriteria(c,
- new AsyncCallback<PageList<Availability>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_availability_loadFailed(), caught);
- countDownLatch.countDown();
- }
-
- @Override
- public void onSuccess(PageList<Availability> availList) {
- Log.debug("\nSuccessfully queried availability in: "+ (System.currentTimeMillis() - startTime) + " ms.");
- PageList<Availability> downAvailList = new PageList<Availability>();
- for (Availability availability : availList)
- {
- if(availability.getAvailabilityType().equals(AvailabilityType.DOWN)
- || availability.getAvailabilityType().equals(AvailabilityType.DISABLED)){
- downAvailList.add(availability);
- }
- }
- metricGraphData.setAvailabilityDownList(downAvailList);
- countDownLatch.countDown();
- }
- });
- }
-
-
- private void queryMeasurementsAndMetricData(final Resource resource, final CountDownLatch countDownLatch){
- final long startTime = System.currentTimeMillis();
- HashSet<Integer> typesSet = new HashSet<Integer>();
- typesSet.add(resource.getResourceType().getId());
- HashSet<String> ancestries = new HashSet<String>();
- ancestries.add(resource.getAncestry());
- // In addition to the types of the result resources, get the types of their ancestry
- typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
-
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- typesSet.toArray(new Integer[typesSet.size()]),
- EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
- new ResourceTypeRepository.TypesLoadedCallback() {
-
- @Override
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- ResourceType type = types.get(resource.getResourceType().getId());
- for (MeasurementDefinition def : type.getMetricDefinitions()) {
- if (def.getId() == metricGraphData.getDefinitionId()) {
- metricGraphData.setDefinition(def);
-
- GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(resource.getId(),
- new int[] { metricGraphData.getDefinitionId() }, 8, MeasurementUtils.UNIT_HOURS, 60,
- new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_resource_monitor_graphs_loadFailed(), caught);
- countDownLatch.countDown();
- }
-
- @Override
- public void onSuccess(final
- List<List<MeasurementDataNumericHighLowComposite>> measurementData) {
- Log.debug("\nSuccessfully queried Metric data in: "+ (System.currentTimeMillis() - startTime)+ " ms." );
- metricGraphData.setMetricData(measurementData.get(0));
- countDownLatch.countDown();
- }
- });
- }
- }
- }
- });
- }
-
- @Override
- protected boolean supportsLiveGraphViewDialog() {
- return true;
- }
-
-
-
- @Override
- /**
- * Delegate the call to rendering the JSNI chart.
- * This way the chart type can be swapped out at any time.
- */
- public void drawJsniChart()
- {
- jsniChart.drawJsniChart();
- }
-
- public void setJsniChart(HasD3JsniChart jsniChart)
- {
- this.jsniChart = jsniChart;
- }
-
- public HasD3JsniChart getJsniChart()
- {
- return jsniChart;
- }
-
- @Override
- protected void displayLiveGraphViewDialog() {
- LiveGraphD3View.displayAsDialog(getLocatorId(), metricGraphData.getEntityId(), metricGraphData.getDefinition());
- }
-}
commit e0e2708de3ccd77644d412d01403b9b44f9bfb28
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Tue Jan 29 17:09:43 2013 -0800
Charting - Dont show avg bar line when individual bars are 4 minute bars or less.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java
index f3bdbc9..20d52b5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java
@@ -461,23 +461,33 @@ public final class MetricStackedBarGraph extends MetricGraphData implements HasD
return timeScale(d.x)+ ((width / chartContext.data.length - barOffset)/ 2);
})
.y(function (d,i) {
+
+ var minuteBarThreshold = 4,
+ firstDate = this.__data__[0].x,
+ secondDate = this.__data__[1].x,
+ barDateDiffInMinutues = (secondDate - firstDate)/ (60000);
+
+ if(barDateDiffInMinutues > minuteBarThreshold){
// on a bar avg line if the value is undefined then use the last defined value
- if(d.y == undefined){
- if(i >= 1){
- // count backward until there is a defined value
- for(var j=i; j>=1;j--){
- if(this.__data__[j].y != undefined){
- //console.log( "using: "+j +" for :"+i+", value"+this.__data__[j].y);
- return yScale(this.__data__[j].y);
- }
+ if(d.y == undefined){
+ if(i >= 1){
+ // count backward until there is a defined value
+ for(var j=i; j>=1;j--){
+ if(this.__data__[j].y != undefined){
+ //console.log( "using: "+j +" for :"+i+", value"+this.__data__[j].y);
+ return yScale(this.__data__[j].y);
+ }
+ }
+ return yScale(0);
+ }else {
+ return yScale(0);
}
- return yScale(0);
+
}else {
- return yScale(0);
+ return yScale(+d.y);
}
-
}else {
- return yScale(+d.y);
+ return yScale(0);
}
});
11 years, 3 months
[rhq] Branch 'nightly/rhq4.6.0.jon' - 8 commits - modules/enterprise modules/integration-tests
by snegrea
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginFileUploadServlet.java | 15 -
modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html | 2
modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/TestServerPluginService.java | 6
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java | 4
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/TestAlertSenderPluginService.java | 5
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java | 5
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java | 7
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftServerPluginService.java | 5
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java | 7
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java | 15 -
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java | 14 -
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/sync/test/SynchronizationManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/system/SystemManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 23 +
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java | 11
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestServerPluginService.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java | 12 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java | 120 ++++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java | 81 +++++-
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java | 110 ++++++++-
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java | 76 ++++++
38 files changed, 460 insertions(+), 106 deletions(-)
New commits:
commit a74896a61f3b8ad1b9372469368c86f115f80b28
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jan 30 17:31:12 2013 -0500
Fix test failure, when I beefed up type removal checking I neglected to
notice a dependent test that also needed updating.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
index dd5311b..7392758 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
@@ -385,6 +385,7 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
resourcesServiceE1.get(0));
List<Resource> resourcesServiceE3 = createResources(2, "RemoveTypesPlugin", "ServiceE3",
resourcesServiceE2.get(0));
+ // Intentionally greater than 200 to test an issue with Criteria fetch defaults
List<Resource> resourcesServiceE4 = createResources(205, "RemoveTypesPlugin", "ServiceE4",
resourcesServiceE3.get(0));
@@ -426,6 +427,7 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
@Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
"RemoveTypes" })
public void deleteParent() throws Exception {
+
SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
ResourceTypeManagerLocal resourceTypeMgr = LookupUtil.getResourceTypeManager();
@@ -459,12 +461,16 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
@Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
"RemoveTypes" })
- public void deleteTypeAndAllItsDescedantTypes() throws Exception {
+ public void deleteTypeAndAllItsDescendantTypes() throws Exception {
+
List<?> typesNotRemoved = getEntityManager()
.createQuery("from ResourceType t where t.plugin = :plugin and t.name in (:resourceTypes)")
.setParameter("plugin", "RemoveTypesPlugin")
- .setParameter("resourceTypes", asList("ServerE", "ServerE1", "ServerE2", "ServerE3", "ServerE4"))
- .getResultList();
+ // the types that should have been removed, if any show up we have a problem
+ .setParameter(
+ "resourceTypes",
+ asList("ServerC", "ServiceC1", "ServiceE4", "ServerF", "ServiceF1", "ServiceF2", "ServiceF3",
+ "ServiceF4")).getResultList();
assertEquals("Failed to delete resource type or one or more of its descendant types", 0, typesNotRemoved.size());
}
commit e8fd5fbf7013a34fa75c761e26a86d9a1956da99
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jan 30 17:30:28 2013 -0500
More test interaction work for the server itests. Many tests need a work area on
disk. The test area being used was typically ${java.io.tmpdir}/rhq/testClassName.
There were two issues with this:
- Different test jobs running concurrently would end up using the same work
directory. This is something that may have been happening on Jenkins.
- An mvn clean had no effect on anything hanging around in those directories,
so if test cleanup was poor it may have left legacy data that could possibly
impact future test runs.
This commit moves all of the tmpdir generation under itests-2/target/test-tmpdir/
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/TestServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/TestServerPluginService.java
index 796a562..5bfff2d 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/TestServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/TestServerPluginService.java
@@ -51,10 +51,8 @@ public abstract class TestServerPluginService extends ServerPluginService implem
public TestMasterServerPluginContainer master;
public MasterServerPluginContainerConfiguration masterConfig;
- protected TestServerPluginService() {
- // build the config at constructor time so tests have it even before the PC is initialized
- File dir = new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
- this.masterConfig = new MasterServerPluginContainerConfiguration(dir, dir, dir, null);
+ protected TestServerPluginService(File tmpdir) {
+ this.masterConfig = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir, tmpdir, null);
}
@Override
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java
index 7e43862..69ffc44 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java
@@ -224,7 +224,7 @@ public class AlertDefinitionWithComplexNotificationsTest extends AbstractEJB3Tes
em.persist(resourceAlertDefinition);
//only need this for a short time now, so that we can precreate the plugin structure
- alertSenderService = new TestAlertSenderPluginService();
+ alertSenderService = new TestAlertSenderPluginService(getTempDir());
prepareCustomServerPluginService(alertSenderService);
alertSenderService.masterConfig.getPluginDirectory().mkdirs();
unprepareServerPluginService();
@@ -247,7 +247,7 @@ public class AlertDefinitionWithComplexNotificationsTest extends AbstractEJB3Tes
//@BeforeMethod
private void containerSetup() {
- alertSenderService = new TestAlertSenderPluginService();
+ alertSenderService = new TestAlertSenderPluginService(getTempDir());
prepareCustomServerPluginService(alertSenderService);
alertSenderService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/TestAlertSenderPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/TestAlertSenderPluginService.java
index 9aae985..ac04276 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/TestAlertSenderPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/TestAlertSenderPluginService.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.alert;
+import java.io.File;
import java.util.Collections;
import java.util.List;
@@ -38,6 +39,10 @@ import org.rhq.enterprise.server.plugin.pc.alert.AlertServerPluginContainer;
*/
public class TestAlertSenderPluginService extends TestServerPluginService {
+ protected TestAlertSenderPluginService(File tmpdir) {
+ super(tmpdir);
+ }
+
@Override
protected List<AbstractTypeServerPluginContainer> createPluginContainers(MasterServerPluginContainer master) {
return Collections.<AbstractTypeServerPluginContainer>singletonList(new TestAlertServerPluginContainer(master));
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index c411671..062d91a 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -116,7 +116,7 @@ public class BundleManagerBeanTest extends AbstractEJB3Test {
agentServiceContainer = prepareForTestAgents();
agentServiceContainer.bundleService = new TestAgentClient(null, agentServiceContainer);
- this.ps = new TestBundleServerPluginService();
+ this.ps = new TestBundleServerPluginService(getTempDir());
prepareCustomServerPluginService(this.ps);
bundleManager = LookupUtil.getBundleManager();
resourceManager = LookupUtil.getResourceManager();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
index 45f210c..7481496 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
@@ -66,10 +66,9 @@ public class TestBundleServerPluginService extends ServerPluginService implement
public RecipeParseResults parseRecipe_returnValue = null;
public BundleDistributionInfo processBundleDistributionFile_returnValue;
- public TestBundleServerPluginService() {
+ public TestBundleServerPluginService(File tmpdir) {
// build the config at constructor time so tests have it even before the PC is initialized
- File dir = new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
- this.masterConfig = new MasterServerPluginContainerConfiguration(dir, dir, dir, null);
+ this.masterConfig = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir, tmpdir, null);
}
@Override
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java
index d031926..b594f61 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java
@@ -53,8 +53,8 @@ public class DatabaseAndFilePluginDeploymentTest extends AbstractEJB3Test {
private static final String PLUGIN_NAME = "DeployTest"; // as defined in our test descriptors
private static final String DESCRIPTORS_LOCATION = "test/deployment/";
- private static final String TEST_DIR = System.getProperty("java.io.tmpdir") + "/rhq/"
- + DatabaseAndFilePluginDeploymentTest.class.getName() + "/";
+ private static final String TEST_DIR = tmpdirRoot + "/" + DatabaseAndFilePluginDeploymentTest.class.getName()
+ + "/";
private static final String JARS_LOCATION = TEST_DIR + "jars";
private static final String DEPLOY_LOCATION = TEST_DIR + "deploy";
private static final String TESTPLUGIN_1_0_FEB = "1.0-feb";
@@ -199,7 +199,8 @@ public class DatabaseAndFilePluginDeploymentTest extends AbstractEJB3Test {
buildPluginJar(descriptor, file);
assert file.exists();
- PluginDescriptor pluginDescriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI().toURL());
+ PluginDescriptor pluginDescriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI()
+ .toURL());
testPluginDescriptors.put(entry.getKey(), pluginDescriptor);
Plugin pluginPojo = new Plugin(PLUGIN_NAME, file.getName());
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java
index 5f7d95c..a95079b 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java
@@ -82,7 +82,7 @@ public abstract class AbstractDriftServerTest extends AbstractEJB3Test {
}
private void initDriftServer() throws Exception {
- driftServerPluginService = new DriftServerPluginService();
+ driftServerPluginService = new DriftServerPluginService(getTempDir());
prepareCustomServerPluginService(driftServerPluginService);
driftServerPluginService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
index aa42a11..fe2ced3 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
@@ -94,7 +94,7 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
prepareScheduler();
- DriftServerPluginService driftServerPluginService = new DriftServerPluginService();
+ DriftServerPluginService driftServerPluginService = new DriftServerPluginService(getTempDir());
prepareCustomServerPluginService(driftServerPluginService);
driftServerPluginService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftServerPluginService.java
index 46d725f..de206d4 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftServerPluginService.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.drift;
+import java.io.File;
import java.util.Collections;
import java.util.List;
@@ -33,6 +34,10 @@ import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginManager;
public class DriftServerPluginService extends TestServerPluginService {
+ public DriftServerPluginService(File tmpDir) {
+ super(tmpDir);
+ }
+
@Override
protected List<AbstractTypeServerPluginContainer> createPluginContainers(MasterServerPluginContainer master) {
return Collections.<AbstractTypeServerPluginContainer>singletonList(new TestDriftServerPluginContainer(master));
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
index 9e8b4e3..1c4b780 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
@@ -122,7 +122,7 @@ public class MeasurementDataManagerBeanTest extends AbstractEJB3Test {
// MeasurementDataManagerUtility looks up config settings from SystemManagerBean.
// SystemManagerBean.getDriftServerPluginManager method requires drift server plugin.
- DriftServerPluginService driftServerPluginService = new DriftServerPluginService();
+ DriftServerPluginService driftServerPluginService = new DriftServerPluginService(getTempDir());
prepareCustomServerPluginService(driftServerPluginService);
driftServerPluginService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBeanTest.java
index 067614e..a7f16ef 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBeanTest.java
@@ -110,7 +110,7 @@ public class MeasurementOOBManagerBeanTest extends AbstractEJB3Test {
protected void beforeMethod() throws Exception {
// MeasurementDataManagerUtility looks up config settings from SystemManagerBean.
// SystemManagerBean.getDriftServerPluginManager method requires drift server plugin.
- DriftServerPluginService driftServerPluginService = new DriftServerPluginService();
+ DriftServerPluginService driftServerPluginService = new DriftServerPluginService(getTempDir());
prepareCustomServerPluginService(driftServerPluginService);
driftServerPluginService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
index ff1193d..d6ac8b2 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
@@ -90,7 +90,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
this.overlord = LookupUtil.getSubjectManager().getOverlord();
additionalResources = new ArrayList<Resource>();
- testServerPluginService = new TestServerPluginService();
+ testServerPluginService = new TestServerPluginService(getTempDir());
prepareCustomServerPluginService(testServerPluginService);
testServerPluginService.masterConfig.getPluginDirectory().mkdirs();
testServerPluginService.startMasterPluginContainer();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
index b12d90c..e7f9da5 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
@@ -54,7 +54,7 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
@Override
protected void beforeMethod() {
TestGenericServerPluginService pluginService;
- pluginService = new TestGenericServerPluginService();
+ pluginService = new TestGenericServerPluginService(getTempDir());
prepareCustomServerPluginService(pluginService);
serverPluginsBean = LookupUtil.getServerPlugins();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java
index 5850985..7642ec1 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java
@@ -42,6 +42,7 @@ public class TestContentServerPluginService extends ServerPluginService implemen
private Map<Integer, ContentProvider> providers = new HashMap<Integer, ContentProvider>();
private TestContentProvider defaultTestContentProvider;
+ private File tmpdir;
/**
* Creates and initializes the content server plugin container for use with the given test case.
@@ -50,6 +51,7 @@ public class TestContentServerPluginService extends ServerPluginService implemen
*/
public TestContentServerPluginService(AbstractEJB3Test testContainer) {
super();
+ tmpdir = testContainer.getTempDir();
testContainer.prepareCustomServerPluginService(this);
startMasterPluginContainer();
@@ -86,9 +88,8 @@ public class TestContentServerPluginService extends ServerPluginService implemen
protected MasterServerPluginContainer createMasterPluginContainer() {
MasterServerPluginContainer master = new TestMasterServerPluginContainer();
- File dir = new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
- MasterServerPluginContainerConfiguration config = new MasterServerPluginContainerConfiguration(dir, dir, dir,
- null);
+ MasterServerPluginContainerConfiguration config = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir,
+ tmpdir, null);
master.initialize(config);
return master;
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
index e8ece2e..1bbe447 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
@@ -55,7 +55,7 @@ public class GenericServerPluginTest extends AbstractEJB3Test {
@Override
protected void beforeMethod() throws Exception {
- this.pluginService = new TestGenericServerPluginService();
+ this.pluginService = new TestGenericServerPluginService(getTempDir());
deleteAllTestPluginJars(); // remove any old server plugins that might be still around
prepareCustomServerPluginService(this.pluginService);
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
index 85f45d0..736b615 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
@@ -55,10 +55,9 @@ public class TestGenericServerPluginService extends ServerPluginService implemen
public TestGenericServerPluginContainer genericPC;
public MasterServerPluginContainerConfiguration masterConfig;
- public TestGenericServerPluginService() {
+ public TestGenericServerPluginService(File tmpdir) {
// build the config at constructor time so tests have it even before the PC is initialized
- File dir = new File(System.getProperty("java.io.tmpdir" + "/rhq"), this.getClass().getSimpleName());
- this.masterConfig = new MasterServerPluginContainerConfiguration(dir, dir, dir, null);
+ this.masterConfig = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir, tmpdir, null);
}
@Override
@@ -197,11 +196,11 @@ public class TestGenericServerPluginService extends ServerPluginService implemen
File pluginFile = new File(env.getPluginUrl().toURI());
ServerPlugin plugin = new ServerPlugin(0, env.getPluginKey().getPluginName(), pluginFile.getName(),
- pluginDescriptor.getDisplayName(), true, PluginStatusType.INSTALLED, pluginDescriptor
- .getDescription(), "", MessageDigestGenerator.getDigestString(pluginFile), pluginDescriptor
- .getVersion(), pluginDescriptor.getVersion(), pluginConfig, scheduledJobsConfig,
- new ServerPluginType(pluginDescriptor).stringify(), System.currentTimeMillis(), System
- .currentTimeMillis());
+ pluginDescriptor.getDisplayName(), true, PluginStatusType.INSTALLED,
+ pluginDescriptor.getDescription(), "", MessageDigestGenerator.getDigestString(pluginFile),
+ pluginDescriptor.getVersion(), pluginDescriptor.getVersion(), pluginConfig, scheduledJobsConfig,
+ new ServerPluginType(pluginDescriptor).stringify(), System.currentTimeMillis(),
+ System.currentTimeMillis());
return plugin;
} catch (Exception e) {
throw new RuntimeException(e);
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java
index 6f8c497..6c0fd5e 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java
@@ -101,7 +101,7 @@ public class LdapGroupManagerBeanTest extends AbstractEJB3Test {
ldapGroupManager = LookupUtil.getLdapGroupManager();
//we need this because the drift plugins are referenced from the system settings that we use in our tests
- testServerPluginService = new TestServerPluginService();
+ testServerPluginService = new TestServerPluginService(getTempDir());
prepareCustomServerPluginService(testServerPluginService);
testServerPluginService.startMasterPluginContainer();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
index 5d3bf77..8afabf2 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
@@ -79,7 +79,7 @@ public class MetadataBeanTest extends AbstractEJB3Test {
setupDB();
- TestBundleServerPluginService bundleService = new TestBundleServerPluginService();
+ TestBundleServerPluginService bundleService = new TestBundleServerPluginService(getTempDir());
prepareCustomServerPluginService(bundleService);
bundleService.startMasterPluginContainerWithoutSchedulingJobs();
prepareScheduler();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java
index f05e079..23e8efe 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java
@@ -79,7 +79,7 @@ public class UpdatePluginMetadataTestBase extends AbstractEJB3Test {
preparePluginScannerService();
// we perform lookups of config settings from SystemManagerBean.
// SystemManagerBean.getDriftServerPluginManager method requires drift server plugin.
- DriftServerPluginService driftServerPluginService = new DriftServerPluginService();
+ DriftServerPluginService driftServerPluginService = new DriftServerPluginService(getTempDir());
prepareCustomServerPluginService(driftServerPluginService);
driftServerPluginService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java
index 7036dc5..e835a2e 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java
@@ -100,7 +100,7 @@ public class ResourceFactoryManagerBeanTest extends AbstractEJB3Test {
agentServiceContainer.resourceFactoryService = mockAgentService;
//the server plugins are in play when package types are involved
- StandardServerPluginService serverPluginService = new StandardServerPluginService();
+ StandardServerPluginService serverPluginService = new StandardServerPluginService(getTempDir());
prepareCustomServerPluginService(serverPluginService);
serverPluginService.startMasterPluginContainer();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
index 2d37c66..9cc4bc9 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
@@ -98,7 +98,7 @@ public class DataPurgeJobTest extends AbstractEJB3Test {
protected void beforeMethod() throws Exception {
try {
//we need this because the drift plugins are referenced from the system settings that we use in our tests
- testServerPluginService = new TestServerPluginService();
+ testServerPluginService = new TestServerPluginService(getTempDir());
prepareCustomServerPluginService(testServerPluginService);
testServerPluginService.startMasterPluginContainer();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/sync/test/SynchronizationManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/sync/test/SynchronizationManagerBeanTest.java
index f00fe27..c870dc9 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/sync/test/SynchronizationManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/sync/test/SynchronizationManagerBeanTest.java
@@ -299,7 +299,7 @@ public class SynchronizationManagerBeanTest extends AbstractEJB3Test {
}
//we need this because the drift plugins are referenced from the system settings that we use in our tests
- testData.testServerPluginService = new TestServerPluginService();
+ testData.testServerPluginService = new TestServerPluginService(getTempDir());
prepareCustomServerPluginService(testData.testServerPluginService);
testData.testServerPluginService.startMasterPluginContainer();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/system/SystemManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/system/SystemManagerBeanTest.java
index 557c787..104ff85 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/system/SystemManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/system/SystemManagerBeanTest.java
@@ -45,7 +45,7 @@ public class SystemManagerBeanTest extends AbstractEJB3Test {
overlord = LookupUtil.getSubjectManager().getOverlord();
//we need this because the drift plugins are referenced from the system settings that we use in our tests
- testServerPluginService = new TestServerPluginService();
+ testServerPluginService = new TestServerPluginService(getTempDir());
prepareCustomServerPluginService(testServerPluginService);
testServerPluginService.startMasterPluginContainer();
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index e4dbc4b..270b053 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -78,6 +78,8 @@ public abstract class AbstractEJB3Test extends Arquillian {
protected static final String JNDI_RHQDS = "java:jboss/datasources/RHQDS";
+ protected static File tmpdirRoot = new File("./target/test-tmpdir");
+
private TestServerCommunicationsService agentService;
private SchedulerService schedulerService;
private ServerPluginService serverPluginService;
@@ -90,16 +92,19 @@ public abstract class AbstractEJB3Test extends Arquillian {
protected InitialContext initialContext;
// We originally (in 4.2.3 days) ran these tests as "unit" tests in the server/jar module using
- // the embedded conatiner. With Arquillian it makes sense to actually deploy an EAR because
+ // the embedded container. With Arquillian it makes sense to actually deploy an EAR because
// we need a way to deploy dependent ears needed to support the server/jar classes. But
// building this jar up (as is done in core/domain) was too difficult due to the huge number
- // of dependencies. It was easier, and probably more sensical, to use the already built rhq.ear
+ // of dependencies. It was easier, and made sense, to use the already built rhq.ear
// and run as true integration tests. We do thin rhq.ear by removing all of the WAR files, and
// deploy only the EJB jars, and the services, which are really the objects under test.
@Deployment
protected static EnterpriseArchive getBaseDeployment() {
+ // Ensure the test working dir exists
+ tmpdirRoot.mkdirs();
+
// deploy the test classes in their own jar, under /lib
JavaArchive testClassesJar = ShrinkWrap.create(JavaArchive.class, "test-classes.jar");
testClassesJar = addClasses(testClassesJar, new File("target/test-classes/org"), null);
@@ -122,8 +127,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
testClassesJar.addAsResource("test-ldap.properties");
testClassesJar.addAsResource("test-scheduler.properties");
testClassesJar
- .addAsResource(
- "org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml");
+ .addAsResource("org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml");
testClassesJar
.addAsResource("org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml");
testClassesJar.addAsResource("org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml");
@@ -321,8 +325,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
testEar.add(new ClassAsset(StrippedDownStartupBeanPreparation.class), ArchivePaths
.create("/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/test/"
+ "StrippedDownStartupBeanPreparation.class"));
- testEar.addAsManifestResource(new ByteArrayAsset("<beans/>".getBytes()),
- ArchivePaths.create("beans.xml"));
+ testEar.addAsManifestResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"));
// add the test classes to the deployment
testEar.addAsLibrary(testClassesJar);
@@ -1105,11 +1108,11 @@ public abstract class AbstractEJB3Test extends Arquillian {
return file.delete();
}
- /**
- * @return a temp directory for testing that is specific to this test class.
+ /**
+ * @return a temp directory for testing that is specific to this test class. Specifically tmpdirRoot/this.getClass().getSimpleName().
*/
- protected File getTempDir() {
- return new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
+ public File getTempDir() {
+ return new File(tmpdirRoot, this.getClass().getSimpleName());
}
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java
index adcde42..6b938fd 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java
@@ -50,10 +50,10 @@ public class StandardServerPluginService extends ServerPluginService implements
public static class TestMasterServerPluginContainer extends MasterServerPluginContainer {
private List<AbstractTypeServerPluginContainer> serverPluginContainers = new ArrayList<AbstractTypeServerPluginContainer>();
-
+
public TestMasterServerPluginContainer(
List<Class<? extends AbstractTypeServerPluginContainer>> pluginContainerClasses) {
-
+
for (Class<? extends AbstractTypeServerPluginContainer> cls : pluginContainerClasses) {
try {
Constructor<? extends AbstractTypeServerPluginContainer> ctor = cls
@@ -65,7 +65,7 @@ public class StandardServerPluginService extends ServerPluginService implements
}
}
}
-
+
@Override
protected List<AbstractTypeServerPluginContainer> createPluginContainers() {
return serverPluginContainers;
@@ -83,9 +83,8 @@ public class StandardServerPluginService extends ServerPluginService implements
*/
public List<Class<? extends AbstractTypeServerPluginContainer>> pluginContainerClasses;
- public StandardServerPluginService() {
- File dir = new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
- this.masterConfig = new MasterServerPluginContainerConfiguration(dir, dir, dir, null);
+ public StandardServerPluginService(File tmpdir) {
+ this.masterConfig = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir, tmpdir, null);
pluginContainerClasses = new ArrayList<Class<? extends AbstractTypeServerPluginContainer>>();
pluginContainerClasses.add(AlertServerPluginContainer.class);
pluginContainerClasses.add(BundleServerPluginContainer.class);
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestServerPluginService.java
index a8b134e..6e62b99 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestServerPluginService.java
@@ -44,10 +44,9 @@ public class TestServerPluginService extends ServerPluginService implements Test
public TestMasterServerPluginContainer master;
public MasterServerPluginContainerConfiguration masterConfig;
- public TestServerPluginService() {
+ public TestServerPluginService(File tmpdir) {
// build the config at constructor time so tests have it even before the PC is initialized
- File dir = new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
- this.masterConfig = new MasterServerPluginContainerConfiguration(dir, dir, dir, null);
+ this.masterConfig = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir, tmpdir, null);
}
@Override
commit 4d29e0578a879ecd56d4339c2be58ba96ab5111a
Author: JÃŒrgen Hoffmann <jhoffmann(a)redhat.com>
Date: Wed Jan 30 17:27:01 2013 +0100
Improving the way the Dashboard view is displayed (correct row/column alignment).
diff --git a/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html b/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html
index e42628a..041dbb7 100644
--- a/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html
+++ b/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html
@@ -30,7 +30,7 @@ an empty database (meaning resource ids and schedule ids starting at 10001).
<li><a href="/rest-examples/stacked3.html">Metrics as stacked bars</a> in pure HTML + (a little) CSS</li>
<li><a href="/rest-examples/stacked2.html">Metrics as rects using stacked bars from above</a></li>
<li><a href="/rest-examples/whisker.html">Whisker chart 1</a></li>
- <li><a href="/rest-examples/whisker2.html">Multiple Whisker charts</a></li>
+ <li><a href="/rest-examples/whisker2.html">Multiple Whisker charts ("Dashboard")</a></li>
<li><a href="/rest-examples/tree.html">Resource tree</a></li>
<li><a href="/rest-examples/raw_graph.html">7 days of raw metrics as dot- or line- chart</a></li>
<li><a href="/rest-examples/raw_graph7.html">7 days of raw metrics as dot- or line- chart - comparing daily values</a></li>
diff --git a/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js b/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js
index 870c423..67b1b17 100644
--- a/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js
+++ b/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js
@@ -2,7 +2,7 @@ var rhq = {
dashboard : function() {
// get all platforms
- $.get('/rest/resource/platforms', function(data) {
+ $.get('/rest/resource/platforms.json', function(data) {
var table = $("#table");
for (var i = 0; i < data.length ; i++ ) {
commit 74dfd37db100de71128db47eb83962c686c8c925
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jan 30 17:08:46 2013 +0100
[Bug 880819 - RFE: expose GroupDefinitionManager remotely] Subset of methods defined in the local intercace has been exposed via the remote intercase and registered in the RhqManager.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
index d374324..32832b2 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerRemote;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerRemote;
import org.rhq.enterprise.server.operation.OperationManagerRemote;
import org.rhq.enterprise.server.report.DataAccessManagerRemote;
+import org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerRemote;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
@@ -70,6 +71,7 @@ public enum RhqManager {
DriftTemplateManager(DriftTemplateManagerRemote.class, "${DriftTemplateManager}"), //
DiscoveryBoss(DiscoveryBossRemote.class, "${DiscoveryBoss}"), //
EventManager(EventManagerRemote.class, "${EventManager}"), //
+ GroupDefinitionManager(GroupDefinitionManagerRemote.class, "${GroupDefinitionManager}"), //
MeasurementBaselineManager(MeasurementBaselineManagerRemote.class, "${MeasurementBaselineManager}"), //
MeasurementDataManager(MeasurementDataManagerRemote.class, "${MeasurementDataManager}"), //
MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class, "${MeasurementDefinitionManager}"), //
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index 190a169..9d5251b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -69,7 +69,7 @@ import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@Stateless
-public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal {
+public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal, GroupDefinitionManagerRemote {
private final Log log = LogFactory.getLog(GroupDefinitionManagerBean.class);
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
@@ -415,15 +415,14 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal {
public PageList<GroupDefinition> findGroupDefinitionsByCriteria(Subject subject,
ResourceGroupDefinitionCriteria criteria) {
- CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
if (authorizationManager.isInventoryManager(subject) == false) {
if (criteria.isInventoryManagerRequired()) {
throw new PermissionException("Subject [" + subject.getName()
+ "] requires InventoryManager permission for requested query criteria.");
}
}
-
+
+ CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
CriteriaQueryRunner<GroupDefinition> queryRunner = new CriteriaQueryRunner<GroupDefinition>(criteria,
generator, entityManager);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java
new file mode 100644
index 0000000..70e3f88
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java
@@ -0,0 +1,120 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.server.resource.group.definition;
+
+import javax.ejb.Remote;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria;
+import org.rhq.core.domain.resource.group.GroupDefinition;
+import org.rhq.core.domain.resource.group.InvalidExpressionException;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.resource.group.ResourceGroupDeleteException;
+import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionAlreadyExistsException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionCreateException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionDeleteException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionNotFoundException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionUpdateException;
+
+
+/**
+ * The remote interface to the SLSB GroupDefinitionManager.
+ *
+ * @author Jirka Kremser
+ */
+@Remote
+public interface GroupDefinitionManagerRemote {
+
+ /**
+ * Finds the group definition by id
+ *
+ * @param groupDefinitionId the id
+ * @return instance of <code>GroupDefinition</code>
+ * @throws GroupDefinitionNotFoundException in case the group definition has not been found
+ */
+ GroupDefinition getById(int groupDefinitionId) throws GroupDefinitionNotFoundException;
+
+ /**
+ * Creates a new group definiton.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking create the group definition
+ * @param newGroupDefinition the object defining the group definition
+ * @return instance of <code>GroupDefinition</code>
+ * @throws GroupDefinitionAlreadyExistsException
+ * @throws GroupDefinitionCreateException
+ */
+ GroupDefinition createGroupDefinition(Subject subject, GroupDefinition newGroupDefinition)
+ throws GroupDefinitionAlreadyExistsException, GroupDefinitionCreateException;
+
+ /**
+ * Fetches the group definitions based on provided criteria.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to find the group definitions
+ * @param criteria the criteria
+ * @return instance of <code>GroupDefinition</code>
+ */
+ PageList<GroupDefinition> findGroupDefinitionsByCriteria(Subject subject, ResourceGroupDefinitionCriteria criteria);
+
+ /**
+ * Deletes the given group definition.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to remove the group definition
+ * @param groupDefinitionId the id of a group definition to be deleted
+ * @throws GroupDefinitionNotFoundException
+ * @throws GroupDefinitionDeleteException
+ */
+ void removeGroupDefinition(Subject subject, Integer groupDefinitionId) throws GroupDefinitionNotFoundException,
+ GroupDefinitionDeleteException;
+
+ /**
+ * Updates the given group definition.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to update the group definition
+ * @param updated the object defining the group definition to be changed (based on its id)
+ * @return the updated group definition
+ * @throws GroupDefinitionAlreadyExistsException
+ * @throws GroupDefinitionUpdateException
+ * @throws InvalidExpressionException
+ * @throws ResourceGroupUpdateException
+ */
+ GroupDefinition updateGroupDefinition(Subject subject, GroupDefinition updated)
+ throws GroupDefinitionAlreadyExistsException, GroupDefinitionUpdateException, InvalidExpressionException,
+ ResourceGroupUpdateException;
+
+ /**
+ * Explicitly recalculates the group membership, depending on the GroupDefinition's expression.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to recalculate the group membership
+ * @param groupDefinitionId the id of a group definition to be recalculated
+ * @throws ResourceGroupDeleteException
+ * @throws GroupDefinitionDeleteException
+ * @throws GroupDefinitionNotFoundException
+ * @throws InvalidExpressionException
+ */
+ void calculateGroupMembership(Subject subject, int groupDefinitionId) throws ResourceGroupDeleteException,
+ GroupDefinitionDeleteException, GroupDefinitionNotFoundException, InvalidExpressionException;
+
+}
\ No newline at end of file
commit bfc0a46761e3a13e17da91dd68be47c32952874e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 29 18:42:09 2013 -0500
Hopefully final tweeks to MergeInventoryReport
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index cea1f6e..d5d7128 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -859,7 +859,6 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
log.debug("getExistingResource processing for [" + resource + "]");
}
- // We perform this query a lot during a large inventory merge, so minimize overhead by using it directly
Resource existingResource = null;
if (resource.getId() != 0) {
@@ -867,7 +866,8 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
log.debug("Agent claims resource is already in inventory. Id=" + resource.getId());
}
- existingResource = entityManager.getReference(Resource.class, resource.getId());
+ // This maybe could be more efficient using a named query that pulls some lazy data, but this should be fine
+ existingResource = entityManager.find(Resource.class, resource.getId());
if (isDebugEnabled) {
if (null != existingResource) {
log.debug("Found resource already in inventory. Id=" + resource.getId());
@@ -889,9 +889,10 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
+ ", key=" + resource.getResourceKey());
}
- // (jshaughn) I'm not 100% sure I understand the need for this while loop, but I believe it has to
- // do with handling the case in which a resource type has moved (see f74b22044) and trying to
- // relocate the parent. Anyway, I'm not going to touch it even though it slows things down.
+ // (jshaughn) I'm not 100% sure but I believe this loop has to do with either or both of:
+ // - protecting against the agent merging a resource it thinks is new but actually exists
+ // - handling the case in which a resource type has moved (see f74b22044) and trying to relocate the parent.
+ // Anyway, I'm not going to touch it even though it slows things down.
ResourceType resourceType = resource.getResourceType();
Resource parent = resource;
@@ -914,6 +915,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
}
if (null == existingParent) {
+ // I think getReference may be slightly faster here but it's likely negligible
existingParent = entityManager.getReference(Resource.class, parentId);
if (null != existingParent) {
if (null != parentMap) {
commit 9e70606deeb4654ae6117a8d36c322372ac63a27
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Tue Jan 29 15:11:15 2013 -0500
[BZ 905632] fix MetadataManager query to use unlimited criteria queries.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
index 5beb643..dd5311b 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
@@ -385,7 +385,7 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
resourcesServiceE1.get(0));
List<Resource> resourcesServiceE3 = createResources(2, "RemoveTypesPlugin", "ServiceE3",
resourcesServiceE2.get(0));
- List<Resource> resourcesServiceE4 = createResources(2, "RemoveTypesPlugin", "ServiceE4",
+ List<Resource> resourcesServiceE4 = createResources(205, "RemoveTypesPlugin", "ServiceE4",
resourcesServiceE3.get(0));
ResourceGroup rgRecursive = createResourceGroup("ServerE Group", "ServerE", "RemoveTypesPlugin", true);
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 2c8a925..9d844e4 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.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceSubCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageControl;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
@@ -268,6 +269,7 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
ResourceCriteria c = new ResourceCriteria();
c.addFilterResourceTypeId(existingType.getId());
c.addFilterInventoryStatus(null);
+ c.setPageControl(PageControl.getUnlimitedInstance());
List<Resource> resources = resourceManager.findResourcesByCriteria(subject, c);
if (resources != null) {
Iterator<Resource> resIter = resources.iterator();
commit 977ff337c997c2f5d63d19d46ada868eed4d9624
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 29 21:30:06 2013 +0100
Use a real UUID for resource creation. Deprecate the endpoints for platform and resource creation.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
index be28d92..8142f17 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
+import java.util.UUID;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@@ -529,15 +530,39 @@ public class ResourceHandlerBean extends AbstractRestBean {
@ApiOperation(value = "Create a new platform in the Server. If the platform already exists, this is a no-op." +
"The platform internally has a special name so that it will not clash with one that was generated" +
- "via a normal RHQ agent")
+ "via a normal RHQ agent. DEPRECATED Use POST /platforms instead")
@POST
@Path("platform/{name}")
- public Response createPlatform(
+ public Response createPlatformOLD(
@ApiParam(value = "Name of the platform") @PathParam("name") String name,
@ApiParam(value = "Type of the platform", allowableValues = "Linux,Windows,... TODO") StringValue typeValue,
@Context UriInfo uriInfo) {
+
String typeName = typeValue.getValue();
+ return createPlatformInternal(name, typeName, uriInfo);
+
+ }
+
+ @POST
+ @Path("platforms")
+ @ApiOperation(value = "Create a new platform in the Server. If the platform already exists, this is a no-op." +
+ "The platform internally has a special name so that it will not clash with one that was generated" +
+ "via a normal RHQ agent. Only resourceName and typeName need to be supplied in the passed object")
+ public Response createPlatform(
+ @ApiParam("The info about the platform. Only type name and resource name need to be supplied") ResourceWithType resource,
+ @Context UriInfo uriInfo)
+ {
+
+ String typeName = resource.getTypeName();
+ String resourceName = resource.getResourceName();
+
+ return createPlatformInternal(resourceName,typeName,uriInfo);
+ }
+
+
+ private Response createPlatformInternal(String name, String typeName, UriInfo uriInfo) {
+
ResourceType type = resourceTypeManager.getResourceTypeByNameAndPlugin(typeName,"Platforms");
if (type==null) {
throw new StuffNotFoundException("Platform with type [" + typeName + "]");
@@ -565,10 +590,8 @@ public class ResourceHandlerBean extends AbstractRestBean {
agent = new Agent("dummy-agent:name"+name,"-dummy-p:"+name,12345,"http://foo.com/p:name/"+name,"abc-"+name);
agentMgr.createAgent(agent);
-
-
Resource platform = new Resource(resourceKey,name,type);
- platform.setUuid(resourceKey);
+ platform.setUuid(UUID.randomUUID().toString());
platform.setAgent(agent);
platform.setInventoryStatus(InventoryStatus.COMMITTED);
platform.setModifiedBy(caller.getName());
@@ -595,40 +618,44 @@ public class ResourceHandlerBean extends AbstractRestBean {
} catch (Exception e) {
throw new RuntimeException(e);
}
-
}
- private void createSchedules(Resource resource) {
- ResourceType rt = resource.getResourceType();
- Set<MeasurementDefinition> definitions = rt.getMetricDefinitions ();
- for (MeasurementDefinition definition : definitions) {
- MeasurementSchedule schedule = new MeasurementSchedule(definition,resource);
- schedule.setEnabled(definition.isDefaultOn());
- schedule.setInterval(definition.getDefaultInterval());
- entityManager.persist(schedule);
- }
- }
- @ApiOperation(value = "Create a resource with a given type below a certain parent")
+ @ApiOperation(value = "Create a resource with a given type below a certain parent. DEPRECATED Use POST / instead")
@POST
@Path("{name}")
- public Response createResource(
+ public Response createResourceOLD(
@ApiParam("Name of the new resource") @PathParam("name") String name,
@ApiParam("Name of the Resource type") StringValue typeValue,
@ApiParam("Name of the plugin providing the type") @QueryParam("plugin") String plugin,
@ApiParam("Id of the future parent to attach this to") @QueryParam("parentId") int parentId,
@Context UriInfo uriInfo) {
+ String typeName = typeValue.getValue();
+
+ return createResourceInternal(name, plugin, parentId, typeName, uriInfo);
+ }
+
+ @POST
+ @Path("/")
+ @ApiOperation("Create a new resource as a child of an existing resource¡")
+ public Response createResource(
+ @ApiParam("THe info about the resource. You need to supply resource name, resource type name, plugin name, id of the parent") ResourceWithType resource,
+ @Context UriInfo uriInfo)
+ {
+ return createResourceInternal(resource.getResourceName(),resource.getPluginName(),resource.getParentId(),resource.getTypeName(),uriInfo);
+ }
+
+ private Response createResourceInternal(String name, String plugin, int parentId, String typeName,
+ UriInfo uriInfo) {
Resource parent = resMgr.getResourceById(caller,parentId);
- String typeName = typeValue.getValue();
ResourceType resType = resourceTypeManager.getResourceTypeByNameAndPlugin(typeName,plugin);
if (resType==null)
throw new StuffNotFoundException("ResourceType with name [" + typeName + "] and plugin [" + plugin + "]");
String resourceKey = "res:" + name + ":" + parentId;
-
Resource r = resMgr.getResourceByParentAndKey(caller,parent,resourceKey,plugin,typeName);
if (r!=null) {
// resource exists - return it
@@ -644,7 +671,7 @@ public class ResourceHandlerBean extends AbstractRestBean {
}
Resource res = new Resource(resourceKey,name,resType);
- res.setUuid(resourceKey);
+ res.setUuid(UUID.randomUUID().toString());
res.setAgent(parent.getAgent());
res.setParentResource(parent);
res.setInventoryStatus(InventoryStatus.COMMITTED);
@@ -683,4 +710,16 @@ public class ResourceHandlerBean extends AbstractRestBean {
return Response.status(Response.Status.NO_CONTENT).build();
}
+
+ private void createSchedules(Resource resource) {
+ ResourceType rt = resource.getResourceType();
+ Set<MeasurementDefinition> definitions = rt.getMetricDefinitions ();
+ for (MeasurementDefinition definition : definitions) {
+ MeasurementSchedule schedule = new MeasurementSchedule(definition,resource);
+ schedule.setEnabled(definition.isDefaultOn());
+ schedule.setInterval(definition.getDefaultInterval());
+ entityManager.persist(schedule);
+ }
+ }
+
}
diff --git a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
index e8066bc..6899995 100644
--- a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
+++ b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
@@ -25,12 +25,16 @@ package org.rhq.modules.integrationTests.restApi;
import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.path.json.JsonPath;
+import com.jayway.restassured.path.xml.XmlPath;
+import com.jayway.restassured.path.xml.element.Node;
import com.jayway.restassured.response.Response;
import org.apache.http.HttpStatus;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
+import org.rhq.modules.integrationTests.restApi.d.Resource;
+
import static com.jayway.restassured.RestAssured.expect;
import static com.jayway.restassured.RestAssured.get;
import static com.jayway.restassured.RestAssured.given;
@@ -129,7 +133,7 @@ public class ResourcesTest extends AbstractBase {
@Test
public void testGetPlatformXml() {
given()
- .header("Accept","application/xml")
+ .header("Accept", "application/xml")
.expect()
.statusCode(200)
.contentType(ContentType.XML)
@@ -140,7 +144,7 @@ public class ResourcesTest extends AbstractBase {
@Test
public void testGetPlatformSchedules() {
given()
- .header("Accept","application/json")
+ .header("Accept", "application/json")
.expect()
.statusCode(200)
.when()
@@ -158,18 +162,66 @@ public class ResourcesTest extends AbstractBase {
}
@Test
- public void testCreatePlatform() throws Exception {
+ public void testCreatePlatformOld() throws Exception {
given().body("{\"value\":\"Linux\"}")
- .header("Content-Type","application/json")
- .header("Accept","application/json")
+ .header("Content-Type", "application/json")
+ .header("Accept", "application/json")
.expect().statusCode(201)
.when().post("/resource/platform/api-test-dummy");
}
@Test
+ public void testCreatePlatform() throws Exception {
+
+ Resource resource = new Resource();
+ resource.setResourceName("dummy-test");
+ resource.setTypeName("Linux");
+
+ given()
+ .header(acceptXml)
+ .contentType(ContentType.JSON)
+ .body(resource)
+ .expect()
+ .statusCode(201)
+ .log().ifError()
+ .when()
+ .post("/resource/platforms");
+
+ }
+
+ @Test
public void testCreatePlatformAndRemove() throws Exception {
+ Resource resource = new Resource();
+ resource.setResourceName("dummy-test");
+ resource.setTypeName("Linux");
+
+ Response response =
+ given()
+ .header(acceptXml)
+ .contentType(ContentType.JSON)
+ .body(resource)
+ .expect()
+ .statusCode(201)
+ .log().ifError()
+ .when()
+ .post("/resource/platforms");
+
+ XmlPath xmlPath = response.xmlPath();
+ Node resource1 = xmlPath.get("resource");
+ Node platformIdNode = resource1.get("resourceId");
+ String platformId = platformIdNode.value();
+
+ given().pathParam("id", platformId)
+ .expect().statusCode(HttpStatus.SC_NO_CONTENT)
+ .when().delete("/resource/{id}");
+
+ }
+
+ @Test
+ public void testCreatePlatformOLDAndRemove() throws Exception {
+
Response response =
with().body("{\"value\":\"Linux\"}")
.header("Content-Type","application/json")
@@ -185,12 +237,12 @@ public class ResourcesTest extends AbstractBase {
}
@Test
- public void testCreatePlatformWithChildAndRemove() throws Exception {
+ public void testCreatePlatformOLDWithChildOLDAndRemove() throws Exception {
Response response =
with().body("{\"value\":\"Linux\"}")
.header("Content-Type","application/json")
- .header("Accept","application/json")
+ .header("Accept", "application/json")
.expect()
.statusCode(201)
.when()
@@ -219,6 +271,50 @@ public class ResourcesTest extends AbstractBase {
}
@Test
+ public void testCreatePlatformWithChildAndRemove() throws Exception {
+
+ Resource platform = new Resource();
+ platform.setResourceName("dummy-test");
+ platform.setTypeName("Linux");
+
+ Response response =
+ with().body(platform)
+ .header("Content-Type","application/json")
+ .header("Accept","application/json")
+ .expect()
+ .statusCode(201)
+ .log().ifError()
+ .when()
+ .post("/resource/platforms");
+
+ String platformId = response.jsonPath().getString("resourceId");
+
+ Resource child = new Resource();
+ child.setResourceName("test");
+ child.setTypeName("CPU");
+ child.setPluginName("Platforms");
+ child.setParentId(Integer.valueOf(platformId));
+
+ try {
+
+ with()
+ .body(child)
+ .header("Content-Type", "application/json")
+ .header("Accept", "application/json")
+ .expect()
+ .statusCode(201)
+ .log().ifError()
+ .when()
+ .post("/resource");
+ }
+ finally {
+ given().pathParam("id",platformId)
+ .expect().statusCode(HttpStatus.SC_NO_CONTENT)
+ .when().delete("/resource/{id}");
+ }
+ }
+
+ @Test
public void testDoubleChildCreate() throws Exception {
// a resource can be created again and again
diff --git a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
new file mode 100644
index 0000000..9c3c1a3
--- /dev/null
+++ b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.modules.integrationTests.restApi.d;
+
+/**
+ * A resource for testing purposes
+ * @author Heiko W. Rupp
+ */
+public class Resource {
+
+ String resourceName;
+ int resourceId;
+ String typeName;
+ String pluginName;
+ Integer parentId;
+
+ public Resource() {
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public Integer getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(Integer parentId) {
+ this.parentId = parentId;
+ }
+
+ public String getPluginName() {
+ return pluginName;
+ }
+
+ public void setPluginName(String pluginName) {
+ this.pluginName = pluginName;
+ }
+
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(int resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+}
commit 75903fd6abdef24ac5bab17f35f3b83ba2b1033c
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 29 20:06:17 2013 +0100
Do not assume everything is a jar - we also support jar-less plugins.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginFileUploadServlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginFileUploadServlet.java
index adc870a..3263d19 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginFileUploadServlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginFileUploadServlet.java
@@ -66,13 +66,16 @@ public class PluginFileUploadServlet extends FileUploadServlet {
File file = files.values().iterator().next();
String newPluginFilename = fileNames.values().iterator().next();
- // make sure its a .jar file and strip off any temp file suffix (in case the browser set the name to something odd)
- int jarExtension = newPluginFilename.lastIndexOf(".jar");
- if (jarExtension < 0) {
- newPluginFilename = newPluginFilename + ".jar"; // make sure it ends with ".jar" in case it is some tmp filename
- jarExtension = newPluginFilename.lastIndexOf(".jar");
+ // see if it is a jar-less plugin descriptor and if not check for .jar
+ if (!newPluginFilename.endsWith("-rhq-plugin.xml")) {
+ // make sure its a .jar file and strip off any temp file suffix (in case the browser set the name to something odd)
+ int jarExtension = newPluginFilename.lastIndexOf(".jar");
+ if (jarExtension < 0) {
+ newPluginFilename = newPluginFilename + ".jar"; // make sure it ends with ".jar" in case it is some tmp filename
+ jarExtension = newPluginFilename.lastIndexOf(".jar");
+ }
+ newPluginFilename = newPluginFilename.substring(0, jarExtension + ".jar".length());
}
- newPluginFilename = newPluginFilename.substring(0, jarExtension + ".jar".length());
log.info("A new plugin [" + newPluginFilename + "] has been uploaded to [" + file + "]");
if (file == null || !file.exists()) {
11 years, 3 months
[rhq] Branch 'feature/cassandra-backend' - 2 commits - modules/common
by John Sanda
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/UnmanagedDeployer.java | 17
modules/common/cassandra-installer/pom.xml | 174 ++++++++++
modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java | 153 ++++++++
modules/common/pom.xml | 1
4 files changed, 328 insertions(+), 17 deletions(-)
New commits:
commit ce678b6298aea507b9443ba3e7a3341b95f9f920
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 30 21:48:48 2013 -0500
add a reminder for updating rhq-server.properties
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
index 368071a..8794c4d 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
@@ -107,6 +107,7 @@ public class CassandraInstaller {
UnmanagedDeployer deployer = new UnmanagedDeployer();
deployer.unpackBundle();
deployer.deploy(options, 1);
+ System.out.println(getInstallationSummary(options));
deployer.cleanUpBundle();
}
}
@@ -125,6 +126,17 @@ public class CassandraInstaller {
return options;
}
+ public String getInstallationSummary(DeploymentOptions options) {
+ return "\n" +
+ "Installation Summary:\n" +
+ "Finished installing Cassandra in " + options.getBasedir() + "\n\n" +
+ "IMPORTANT - remember to update the rhq.cassandra.seeds property in rhq-server.properties with the " +
+ "following:\n" +
+ "\thostname: " + options.getListenAddress() + "\n" +
+ "\tthrift port: " + options.getRpcPort() + "\n" +
+ "\tcql port: " + options.getNativeTransportPort();
+ }
+
public static void main(String[] args) throws Exception {
System.out.println("Running Cassandra installer...");
CassandraInstaller installer = new CassandraInstaller();
commit 7329251321d53ccec536ea6eb1b391a5a3e70308
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 30 21:37:38 2013 -0500
initial commit for cassandra-installer module
This is a first pass at a stand alone installer. The goal right now is to have
something in place so that QE can start testing.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/UnmanagedDeployer.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/UnmanagedDeployer.java
index 1668afa..7eabb86 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/UnmanagedDeployer.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/UnmanagedDeployer.java
@@ -58,19 +58,6 @@ public class UnmanagedDeployer {
private File bundleDir;
- public void setDeploymentOptions(DeploymentOptions deploymentOptions) {
- this.deploymentOptions = deploymentOptions;
- }
-
- public String getCassandraHosts() {
- StringBuilder hosts = new StringBuilder();
- for (int i = 0; i < deploymentOptions.getNumNodes(); ++i) {
- hosts.append(getLocalIPAddress(i + 1)).append(":9160,");
- }
- hosts.deleteCharAt(hosts.length() - 1);
- return hosts.toString();
- }
-
public void unpackBundle() throws CassandraException {
try {
File bundleZipFile = unpackBundleZipFile();
@@ -145,8 +132,4 @@ public class UnmanagedDeployer {
return bundleDir;
}
- private String getLocalIPAddress(int i) {
- return "127.0.0." + i;
- }
-
}
diff --git a/modules/common/cassandra-installer/pom.xml b/modules/common/cassandra-installer/pom.xml
new file mode 100644
index 0000000..bf85e56
--- /dev/null
+++ b/modules/common/cassandra-installer/pom.xml
@@ -0,0 +1,174 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-common-parent</artifactId>
+ <version>4.6.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>rhq-cassandra-installer</artifactId>
+ <name>RHQ Cassandra Installer</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-cassandra-ccm-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <!--<configuration>-->
+ <!--<archive>-->
+ <!--<manifest>-->
+ <!--<mainClass>org.rhq.cassandra.installer.Main</mainClass>-->
+ <!--<addClasspath>true</addClasspath>-->
+ <!--<classpathPrefix>lib/</classpathPrefix>-->
+ <!--</manifest>-->
+ <!--</archive>-->
+ <!--</configuration>-->
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-4</version>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ <archive>
+ <manifest>
+ <mainClass>org.rhq.cassandra.installer.CassandraInstaller</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!--<plugin>-->
+ <!--<artifactId>maven-dependency-plugin</artifactId>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<id>copy-deps</id>-->
+ <!--<phase>prepare-package</phase>-->
+ <!--<goals>-->
+ <!--<goal>copy</goal>-->
+ <!--</goals>-->
+ <!--<configuration>-->
+ <!--<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>-->
+ <!--<artifactItems>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+ <!--<artifactId>rhq-cassandra-ccm-core</artifactId>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+ <!--<artifactId>rhq-ant-bundle-common</artifactId>-->
+ <!--<version>${project.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+ <!--<artifactId>rhq-core-util</artifactId>-->
+ <!--<version>${project.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>jdom</groupId>-->
+ <!--<artifactId>jdom</artifactId>-->
+ <!--<version>1.0</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>i18nlog</groupId>-->
+ <!--<artifactId>i18nlog</artifactId>-->
+ <!--<version>1.0.10</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+ <!--<artifactId>rhq-core-native-system</artifactId>-->
+ <!--<version>${project.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.apache.ant</groupId>-->
+ <!--<artifactId>ant</artifactId>-->
+ <!--<version>1.8.0</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.apache.ant</groupId>-->
+ <!--<artifactId>ant-launcher</artifactId>-->
+ <!--<version>1.8.0</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.apache.ant</groupId>-->
+ <!--<artifactId>ant-nodeps</artifactId>-->
+ <!--<version>1.8.0</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>ant-contrib</groupId>-->
+ <!--<artifactId>ant-contrib</artifactId>-->
+ <!--<version>1.0b3</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+ <!--<artifactId>rhq-core-plugin-api</artifactId>-->
+ <!--<version>${project.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.apache.cassandra</groupId>-->
+ <!--<artifactId>cassandra-thrift</artifactId>-->
+ <!--<version>${cassandra.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.slf4j</groupId>-->
+ <!--<artifactId>slf4j-api</artifactId>-->
+ <!--<version>1.7.2</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>${project.groupId}</groupId>-->
+ <!--<artifactId>rhq-core-domain</artifactId>-->
+ <!--<version>${project.version}</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>commons-lang</groupId>-->
+ <!--<artifactId>commons-lang</artifactId>-->
+ <!--<version>2.4</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.slf4j</groupId>-->
+ <!--<artifactId>slf4j-api</artifactId>-->
+ <!--<version>1.7.2</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>org.apache.thrift</groupId>-->
+ <!--<artifactId>libthrift</artifactId>-->
+ <!--<version>0.7.0</version>-->
+ <!--</artifactItem>-->
+ <!--<artifactItem>-->
+ <!--<groupId>commons-codec</groupId>-->
+ <!--<artifactId>commons-codec</artifactId>-->
+ <!--<version>1.3</version>-->
+ <!--</artifactItem>-->
+ <!--</artifactItems>-->
+ <!--</configuration>-->
+ <!--</execution>-->
+ <!--</executions>-->
+ <!--</plugin>-->
+ </plugins>
+ </build>
+</project>
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
new file mode 100644
index 0000000..368071a
--- /dev/null
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/cassandra/installer/CassandraInstaller.java
@@ -0,0 +1,141 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 Red Hat, Inc.
+ * * All rights reserved.
+ * *
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License, 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.cassandra.installer;
+
+import java.io.File;
+import java.net.InetAddress;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+
+import org.rhq.cassandra.DeploymentOptions;
+import org.rhq.cassandra.UnmanagedDeployer;
+
+/**
+ * @author John Sanda
+ */
+public class CassandraInstaller {
+
+ private Options options;
+
+ public CassandraInstaller() {
+ Option hostname = new Option("n", "hostname", true, "The hostname or IP address on which the node will listen for " +
+ "requests. If not specified, defaults to the value returned by InetAddress.getLocalHost().getHostName().");
+ hostname.setArgName("HOSTNAME");
+
+ Option dir = new Option("d", "dir", true, "The directory in which to install Cassandra. Defaults to the " +
+ "current working directory");
+ dir.setArgName("INSTALL_DIR");
+
+ Option seeds = new Option("s", "seeds", true, "A comma-delimited list of hostnames or IP addresses that " +
+ "serve as contact points. Nodes use this list to find each other and to learn the cluster topology. " +
+ "It does not need to specify all nodes in the cluster. Defaults to this nodes hostname.");
+ seeds.setArgName("SEEDS");
+
+ options = new Options()
+ .addOption(new Option("h", "help", false, "Show this message."))
+ .addOption(hostname)
+ .addOption(dir)
+ .addOption(seeds);
+ }
+
+ public void run(CommandLine cmdLine) throws Exception {
+ if (cmdLine.hasOption("h")) {
+ printUsage();
+ } else {
+ DeploymentOptions options = new DeploymentOptions();
+
+ File basedir;
+ if (cmdLine.hasOption("d")) {
+ basedir = new File(cmdLine.getOptionValue("d"));
+ } else {
+ basedir = new File(System.getProperty("user.dir"));
+ }
+ options.setBasedir(basedir.getAbsolutePath());
+
+ String hostname;
+ if (cmdLine.hasOption("n")) {
+ hostname = cmdLine.getOptionValue("n");
+ } else {
+ hostname = InetAddress.getLocalHost().getHostName();
+ }
+ options.setListenAddress(hostname);
+ options.setRpcAddress(hostname);
+
+ String seeds;
+ if (cmdLine.hasOption("s")) {
+ seeds = cmdLine.getOptionValue("s");
+ } else {
+ seeds = hostname;
+ }
+ options.setSeeds(seeds);
+
+ options.setCommitLogDir(new File(basedir, "commit_log").getAbsolutePath());
+ options.setSavedCachesDir(new File(basedir, "saved_caches").getAbsolutePath());
+ options.setDataDir(new File(basedir, "data").getAbsolutePath());
+ options.setLogDir(new File(basedir, "logs").getAbsolutePath());
+ options.load();
+
+ UnmanagedDeployer deployer = new UnmanagedDeployer();
+ deployer.unpackBundle();
+ deployer.deploy(options, 1);
+ deployer.cleanUpBundle();
+ }
+ }
+
+ public void printUsage() {
+ Options options = getOptions();
+ HelpFormatter helpFormatter = new HelpFormatter();
+ String header = "\nInstalls RHQ metrics database.\n\n";
+ String syntax = "java -jar rhq-cassandra-installer.jar [options]";
+
+ helpFormatter.setNewLine("\n");
+ helpFormatter.printHelp(syntax, header, options, null);
+ }
+
+ public Options getOptions() {
+ return options;
+ }
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Running Cassandra installer...");
+ CassandraInstaller installer = new CassandraInstaller();
+ try {
+ CommandLineParser parser = new PosixParser();
+ CommandLine cmdLine = parser.parse(installer.getOptions(), args);
+ installer.run(cmdLine);
+ return;
+ } catch (ParseException e) {
+ installer.printUsage();
+ }
+ }
+
+}
diff --git a/modules/common/pom.xml b/modules/common/pom.xml
index f131ccf..cc557b8 100644
--- a/modules/common/pom.xml
+++ b/modules/common/pom.xml
@@ -33,5 +33,6 @@
<module>cassandra-auth</module>
<module>cassandra-schema</module>
<module>cassandra-ccm</module>
+ <module>cassandra-installer</module>
</modules>
</project>
11 years, 3 months
[rhq] 2 commits - modules/enterprise
by Jay Shaughnessy
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/TestServerPluginService.java | 6 --
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java | 4 -
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/TestAlertSenderPluginService.java | 5 ++
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java | 5 --
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java | 7 +--
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftServerPluginService.java | 5 ++
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java | 7 +--
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java | 15 +++---
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java | 12 +++--
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/sync/test/SynchronizationManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/system/SystemManagerBeanTest.java | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 23 +++++-----
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java | 11 ++--
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestServerPluginService.java | 5 --
27 files changed, 75 insertions(+), 60 deletions(-)
New commits:
commit a74896a61f3b8ad1b9372469368c86f115f80b28
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jan 30 17:31:12 2013 -0500
Fix test failure, when I beefed up type removal checking I neglected to
notice a dependent test that also needed updating.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
index dd5311b..7392758 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
@@ -385,6 +385,7 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
resourcesServiceE1.get(0));
List<Resource> resourcesServiceE3 = createResources(2, "RemoveTypesPlugin", "ServiceE3",
resourcesServiceE2.get(0));
+ // Intentionally greater than 200 to test an issue with Criteria fetch defaults
List<Resource> resourcesServiceE4 = createResources(205, "RemoveTypesPlugin", "ServiceE4",
resourcesServiceE3.get(0));
@@ -426,6 +427,7 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
@Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
"RemoveTypes" })
public void deleteParent() throws Exception {
+
SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
ResourceTypeManagerLocal resourceTypeMgr = LookupUtil.getResourceTypeManager();
@@ -459,12 +461,16 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
@Test(dependsOnMethods = { "upgradePluginWithTypesRemoved" }, groups = { "plugin.resource.metadata.test",
"RemoveTypes" })
- public void deleteTypeAndAllItsDescedantTypes() throws Exception {
+ public void deleteTypeAndAllItsDescendantTypes() throws Exception {
+
List<?> typesNotRemoved = getEntityManager()
.createQuery("from ResourceType t where t.plugin = :plugin and t.name in (:resourceTypes)")
.setParameter("plugin", "RemoveTypesPlugin")
- .setParameter("resourceTypes", asList("ServerE", "ServerE1", "ServerE2", "ServerE3", "ServerE4"))
- .getResultList();
+ // the types that should have been removed, if any show up we have a problem
+ .setParameter(
+ "resourceTypes",
+ asList("ServerC", "ServiceC1", "ServiceE4", "ServerF", "ServiceF1", "ServiceF2", "ServiceF3",
+ "ServiceF4")).getResultList();
assertEquals("Failed to delete resource type or one or more of its descendant types", 0, typesNotRemoved.size());
}
commit e8fd5fbf7013a34fa75c761e26a86d9a1956da99
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jan 30 17:30:28 2013 -0500
More test interaction work for the server itests. Many tests need a work area on
disk. The test area being used was typically ${java.io.tmpdir}/rhq/testClassName.
There were two issues with this:
- Different test jobs running concurrently would end up using the same work
directory. This is something that may have been happening on Jenkins.
- An mvn clean had no effect on anything hanging around in those directories,
so if test cleanup was poor it may have left legacy data that could possibly
impact future test runs.
This commit moves all of the tmpdir generation under itests-2/target/test-tmpdir/
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/TestServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/TestServerPluginService.java
index 796a562..5bfff2d 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/TestServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/TestServerPluginService.java
@@ -51,10 +51,8 @@ public abstract class TestServerPluginService extends ServerPluginService implem
public TestMasterServerPluginContainer master;
public MasterServerPluginContainerConfiguration masterConfig;
- protected TestServerPluginService() {
- // build the config at constructor time so tests have it even before the PC is initialized
- File dir = new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
- this.masterConfig = new MasterServerPluginContainerConfiguration(dir, dir, dir, null);
+ protected TestServerPluginService(File tmpdir) {
+ this.masterConfig = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir, tmpdir, null);
}
@Override
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java
index 7e43862..69ffc44 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/AlertDefinitionWithComplexNotificationsTest.java
@@ -224,7 +224,7 @@ public class AlertDefinitionWithComplexNotificationsTest extends AbstractEJB3Tes
em.persist(resourceAlertDefinition);
//only need this for a short time now, so that we can precreate the plugin structure
- alertSenderService = new TestAlertSenderPluginService();
+ alertSenderService = new TestAlertSenderPluginService(getTempDir());
prepareCustomServerPluginService(alertSenderService);
alertSenderService.masterConfig.getPluginDirectory().mkdirs();
unprepareServerPluginService();
@@ -247,7 +247,7 @@ public class AlertDefinitionWithComplexNotificationsTest extends AbstractEJB3Tes
//@BeforeMethod
private void containerSetup() {
- alertSenderService = new TestAlertSenderPluginService();
+ alertSenderService = new TestAlertSenderPluginService(getTempDir());
prepareCustomServerPluginService(alertSenderService);
alertSenderService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/TestAlertSenderPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/TestAlertSenderPluginService.java
index 9aae985..ac04276 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/TestAlertSenderPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/alert/TestAlertSenderPluginService.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.alert;
+import java.io.File;
import java.util.Collections;
import java.util.List;
@@ -38,6 +39,10 @@ import org.rhq.enterprise.server.plugin.pc.alert.AlertServerPluginContainer;
*/
public class TestAlertSenderPluginService extends TestServerPluginService {
+ protected TestAlertSenderPluginService(File tmpdir) {
+ super(tmpdir);
+ }
+
@Override
protected List<AbstractTypeServerPluginContainer> createPluginContainers(MasterServerPluginContainer master) {
return Collections.<AbstractTypeServerPluginContainer>singletonList(new TestAlertServerPluginContainer(master));
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index c411671..062d91a 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -116,7 +116,7 @@ public class BundleManagerBeanTest extends AbstractEJB3Test {
agentServiceContainer = prepareForTestAgents();
agentServiceContainer.bundleService = new TestAgentClient(null, agentServiceContainer);
- this.ps = new TestBundleServerPluginService();
+ this.ps = new TestBundleServerPluginService(getTempDir());
prepareCustomServerPluginService(this.ps);
bundleManager = LookupUtil.getBundleManager();
resourceManager = LookupUtil.getResourceManager();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
index 45f210c..7481496 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
@@ -66,10 +66,9 @@ public class TestBundleServerPluginService extends ServerPluginService implement
public RecipeParseResults parseRecipe_returnValue = null;
public BundleDistributionInfo processBundleDistributionFile_returnValue;
- public TestBundleServerPluginService() {
+ public TestBundleServerPluginService(File tmpdir) {
// build the config at constructor time so tests have it even before the PC is initialized
- File dir = new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
- this.masterConfig = new MasterServerPluginContainerConfiguration(dir, dir, dir, null);
+ this.masterConfig = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir, tmpdir, null);
}
@Override
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java
index d031926..b594f61 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/core/plugin/DatabaseAndFilePluginDeploymentTest.java
@@ -53,8 +53,8 @@ public class DatabaseAndFilePluginDeploymentTest extends AbstractEJB3Test {
private static final String PLUGIN_NAME = "DeployTest"; // as defined in our test descriptors
private static final String DESCRIPTORS_LOCATION = "test/deployment/";
- private static final String TEST_DIR = System.getProperty("java.io.tmpdir") + "/rhq/"
- + DatabaseAndFilePluginDeploymentTest.class.getName() + "/";
+ private static final String TEST_DIR = tmpdirRoot + "/" + DatabaseAndFilePluginDeploymentTest.class.getName()
+ + "/";
private static final String JARS_LOCATION = TEST_DIR + "jars";
private static final String DEPLOY_LOCATION = TEST_DIR + "deploy";
private static final String TESTPLUGIN_1_0_FEB = "1.0-feb";
@@ -199,7 +199,8 @@ public class DatabaseAndFilePluginDeploymentTest extends AbstractEJB3Test {
buildPluginJar(descriptor, file);
assert file.exists();
- PluginDescriptor pluginDescriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI().toURL());
+ PluginDescriptor pluginDescriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI()
+ .toURL());
testPluginDescriptors.put(entry.getKey(), pluginDescriptor);
Plugin pluginPojo = new Plugin(PLUGIN_NAME, file.getName());
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java
index 5f7d95c..a95079b 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/AbstractDriftServerTest.java
@@ -82,7 +82,7 @@ public abstract class AbstractDriftServerTest extends AbstractEJB3Test {
}
private void initDriftServer() throws Exception {
- driftServerPluginService = new DriftServerPluginService();
+ driftServerPluginService = new DriftServerPluginService(getTempDir());
prepareCustomServerPluginService(driftServerPluginService);
driftServerPluginService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
index aa42a11..fe2ced3 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
@@ -94,7 +94,7 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
prepareScheduler();
- DriftServerPluginService driftServerPluginService = new DriftServerPluginService();
+ DriftServerPluginService driftServerPluginService = new DriftServerPluginService(getTempDir());
prepareCustomServerPluginService(driftServerPluginService);
driftServerPluginService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftServerPluginService.java
index 46d725f..de206d4 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/drift/DriftServerPluginService.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.drift;
+import java.io.File;
import java.util.Collections;
import java.util.List;
@@ -33,6 +34,10 @@ import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginManager;
public class DriftServerPluginService extends TestServerPluginService {
+ public DriftServerPluginService(File tmpDir) {
+ super(tmpDir);
+ }
+
@Override
protected List<AbstractTypeServerPluginContainer> createPluginContainers(MasterServerPluginContainer master) {
return Collections.<AbstractTypeServerPluginContainer>singletonList(new TestDriftServerPluginContainer(master));
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
index 9e8b4e3..1c4b780 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
@@ -122,7 +122,7 @@ public class MeasurementDataManagerBeanTest extends AbstractEJB3Test {
// MeasurementDataManagerUtility looks up config settings from SystemManagerBean.
// SystemManagerBean.getDriftServerPluginManager method requires drift server plugin.
- DriftServerPluginService driftServerPluginService = new DriftServerPluginService();
+ DriftServerPluginService driftServerPluginService = new DriftServerPluginService(getTempDir());
prepareCustomServerPluginService(driftServerPluginService);
driftServerPluginService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBeanTest.java
index 067614e..a7f16ef 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBeanTest.java
@@ -110,7 +110,7 @@ public class MeasurementOOBManagerBeanTest extends AbstractEJB3Test {
protected void beforeMethod() throws Exception {
// MeasurementDataManagerUtility looks up config settings from SystemManagerBean.
// SystemManagerBean.getDriftServerPluginManager method requires drift server plugin.
- DriftServerPluginService driftServerPluginService = new DriftServerPluginService();
+ DriftServerPluginService driftServerPluginService = new DriftServerPluginService(getTempDir());
prepareCustomServerPluginService(driftServerPluginService);
driftServerPluginService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
index ff1193d..d6ac8b2 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/AvailabilityManagerTest.java
@@ -90,7 +90,7 @@ public class AvailabilityManagerTest extends AbstractEJB3Test {
this.overlord = LookupUtil.getSubjectManager().getOverlord();
additionalResources = new ArrayList<Resource>();
- testServerPluginService = new TestServerPluginService();
+ testServerPluginService = new TestServerPluginService(getTempDir());
prepareCustomServerPluginService(testServerPluginService);
testServerPluginService.masterConfig.getPluginDirectory().mkdirs();
testServerPluginService.startMasterPluginContainer();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
index b12d90c..e7f9da5 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
@@ -54,7 +54,7 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
@Override
protected void beforeMethod() {
TestGenericServerPluginService pluginService;
- pluginService = new TestGenericServerPluginService();
+ pluginService = new TestGenericServerPluginService(getTempDir());
prepareCustomServerPluginService(pluginService);
serverPluginsBean = LookupUtil.getServerPlugins();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java
index 5850985..7642ec1 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java
@@ -42,6 +42,7 @@ public class TestContentServerPluginService extends ServerPluginService implemen
private Map<Integer, ContentProvider> providers = new HashMap<Integer, ContentProvider>();
private TestContentProvider defaultTestContentProvider;
+ private File tmpdir;
/**
* Creates and initializes the content server plugin container for use with the given test case.
@@ -50,6 +51,7 @@ public class TestContentServerPluginService extends ServerPluginService implemen
*/
public TestContentServerPluginService(AbstractEJB3Test testContainer) {
super();
+ tmpdir = testContainer.getTempDir();
testContainer.prepareCustomServerPluginService(this);
startMasterPluginContainer();
@@ -86,9 +88,8 @@ public class TestContentServerPluginService extends ServerPluginService implemen
protected MasterServerPluginContainer createMasterPluginContainer() {
MasterServerPluginContainer master = new TestMasterServerPluginContainer();
- File dir = new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
- MasterServerPluginContainerConfiguration config = new MasterServerPluginContainerConfiguration(dir, dir, dir,
- null);
+ MasterServerPluginContainerConfiguration config = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir,
+ tmpdir, null);
master.initialize(config);
return master;
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
index e8ece2e..1bbe447 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/GenericServerPluginTest.java
@@ -55,7 +55,7 @@ public class GenericServerPluginTest extends AbstractEJB3Test {
@Override
protected void beforeMethod() throws Exception {
- this.pluginService = new TestGenericServerPluginService();
+ this.pluginService = new TestGenericServerPluginService(getTempDir());
deleteAllTestPluginJars(); // remove any old server plugins that might be still around
prepareCustomServerPluginService(this.pluginService);
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
index 85f45d0..736b615 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/plugin/pc/generic/TestGenericServerPluginService.java
@@ -55,10 +55,9 @@ public class TestGenericServerPluginService extends ServerPluginService implemen
public TestGenericServerPluginContainer genericPC;
public MasterServerPluginContainerConfiguration masterConfig;
- public TestGenericServerPluginService() {
+ public TestGenericServerPluginService(File tmpdir) {
// build the config at constructor time so tests have it even before the PC is initialized
- File dir = new File(System.getProperty("java.io.tmpdir" + "/rhq"), this.getClass().getSimpleName());
- this.masterConfig = new MasterServerPluginContainerConfiguration(dir, dir, dir, null);
+ this.masterConfig = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir, tmpdir, null);
}
@Override
@@ -197,11 +196,11 @@ public class TestGenericServerPluginService extends ServerPluginService implemen
File pluginFile = new File(env.getPluginUrl().toURI());
ServerPlugin plugin = new ServerPlugin(0, env.getPluginKey().getPluginName(), pluginFile.getName(),
- pluginDescriptor.getDisplayName(), true, PluginStatusType.INSTALLED, pluginDescriptor
- .getDescription(), "", MessageDigestGenerator.getDigestString(pluginFile), pluginDescriptor
- .getVersion(), pluginDescriptor.getVersion(), pluginConfig, scheduledJobsConfig,
- new ServerPluginType(pluginDescriptor).stringify(), System.currentTimeMillis(), System
- .currentTimeMillis());
+ pluginDescriptor.getDisplayName(), true, PluginStatusType.INSTALLED,
+ pluginDescriptor.getDescription(), "", MessageDigestGenerator.getDigestString(pluginFile),
+ pluginDescriptor.getVersion(), pluginDescriptor.getVersion(), pluginConfig, scheduledJobsConfig,
+ new ServerPluginType(pluginDescriptor).stringify(), System.currentTimeMillis(),
+ System.currentTimeMillis());
return plugin;
} catch (Exception e) {
throw new RuntimeException(e);
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java
index 6f8c497..6c0fd5e 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/group/test/LdapGroupManagerBeanTest.java
@@ -101,7 +101,7 @@ public class LdapGroupManagerBeanTest extends AbstractEJB3Test {
ldapGroupManager = LookupUtil.getLdapGroupManager();
//we need this because the drift plugins are referenced from the system settings that we use in our tests
- testServerPluginService = new TestServerPluginService();
+ testServerPluginService = new TestServerPluginService(getTempDir());
prepareCustomServerPluginService(testServerPluginService);
testServerPluginService.startMasterPluginContainer();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
index 5d3bf77..8afabf2 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
@@ -79,7 +79,7 @@ public class MetadataBeanTest extends AbstractEJB3Test {
setupDB();
- TestBundleServerPluginService bundleService = new TestBundleServerPluginService();
+ TestBundleServerPluginService bundleService = new TestBundleServerPluginService(getTempDir());
prepareCustomServerPluginService(bundleService);
bundleService.startMasterPluginContainerWithoutSchedulingJobs();
prepareScheduler();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java
index f05e079..23e8efe 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdatePluginMetadataTestBase.java
@@ -79,7 +79,7 @@ public class UpdatePluginMetadataTestBase extends AbstractEJB3Test {
preparePluginScannerService();
// we perform lookups of config settings from SystemManagerBean.
// SystemManagerBean.getDriftServerPluginManager method requires drift server plugin.
- DriftServerPluginService driftServerPluginService = new DriftServerPluginService();
+ DriftServerPluginService driftServerPluginService = new DriftServerPluginService(getTempDir());
prepareCustomServerPluginService(driftServerPluginService);
driftServerPluginService.masterConfig.getPluginDirectory().mkdirs();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java
index 7036dc5..e835a2e 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/test/ResourceFactoryManagerBeanTest.java
@@ -100,7 +100,7 @@ public class ResourceFactoryManagerBeanTest extends AbstractEJB3Test {
agentServiceContainer.resourceFactoryService = mockAgentService;
//the server plugins are in play when package types are involved
- StandardServerPluginService serverPluginService = new StandardServerPluginService();
+ StandardServerPluginService serverPluginService = new StandardServerPluginService(getTempDir());
prepareCustomServerPluginService(serverPluginService);
serverPluginService.startMasterPluginContainer();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
index 2d37c66..9cc4bc9 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/scheduler/jobs/DataPurgeJobTest.java
@@ -98,7 +98,7 @@ public class DataPurgeJobTest extends AbstractEJB3Test {
protected void beforeMethod() throws Exception {
try {
//we need this because the drift plugins are referenced from the system settings that we use in our tests
- testServerPluginService = new TestServerPluginService();
+ testServerPluginService = new TestServerPluginService(getTempDir());
prepareCustomServerPluginService(testServerPluginService);
testServerPluginService.startMasterPluginContainer();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/sync/test/SynchronizationManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/sync/test/SynchronizationManagerBeanTest.java
index f00fe27..c870dc9 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/sync/test/SynchronizationManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/sync/test/SynchronizationManagerBeanTest.java
@@ -299,7 +299,7 @@ public class SynchronizationManagerBeanTest extends AbstractEJB3Test {
}
//we need this because the drift plugins are referenced from the system settings that we use in our tests
- testData.testServerPluginService = new TestServerPluginService();
+ testData.testServerPluginService = new TestServerPluginService(getTempDir());
prepareCustomServerPluginService(testData.testServerPluginService);
testData.testServerPluginService.startMasterPluginContainer();
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/system/SystemManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/system/SystemManagerBeanTest.java
index 557c787..104ff85 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/system/SystemManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/system/SystemManagerBeanTest.java
@@ -45,7 +45,7 @@ public class SystemManagerBeanTest extends AbstractEJB3Test {
overlord = LookupUtil.getSubjectManager().getOverlord();
//we need this because the drift plugins are referenced from the system settings that we use in our tests
- testServerPluginService = new TestServerPluginService();
+ testServerPluginService = new TestServerPluginService(getTempDir());
prepareCustomServerPluginService(testServerPluginService);
testServerPluginService.startMasterPluginContainer();
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index e4dbc4b..270b053 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -78,6 +78,8 @@ public abstract class AbstractEJB3Test extends Arquillian {
protected static final String JNDI_RHQDS = "java:jboss/datasources/RHQDS";
+ protected static File tmpdirRoot = new File("./target/test-tmpdir");
+
private TestServerCommunicationsService agentService;
private SchedulerService schedulerService;
private ServerPluginService serverPluginService;
@@ -90,16 +92,19 @@ public abstract class AbstractEJB3Test extends Arquillian {
protected InitialContext initialContext;
// We originally (in 4.2.3 days) ran these tests as "unit" tests in the server/jar module using
- // the embedded conatiner. With Arquillian it makes sense to actually deploy an EAR because
+ // the embedded container. With Arquillian it makes sense to actually deploy an EAR because
// we need a way to deploy dependent ears needed to support the server/jar classes. But
// building this jar up (as is done in core/domain) was too difficult due to the huge number
- // of dependencies. It was easier, and probably more sensical, to use the already built rhq.ear
+ // of dependencies. It was easier, and made sense, to use the already built rhq.ear
// and run as true integration tests. We do thin rhq.ear by removing all of the WAR files, and
// deploy only the EJB jars, and the services, which are really the objects under test.
@Deployment
protected static EnterpriseArchive getBaseDeployment() {
+ // Ensure the test working dir exists
+ tmpdirRoot.mkdirs();
+
// deploy the test classes in their own jar, under /lib
JavaArchive testClassesJar = ShrinkWrap.create(JavaArchive.class, "test-classes.jar");
testClassesJar = addClasses(testClassesJar, new File("target/test-classes/org"), null);
@@ -122,8 +127,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
testClassesJar.addAsResource("test-ldap.properties");
testClassesJar.addAsResource("test-scheduler.properties");
testClassesJar
- .addAsResource(
- "org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml");
+ .addAsResource("org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v1.xml");
testClassesJar
.addAsResource("org/rhq/enterprise/server/configuration/metadata/configuration_metadata_manager_bean_test_v2.xml");
testClassesJar.addAsResource("org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml");
@@ -321,8 +325,7 @@ public abstract class AbstractEJB3Test extends Arquillian {
testEar.add(new ClassAsset(StrippedDownStartupBeanPreparation.class), ArchivePaths
.create("/rhq-enterprise-server-ejb3.jar/org/rhq/enterprise/server/test/"
+ "StrippedDownStartupBeanPreparation.class"));
- testEar.addAsManifestResource(new ByteArrayAsset("<beans/>".getBytes()),
- ArchivePaths.create("beans.xml"));
+ testEar.addAsManifestResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"));
// add the test classes to the deployment
testEar.addAsLibrary(testClassesJar);
@@ -1105,11 +1108,11 @@ public abstract class AbstractEJB3Test extends Arquillian {
return file.delete();
}
- /**
- * @return a temp directory for testing that is specific to this test class.
+ /**
+ * @return a temp directory for testing that is specific to this test class. Specifically tmpdirRoot/this.getClass().getSimpleName().
*/
- protected File getTempDir() {
- return new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
+ public File getTempDir() {
+ return new File(tmpdirRoot, this.getClass().getSimpleName());
}
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java
index adcde42..6b938fd 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java
@@ -50,10 +50,10 @@ public class StandardServerPluginService extends ServerPluginService implements
public static class TestMasterServerPluginContainer extends MasterServerPluginContainer {
private List<AbstractTypeServerPluginContainer> serverPluginContainers = new ArrayList<AbstractTypeServerPluginContainer>();
-
+
public TestMasterServerPluginContainer(
List<Class<? extends AbstractTypeServerPluginContainer>> pluginContainerClasses) {
-
+
for (Class<? extends AbstractTypeServerPluginContainer> cls : pluginContainerClasses) {
try {
Constructor<? extends AbstractTypeServerPluginContainer> ctor = cls
@@ -65,7 +65,7 @@ public class StandardServerPluginService extends ServerPluginService implements
}
}
}
-
+
@Override
protected List<AbstractTypeServerPluginContainer> createPluginContainers() {
return serverPluginContainers;
@@ -83,9 +83,8 @@ public class StandardServerPluginService extends ServerPluginService implements
*/
public List<Class<? extends AbstractTypeServerPluginContainer>> pluginContainerClasses;
- public StandardServerPluginService() {
- File dir = new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
- this.masterConfig = new MasterServerPluginContainerConfiguration(dir, dir, dir, null);
+ public StandardServerPluginService(File tmpdir) {
+ this.masterConfig = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir, tmpdir, null);
pluginContainerClasses = new ArrayList<Class<? extends AbstractTypeServerPluginContainer>>();
pluginContainerClasses.add(AlertServerPluginContainer.class);
pluginContainerClasses.add(BundleServerPluginContainer.class);
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestServerPluginService.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestServerPluginService.java
index a8b134e..6e62b99 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestServerPluginService.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestServerPluginService.java
@@ -44,10 +44,9 @@ public class TestServerPluginService extends ServerPluginService implements Test
public TestMasterServerPluginContainer master;
public MasterServerPluginContainerConfiguration masterConfig;
- public TestServerPluginService() {
+ public TestServerPluginService(File tmpdir) {
// build the config at constructor time so tests have it even before the PC is initialized
- File dir = new File(System.getProperty("java.io.tmpdir") + "/rhq", this.getClass().getSimpleName());
- this.masterConfig = new MasterServerPluginContainerConfiguration(dir, dir, dir, null);
+ this.masterConfig = new MasterServerPluginContainerConfiguration(tmpdir, tmpdir, tmpdir, null);
}
@Override
11 years, 3 months
[rhq] Branch 'bug/902406' - modules/core
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 61 +++++++---
1 file changed, 47 insertions(+), 14 deletions(-)
New commits:
commit 791f8148611c4e6d830dd3cfdfe55b8d7489e86b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 30 17:30:11 2013 -0500
[BZ 902406] i still think this doesn't work. but its close. we now merge unknown resources and their children breadth first. however, i think we need children specified in some resources when we don't. need to take a closer look and test
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 56a372e..aea8380 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
@@ -25,6 +25,7 @@ package org.rhq.core.pc.inventory;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
@@ -36,10 +37,12 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Queue;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
@@ -1135,7 +1138,7 @@ public class InventoryManager extends AgentService implements ContainerService,
modifiedResourceIds.size()));
}
- mergeUnknownResources(unknownResourceIds);
+ mergeUnknownResources(unknownResourceIds, syncInfo);
mergeModifiedResources(modifiedResourceIds);
if (!partialInventory) {
purgeObsoleteResources(allServerSideUuids);
@@ -2836,7 +2839,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return;
}
- private void mergeUnknownResources(Set<Integer> unknownResourceIds) {
+ private void mergeUnknownResources(Set<Integer> unknownResourceIds, ResourceSyncInfo syncInfo) {
if (log.isDebugEnabled()) {
log.debug("Merging [" + unknownResourceIds.size()
+ "] unknown Resources and their descendants into local inventory...");
@@ -2847,8 +2850,8 @@ public class InventoryManager extends AgentService implements ContainerService,
DiscoveryServerService dss = configuration.getServerServices().getDiscoveryServerService();
Set<Resource> unknownResources = dss.getResources(unknownResourceIds, false);
- Map<Integer, Set<Integer>> childrenIdsOfUnknownResources;
- childrenIdsOfUnknownResources = new HashMap<Integer, Set<Integer>>(unknownResources.size());
+ Map<ResourceSyncInfo, Set<Integer>> childrenIdsOfUnknownResources;
+ childrenIdsOfUnknownResources = new HashMap<ResourceSyncInfo, Set<Integer>>(unknownResources.size());
Set<Integer> toBeIgnored = new HashSet<Integer>();
for (Resource unknownResource : unknownResources) {
@@ -2867,30 +2870,60 @@ public class InventoryManager extends AgentService implements ContainerService,
}
// get all the children IDs of the unknown resources we just merged
- Set<Resource> unknownChildren = unknownResource.getChildResources();
- Set<Integer> unknownChildrenIds = new HashSet<Integer>(unknownChildren.size());
- for (Resource unknownChild : unknownChildren) {
- unknownChildrenIds.add(unknownChild.getId());
+ ResourceSyncInfo unknownResourceAndItsTree = findResourceSyncInfoById(unknownResource.getId(), syncInfo);
+ if (unknownResourceAndItsTree != null) {
+ Collection<ResourceSyncInfo> unknownChildren = unknownResourceAndItsTree.getChildSyncInfos();
+ Set<Integer> unknownChildrenIds = new HashSet<Integer>(unknownChildren.size());
+ for (ResourceSyncInfo unknownChild : unknownChildren) {
+ unknownChildrenIds.add(unknownChild.getId());
+ }
+ childrenIdsOfUnknownResources.put(unknownResourceAndItsTree, unknownChildrenIds);
+ } else {
+ log.error("Could not find the unknown resource in the sync info: " + unknownResource);
}
- childrenIdsOfUnknownResources.put(unknownResource.getId(), unknownChildrenIds);
- unknownChildren.clear(); // help GC
}
unknownResourceIds.removeAll(toBeIgnored);
// now, do it again recursively so we merge the children
- Set<Entry<Integer, Set<Integer>>> entrySet = childrenIdsOfUnknownResources.entrySet();
- Iterator<Entry<Integer, Set<Integer>>> entrySetIterator = entrySet.iterator();
+ Set<Entry<ResourceSyncInfo, Set<Integer>>> entrySet = childrenIdsOfUnknownResources.entrySet();
+ Iterator<Entry<ResourceSyncInfo, Set<Integer>>> entrySetIterator = entrySet.iterator();
while (entrySetIterator.hasNext()) {
- Entry<Integer, Set<Integer>> entry = entrySetIterator.next();
+ Entry<ResourceSyncInfo, Set<Integer>> entry = entrySetIterator.next();
+ ResourceSyncInfo unknownParent = entry.getKey();
Set<Integer> unknownChildrenIds = entry.getValue();
entrySetIterator.remove(); // help GC
- mergeUnknownResources(unknownChildrenIds);
+ mergeUnknownResources(unknownChildrenIds, unknownParent);
unknownChildrenIds.clear(); // help GC
}
}
return;
}
+ // this is potentially expensive - only use this if you know the ID you are looking for is
+ // near the top of the provided tree of sync infos.
+ private ResourceSyncInfo findResourceSyncInfoById(int needle, ResourceSyncInfo haystack) {
+ // use a Q so we do this breadth first
+ Queue<ResourceSyncInfo> q = new ConcurrentLinkedQueue<ResourceSyncInfo>();
+ try {
+ q.offer(haystack);
+ while (!q.isEmpty()) {
+ ResourceSyncInfo node = q.poll();
+ if (node.getId() == needle) {
+ return node;
+ }
+ Collection<ResourceSyncInfo> children = node.getChildSyncInfos();
+ if (children != null) {
+ for (ResourceSyncInfo child : children) {
+ q.offer(child);
+ }
+ }
+ }
+ return null; // couldn't find it
+ } finally {
+ q.clear(); // help GC
+ }
+ }
+
// private void print(Resource resourceTreeNode, int level) {
// StringBuilder builder = new StringBuilder();
// for (int i = 0; i < level; i++) {
11 years, 3 months
[rhq] Branch 'bug/902406' - 2 commits - modules/core
by mazz
modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java | 1
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 46 +++++++---
2 files changed, 37 insertions(+), 10 deletions(-)
New commits:
commit f16bf96fe7491e146fe9117aaf623d551f4b1102
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 30 16:08:21 2013 -0500
[BZ 902406] this doesn't work. the getResources call with "false" means we don't get the children, which we need to recursively process the tree
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 eaca661..56a372e 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
@@ -30,10 +30,12 @@ import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
+import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
@@ -2822,13 +2824,16 @@ 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);
- syncSchedules(modifiedResources); // RHQ-792, mtime is the indicator that schedules should be sync'ed too
- syncDriftDefinitions(modifiedResources);
- for (Resource modifiedResource : modifiedResources) {
- mergeResource(modifiedResource);
+ if (!modifiedResourceIds.isEmpty()) {
+ Set<Resource> modifiedResources = configuration.getServerServices().getDiscoveryServerService()
+ .getResources(modifiedResourceIds, false);
+ syncSchedules(modifiedResources); // RHQ-792, mtime is the indicator that schedules should be sync'ed too
+ syncDriftDefinitions(modifiedResources);
+ for (Resource modifiedResource : modifiedResources) {
+ mergeResource(modifiedResource);
+ }
}
+ return;
}
private void mergeUnknownResources(Set<Integer> unknownResourceIds) {
@@ -2839,13 +2844,15 @@ public class InventoryManager extends AgentService implements ContainerService,
if (!unknownResourceIds.isEmpty()) {
PluginMetadataManager pmm = this.pluginManager.getMetadataManager();
+ DiscoveryServerService dss = configuration.getServerServices().getDiscoveryServerService();
+ Set<Resource> unknownResources = dss.getResources(unknownResourceIds, false);
- Set<Resource> unknownResources = configuration.getServerServices().getDiscoveryServerService()
- .getResources(unknownResourceIds, true);
+ Map<Integer, Set<Integer>> childrenIdsOfUnknownResources;
+ childrenIdsOfUnknownResources = new HashMap<Integer, Set<Integer>>(unknownResources.size());
Set<Integer> toBeIgnored = new HashSet<Integer>();
-
for (Resource unknownResource : unknownResources) {
+ // merge all the unknown resources (note: we aren't doing the children)
ResourceType resourceType = pmm.getType(unknownResource.getResourceType());
if (resourceType != null) {
mergeResource(unknownResource);
@@ -2858,9 +2865,28 @@ public class InventoryManager extends AgentService implements ContainerService,
+ "] but its type is disabled in the agent; ignoring it");
}
}
- }
+ // get all the children IDs of the unknown resources we just merged
+ Set<Resource> unknownChildren = unknownResource.getChildResources();
+ Set<Integer> unknownChildrenIds = new HashSet<Integer>(unknownChildren.size());
+ for (Resource unknownChild : unknownChildren) {
+ unknownChildrenIds.add(unknownChild.getId());
+ }
+ childrenIdsOfUnknownResources.put(unknownResource.getId(), unknownChildrenIds);
+ unknownChildren.clear(); // help GC
+ }
unknownResourceIds.removeAll(toBeIgnored);
+
+ // now, do it again recursively so we merge the children
+ Set<Entry<Integer, Set<Integer>>> entrySet = childrenIdsOfUnknownResources.entrySet();
+ Iterator<Entry<Integer, Set<Integer>>> entrySetIterator = entrySet.iterator();
+ while (entrySetIterator.hasNext()) {
+ Entry<Integer, Set<Integer>> entry = entrySetIterator.next();
+ Set<Integer> unknownChildrenIds = entry.getValue();
+ entrySetIterator.remove(); // help GC
+ mergeUnknownResources(unknownChildrenIds);
+ unknownChildrenIds.clear(); // help GC
+ }
}
return;
}
commit abda69f79c03cfe996c2bb3d959647a6829d43b8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 30 16:07:44 2013 -0500
[BZ 902406] we need to have a limit on getResources since it is a major part of the inventory sync and can be expensive
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
index 6b2fba6..52da745 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
@@ -90,6 +90,7 @@ public interface DiscoveryServerService {
* @param includeDescendants
* @return a tree of resources with the latest data
*/
+ @LimitedConcurrency(CONCURRENCY_LIMIT_INVENTORY_SYNC)
Set<Resource> getResources(Set<Integer> resourceIds, boolean includeDescendants);
/**
11 years, 3 months
[rhq] Branch 'bug/902406' - 13 commits - modules/enterprise modules/helpers modules/integration-tests modules/plugins
by mazz
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginFileUploadServlet.java | 15
modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html | 2
modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js | 2
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java | 2
modules/enterprise/server/jar/pom.xml | 107 +++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java | 166 ++++++----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java | 120 +++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AlertDefinitionHandlerBean.java | 62 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java | 81 +++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/RootHandlerBean.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertConditionRest.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertNotificationRest.java | 4
modules/enterprise/server/jar/src/main/xsl/apiout2docbook.xsl | 22 +
modules/helpers/rest-docs-generator/pom.xml | 9
modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java | 37 +-
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java | 110 ++++++
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java | 76 ++++
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java | 24 -
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 4
23 files changed, 673 insertions(+), 204 deletions(-)
New commits:
commit 4d29e0578a879ecd56d4339c2be58ba96ab5111a
Author: JÃŒrgen Hoffmann <jhoffmann(a)redhat.com>
Date: Wed Jan 30 17:27:01 2013 +0100
Improving the way the Dashboard view is displayed (correct row/column alignment).
diff --git a/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html b/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html
index e42628a..041dbb7 100644
--- a/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html
+++ b/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html
@@ -30,7 +30,7 @@ an empty database (meaning resource ids and schedule ids starting at 10001).
<li><a href="/rest-examples/stacked3.html">Metrics as stacked bars</a> in pure HTML + (a little) CSS</li>
<li><a href="/rest-examples/stacked2.html">Metrics as rects using stacked bars from above</a></li>
<li><a href="/rest-examples/whisker.html">Whisker chart 1</a></li>
- <li><a href="/rest-examples/whisker2.html">Multiple Whisker charts</a></li>
+ <li><a href="/rest-examples/whisker2.html">Multiple Whisker charts ("Dashboard")</a></li>
<li><a href="/rest-examples/tree.html">Resource tree</a></li>
<li><a href="/rest-examples/raw_graph.html">7 days of raw metrics as dot- or line- chart</a></li>
<li><a href="/rest-examples/raw_graph7.html">7 days of raw metrics as dot- or line- chart - comparing daily values</a></li>
diff --git a/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js b/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js
index 870c423..67b1b17 100644
--- a/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js
+++ b/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js
@@ -2,7 +2,7 @@ var rhq = {
dashboard : function() {
// get all platforms
- $.get('/rest/resource/platforms', function(data) {
+ $.get('/rest/resource/platforms.json', function(data) {
var table = $("#table");
for (var i = 0; i < data.length ; i++ ) {
commit 74dfd37db100de71128db47eb83962c686c8c925
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jan 30 17:08:46 2013 +0100
[Bug 880819 - RFE: expose GroupDefinitionManager remotely] Subset of methods defined in the local intercace has been exposed via the remote intercase and registered in the RhqManager.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
index d374324..32832b2 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerRemote;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerRemote;
import org.rhq.enterprise.server.operation.OperationManagerRemote;
import org.rhq.enterprise.server.report.DataAccessManagerRemote;
+import org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerRemote;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
@@ -70,6 +71,7 @@ public enum RhqManager {
DriftTemplateManager(DriftTemplateManagerRemote.class, "${DriftTemplateManager}"), //
DiscoveryBoss(DiscoveryBossRemote.class, "${DiscoveryBoss}"), //
EventManager(EventManagerRemote.class, "${EventManager}"), //
+ GroupDefinitionManager(GroupDefinitionManagerRemote.class, "${GroupDefinitionManager}"), //
MeasurementBaselineManager(MeasurementBaselineManagerRemote.class, "${MeasurementBaselineManager}"), //
MeasurementDataManager(MeasurementDataManagerRemote.class, "${MeasurementDataManager}"), //
MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class, "${MeasurementDefinitionManager}"), //
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index 190a169..9d5251b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -69,7 +69,7 @@ import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@Stateless
-public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal {
+public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal, GroupDefinitionManagerRemote {
private final Log log = LogFactory.getLog(GroupDefinitionManagerBean.class);
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
@@ -415,15 +415,14 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal {
public PageList<GroupDefinition> findGroupDefinitionsByCriteria(Subject subject,
ResourceGroupDefinitionCriteria criteria) {
- CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
if (authorizationManager.isInventoryManager(subject) == false) {
if (criteria.isInventoryManagerRequired()) {
throw new PermissionException("Subject [" + subject.getName()
+ "] requires InventoryManager permission for requested query criteria.");
}
}
-
+
+ CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
CriteriaQueryRunner<GroupDefinition> queryRunner = new CriteriaQueryRunner<GroupDefinition>(criteria,
generator, entityManager);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java
new file mode 100644
index 0000000..70e3f88
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java
@@ -0,0 +1,120 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.server.resource.group.definition;
+
+import javax.ejb.Remote;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria;
+import org.rhq.core.domain.resource.group.GroupDefinition;
+import org.rhq.core.domain.resource.group.InvalidExpressionException;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.resource.group.ResourceGroupDeleteException;
+import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionAlreadyExistsException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionCreateException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionDeleteException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionNotFoundException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionUpdateException;
+
+
+/**
+ * The remote interface to the SLSB GroupDefinitionManager.
+ *
+ * @author Jirka Kremser
+ */
+@Remote
+public interface GroupDefinitionManagerRemote {
+
+ /**
+ * Finds the group definition by id
+ *
+ * @param groupDefinitionId the id
+ * @return instance of <code>GroupDefinition</code>
+ * @throws GroupDefinitionNotFoundException in case the group definition has not been found
+ */
+ GroupDefinition getById(int groupDefinitionId) throws GroupDefinitionNotFoundException;
+
+ /**
+ * Creates a new group definiton.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking create the group definition
+ * @param newGroupDefinition the object defining the group definition
+ * @return instance of <code>GroupDefinition</code>
+ * @throws GroupDefinitionAlreadyExistsException
+ * @throws GroupDefinitionCreateException
+ */
+ GroupDefinition createGroupDefinition(Subject subject, GroupDefinition newGroupDefinition)
+ throws GroupDefinitionAlreadyExistsException, GroupDefinitionCreateException;
+
+ /**
+ * Fetches the group definitions based on provided criteria.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to find the group definitions
+ * @param criteria the criteria
+ * @return instance of <code>GroupDefinition</code>
+ */
+ PageList<GroupDefinition> findGroupDefinitionsByCriteria(Subject subject, ResourceGroupDefinitionCriteria criteria);
+
+ /**
+ * Deletes the given group definition.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to remove the group definition
+ * @param groupDefinitionId the id of a group definition to be deleted
+ * @throws GroupDefinitionNotFoundException
+ * @throws GroupDefinitionDeleteException
+ */
+ void removeGroupDefinition(Subject subject, Integer groupDefinitionId) throws GroupDefinitionNotFoundException,
+ GroupDefinitionDeleteException;
+
+ /**
+ * Updates the given group definition.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to update the group definition
+ * @param updated the object defining the group definition to be changed (based on its id)
+ * @return the updated group definition
+ * @throws GroupDefinitionAlreadyExistsException
+ * @throws GroupDefinitionUpdateException
+ * @throws InvalidExpressionException
+ * @throws ResourceGroupUpdateException
+ */
+ GroupDefinition updateGroupDefinition(Subject subject, GroupDefinition updated)
+ throws GroupDefinitionAlreadyExistsException, GroupDefinitionUpdateException, InvalidExpressionException,
+ ResourceGroupUpdateException;
+
+ /**
+ * Explicitly recalculates the group membership, depending on the GroupDefinition's expression.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to recalculate the group membership
+ * @param groupDefinitionId the id of a group definition to be recalculated
+ * @throws ResourceGroupDeleteException
+ * @throws GroupDefinitionDeleteException
+ * @throws GroupDefinitionNotFoundException
+ * @throws InvalidExpressionException
+ */
+ void calculateGroupMembership(Subject subject, int groupDefinitionId) throws ResourceGroupDeleteException,
+ GroupDefinitionDeleteException, GroupDefinitionNotFoundException, InvalidExpressionException;
+
+}
\ No newline at end of file
commit bfc0a46761e3a13e17da91dd68be47c32952874e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 29 18:42:09 2013 -0500
Hopefully final tweeks to MergeInventoryReport
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index cea1f6e..d5d7128 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -859,7 +859,6 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
log.debug("getExistingResource processing for [" + resource + "]");
}
- // We perform this query a lot during a large inventory merge, so minimize overhead by using it directly
Resource existingResource = null;
if (resource.getId() != 0) {
@@ -867,7 +866,8 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
log.debug("Agent claims resource is already in inventory. Id=" + resource.getId());
}
- existingResource = entityManager.getReference(Resource.class, resource.getId());
+ // This maybe could be more efficient using a named query that pulls some lazy data, but this should be fine
+ existingResource = entityManager.find(Resource.class, resource.getId());
if (isDebugEnabled) {
if (null != existingResource) {
log.debug("Found resource already in inventory. Id=" + resource.getId());
@@ -889,9 +889,10 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
+ ", key=" + resource.getResourceKey());
}
- // (jshaughn) I'm not 100% sure I understand the need for this while loop, but I believe it has to
- // do with handling the case in which a resource type has moved (see f74b22044) and trying to
- // relocate the parent. Anyway, I'm not going to touch it even though it slows things down.
+ // (jshaughn) I'm not 100% sure but I believe this loop has to do with either or both of:
+ // - protecting against the agent merging a resource it thinks is new but actually exists
+ // - handling the case in which a resource type has moved (see f74b22044) and trying to relocate the parent.
+ // Anyway, I'm not going to touch it even though it slows things down.
ResourceType resourceType = resource.getResourceType();
Resource parent = resource;
@@ -914,6 +915,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
}
if (null == existingParent) {
+ // I think getReference may be slightly faster here but it's likely negligible
existingParent = entityManager.getReference(Resource.class, parentId);
if (null != existingParent) {
if (null != parentMap) {
commit 9e70606deeb4654ae6117a8d36c322372ac63a27
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Tue Jan 29 15:11:15 2013 -0500
[BZ 905632] fix MetadataManager query to use unlimited criteria queries.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
index 5beb643..dd5311b 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/resource/metadata/ResourceMetadataManagerBeanTest.java
@@ -385,7 +385,7 @@ public class ResourceMetadataManagerBeanTest extends MetadataBeanTest {
resourcesServiceE1.get(0));
List<Resource> resourcesServiceE3 = createResources(2, "RemoveTypesPlugin", "ServiceE3",
resourcesServiceE2.get(0));
- List<Resource> resourcesServiceE4 = createResources(2, "RemoveTypesPlugin", "ServiceE4",
+ List<Resource> resourcesServiceE4 = createResources(205, "RemoveTypesPlugin", "ServiceE4",
resourcesServiceE3.get(0));
ResourceGroup rgRecursive = createResourceGroup("ServerE Group", "ServerE", "RemoveTypesPlugin", true);
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 2c8a925..9d844e4 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.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceSubCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageControl;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
@@ -268,6 +269,7 @@ public class ResourceMetadataManagerBean implements ResourceMetadataManagerLocal
ResourceCriteria c = new ResourceCriteria();
c.addFilterResourceTypeId(existingType.getId());
c.addFilterInventoryStatus(null);
+ c.setPageControl(PageControl.getUnlimitedInstance());
List<Resource> resources = resourceManager.findResourcesByCriteria(subject, c);
if (resources != null) {
Iterator<Resource> resIter = resources.iterator();
commit 977ff337c997c2f5d63d19d46ada868eed4d9624
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 29 21:30:06 2013 +0100
Use a real UUID for resource creation. Deprecate the endpoints for platform and resource creation.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
index be28d92..8142f17 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
+import java.util.UUID;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@@ -529,15 +530,39 @@ public class ResourceHandlerBean extends AbstractRestBean {
@ApiOperation(value = "Create a new platform in the Server. If the platform already exists, this is a no-op." +
"The platform internally has a special name so that it will not clash with one that was generated" +
- "via a normal RHQ agent")
+ "via a normal RHQ agent. DEPRECATED Use POST /platforms instead")
@POST
@Path("platform/{name}")
- public Response createPlatform(
+ public Response createPlatformOLD(
@ApiParam(value = "Name of the platform") @PathParam("name") String name,
@ApiParam(value = "Type of the platform", allowableValues = "Linux,Windows,... TODO") StringValue typeValue,
@Context UriInfo uriInfo) {
+
String typeName = typeValue.getValue();
+ return createPlatformInternal(name, typeName, uriInfo);
+
+ }
+
+ @POST
+ @Path("platforms")
+ @ApiOperation(value = "Create a new platform in the Server. If the platform already exists, this is a no-op." +
+ "The platform internally has a special name so that it will not clash with one that was generated" +
+ "via a normal RHQ agent. Only resourceName and typeName need to be supplied in the passed object")
+ public Response createPlatform(
+ @ApiParam("The info about the platform. Only type name and resource name need to be supplied") ResourceWithType resource,
+ @Context UriInfo uriInfo)
+ {
+
+ String typeName = resource.getTypeName();
+ String resourceName = resource.getResourceName();
+
+ return createPlatformInternal(resourceName,typeName,uriInfo);
+ }
+
+
+ private Response createPlatformInternal(String name, String typeName, UriInfo uriInfo) {
+
ResourceType type = resourceTypeManager.getResourceTypeByNameAndPlugin(typeName,"Platforms");
if (type==null) {
throw new StuffNotFoundException("Platform with type [" + typeName + "]");
@@ -565,10 +590,8 @@ public class ResourceHandlerBean extends AbstractRestBean {
agent = new Agent("dummy-agent:name"+name,"-dummy-p:"+name,12345,"http://foo.com/p:name/"+name,"abc-"+name);
agentMgr.createAgent(agent);
-
-
Resource platform = new Resource(resourceKey,name,type);
- platform.setUuid(resourceKey);
+ platform.setUuid(UUID.randomUUID().toString());
platform.setAgent(agent);
platform.setInventoryStatus(InventoryStatus.COMMITTED);
platform.setModifiedBy(caller.getName());
@@ -595,40 +618,44 @@ public class ResourceHandlerBean extends AbstractRestBean {
} catch (Exception e) {
throw new RuntimeException(e);
}
-
}
- private void createSchedules(Resource resource) {
- ResourceType rt = resource.getResourceType();
- Set<MeasurementDefinition> definitions = rt.getMetricDefinitions ();
- for (MeasurementDefinition definition : definitions) {
- MeasurementSchedule schedule = new MeasurementSchedule(definition,resource);
- schedule.setEnabled(definition.isDefaultOn());
- schedule.setInterval(definition.getDefaultInterval());
- entityManager.persist(schedule);
- }
- }
- @ApiOperation(value = "Create a resource with a given type below a certain parent")
+ @ApiOperation(value = "Create a resource with a given type below a certain parent. DEPRECATED Use POST / instead")
@POST
@Path("{name}")
- public Response createResource(
+ public Response createResourceOLD(
@ApiParam("Name of the new resource") @PathParam("name") String name,
@ApiParam("Name of the Resource type") StringValue typeValue,
@ApiParam("Name of the plugin providing the type") @QueryParam("plugin") String plugin,
@ApiParam("Id of the future parent to attach this to") @QueryParam("parentId") int parentId,
@Context UriInfo uriInfo) {
+ String typeName = typeValue.getValue();
+
+ return createResourceInternal(name, plugin, parentId, typeName, uriInfo);
+ }
+
+ @POST
+ @Path("/")
+ @ApiOperation("Create a new resource as a child of an existing resource¡")
+ public Response createResource(
+ @ApiParam("THe info about the resource. You need to supply resource name, resource type name, plugin name, id of the parent") ResourceWithType resource,
+ @Context UriInfo uriInfo)
+ {
+ return createResourceInternal(resource.getResourceName(),resource.getPluginName(),resource.getParentId(),resource.getTypeName(),uriInfo);
+ }
+
+ private Response createResourceInternal(String name, String plugin, int parentId, String typeName,
+ UriInfo uriInfo) {
Resource parent = resMgr.getResourceById(caller,parentId);
- String typeName = typeValue.getValue();
ResourceType resType = resourceTypeManager.getResourceTypeByNameAndPlugin(typeName,plugin);
if (resType==null)
throw new StuffNotFoundException("ResourceType with name [" + typeName + "] and plugin [" + plugin + "]");
String resourceKey = "res:" + name + ":" + parentId;
-
Resource r = resMgr.getResourceByParentAndKey(caller,parent,resourceKey,plugin,typeName);
if (r!=null) {
// resource exists - return it
@@ -644,7 +671,7 @@ public class ResourceHandlerBean extends AbstractRestBean {
}
Resource res = new Resource(resourceKey,name,resType);
- res.setUuid(resourceKey);
+ res.setUuid(UUID.randomUUID().toString());
res.setAgent(parent.getAgent());
res.setParentResource(parent);
res.setInventoryStatus(InventoryStatus.COMMITTED);
@@ -683,4 +710,16 @@ public class ResourceHandlerBean extends AbstractRestBean {
return Response.status(Response.Status.NO_CONTENT).build();
}
+
+ private void createSchedules(Resource resource) {
+ ResourceType rt = resource.getResourceType();
+ Set<MeasurementDefinition> definitions = rt.getMetricDefinitions ();
+ for (MeasurementDefinition definition : definitions) {
+ MeasurementSchedule schedule = new MeasurementSchedule(definition,resource);
+ schedule.setEnabled(definition.isDefaultOn());
+ schedule.setInterval(definition.getDefaultInterval());
+ entityManager.persist(schedule);
+ }
+ }
+
}
diff --git a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
index e8066bc..6899995 100644
--- a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
+++ b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
@@ -25,12 +25,16 @@ package org.rhq.modules.integrationTests.restApi;
import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.path.json.JsonPath;
+import com.jayway.restassured.path.xml.XmlPath;
+import com.jayway.restassured.path.xml.element.Node;
import com.jayway.restassured.response.Response;
import org.apache.http.HttpStatus;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
+import org.rhq.modules.integrationTests.restApi.d.Resource;
+
import static com.jayway.restassured.RestAssured.expect;
import static com.jayway.restassured.RestAssured.get;
import static com.jayway.restassured.RestAssured.given;
@@ -129,7 +133,7 @@ public class ResourcesTest extends AbstractBase {
@Test
public void testGetPlatformXml() {
given()
- .header("Accept","application/xml")
+ .header("Accept", "application/xml")
.expect()
.statusCode(200)
.contentType(ContentType.XML)
@@ -140,7 +144,7 @@ public class ResourcesTest extends AbstractBase {
@Test
public void testGetPlatformSchedules() {
given()
- .header("Accept","application/json")
+ .header("Accept", "application/json")
.expect()
.statusCode(200)
.when()
@@ -158,18 +162,66 @@ public class ResourcesTest extends AbstractBase {
}
@Test
- public void testCreatePlatform() throws Exception {
+ public void testCreatePlatformOld() throws Exception {
given().body("{\"value\":\"Linux\"}")
- .header("Content-Type","application/json")
- .header("Accept","application/json")
+ .header("Content-Type", "application/json")
+ .header("Accept", "application/json")
.expect().statusCode(201)
.when().post("/resource/platform/api-test-dummy");
}
@Test
+ public void testCreatePlatform() throws Exception {
+
+ Resource resource = new Resource();
+ resource.setResourceName("dummy-test");
+ resource.setTypeName("Linux");
+
+ given()
+ .header(acceptXml)
+ .contentType(ContentType.JSON)
+ .body(resource)
+ .expect()
+ .statusCode(201)
+ .log().ifError()
+ .when()
+ .post("/resource/platforms");
+
+ }
+
+ @Test
public void testCreatePlatformAndRemove() throws Exception {
+ Resource resource = new Resource();
+ resource.setResourceName("dummy-test");
+ resource.setTypeName("Linux");
+
+ Response response =
+ given()
+ .header(acceptXml)
+ .contentType(ContentType.JSON)
+ .body(resource)
+ .expect()
+ .statusCode(201)
+ .log().ifError()
+ .when()
+ .post("/resource/platforms");
+
+ XmlPath xmlPath = response.xmlPath();
+ Node resource1 = xmlPath.get("resource");
+ Node platformIdNode = resource1.get("resourceId");
+ String platformId = platformIdNode.value();
+
+ given().pathParam("id", platformId)
+ .expect().statusCode(HttpStatus.SC_NO_CONTENT)
+ .when().delete("/resource/{id}");
+
+ }
+
+ @Test
+ public void testCreatePlatformOLDAndRemove() throws Exception {
+
Response response =
with().body("{\"value\":\"Linux\"}")
.header("Content-Type","application/json")
@@ -185,12 +237,12 @@ public class ResourcesTest extends AbstractBase {
}
@Test
- public void testCreatePlatformWithChildAndRemove() throws Exception {
+ public void testCreatePlatformOLDWithChildOLDAndRemove() throws Exception {
Response response =
with().body("{\"value\":\"Linux\"}")
.header("Content-Type","application/json")
- .header("Accept","application/json")
+ .header("Accept", "application/json")
.expect()
.statusCode(201)
.when()
@@ -219,6 +271,50 @@ public class ResourcesTest extends AbstractBase {
}
@Test
+ public void testCreatePlatformWithChildAndRemove() throws Exception {
+
+ Resource platform = new Resource();
+ platform.setResourceName("dummy-test");
+ platform.setTypeName("Linux");
+
+ Response response =
+ with().body(platform)
+ .header("Content-Type","application/json")
+ .header("Accept","application/json")
+ .expect()
+ .statusCode(201)
+ .log().ifError()
+ .when()
+ .post("/resource/platforms");
+
+ String platformId = response.jsonPath().getString("resourceId");
+
+ Resource child = new Resource();
+ child.setResourceName("test");
+ child.setTypeName("CPU");
+ child.setPluginName("Platforms");
+ child.setParentId(Integer.valueOf(platformId));
+
+ try {
+
+ with()
+ .body(child)
+ .header("Content-Type", "application/json")
+ .header("Accept", "application/json")
+ .expect()
+ .statusCode(201)
+ .log().ifError()
+ .when()
+ .post("/resource");
+ }
+ finally {
+ given().pathParam("id",platformId)
+ .expect().statusCode(HttpStatus.SC_NO_CONTENT)
+ .when().delete("/resource/{id}");
+ }
+ }
+
+ @Test
public void testDoubleChildCreate() throws Exception {
// a resource can be created again and again
diff --git a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
new file mode 100644
index 0000000..9c3c1a3
--- /dev/null
+++ b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.modules.integrationTests.restApi.d;
+
+/**
+ * A resource for testing purposes
+ * @author Heiko W. Rupp
+ */
+public class Resource {
+
+ String resourceName;
+ int resourceId;
+ String typeName;
+ String pluginName;
+ Integer parentId;
+
+ public Resource() {
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public Integer getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(Integer parentId) {
+ this.parentId = parentId;
+ }
+
+ public String getPluginName() {
+ return pluginName;
+ }
+
+ public void setPluginName(String pluginName) {
+ this.pluginName = pluginName;
+ }
+
+ public int getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(int resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+}
commit 75903fd6abdef24ac5bab17f35f3b83ba2b1033c
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 29 20:06:17 2013 +0100
Do not assume everything is a jar - we also support jar-less plugins.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginFileUploadServlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginFileUploadServlet.java
index adc870a..3263d19 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginFileUploadServlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/PluginFileUploadServlet.java
@@ -66,13 +66,16 @@ public class PluginFileUploadServlet extends FileUploadServlet {
File file = files.values().iterator().next();
String newPluginFilename = fileNames.values().iterator().next();
- // make sure its a .jar file and strip off any temp file suffix (in case the browser set the name to something odd)
- int jarExtension = newPluginFilename.lastIndexOf(".jar");
- if (jarExtension < 0) {
- newPluginFilename = newPluginFilename + ".jar"; // make sure it ends with ".jar" in case it is some tmp filename
- jarExtension = newPluginFilename.lastIndexOf(".jar");
+ // see if it is a jar-less plugin descriptor and if not check for .jar
+ if (!newPluginFilename.endsWith("-rhq-plugin.xml")) {
+ // make sure its a .jar file and strip off any temp file suffix (in case the browser set the name to something odd)
+ int jarExtension = newPluginFilename.lastIndexOf(".jar");
+ if (jarExtension < 0) {
+ newPluginFilename = newPluginFilename + ".jar"; // make sure it ends with ".jar" in case it is some tmp filename
+ jarExtension = newPluginFilename.lastIndexOf(".jar");
+ }
+ newPluginFilename = newPluginFilename.substring(0, jarExtension + ".jar".length());
}
- newPluginFilename = newPluginFilename.substring(0, jarExtension + ".jar".length());
log.info("A new plugin [" + newPluginFilename + "] has been uploaded to [" + file + "]");
if (file == null || !file.exists()) {
commit ffc824545987d3a3ec959b82208f79c933c2ae41
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 29 14:23:16 2013 -0500
Even more MergeInventoryReport speed
- avoid slsb call overhead by performing relevant query locally
- remove unnecessary em.find
- convert some em.find calls to em.getReference
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index 29ea65c..cea1f6e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -37,6 +37,7 @@ import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.security.auth.login.LoginException;
@@ -866,7 +867,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
log.debug("Agent claims resource is already in inventory. Id=" + resource.getId());
}
- existingResource = entityManager.find(Resource.class, resource.getId());
+ existingResource = entityManager.getReference(Resource.class, resource.getId());
if (isDebugEnabled) {
if (null != existingResource) {
log.debug("Found resource already in inventory. Id=" + resource.getId());
@@ -893,7 +894,6 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
// relocate the parent. Anyway, I'm not going to touch it even though it slows things down.
ResourceType resourceType = resource.getResourceType();
Resource parent = resource;
- Subject overlord = subjectManager.getOverlord();
while (null != parent && null == existingResource) {
parent = parent.getParentResource();
@@ -914,7 +914,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
}
if (null == existingParent) {
- existingParent = entityManager.find(Resource.class, parentId);
+ existingParent = entityManager.getReference(Resource.class, parentId);
if (null != existingParent) {
if (null != parentMap) {
parentMap.put(parentId, existingParent);
@@ -928,8 +928,16 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
// We found the parent in inventory, so now see if we can find this resource in inventory by using
// the parent, the resource key (unique among siblings), the plugin and the type.
- existingResource = resourceManager.getResourceByParentAndKey(overlord, existingParent,
- resource.getResourceKey(), resourceType.getPlugin(), resourceType.getName());
+ Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_BY_PARENT_AND_KEY);
+ query.setParameter("parent", existingParent);
+ query.setParameter("key", resource.getResourceKey());
+ query.setParameter("plugin", resourceType.getPlugin());
+ query.setParameter("typeName", resourceType.getName());
+ try {
+ existingResource = (Resource) query.getSingleResult();
+ } catch (NoResultException e) {
+ existingResource = null;
+ }
}
if (null != existingResource) {
@@ -957,6 +965,12 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
return existingResource;
}
+ /**
+ * <p>Requires A Transaction.</p>
+ * @param updatedResource pojo
+ * @param existingResource attached entity
+ * @throws InvalidInventoryReportException
+ */
private void updateExistingResource(Resource updatedResource, Resource existingResource)
throws InvalidInventoryReportException {
/*
@@ -974,9 +988,6 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
return;
}
- // get an attached entity to update
- existingResource = entityManager.find(Resource.class, existingResource.getId());
-
Resource existingParent = existingResource.getParentResource();
Resource updatedParent = updatedResource.getParentResource();
ResourceType existingResourceParentType = (existingParent != null) ? existingResource.getParentResource()
commit 16a2dc05205e491850e747368627ec54bdfdbedd
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 29 11:36:46 2013 -0500
More mergeInventoryReport speed
- add map cache of attached parent entities to avoid redundant DB fetches
- replace named query fetch with simple em.find where possible
- trivial, rename some private methods that were named inappropriately
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index 7a5d024..29ea65c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -37,7 +37,6 @@ import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.security.auth.login.LoginException;
@@ -509,7 +508,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
+ resource.getResourceType());
}
- Resource existingResource = findExistingResource(resource);
+ Resource existingResource = findExistingResource(resource, null);
if (existingResource != null) {
mergeResourceResponse = new MergeResourceResponse(existingResource.getId(), true);
} else {
@@ -791,20 +790,22 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
long batchStart = System.currentTimeMillis();
boolean isDebugEnabled = log.isDebugEnabled();
+ // Cache parent resources we've already fetched from the DB, many resources will have the same parent
+ Map<Integer, Resource> parentMap = new HashMap<Integer, Resource>();
for (Resource resource : resourceBatch) {
Resource existingResource = null;
long start = System.currentTimeMillis();
- existingResource = findExistingResource(resource);
+ existingResource = findExistingResource(resource, parentMap);
// Does this resource already exist in inventory? If so, update, otherwise add
if (null != existingResource) {
- updateExistingResourceInNewTransaction(resource, existingResource);
+ updateExistingResource(resource, existingResource);
} else {
presetAgent(resource, agent);
- persistResourceInNewTransaction(resource);
+ persistResource(resource, parentMap);
}
if (isDebugEnabled) {
@@ -813,6 +814,9 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
}
}
+ // Help out the GC
+ parentMap.clear();
+
if (isDebugEnabled) {
long delta = (System.currentTimeMillis() - batchStart);
log.debug("Resource Batch merged: size/average/millis=" + resourceBatch.size() + "/" + delta
@@ -834,15 +838,19 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
}
/**
+ * <p>Requires A Transaction</p>
+ *
* Given a resource, will attempt to find it in the server's inventory (that is, finds it in the database). If the
* given resource's ID does not exist in the database, it will be looked up by its resource key. If the resource
* cannot be found either via ID or resource key then SIDE EFFECT: the given resource's ID will be reset to 0 and null
* will be returned.
*
- * @param resource Pojo containing resourceId, key, and parentResoure (if applicable)
+ * @param resource Pojo containing resourceId, key, and parentResoure (if applicable)
+ * @param parentMap, if supplied, holds previously fetched parent pojos. useful when the calling code does many
+ * finds for a few parents. If not found in the map the db will be searched, the map will be updated if possible.
* @return the Resource entity found in the database and matching the given resource.
*/
- private Resource findExistingResource(Resource resource) {
+ private Resource findExistingResource(Resource resource, Map<Integer, Resource> parentMap) {
boolean isDebugEnabled = log.isDebugEnabled();
@@ -850,27 +858,20 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
log.debug("getExistingResource processing for [" + resource + "]");
}
- // We perform this query a lot during a large inventory merge, so minimize overhead by using it directly
- Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_BY_ID);
+ // We perform this query a lot during a large inventory merge, so minimize overhead by using it directly
Resource existingResource = null;
- Subject overlord = subjectManager.getOverlord();
if (resource.getId() != 0) {
if (isDebugEnabled) {
log.debug("Agent claims resource is already in inventory. Id=" + resource.getId());
}
- try {
- query.setParameter("resourceId", resource.getId());
- existingResource = (Resource) query.getSingleResult();
- if (isDebugEnabled) {
+ existingResource = entityManager.find(Resource.class, resource.getId());
+ if (isDebugEnabled) {
+ if (null != existingResource) {
log.debug("Found resource already in inventory. Id=" + resource.getId());
- }
- } catch (NoResultException e) {
- existingResource = null;
-
- // agent lied - agent's copy of JON server inventory must be stale.
- if (isDebugEnabled) {
+ } else {
+ // agent lied - agent's copy of JON server inventory must be stale.
log.debug("However, no resource exists with the specified id. Id=" + resource.getId());
}
}
@@ -892,6 +893,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
// relocate the parent. Anyway, I'm not going to touch it even though it slows things down.
ResourceType resourceType = resource.getResourceType();
Resource parent = resource;
+ Subject overlord = subjectManager.getOverlord();
while (null != parent && null == existingResource) {
parent = parent.getParentResource();
@@ -899,18 +901,28 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
// check if the parent is in inventory. This might not be the case during initial sync-up for resource upgrade.
Resource existingParent = null;
if (null != parent) {
- if (parent.getId() <= 0) {
+ int parentId = parent.getId();
+
+ if (parentId <= 0) {
log.warn("Expected potential parent resource to have a valid ID. Parent=" + parent + ", Child="
+ resource);
}
- try {
- query.setParameter("resourceId", parent.getId());
- existingParent = (Resource) query.getSingleResult();
+ // See if we already fetched this parent and it's in our cache map, if so, use it.
+ if (null != parentMap) {
+ existingParent = parentMap.get(parentId);
+ }
- } catch (NoResultException e) {
- // this parent is not known to the server, so there's no point in trying to find a child of it...
- continue;
+ if (null == existingParent) {
+ existingParent = entityManager.find(Resource.class, parentId);
+ if (null != existingParent) {
+ if (null != parentMap) {
+ parentMap.put(parentId, existingParent);
+ }
+ } else {
+ // this parent is not known to the server, so there's no point in trying to find a child of it...
+ continue;
+ }
}
}
@@ -945,7 +957,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
return existingResource;
}
- private void updateExistingResourceInNewTransaction(Resource updatedResource, Resource existingResource)
+ private void updateExistingResource(Resource updatedResource, Resource existingResource)
throws InvalidInventoryReportException {
/*
* there exists a small window of time after the synchronous part of the uninventory and before the async
@@ -1088,13 +1100,25 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
return true;
}
- private void persistResourceInNewTransaction(Resource resource) {
+ private void persistResource(Resource resource, Map<Integer, Resource> parentMap) {
- Resource parentResource = resource.getParentResource();
+ // Id of detached parent resource
+ Integer parentId = (null != resource.getParentResource()) ? resource.getParentResource().getId() : null;
- if (null != parentResource) {
- // Find the parent resource entity and create the parent-child relationship
- parentResource = findExistingResource(parentResource);
+ // attached parentResource
+ Resource parentResource = null;
+
+ if (null != parentId) {
+ // look in our map cache first
+ if (null != parentMap) {
+ parentResource = parentMap.get(parentId);
+ }
+ // if not in cache, try the DB
+ if (null == parentResource) {
+ // Find the parent resource entity
+ parentResource = entityManager.find(Resource.class, parentId);
+ }
+ // if the parent exists, create the parent-child relationship
if (null != parentResource) {
parentResource.addChildResource(resource);
}
commit 6c6b3984c01f54c98c2c19536410af8704063108
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 29 17:16:41 2013 +0100
Improve representation of types.
diff --git a/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java b/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
index cb1a56e..72be1ed 100644
--- a/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
+++ b/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
@@ -328,8 +328,11 @@ public class ClassLevelProcessor extends AbstractProcessor {
}
if (typeString.contains(modelPackage)) {
String mps = modelPackage.endsWith(".") ? modelPackage : modelPackage + ".";
+ // For a generic collection we need to find the "inner type" and link to it
+ int offset = typeString.contains("<") ? typeString.indexOf('<') +1 : 0;
+ String restType = typeString.substring(offset + modelPackage.length()+1);
typeString = typeString.replace(mps,"");
- typeId = "..." + typeString; // TODO in case of Collection<TypeString> only take the part from the modelPackage
+ typeId = "..." + restType;
}
element.setAttribute("type", typeString);
element.setAttribute("typeId", typeId);
@@ -380,7 +383,7 @@ public class ClassLevelProcessor extends AbstractProcessor {
Element elem = doc.createElement("data");
xmlRoot.appendChild(elem);
- elem.setAttribute("name",classElementIn.getSimpleName().toString());
+ elem.setAttribute("name", classElementIn.getSimpleName().toString());
elem.setAttribute("nameId","..." + classElementIn.getSimpleName().toString());
ApiClass api = classElementIn.getAnnotation(ApiClass.class);
if (api!=null) {
@@ -427,13 +430,15 @@ public class ClassLevelProcessor extends AbstractProcessor {
TypeMirror returnTypeMirror = m.getReturnType();
// for types in the modelPackage or java.lang, remove the fqdn
String typeName = returnTypeMirror.toString();
- if (typeName.startsWith(modelPackage)) {
- typeName = typeName.substring(modelPackage.length()+1);
+ if (typeName.contains(modelPackage)) {
+ typeName = typeName.replace(modelPackage+".","");
}
- else if (typeName.startsWith("java.lang")) {
- typeName = typeName.substring("java.lang".length()+1);
+ if (typeName.contains("java.lang.")) {
+ typeName = typeName.replaceAll("java\\.lang\\.", "");
+ }
+ if (typeName.contains("java.util.")) {
+ typeName = typeName.replaceAll("java\\.util\\.","");
}
- // TODO for collection<type> remove the collection expression and set some collection attribute
mElem.setAttribute("type", typeName);
}
}
commit 4fa01930008ddf35ff9956c7c8a0ad9fb9ef72d4
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 29 11:19:31 2013 +0100
Improve documentation and get the processor to work again.
Generate links from parameters to domain classes, upgrade the docbook plugin.
diff --git a/modules/enterprise/server/jar/pom.xml b/modules/enterprise/server/jar/pom.xml
index 3b9f92d..7aef625 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -22,7 +22,7 @@
</properties>
<dependencies>
-
+
<!-- Internal Deps -->
<!-- rhq-enterprise-comm pulls in the old version of jboss remoting. The old version of remoting
@@ -35,7 +35,7 @@
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
- <version>3.1.0.GA</version>
+ <version>${jboss-logging.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -86,7 +86,7 @@
<artifactId>rhq-common-drift</artifactId>
<version>${project.version}</version>
</dependency>
-
+
<dependency>
<groupId>com.googlecode.java-diff-utils</groupId>
<artifactId>diffutils</artifactId>
@@ -115,7 +115,7 @@
<!-- Note, the test deps are intentionally placed above the other scoped deps because of classpath
reasons. Maven orders the [test] classpath in the order listed in the pom. -->
-
+
<dependency>
<groupId>org.jboss.spec</groupId>
@@ -124,7 +124,7 @@
<scope>provided</scope>
<type>pom</type>
</dependency>
-
+
<dependency>
<groupId>org.rhq</groupId>
<artifactId>test-utils</artifactId>
@@ -137,7 +137,7 @@
</exclusion>
</exclusions>
</dependency>
-
+
<dependency>
<groupId>org.rhq</groupId>
<artifactId>rhq-core-domain</artifactId>
@@ -145,15 +145,15 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
-
-
+
+
<!-- 3rd Party Deps -->
- <!-- do we really need this version, for now use the version provided by AS7, declare just below -->
+ <!-- do we really need this version, for now use the version provided by AS7, declare just below -->
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr-runtime</artifactId>
- <version>3.2</version>
+ <version>3.2</version>
<exclusions>
<exclusion>
<groupId>antlr</groupId>
@@ -162,13 +162,13 @@
<exclusion>
<groupId>org.antlr</groupId>
<artifactId>antlr</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>antlr</groupId>
- <artifactId>antlr</artifactId>
+ <artifactId>antlr</artifactId>
<scope>provided</scope>
</dependency>
@@ -217,7 +217,7 @@
<groupId>gnu-getopt</groupId>
<artifactId>getopt</artifactId>
</dependency>
-
+
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
@@ -226,7 +226,7 @@
<dependency>
<groupId>jboss</groupId>
- <artifactId>jboss-cache</artifactId>
+ <artifactId>jboss-cache</artifactId>
<scope>compile</scope>
</dependency>
@@ -236,13 +236,13 @@
<scope>provided</scope>
</dependency>
- <!-- JBoss annotations like @TransactionTimeout -->
+ <!-- JBoss annotations like @TransactionTimeout -->
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-ext-api</artifactId>
<scope>provided</scope>
</dependency>
-
+
<!-- annotations like @ExcludeDefaultInterceptors -->
<dependency>
<groupId>org.jboss.spec.javax.interceptor</groupId>
@@ -268,7 +268,7 @@
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
-
+
<dependency>
<groupId>org.jboss.spec.javax.jms</groupId>
<artifactId>jboss-jms-api_1.1_spec</artifactId>
@@ -402,7 +402,7 @@
<artifactId>snakeyaml</artifactId>
<version>1.8</version>
</dependency>
-
+
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
@@ -424,6 +424,13 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>rest-docs-generator</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
<build>
@@ -836,26 +843,37 @@
<groupId>org.rhq.helpers</groupId>
<artifactId>rest-docs-generator</artifactId>
<version>${project.version}</version>
- <scope>provided</scope>
</dependency>
+
+ <!-- We need this, as otherwise processing fails completely with a class not found exception -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging</artifactId>
+ <version>${jboss-logging.version}</version>
+ </dependency>
+
</dependencies>
<build>
<!-- Document generation from the Annotations on the REST-API. -->
- <!-- TODO move to a better suited processing phase -->
<plugins>
-
<plugin>
- <groupId>org.bsc.maven</groupId>
- <artifactId>maven-processor-plugin</artifactId>
- <version>2.0.6-redhat</version>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.0</version>
<configuration>
- <processors>
+ <annotationProcessors>
<processor>org.rhq.helpers.rest_docs_generator.ClassLevelProcessor</processor>
- </processors>
- <compilerArguments>-AtargetDirectory=${project.build.directory}/docs/xml</compilerArguments>
- <!-- Comment the next line in to get more verbose output for debugging -->
- <!--<compilerArguments>-Averbose=true</compilerArguments> -->
+ </annotationProcessors>
+ <proc>only</proc>
+ <compilerArguments>
+ <AtargetDirectory>${project.build.directory}/docs/xml</AtargetDirectory>
+ <AmodelPkg>org.rhq.enterprise.server.rest.domain</AmodelPkg>
+ <!-- enable the next line to have the output of the processor shown on console -->
+ <!--<Averbose>true</Averbose>-->
+ </compilerArguments>
+ <!-- set the next to true to enable verbose output of the compiler plugin; default from the evn is true, but this is too noisy -->
+ <verbose>false</verbose>
</configuration>
<executions>
<execution>
@@ -863,20 +881,11 @@
<phase>process-classes</phase>
<goals>
<!-- We want to process the classes in src/ -->
- <goal>process</goal>
+ <goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
-
- <!-- Disable annotation processors during normal compilation -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -892,6 +901,7 @@
<configuration>
<transformationSets>
<transformationSet>
+ <!-- Generate a html rendering -->
<!-- org.rhq.helpers.rest_docs_generator.test plugin wrote to target/docs/xml (see -AtargetDirectory above) -->
<dir>target/docs/xml</dir>
<includes>
@@ -901,7 +911,7 @@
<parameters>
<parameter>
<name>basePath</name>
- <value>http://localhost:7080/rest/1</value>
+ <value>http://localhost:7080/rest</value>
</parameter>
</parameters>
<outputDir>${project.build.directory}/docs/html</outputDir>
@@ -912,6 +922,7 @@
</fileMappers>
</transformationSet>
<transformationSet>
+ <!-- Generate a docbook file as input to fop -->
<!-- org.rhq.helpers.rest_docs_generator.test plugin wrote to target/docs/xml (see -AtargetDirectory above) -->
<dir>target/docs/xml</dir>
<includes>
@@ -921,7 +932,7 @@
<parameters>
<parameter>
<name>basePath</name>
- <value>http://localhost:7080/rest/1</value>
+ <value>http://localhost:7080/rest</value>
</parameter>
</parameters>
<outputDir>${project.build.directory}/docs/xml</outputDir>
@@ -934,11 +945,11 @@
</transformationSets>
</configuration>
</plugin>
-
+
<plugin>
<groupId>com.agilejava.docbkx</groupId>
<artifactId>docbkx-maven-plugin</artifactId>
- <version>2.0.9</version>
+ <version>2.0.14</version>
<executions>
<execution>
<phase>process-classes</phase>
@@ -951,14 +962,14 @@
<configuration>
<sourceDirectory>target/docs/xml</sourceDirectory> <!-- from previous plugin, 2nd transformation set -->
<includes>rest-api-out.dbx.xml</includes>
- <hyphenate>false</hyphenate>
+ <hyphenate>true</hyphenate>
<generateToc>true</generateToc>
</configuration>
</plugin>
</plugins>
</build>
</profile>
-
+
<profile>
<id>cobertura</id>
<build>
@@ -1067,7 +1078,7 @@
</plugins>
</build>
</profile>
-
+
</profiles>
<reporting>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AlertDefinitionHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AlertDefinitionHandlerBean.java
index d0bb88e..97200cd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AlertDefinitionHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AlertDefinitionHandlerBean.java
@@ -126,6 +126,7 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
+ // Redirect from /definition to /definitions for GET requests
@GET
@Path("/definition")
public Response redirectDefinitionToDefinitions(@Context UriInfo uriInfo) {
@@ -178,11 +179,11 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@POST
@Path("/definitions")
- @ApiOperation("Create an AlertDefinition for the resource/group/resource type passed as query param. Only one of the three params may be given at any time.")
- public Response createAlertDefinition(@QueryParam("resourceId") Integer resourceId,
- @QueryParam("groupId") Integer groupId,
- @QueryParam("resourceTypeId") Integer resourceTypeId,
- AlertDefinitionRest adr,
+ @ApiOperation("Create an AlertDefinition for the resource/group/resource type passed as query param. One and only one of the three params must be given at any time.")
+ public Response createAlertDefinition(@ApiParam("The id of the resource to attach the definition to") @QueryParam("resourceId") Integer resourceId,
+ @ApiParam("The id of the group to attach the definition to") @QueryParam("groupId") Integer groupId,
+ @ApiParam("The id of the resource type to attach the definition to") @QueryParam("resourceTypeId") Integer resourceTypeId,
+ @ApiParam("The data for the new definition") AlertDefinitionRest adr,
@Context UriInfo uriInfo) {
int i = 0;
@@ -266,7 +267,7 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@ApiOperation(value = "Update the alert definition (priority, enablement, dampening, recovery)", notes = "Priority must be HIGH,LOW,MEDIUM")
public Response updateDefinition(
@ApiParam("Id of the alert definition to update") @PathParam("id") int definitionId,
- AlertDefinitionRest definitionRest) {
+ @ApiParam("Data for the update") AlertDefinitionRest definitionRest) {
AlertDefinition definition = alertDefinitionManager.getAlertDefinition(caller,definitionId);
if (definition==null)
@@ -303,14 +304,18 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@DELETE
@Path("definition/{id}")
@ApiOperation("Delete an alert definition")
- public Response deleteDefinition(@PathParam("id") int definitionId) {
+ public Response deleteDefinition(@ApiParam("Id of the definition to delete") @PathParam("id") int definitionId) {
- int count = alertDefinitionManager.removeAlertDefinitions(caller, new int[]{definitionId});
+ alertDefinitionManager.removeAlertDefinitions(caller, new int[]{definitionId});
return Response.noContent().build();
}
-
+ /**
+ * Create a dampening object for the passed definition from the alert definition rest that is passed in.
+ * @param alertDefinition The alert definition to modify
+ * @param adr The incoming AlertDefinitonRest object
+ */
private void setDampeningFromRest(AlertDefinition alertDefinition, AlertDefinitionRest adr) {
AlertDampening.Category dampeningCategory;
try {
@@ -373,7 +378,10 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@POST
@Path("definition/{id}/conditions")
- public Response addConditionToDefinition(@PathParam("id") int definitionId, AlertConditionRest conditionRest, @Context UriInfo uriInfo) {
+ @ApiOperation("Add a new alert condition to an existing alert definition")
+ public Response addConditionToDefinition(
+ @ApiParam("The id of the alert definition") @PathParam("id") int definitionId,
+ @ApiParam("The condition to add") AlertConditionRest conditionRest, @Context UriInfo uriInfo) {
AlertDefinition definition = alertDefinitionManager.getAlertDefinition(caller,definitionId);
if (definition==null)
@@ -392,7 +400,9 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@DELETE
@Path("condition/{cid}")
- public Response deleteCondition(@PathParam("cid") int conditionId) {
+ @ApiOperation("Remove an alert condition")
+ public Response deleteCondition(
+ @ApiParam("The id of the condition to remove")@PathParam("cid") int conditionId) {
Integer definitionId = findDefinitionIdForConditionId(conditionId);
AlertDefinition definition2 = entityManager.find(AlertDefinition.class,definitionId);
@@ -427,7 +437,10 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@PUT
@Path("condition/{cid}")
- public Response updateCondition(@PathParam("cid") int conditionId, AlertConditionRest conditionRest, @Context UriInfo uriInfo) {
+ @ApiOperation("Update an existing condition of an alert definition.Note that the update will change the id of the condition")
+ public Response updateCondition(
+ @ApiParam("The id of the condition to update") @PathParam("cid") int conditionId,
+ @ApiParam("The updated condition") AlertConditionRest conditionRest, @Context UriInfo uriInfo) {
Integer definitionId = findDefinitionIdForConditionId(conditionId);
@@ -465,7 +478,9 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@GET
@Path("condition/{cid}")
- public Response getCondition(@PathParam("cid") int conditionId) {
+ @ApiOperation("Retrieve a condition of an alert definition by its condition id")
+ public Response getCondition(
+ @ApiParam("The id of the condition to retrieve") @PathParam("cid") int conditionId) {
AlertCondition condition = conditionMgr.getAlertConditionById(conditionId);
AlertConditionRest acr = conditionToConditionRest(condition);
@@ -521,7 +536,9 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@GET
@Path("notification/{nid}")
- public Response getNotification(@PathParam("nid") int notificationId) {
+ @ApiOperation("Return a notification definition by its id")
+ public Response getNotification(
+ @ApiParam("The id of the notification definition to retrieve") @PathParam("nid") int notificationId) {
AlertNotification notification = notificationMgr.getAlertNotification(caller,notificationId);
AlertNotificationRest anr = notificationToNotificationRest(notification);
@@ -531,7 +548,9 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@DELETE
@Path("notification/{nid}")
- public Response deleteNotification(@PathParam("nid") int notificationId) {
+ @ApiOperation("Remove a notification definition")
+ public Response deleteNotification(
+ @ApiParam("The id of the notification definition to remove") @PathParam("nid") int notificationId) {
AlertNotification notification = notificationMgr.getAlertNotification(caller,notificationId);
AlertDefinition definition = alertDefinitionManager.getAlertDefinition(caller,notification.getAlertDefinition().getId());
@@ -548,7 +567,10 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@PUT
@Path("notification/{nid}")
- public Response updateNotification(@PathParam("nid") int notificationId, AlertNotificationRest notificationRest) {
+ @ApiOperation("Update a notification definition")
+ public Response updateNotification(
+ @ApiParam("The id of the notification definition to update") @PathParam("nid") int notificationId,
+ @ApiParam("The updated notification definition to use") AlertNotificationRest notificationRest) {
AlertNotification notification = notificationMgr.getAlertNotification(caller,notificationId);
AlertDefinition definition = alertDefinitionManager.getAlertDefinition(caller,notification.getAlertDefinition().getId());
@@ -578,7 +600,10 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@POST
@Path("definition/{id}/notifications")
- public Response addNotificationToDefinition(@PathParam("id") int definitionId, AlertNotificationRest notificationRest, @Context UriInfo uriInfo) {
+ @ApiOperation("Add a new notification definition to an alert definition")
+ public Response addNotificationToDefinition(
+ @ApiParam("Id of the alert definition that should get the notification definition") @PathParam("id") int definitionId,
+ @ApiParam("The notification definition to add") AlertNotificationRest notificationRest, @Context UriInfo uriInfo) {
AlertNotification notification = new AlertNotification(notificationRest.getSenderName());
@@ -670,7 +695,8 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@ApiOperation("Return an alert notification sender by name. This includes information about the configuration it expects")
@GET @GZIP
@Path("sender/{name}")
- public Response getAlertSenderByName(@PathParam("name")String senderName, @Context UriInfo uriInfo) {
+ public Response getAlertSenderByName(
+ @ApiParam("Name of the sender to retrieve") @PathParam("name")String senderName, @Context UriInfo uriInfo) {
AlertSenderInfo info = notificationMgr.getAlertInfoForSender(senderName);
if (info==null) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/RootHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/RootHandlerBean.java
index 7998294..e2abffd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/RootHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/RootHandlerBean.java
@@ -35,6 +35,9 @@ import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
import org.rhq.enterprise.server.rest.domain.Link;
/**
@@ -42,6 +45,7 @@ import org.rhq.enterprise.server.rest.domain.Link;
*
* @author Heiko W. Rupp
*/
+@Api("Handle the root context to have an anchor for discoverability")
@Path("/")
@Interceptors(SetCallerInterceptor.class)
@Stateless
@@ -60,12 +64,14 @@ public class RootHandlerBean extends AbstractRestBean {
@GET
@Path("index")
+ @ApiOperation("Return links from the root /index of the REST-resource tree")
public Response index(@Context Request request, @Context HttpHeaders headers, @Context UriInfo uriInfo) {
return handleIndex(headers,uriInfo);
}
@GET
@Path("/")
+ @ApiOperation("Return links from the root / of the REST-resource tree")
public Response index2(@Context Request request, @Context HttpHeaders headers, @Context UriInfo uriInfo) {
return handleIndex(headers,uriInfo);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertConditionRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertConditionRest.java
index 890a3fe..1ada16c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertConditionRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertConditionRest.java
@@ -21,6 +21,9 @@ package org.rhq.enterprise.server.rest.domain;
import javax.xml.bind.annotation.XmlRootElement;
+import com.wordnik.swagger.annotations.ApiClass;
+import com.wordnik.swagger.annotations.ApiProperty;
+
import org.rhq.core.domain.alert.AlertConditionCategory;
import org.rhq.core.domain.alert.AlertConditionOperator;
@@ -29,6 +32,7 @@ import org.rhq.core.domain.alert.AlertConditionOperator;
* An alert definition can have any number of definitions
* @author Heiko W. Rupp
*/
+@ApiClass(value = "One condition for an alert definition")
@XmlRootElement(name = "condition")
public class AlertConditionRest {
@@ -44,6 +48,7 @@ public class AlertConditionRest {
public AlertConditionRest() {
}
+ @ApiProperty("Comparator to use with this definition")
public AlertConditionOperator getName() {
return name;
}
@@ -52,6 +57,7 @@ public class AlertConditionRest {
this.name = name;
}
+ @ApiProperty("The category")
public AlertConditionCategory getCategory() {
return category;
}
@@ -64,10 +70,12 @@ public class AlertConditionRest {
this.id = id;
}
+ @ApiProperty("Id of the condition.Note that this is not stable - when you update the condition, its id will change")
public int getId() {
return id;
}
+ @ApiProperty("THe threshold to compare against")
public Double getThreshold() {
return threshold;
}
@@ -76,6 +84,7 @@ public class AlertConditionRest {
this.threshold = threshold;
}
+ @ApiProperty("Options to this condition. Depends on the category used")
public String getOption() {
return option;
}
@@ -100,6 +109,7 @@ public class AlertConditionRest {
this.comparator = comparator;
}
+ @ApiProperty("The id of the measurement definition, this comparator should apply to. A metric schedule can be identified by a resource id and a definition id.")
public int getMeasurementDefinition() {
return measurementDefinition;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
index 0e6b351..cecd946 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertDefinitionRest.java
@@ -26,8 +26,6 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.wordnik.swagger.annotations.ApiClass;
import com.wordnik.swagger.annotations.ApiProperty;
-import org.rhq.core.domain.alert.AlertDampening;
-
/**
* Alert Definition
* @author Heiko W. Rupp
@@ -48,6 +46,7 @@ public class AlertDefinitionRest {
String dampeningCount;
String dampeningPeriod;
+ @SuppressWarnings("unused")
public AlertDefinitionRest() {
}
@@ -92,6 +91,7 @@ public class AlertDefinitionRest {
this.priority = priority;
}
+ @ApiProperty(value = "Id of an alert definition to recover")
public int getRecoveryId() {
return recoveryId;
}
@@ -128,6 +128,7 @@ public class AlertDefinitionRest {
this.notifications = notifications;
}
+ @ApiProperty(value = "Category for dampening. ONCE means 'disable definition after firing'", allowableValues = "NONE, CONSECUTIVE_COUNT, PARTIAL_COUNT, INVERSE_COUNT, DURATION_COUNT, NO_DUPLICATES, ONCE")
public String getDampeningCategory() {
return dampeningCategory;
}
@@ -136,6 +137,7 @@ public class AlertDefinitionRest {
this.dampeningCategory = dampeningCategory;
}
+ @ApiProperty(value = "Number of occurrences of an alert (in a given period)")
public String getDampeningCount() {
return dampeningCount;
}
@@ -144,6 +146,7 @@ public class AlertDefinitionRest {
this.dampeningCount = dampeningCount;
}
+ @ApiProperty( value = "Period to check events. Only applicable for PARTIAL_COUNT, DURATION_COUNT, INVERSE_COUNT")
public String getDampeningPeriod() {
return dampeningPeriod;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertNotificationRest.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertNotificationRest.java
index 1b6a46b..c4cd0c5 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertNotificationRest.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/AlertNotificationRest.java
@@ -31,7 +31,7 @@ import com.wordnik.swagger.annotations.ApiProperty;
* Representation of notifications
* @author Heiko W. Rupp
*/
-@ApiClass("Represents an alert notification")
+@ApiClass("Represents an alert notification definition")
@XmlRootElement(name = "notification")
public class AlertNotificationRest {
@@ -42,6 +42,7 @@ public class AlertNotificationRest {
public AlertNotificationRest() {
}
+ @ApiProperty("Id of the definition. This will change if the notification is updated.")
public int getId() {
return id;
}
@@ -59,6 +60,7 @@ public class AlertNotificationRest {
this.senderName = senderName;
}
+ @ApiProperty("Configuration that needs to be passed to the definition.")
public Map<String, Object> getConfig() {
return config;
}
diff --git a/modules/enterprise/server/jar/src/main/xsl/apiout2docbook.xsl b/modules/enterprise/server/jar/src/main/xsl/apiout2docbook.xsl
index 97e0598..512a8d4 100644
--- a/modules/enterprise/server/jar/src/main/xsl/apiout2docbook.xsl
+++ b/modules/enterprise/server/jar/src/main/xsl/apiout2docbook.xsl
@@ -40,7 +40,7 @@
<xsl:element name="tocentry">
<link>
<xsl:attribute name="linkend">
- <xsl:value-of select="@path"/>
+ <xsl:value-of select="generate-id(@path)"/>
</xsl:attribute>
<xsl:if test="@basePath">
<xsl:value-of select="@basePath"/>
@@ -63,7 +63,7 @@
<xsl:template match="class">
<xsl:element name="section">
<xsl:attribute name="xml:id">
- <xsl:value-of select="@path"/>
+ <xsl:value-of select="generate-id(@path)"/>
</xsl:attribute>
<title>
<!--/<xsl:value-of select="@path"/>-->
@@ -167,7 +167,20 @@
<xsl:value-of select="@required"/>
</td>
<td>
- <xsl:value-of select="@type"/>
+ <xsl:choose>
+
+ <xsl:when test="starts-with(@typeId,'...')">
+ <link>
+ <xsl:attribute name="linkend">
+ <xsl:value-of select="@typeId"/>
+ </xsl:attribute>
+ <xsl:value-of select="@type"/>
+ </link>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@type"/>
+ </xsl:otherwise>
+ </xsl:choose>
</td>
<td>
<xsl:choose>
@@ -233,6 +246,9 @@
<xsl:template match="data">
<xsl:element name="section">
+ <xsl:attribute name="xml:id">
+ <xsl:value-of select="@nameId"/>
+ </xsl:attribute>
<title>Data-Class: <xsl:value-of select="@name"/></title>
<xsl:if test="@abstract">
<subtitle><xsl:value-of select="@abstract"/></subtitle>
diff --git a/modules/helpers/rest-docs-generator/pom.xml b/modules/helpers/rest-docs-generator/pom.xml
index af3374f..f97d2de 100644
--- a/modules/helpers/rest-docs-generator/pom.xml
+++ b/modules/helpers/rest-docs-generator/pom.xml
@@ -48,15 +48,6 @@
</testResources>
<plugins>
-<!--
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>animal-sniffer-maven-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
--->
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
diff --git a/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java b/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
index c10dd62..cb1a56e 100644
--- a/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
+++ b/modules/helpers/rest-docs-generator/src/main/java/org/rhq/helpers/rest_docs_generator/ClassLevelProcessor.java
@@ -58,7 +58,7 @@ import org.jboss.resteasy.annotations.GZIP;
*/
@SupportedOptions({ClassLevelProcessor.TARGET_DIRECTORY,ClassLevelProcessor.VERBOSE,ClassLevelProcessor.MODEL_PACKAGE_KEY})
-(a)SupportedSourceVersion(SourceVersion.RELEASE_6)
+(a)SupportedSourceVersion(SourceVersion.RELEASE_7)
@SupportedAnnotationTypes(value = {"com.wordnik.swagger.annotations.*","javax.ws.rs.*","javax.xml.bind.annotation.XmlRootElement"})
public class ClassLevelProcessor extends AbstractProcessor {
@@ -318,8 +318,21 @@ public class ClassLevelProcessor extends AbstractProcessor {
if (defaultValue!=null)
element.setAttribute("defaultValue",defaultValue);
-
- element.setAttribute("type", t.toString());
+ String typeString = t.toString();
+ String typeId = typeString;
+ if (typeString.contains("java.lang.")) {
+ typeString = typeString.replaceAll("java\\.lang\\.","");
+ }
+ else if (typeString.contains("java.util.")) {
+ typeString = typeString.replaceAll("java\\.util\\.","");
+ }
+ if (typeString.contains(modelPackage)) {
+ String mps = modelPackage.endsWith(".") ? modelPackage : modelPackage + ".";
+ typeString = typeString.replace(mps,"");
+ typeId = "..." + typeString; // TODO in case of Collection<TypeString> only take the part from the modelPackage
+ }
+ element.setAttribute("type", typeString);
+ element.setAttribute("typeId", typeId);
}
}
@@ -368,6 +381,7 @@ public class ClassLevelProcessor extends AbstractProcessor {
Element elem = doc.createElement("data");
xmlRoot.appendChild(elem);
elem.setAttribute("name",classElementIn.getSimpleName().toString());
+ elem.setAttribute("nameId","..." + classElementIn.getSimpleName().toString());
ApiClass api = classElementIn.getAnnotation(ApiClass.class);
if (api!=null) {
elem.setAttribute("abstract",api.value());
commit 3e15d816c287e10e628dd0b750896c9f1d927bef
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Tue Jan 29 14:41:26 2013 +0100
BZ905000 - RFE: RHQ fails to set JBOSS_PIDFILE and LAUNCH_JBOSS_IN_BACKGROUND when importing JBoss AS7
Added missing variables in START_SCRIPT_ENV_VAR_NAMES set
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 18bab92..fb328a3 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -98,7 +98,9 @@ public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent
"JBOSS_MODULEPATH", //
"JBOSS_BASE_DIR", //
"JBOSS_LOG_DIR", //
- "JBOSS_CONFIG_DIR" //
+ "JBOSS_CONFIG_DIR", //
+ "JBOSS_PIDFILE", //
+ "LAUNCH_JBOSS_IN_BACKGROUND" //
));
// If OS is Windows, add env vars that are only used by the batch files.
commit b4dabd62afa92e52cfeeb19580d8e38000c7707b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Jan 28 15:20:16 2013 -0500
Change some test logging from info to debug
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index 67bd1fa..7a5d024 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -744,10 +744,10 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
// tree and chunk through it. Parents must be merged before children, so use a breadth first approach.
List<Resource> resourceList = treeToBreadthFirstList(resource);
- // TODO: if (log.isDebugEnabled()) {
- log.info("Preparing to merge [" + resourceList.size() + "] Resources with a batch size of [" + MERGE_BATCH_SIZE
- + "]");
- //}
+ if (log.isDebugEnabled()) {
+ log.debug("Preparing to merge [" + resourceList.size() + "] Resources with a batch size of ["
+ + MERGE_BATCH_SIZE + "]");
+ }
while (!resourceList.isEmpty()) {
int size = resourceList.size();
@@ -760,10 +760,10 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
resourceBatch.clear();
}
- // TODO: if (log.isDebugEnabled()) {
- log.info("Resource and children merged: resource/millis=" + resource.getName() + '/'
- + (System.currentTimeMillis() - start));
- //}
+ if (log.isDebugEnabled()) {
+ log.debug("Resource and children merged: resource/millis=" + resource.getName() + '/'
+ + (System.currentTimeMillis() - start));
+ }
return;
}
@@ -790,6 +790,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
throws InvalidInventoryReportException {
long batchStart = System.currentTimeMillis();
+ boolean isDebugEnabled = log.isDebugEnabled();
for (Resource resource : resourceBatch) {
Resource existingResource = null;
@@ -806,17 +807,17 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
persistResourceInNewTransaction(resource);
}
- //TODO: if (log.isDebugEnabled()) {
- log.info("Single Resource merged: resource/millis=" + resource.getName() + '/'
- + (System.currentTimeMillis() - start));
- //}
+ if (isDebugEnabled) {
+ log.debug("Single Resource merged: resource/millis=" + resource.getName() + '/'
+ + (System.currentTimeMillis() - start));
+ }
}
- //TODO: if (log.isDebugEnabled()) {
- long delta = (System.currentTimeMillis() - batchStart);
- log.info("Resource Batch merged: size/average/millis=" + resourceBatch.size() + "/" + delta
- / resourceBatch.size() + "/" + delta);
- //}
+ if (isDebugEnabled) {
+ long delta = (System.currentTimeMillis() - batchStart);
+ log.debug("Resource Batch merged: size/average/millis=" + resourceBatch.size() + "/" + delta
+ / resourceBatch.size() + "/" + delta);
+ }
}
/**
@@ -843,7 +844,9 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
*/
private Resource findExistingResource(Resource resource) {
- if (log.isDebugEnabled()) {
+ boolean isDebugEnabled = log.isDebugEnabled();
+
+ if (isDebugEnabled) {
log.debug("getExistingResource processing for [" + resource + "]");
}
@@ -853,21 +856,21 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
Subject overlord = subjectManager.getOverlord();
if (resource.getId() != 0) {
- if (log.isDebugEnabled()) {
+ if (isDebugEnabled) {
log.debug("Agent claims resource is already in inventory. Id=" + resource.getId());
}
try {
query.setParameter("resourceId", resource.getId());
existingResource = (Resource) query.getSingleResult();
- if (log.isDebugEnabled()) {
+ if (isDebugEnabled) {
log.debug("Found resource already in inventory. Id=" + resource.getId());
}
} catch (NoResultException e) {
existingResource = null;
// agent lied - agent's copy of JON server inventory must be stale.
- if (log.isDebugEnabled()) {
+ if (isDebugEnabled) {
log.debug("However, no resource exists with the specified id. Id=" + resource.getId());
}
}
@@ -879,7 +882,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
// this will happen if the agent found the resource (non-zero id) but the DB didn't know about it,
// or if the agent didn't know about it to begin with (id was 0).
if (existingResource == null) {
- if (log.isDebugEnabled()) {
+ if (isDebugEnabled) {
log.debug("Checking if a resource exists with the specified business key. Id=" + resource.getId()
+ ", key=" + resource.getResourceKey());
}
@@ -920,7 +923,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
if (null != existingResource) {
// We found it - reset the id to what it should be.
resource.setId(existingResource.getId());
- if (log.isDebugEnabled()) {
+ if (isDebugEnabled) {
log.debug("Found resource already in inventory with specified business key, Id=" + resource.getId());
}
@@ -934,9 +937,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
// TODO: Is there anything else we should do here to inform the agent it has an out-of-sync resource?
} else {
- if (log.isDebugEnabled()) {
- log.debug("Resource's id was already zero, nothing to do for the merge.");
- }
+ log.debug("Resource's id was already zero, nothing to do for the merge.");
}
}
}
commit 4403c93e9f56274644f397174582a0540c0195fc
Author: Larry O'Leary <loleary(a)redhat.com>
Date: Tue Jan 8 16:59:11 2013 -0600
Bug 905183 - [as5 plugin] Unable to collect metric from web application context due to WebApplicationContextComponent not initializing 'clustered' property value
Added code to verify that clustered has been initialized and if it has not, an attempt is made to initialize it. Additionally, it will not be used if it is not initialized.
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java
index 07708b7..dd63305 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java
@@ -142,16 +142,24 @@ public class WebApplicationContextComponent extends ManagedComponentComponent {
report.addData(trait);
}
} else {
- String metricNameToUse = metricName;
- if (clustered && !"runState".equals(metricName)) {
- metricNameToUse = toUpperCaseFirstLetter(metricName);
+ String value = null;
+
+ /*
+ * Bug 737996 - Working around the property names inconsistency in the clustered web app contexts.
+ * If clustered we need to capitalize the first letter of the metric name to workaround JBPAPP-7172.
+ * If null is returned then we can assume that JBPAPP-7172 does not apply here and use the expected
+ * metric name.
+ */
+ if (clustered == null) {
+ retrieveClusteredProperty();
}
- String value = getMeasurement(component, metricNameToUse);
+ if (clustered != null && clustered && !"runState".equals(metricName)) {
+ value = getMeasurement(component, toUpperCaseFirstLetter(metricName));
+ }
- if (clustered && !"runState".equals(metricName) && value == null) {
- //hmm... so it looks like https://issues.jboss.org/browse/JBPAPP-7172 has been fixed
- //and we're getting the metric names in lower case even for clustered contexts
+ // value should be null unless app is clustered and JBPAPP-7172 applies
+ if (value == null) {
value = getMeasurement(component, metricName);
}
@@ -265,4 +273,4 @@ public class WebApplicationContextComponent extends ManagedComponentComponent {
return Character.toUpperCase(first) + name.substring(1);
}
-}
\ No newline at end of file
+}
11 years, 3 months
[rhq] modules/enterprise
by Heiko W. Rupp
modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html | 2 +-
modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 4d29e0578a879ecd56d4339c2be58ba96ab5111a
Author: Jürgen Hoffmann <jhoffmann(a)redhat.com>
Date: Wed Jan 30 17:27:01 2013 +0100
Improving the way the Dashboard view is displayed (correct row/column alignment).
diff --git a/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html b/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html
index e42628a..041dbb7 100644
--- a/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html
+++ b/modules/enterprise/gui/rest-examples-war/src/main/webapp/index.html
@@ -30,7 +30,7 @@ an empty database (meaning resource ids and schedule ids starting at 10001).
<li><a href="/rest-examples/stacked3.html">Metrics as stacked bars</a> in pure HTML + (a little) CSS</li>
<li><a href="/rest-examples/stacked2.html">Metrics as rects using stacked bars from above</a></li>
<li><a href="/rest-examples/whisker.html">Whisker chart 1</a></li>
- <li><a href="/rest-examples/whisker2.html">Multiple Whisker charts</a></li>
+ <li><a href="/rest-examples/whisker2.html">Multiple Whisker charts ("Dashboard")</a></li>
<li><a href="/rest-examples/tree.html">Resource tree</a></li>
<li><a href="/rest-examples/raw_graph.html">7 days of raw metrics as dot- or line- chart</a></li>
<li><a href="/rest-examples/raw_graph7.html">7 days of raw metrics as dot- or line- chart - comparing daily values</a></li>
diff --git a/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js b/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js
index 870c423..67b1b17 100644
--- a/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js
+++ b/modules/enterprise/gui/rest-examples-war/src/main/webapp/js/rhq.js
@@ -2,7 +2,7 @@ var rhq = {
dashboard : function() {
// get all platforms
- $.get('/rest/resource/platforms', function(data) {
+ $.get('/rest/resource/platforms.json', function(data) {
var table = $("#table");
for (var i = 0; i < data.length ; i++ ) {
11 years, 3 months
[rhq] modules/enterprise
by Jiri Kremser
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java | 120 ++++++++++
3 files changed, 125 insertions(+), 4 deletions(-)
New commits:
commit 74dfd37db100de71128db47eb83962c686c8c925
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jan 30 17:08:46 2013 +0100
[Bug 880819 - RFE: expose GroupDefinitionManager remotely] Subset of methods defined in the local intercace has been exposed via the remote intercase and registered in the RhqManager.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
index d374324..32832b2 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerRemote;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerRemote;
import org.rhq.enterprise.server.operation.OperationManagerRemote;
import org.rhq.enterprise.server.report.DataAccessManagerRemote;
+import org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerRemote;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
@@ -70,6 +71,7 @@ public enum RhqManager {
DriftTemplateManager(DriftTemplateManagerRemote.class, "${DriftTemplateManager}"), //
DiscoveryBoss(DiscoveryBossRemote.class, "${DiscoveryBoss}"), //
EventManager(EventManagerRemote.class, "${EventManager}"), //
+ GroupDefinitionManager(GroupDefinitionManagerRemote.class, "${GroupDefinitionManager}"), //
MeasurementBaselineManager(MeasurementBaselineManagerRemote.class, "${MeasurementBaselineManager}"), //
MeasurementDataManager(MeasurementDataManagerRemote.class, "${MeasurementDataManager}"), //
MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class, "${MeasurementDefinitionManager}"), //
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index 190a169..9d5251b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -69,7 +69,7 @@ import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@Stateless
-public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal {
+public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal, GroupDefinitionManagerRemote {
private final Log log = LogFactory.getLog(GroupDefinitionManagerBean.class);
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
@@ -415,15 +415,14 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal {
public PageList<GroupDefinition> findGroupDefinitionsByCriteria(Subject subject,
ResourceGroupDefinitionCriteria criteria) {
- CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
- ;
if (authorizationManager.isInventoryManager(subject) == false) {
if (criteria.isInventoryManagerRequired()) {
throw new PermissionException("Subject [" + subject.getName()
+ "] requires InventoryManager permission for requested query criteria.");
}
}
-
+
+ CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
CriteriaQueryRunner<GroupDefinition> queryRunner = new CriteriaQueryRunner<GroupDefinition>(criteria,
generator, entityManager);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java
new file mode 100644
index 0000000..70e3f88
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java
@@ -0,0 +1,120 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.server.resource.group.definition;
+
+import javax.ejb.Remote;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria;
+import org.rhq.core.domain.resource.group.GroupDefinition;
+import org.rhq.core.domain.resource.group.InvalidExpressionException;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.resource.group.ResourceGroupDeleteException;
+import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionAlreadyExistsException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionCreateException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionDeleteException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionNotFoundException;
+import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionUpdateException;
+
+
+/**
+ * The remote interface to the SLSB GroupDefinitionManager.
+ *
+ * @author Jirka Kremser
+ */
+@Remote
+public interface GroupDefinitionManagerRemote {
+
+ /**
+ * Finds the group definition by id
+ *
+ * @param groupDefinitionId the id
+ * @return instance of <code>GroupDefinition</code>
+ * @throws GroupDefinitionNotFoundException in case the group definition has not been found
+ */
+ GroupDefinition getById(int groupDefinitionId) throws GroupDefinitionNotFoundException;
+
+ /**
+ * Creates a new group definiton.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking create the group definition
+ * @param newGroupDefinition the object defining the group definition
+ * @return instance of <code>GroupDefinition</code>
+ * @throws GroupDefinitionAlreadyExistsException
+ * @throws GroupDefinitionCreateException
+ */
+ GroupDefinition createGroupDefinition(Subject subject, GroupDefinition newGroupDefinition)
+ throws GroupDefinitionAlreadyExistsException, GroupDefinitionCreateException;
+
+ /**
+ * Fetches the group definitions based on provided criteria.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to find the group definitions
+ * @param criteria the criteria
+ * @return instance of <code>GroupDefinition</code>
+ */
+ PageList<GroupDefinition> findGroupDefinitionsByCriteria(Subject subject, ResourceGroupDefinitionCriteria criteria);
+
+ /**
+ * Deletes the given group definition.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to remove the group definition
+ * @param groupDefinitionId the id of a group definition to be deleted
+ * @throws GroupDefinitionNotFoundException
+ * @throws GroupDefinitionDeleteException
+ */
+ void removeGroupDefinition(Subject subject, Integer groupDefinitionId) throws GroupDefinitionNotFoundException,
+ GroupDefinitionDeleteException;
+
+ /**
+ * Updates the given group definition.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to update the group definition
+ * @param updated the object defining the group definition to be changed (based on its id)
+ * @return the updated group definition
+ * @throws GroupDefinitionAlreadyExistsException
+ * @throws GroupDefinitionUpdateException
+ * @throws InvalidExpressionException
+ * @throws ResourceGroupUpdateException
+ */
+ GroupDefinition updateGroupDefinition(Subject subject, GroupDefinition updated)
+ throws GroupDefinitionAlreadyExistsException, GroupDefinitionUpdateException, InvalidExpressionException,
+ ResourceGroupUpdateException;
+
+ /**
+ * Explicitly recalculates the group membership, depending on the GroupDefinition's expression.
+ * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject the user who is asking to recalculate the group membership
+ * @param groupDefinitionId the id of a group definition to be recalculated
+ * @throws ResourceGroupDeleteException
+ * @throws GroupDefinitionDeleteException
+ * @throws GroupDefinitionNotFoundException
+ * @throws InvalidExpressionException
+ */
+ void calculateGroupMembership(Subject subject, int groupDefinitionId) throws ResourceGroupDeleteException,
+ GroupDefinitionDeleteException, GroupDefinitionNotFoundException, InvalidExpressionException;
+
+}
\ No newline at end of file
11 years, 3 months
[rhq] Branch 'release/jon3.1.x' - modules/enterprise
by Jay Shaughnessy
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java | 12 +++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
New commits:
commit d94eaa32b1d9adeddaa5e2687ae3834415c2a000
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jan 29 18:42:09 2013 -0500
Hopefully final tweeks to MergeInventoryReport
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index 9eef962..d68b051 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -849,7 +849,6 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
log.debug("getExistingResource processing for [" + resource + "]");
}
- // We perform this query a lot during a large inventory merge, so minimize overhead by using it directly
Resource existingResource = null;
if (resource.getId() != 0) {
@@ -857,7 +856,8 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
log.debug("Agent claims resource is already in inventory. Id=" + resource.getId());
}
- existingResource = entityManager.getReference(Resource.class, resource.getId());
+ // This maybe could be more efficient using a named query that pulls some lazy data, but this should be fine
+ existingResource = entityManager.find(Resource.class, resource.getId());
if (isDebugEnabled) {
if (null != existingResource) {
log.debug("Found resource already in inventory. Id=" + resource.getId());
@@ -879,9 +879,10 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
+ ", key=" + resource.getResourceKey());
}
- // (jshaughn) I'm not 100% sure I understand the need for this while loop, but I believe it has to
- // do with handling the case in which a resource type has moved (see f74b22044) and trying to
- // relocate the parent. Anyway, I'm not going to touch it even though it slows things down.
+ // (jshaughn) I'm not 100% sure but I believe this loop has to do with either or both of:
+ // - protecting against the agent merging a resource it thinks is new but actually exists
+ // - handling the case in which a resource type has moved (see f74b22044) and trying to relocate the parent.
+ // Anyway, I'm not going to touch it even though it slows things down.
ResourceType resourceType = resource.getResourceType();
Resource parent = resource;
@@ -904,6 +905,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
}
if (null == existingParent) {
+ // I think getReference may be slightly faster here but it's likely negligible
existingParent = entityManager.getReference(Resource.class, parentId);
if (null != existingParent) {
if (null != parentMap) {
11 years, 3 months