modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java | 20 +
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java | 72 ++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java | 43 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java | 8
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java | 60 ++-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/test/LargeGroupCriteriaTest.java | 166 ++++++++++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java | 144 ++++++--
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/util/SessionTestHelper.java | 7
11 files changed, 422 insertions(+), 106 deletions(-)
New commits:
commit eef406b0d827e8027a81f2ec20ad5e4eba5dfaca
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 30 14:05:49 2012 -0400
[BZ 815341] clear the entity manager in our tests
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java
index c084c27..089379e 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java
@@ -261,6 +261,7 @@ public abstract class LargeGroupTestBase extends AbstractEJB3Test {
System.out.println(" Done.");
em.flush();
+ em.clear();
return null;
}
});
commit 2567366ed179b4b896b1b501d8d0d50007000ba8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 27 16:44:35 2012 -0400
[BZ 815341] unit tests for unknown counts in group queries
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/test/LargeGroupCriteriaTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/test/LargeGroupCriteriaTest.java
new file mode 100644
index 0000000..cf39135
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/group/test/LargeGroupCriteriaTest.java
@@ -0,0 +1,166 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.resource.group.test;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
+import org.rhq.enterprise.server.test.LargeGroupTestBase;
+import org.rhq.enterprise.server.test.TestServerCommunicationsService;
+import org.rhq.enterprise.server.util.LookupUtil;
+import org.rhq.enterprise.server.util.SessionTestHelper;
+
+@Test
+public class LargeGroupCriteriaTest extends LargeGroupTestBase {
+
+ private ArrayList<LargeGroupEnvironment> env;
+
+ private class GroupAvailCounts {
+ public int up;
+ public int down;
+ public int unknown;
+ public int disabled;
+ public final int total;
+
+ GroupAvailCounts(int up, int down, int unknown, int disabled) {
+ this.up = up;
+ this.down = down;
+ this.unknown = unknown;
+ this.disabled = disabled;
+ this.total = up + down + unknown + disabled;
+ }
+ }
+
+ @Override
+ protected void setupMockAgentServices(TestServerCommunicationsService agentServiceContainer) {
+ }
+
+ /**
+ * Remove the group and all its members.
+ */
+ @AfterMethod(alwaysRun = true)
+ public void afterMethod() throws Exception {
+ if (env != null) {
+ Iterator<LargeGroupEnvironment> iter = env.iterator();
+ while (iter.hasNext()) {
+ LargeGroupEnvironment doomed = iter.next();
+ tearDownLargeGroupWithNormalUserRoleAccess(doomed, iter.hasNext());
+ SessionTestHelper.simulateLogout(doomed.normalSubject);
+ }
+ env = null;
+ }
+ }
+
+
+ public void testSmallGroups() throws Exception {
+ ArrayList<GroupAvailCounts> gacs = new ArrayList<LargeGroupCriteriaTest.GroupAvailCounts>();
+ gacs.add(new GroupAvailCounts(8, 4, 2, 1));
+ gacs.add(new GroupAvailCounts(2, 4, 6, 8));
+ testGroupQueries(gacs);
+ }
+
+ public void testLotsOfSmallGroups() throws Exception {
+ ArrayList<GroupAvailCounts> gacs = new ArrayList<LargeGroupCriteriaTest.GroupAvailCounts>();
+ for (int i = 0; i < 50; i++) {
+ gacs.add(new GroupAvailCounts(1, 1, 1, 1));
+ gacs.add(new GroupAvailCounts(2, 2, 2, 2));
+ }
+ testGroupQueries(gacs);
+ }
+
+ public void testLargeGroup() throws Exception {
+ ArrayList<GroupAvailCounts> gacs = new ArrayList<LargeGroupCriteriaTest.GroupAvailCounts>();
+ gacs.add(new GroupAvailCounts(500, 250, 150, 110)); // purposefully over 1,000
+ testGroupQueries(gacs);
+ }
+
+ public void testLotsOfLargeGroups() throws Exception {
+ ArrayList<GroupAvailCounts> gacs = new ArrayList<LargeGroupCriteriaTest.GroupAvailCounts>();
+ for (int i = 0; i < 5; i++) {
+ gacs.add(new GroupAvailCounts(10, 10, 10, 10));
+ gacs.add(new GroupAvailCounts(20, 20, 20, 20));
+ }
+ testGroupQueries(gacs);
+ }
+
+ private void testGroupQueries(ArrayList<GroupAvailCounts> groupAvailCounts) throws Exception {
+ ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
+
+ env = new ArrayList<LargeGroupEnvironment>(groupAvailCounts.size());
+
+ LargeGroupEnvironment lgeWithTypes = null;
+ for (GroupAvailCounts gac : groupAvailCounts) {
+ env.add(createLargeGroupWithNormalUserRoleAccess(lgeWithTypes, gac.total, gac.down, gac.unknown,
+ gac.disabled, Permission.CONFIGURE_READ));
+ lgeWithTypes = env.get(0);
+ }
+
+ ResourceGroupCriteria criteria;
+ PageList<ResourceGroupComposite> pageList;
+ ResourceGroupComposite groupComp;
+ long start;
+
+ // test findResourceGroupCompositesByCriteria
+ for (int i = 0; i < groupAvailCounts.size(); i++) {
+ LargeGroupEnvironment lge = env.get(i);
+ GroupAvailCounts gac = groupAvailCounts.get(i);
+
+ SessionTestHelper.simulateLogin(lge.normalSubject);
+ criteria = new ResourceGroupCriteria();
+ start = System.currentTimeMillis();
+ pageList = groupManager.findResourceGroupCompositesByCriteria(lge.normalSubject, criteria);
+ System.out.println("findResourceGroupCompositesByCriteria #" + i + "==>" + (System.currentTimeMillis() - start) + "ms");
+ assert pageList.size() == 1 : "the query should only have selected the one group for our user";
+ groupComp = pageList.get(0);
+ System.out.println("-->" + groupComp);
+ assert groupComp.getExplicitCount() == gac.total;
+ assert groupComp.getExplicitCount() == groupComp.getImplicitCount(); // we aren't testing recursive groups
+ assert groupComp.getExplicitUp() == gac.up;
+ assert groupComp.getExplicitDown() == gac.down;
+ assert groupComp.getExplicitUnknown() == gac.unknown;
+ assert groupComp.getExplicitDisabled() == gac.disabled;
+ }
+
+ // test getResourceGroupComposite
+ for (int i = 0; i < groupAvailCounts.size(); i++) {
+ LargeGroupEnvironment lge = env.get(i);
+ GroupAvailCounts gac = groupAvailCounts.get(i);
+
+ SessionTestHelper.simulateLogin(lge.normalSubject);
+ start = System.currentTimeMillis();
+ groupComp = groupManager.getResourceGroupComposite(lge.normalSubject, lge.compatibleGroup.getId());
+ System.out.println("getResourceGroupComposite #" + i + "==>" + (System.currentTimeMillis() - start) + "ms");
+ System.out.println("-->" + groupComp);
+ assert groupComp.getExplicitCount() == gac.total;
+ assert groupComp.getExplicitCount() == groupComp.getImplicitCount(); // we aren't testing recursive groups
+ assert groupComp.getExplicitUp() == gac.up;
+ assert groupComp.getExplicitDown() == gac.down;
+ assert groupComp.getExplicitUnknown() == gac.unknown;
+ assert groupComp.getExplicitDisabled() == gac.disabled;
+ }
+ }
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java
index 27a08b2..c084c27 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/LargeGroupTestBase.java
@@ -40,6 +40,7 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.configuration.group.GroupPluginConfigurationUpdate;
import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
+import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
@@ -81,6 +82,22 @@ public abstract class LargeGroupTestBase extends AbstractEJB3Test {
public Subject normalSubject; // user with a role that has access to the group
public Role normalRole; // role with permissions on the group
public Subject unauthzSubject; // a subject with no authorization to do anything
+
+ public LargeGroupEnvironment() {
+ }
+
+ /**
+ * Stores references to the existing lge's resource types' metadata but nothing else.
+ * @param lge the object whose platformType and serverType are stored in the new lge object
+ */
+ public LargeGroupEnvironment(LargeGroupEnvironment lge) {
+ if (lge != null) {
+ this.platformType = lge.platformType;
+ this.serverType = lge.serverType;
+ this.serverPluginConfiguration = lge.serverPluginConfiguration;
+ this.serverResourceConfiguration = lge.serverResourceConfiguration;
+ }
+ }
}
/**
@@ -124,10 +141,30 @@ public abstract class LargeGroupTestBase extends AbstractEJB3Test {
*/
protected LargeGroupEnvironment createLargeGroupWithNormalUserRoleAccess(final int groupSize,
final Permission... permissions) {
+ return createLargeGroupWithNormalUserRoleAccess(null, groupSize, 0, 0, 0, permissions);
+ }
+
+ /**
+ * Creates a compatible group of the given size. This also creates a normal user and a role
+ * and makes sure that user can access the group that was created. The role will be assigned the
+ * given permissions and that role be placed on the new group and the new user.
+ *
+ * If lge is not null, that means we already have resource types created. We'll reuse those types.
+ *
+ * @param largeGroupEnv an already-created large group environment object (may be null)
+ * @param groupSize the number of members to create and put into the compatible group that is created.
+ * @param down number of resources that are to be set as DOWN
+ * @param unknown number of resources whose availability status is to be marked as UNKNOWN
+ * @param disabled number of resources that are to be set as DISABLED
+ * @param permissions permissions to grant the new user via the new role.
+ * @return information about the entities that were created
+ */
+ protected LargeGroupEnvironment createLargeGroupWithNormalUserRoleAccess(LargeGroupEnvironment largeGroupEnv,
+ final int groupSize, final int down, final int unknown, final int disabled, final Permission... permissions) {
System.out.println("=====Creating a group with [" + groupSize + "] members");
- final LargeGroupEnvironment lge = new LargeGroupEnvironment();
+ final LargeGroupEnvironment lge = new LargeGroupEnvironment(largeGroupEnv);
JPAUtils.executeInTransaction(new TransactionCallbackWithContext<Object>() {
public Object execute(TransactionManager tm, EntityManager em) throws Exception {
// create the agent where all resources will be housed
@@ -135,28 +172,36 @@ public abstract class LargeGroupTestBase extends AbstractEJB3Test {
// create the platform resource type and server resource type
// the server type will have both a plugin configuration definition and resource config def
- lge.platformType = new ResourceType("LargeGroupTestPlatformType", "testPlugin",
- ResourceCategory.PLATFORM, null);
- em.persist(lge.platformType);
+ if (lge.platformType == null) {
+ lge.platformType = new ResourceType("LargeGroupTestPlatformType", "testPlugin",
+ ResourceCategory.PLATFORM, null);
+ em.persist(lge.platformType);
+ } else {
+ lge.platformType = em.find(ResourceType.class, lge.platformType.getId());
+ }
- lge.serverType = new ResourceType("LargeGroupTestServerType", "testPlugin", ResourceCategory.SERVER,
- lge.platformType);
- lge.serverPluginConfiguration = new ConfigurationDefinition("LargeGroupTestPCDef", "pc desc");
- lge.serverPluginConfiguration.put(new PropertyDefinitionSimple(PC_PROP1_NAME, "pc prop1desc", false,
- PropertySimpleType.STRING));
- lge.serverPluginConfiguration.put(new PropertyDefinitionSimple(PC_PROP2_NAME, "pc prop2desc", false,
- PropertySimpleType.STRING));
- lge.serverType.setPluginConfigurationDefinition(lge.serverPluginConfiguration);
-
- lge.serverResourceConfiguration = new ConfigurationDefinition("LargeGroupTestRCDef", "rc desc");
- lge.serverResourceConfiguration.put(new PropertyDefinitionSimple(RC_PROP1_NAME, "rc prop1desc", false,
- PropertySimpleType.STRING));
- lge.serverResourceConfiguration.put(new PropertyDefinitionSimple(RC_PROP2_NAME, "rc prop2desc", false,
- PropertySimpleType.STRING));
- lge.serverType.setResourceConfigurationDefinition(lge.serverResourceConfiguration);
-
- em.persist(lge.serverType);
- em.flush();
+ if (lge.serverType == null) {
+ lge.serverType = new ResourceType("LargeGroupTestServerType", "testPlugin",
+ ResourceCategory.SERVER, lge.platformType);
+ lge.serverPluginConfiguration = new ConfigurationDefinition("LargeGroupTestPCDef", "pc desc");
+ lge.serverPluginConfiguration.put(new PropertyDefinitionSimple(PC_PROP1_NAME, "pc prop1desc",
+ false, PropertySimpleType.STRING));
+ lge.serverPluginConfiguration.put(new PropertyDefinitionSimple(PC_PROP2_NAME, "pc prop2desc",
+ false, PropertySimpleType.STRING));
+ lge.serverType.setPluginConfigurationDefinition(lge.serverPluginConfiguration);
+
+ lge.serverResourceConfiguration = new ConfigurationDefinition("LargeGroupTestRCDef", "rc desc");
+ lge.serverResourceConfiguration.put(new PropertyDefinitionSimple(RC_PROP1_NAME, "rc prop1desc",
+ false, PropertySimpleType.STRING));
+ lge.serverResourceConfiguration.put(new PropertyDefinitionSimple(RC_PROP2_NAME, "rc prop2desc",
+ false, PropertySimpleType.STRING));
+ lge.serverType.setResourceConfigurationDefinition(lge.serverResourceConfiguration);
+
+ em.persist(lge.serverType);
+ em.flush();
+ } else {
+ lge.serverType = em.find(ResourceType.class, lge.serverType.getId());
+ }
// create our platform - all of our server resources will have this as their parent
lge.platformResource = SessionTestHelper.createNewResource(em, "LargeGroupTestPlatform",
@@ -164,7 +209,7 @@ public abstract class LargeGroupTestBase extends AbstractEJB3Test {
lge.platformResource.setAgent(lge.agent);
// create our subject and role
- lge.normalSubject = new Subject("LargeGroupTestSubject", true, false);
+ lge.normalSubject = new Subject("LargeGroupTestSubject" + System.currentTimeMillis(), true, false);
lge.normalRole = SessionTestHelper.createNewRoleForSubject(em, lge.normalSubject, "LargeGroupTestRole",
permissions);
@@ -176,10 +221,27 @@ public abstract class LargeGroupTestBase extends AbstractEJB3Test {
"LargeGroupTestCompatGroup", lge.serverType);
// create our many server resources
+ int downCount = down;
+ int unknownCount = unknown;
+ int disabledCount = disabled;
System.out.print("=====> Creating member Resources (this might take some time)...");
for (int i = 1; i <= groupSize; i++) {
+ AvailabilityType avail;
+ if (downCount > 0) {
+ avail = AvailabilityType.DOWN;
+ downCount--;
+ } else if (unknownCount > 0) {
+ avail = AvailabilityType.UNKNOWN;
+ unknownCount--;
+ } else if (disabledCount > 0) {
+ avail = AvailabilityType.DISABLED;
+ disabledCount--;
+ } else {
+ avail = AvailabilityType.UP;
+ }
+
Resource res = SessionTestHelper.createNewResourceForGroup(em, lge.compatibleGroup,
- "LargeGroupTestServer", lge.serverType, (i % 100) == 0);
+ "LargeGroupTestServer", lge.serverType, avail, (i % 100) == 0);
res.setAgent(lge.agent);
lge.platformResource.addChildResource(res);
@@ -209,14 +271,20 @@ public abstract class LargeGroupTestBase extends AbstractEJB3Test {
return lge;
}
+ protected void tearDownLargeGroupWithNormalUserRoleAccess(final LargeGroupEnvironment lge) throws Exception {
+ tearDownLargeGroupWithNormalUserRoleAccess(lge, false);
+ }
+
/**
* Purges all the entities that were created by the
* {@link #createLargeGroupWithNormalUserRoleAccess(int, org.rhq.core.domain.authz.Permission...)} method.
* This includes the user, role, agent and all resources, along with the group itself.
*
* @param lge contains information that was created which needs to be deleted
+ * @param keepTypes if true, do not delete the resource types
*/
- protected void tearDownLargeGroupWithNormalUserRoleAccess(final LargeGroupEnvironment lge) throws Exception {
+ protected void tearDownLargeGroupWithNormalUserRoleAccess(final LargeGroupEnvironment lge, boolean keepTypes)
+ throws Exception {
System.out.println("=====Cleaning up test data from " + this.getClass().getSimpleName());
// purge the group itself
@@ -252,17 +320,20 @@ public abstract class LargeGroupTestBase extends AbstractEJB3Test {
}
});
- // purge the resource types
- JPAUtils.executeInTransaction(new TransactionCallbackWithContext<Object>() {
- public Object execute(TransactionManager tm, EntityManager em) throws Exception {
- ResourceType pType = em
- .getReference(ResourceType.class, lge.platformResource.getResourceType().getId());
- ResourceType sType = em.getReference(ResourceType.class, lge.compatibleGroup.getResourceType().getId());
- em.remove(sType);
- em.remove(pType);
- return null;
- }
- });
+ if (!keepTypes) {
+ // purge the resource types
+ JPAUtils.executeInTransaction(new TransactionCallbackWithContext<Object>() {
+ public Object execute(TransactionManager tm, EntityManager em) throws Exception {
+ ResourceType pType = em.getReference(ResourceType.class, lge.platformResource.getResourceType()
+ .getId());
+ ResourceType sType = em.getReference(ResourceType.class, lge.compatibleGroup.getResourceType()
+ .getId());
+ em.remove(sType);
+ em.remove(pType);
+ return null;
+ }
+ });
+ }
System.out.println("=====Cleaned up test data from " + this.getClass().getSimpleName());
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/util/SessionTestHelper.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/util/SessionTestHelper.java
index 6791285..7b3c55d 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/util/SessionTestHelper.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/util/SessionTestHelper.java
@@ -198,6 +198,11 @@ public class SessionTestHelper {
public static Resource createNewResourceForGroup(EntityManager em, ResourceGroup group, String resourceName,
ResourceType type, boolean doFlush) {
+ return createNewResourceForGroup(em, group, resourceName, type, AvailabilityType.UP, doFlush);
+ }
+
+ public static Resource createNewResourceForGroup(EntityManager em, ResourceGroup group, String resourceName,
+ ResourceType type, AvailabilityType avail, boolean doFlush) {
if (type == null) {
type = createNewResourceType(em);
@@ -207,7 +212,7 @@ public class SessionTestHelper {
Resource resource = new Resource(resourceName, resourceName, type);
resource.setUuid("" + new Random().nextInt());
resource.setInventoryStatus(InventoryStatus.COMMITTED);
- resource.setCurrentAvailability(new ResourceAvailability(resource, AvailabilityType.UP));
+ resource.setCurrentAvailability(new ResourceAvailability(resource, avail));
group.addExplicitResource(resource);
resource.getExplicitGroups().add(group);
commit 0c1f0a03e4709b89890bedd85b75af9a13dd9142
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 27 16:44:15 2012 -0400
[BZ 815341] get unknown count from group queries
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
index 04aa4ef..2a5c479 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
@@ -257,6 +257,16 @@ public class ResourceGroup extends Group {
+ " AND eresAvail.availability_type = 0 "
+ " ) as explicitDown, "
+ "" //
+ + " ( SELECT COUNT(eresAvail.ID) " // UNKNOWN explicit members
+ + " FROM rhq_resource_avail eresAvail "
+ + " INNER JOIN rhq_resource eres "
+ + " ON eresAvail.resource_id = eres.id "
+ + " INNER JOIN rhq_resource_group_res_exp_map expMap "
+ + " ON eres.id = expMap.resource_id "
+ + " WHERE expMap.resource_group_id = rg.id "
+ + " AND eresAvail.availability_type = 2 "
+ + " ) as explicitUnknown, "
+ + "" //
+ " ( SELECT COUNT(eresAvail.ID) " // DISABLED explicit members
+ " FROM rhq_resource_avail eresAvail "
+ " INNER JOIN rhq_resource eres "
@@ -286,6 +296,16 @@ public class ResourceGroup extends Group {
+ " AND iresAvail.availability_type = 0 "
+ " ) as implicitDown, "
+ "" //
+ + " ( SELECT COUNT(iresAvail.ID) " // UNKNOWN implicit members
+ + " FROM rhq_resource_avail iresAvail "
+ + " INNER JOIN rhq_resource ires "
+ + " ON iresAvail.resource_id = ires.id "
+ + " INNER JOIN rhq_resource_group_res_imp_map impMap "
+ + " ON ires.id = impMap.resource_id "
+ + " WHERE impMap.resource_group_id = rg.id "
+ + " AND iresAvail.availability_type = 2 "
+ + " ) as implicitUnknown, "
+ + "" //
+ " ( SELECT COUNT(iresAvail.ID) " // DISABLED implicit members
+ " FROM rhq_resource_avail iresAvail "
+ " INNER JOIN rhq_resource ires "
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
index 85a3fab..66fc42a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
@@ -50,9 +50,11 @@ public class ResourceGroupComposite implements Serializable {
private GroupCategory category;
private long implicitCount;
private long implicitDown;
+ private long implicitUnknown;
private long implicitDisabled;
private long explicitCount;
private long explicitDown;
+ private long explicitUnknown;
private long explicitDisabled;
private ResourceFacets resourceFacets;
@@ -65,44 +67,52 @@ public class ResourceGroupComposite implements Serializable {
}
// Constructor used in Hibernate Query, see ResourceGroupManagerBean
- public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitDisabled, Long implicitCount,
- Long implicitDown, Long implicitDisabled, ResourceGroup resourceGroup) {
+ public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitUnknown, Long explicitDisabled,
+ Long implicitCount, Long implicitDown, Long implicitUnknown, Long implicitDisabled, ResourceGroup resourceGroup) {
- this(explicitCount, explicitDown, explicitDisabled, implicitCount, implicitDown, implicitDisabled,
+ this(explicitCount, explicitDown, explicitUnknown, explicitDisabled, implicitCount, implicitDown,
+ implicitUnknown, implicitDisabled,
resourceGroup, null, new ResourcePermission());
}
// Constructor used in Hibernate Query, see ResourceGroupManagerBean
- public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitDisabled, Long implicitCount,
- Long implicitDown, Long implicitDisabled, ResourceGroup resourceGroup, Number measure, Number inventory,
+ public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitUnknown, Long explicitDisabled,
+ Long implicitCount, Long implicitDown, Long implicitUnknown, Long implicitDisabled,
+ ResourceGroup resourceGroup, Number measure, Number inventory,
Number control, Number alert, Number event, Number configureRead, Number configureWrite, Number content,
Number createChildResources, Number deleteResources, Number drift) {
- this(explicitCount, explicitDown, explicitDisabled, implicitCount, implicitDown, implicitDisabled,
+ this(explicitCount, explicitDown, explicitUnknown, explicitDisabled, implicitCount, implicitDown,
+ implicitUnknown, implicitDisabled,
resourceGroup, null, new ResourcePermission(measure.intValue() > 0, inventory.intValue() > 0,
control.intValue() > 0, alert.intValue() > 0, event.intValue() > 0, configureRead.intValue() > 0,
configureWrite.intValue() > 0, content.intValue() > 0, createChildResources.intValue() > 0,
deleteResources.intValue() > 0, drift.intValue() > 0));
}
- public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitDisabled, Long implicitCount,
- Long implicitDown, Long implicitDisabled, ResourceGroup resourceGroup, ResourceFacets facets) {
+ public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitUnknown, Long explicitDisabled,
+ Long implicitCount, Long implicitDown, Long implicitUnknown, Long implicitDisabled,
+ ResourceGroup resourceGroup, ResourceFacets facets) {
- this(explicitCount, explicitDown, explicitDisabled, implicitCount, implicitDown, implicitDisabled,
+ this(explicitCount, explicitDown, explicitUnknown, explicitDisabled, implicitCount, implicitDown,
+ implicitUnknown, implicitDisabled,
resourceGroup, facets, new ResourcePermission());
}
// Private constructor that all public constructors delegate to
- public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitDisabled, Long implicitCount,
- Long implicitDown, Long implicitDisabled, ResourceGroup resourceGroup, ResourceFacets facets,
+ public ResourceGroupComposite(Long explicitCount, Long explicitDown, Long explicitUnknown, Long explicitDisabled,
+ Long implicitCount, Long implicitDown, Long implicitUnknown, Long implicitDisabled,
+ ResourceGroup resourceGroup, ResourceFacets facets,
ResourcePermission permissions) {
this.implicitCount = implicitCount;
this.implicitDown = implicitDown;
+ this.implicitUnknown = implicitUnknown;
this.implicitDisabled = implicitDisabled;
this.explicitCount = explicitCount;
this.explicitDown = explicitDown;
+ this.explicitUnknown = explicitUnknown;
this.explicitDisabled = explicitDisabled;
this.resourceGroup = resourceGroup;
@@ -128,12 +138,16 @@ public class ResourceGroupComposite implements Serializable {
return implicitDown;
}
+ public long getImplicitUnknown() {
+ return implicitUnknown;
+ }
+
public long getImplicitDisabled() {
return implicitDisabled;
}
- public long getImplicitUpAndUnknown() {
- return implicitCount - implicitDown - implicitDisabled;
+ public long getImplicitUp() {
+ return implicitCount - implicitDown - implicitDisabled - implicitUnknown;
}
public long getExplicitCount() {
@@ -144,12 +158,16 @@ public class ResourceGroupComposite implements Serializable {
return explicitDown;
}
+ public long getExplicitUnknown() {
+ return explicitUnknown;
+ }
+
public long getExplicitDisabled() {
return explicitDisabled;
}
- public long getExplicitUpAndUnknown() {
- return explicitCount - explicitDown - explicitDisabled;
+ public long getExplicitUp() {
+ return explicitCount - explicitDown - explicitDisabled - explicitUnknown;
}
public ResourceGroup getResourceGroup() {
@@ -165,9 +183,9 @@ public class ResourceGroupComposite implements Serializable {
* <pre>
* empty group = EMPTY
* allDown = DOWN
- * someDown = WARN
+ * someDown/someUnknown = WARN
* someDisabled = DISABLED
- * otherwise = UP (all members UP or UNKNOWN)
+ * otherwise = UP (all members UP)
* </pre>
*
* @return the group availability type, null for an empty group
@@ -181,9 +199,9 @@ public class ResourceGroupComposite implements Serializable {
* <pre>
* empty group = EMPTY
* allDown = DOWN
- * someDown = WARN
+ * someDown/someUnknown = WARN
* someDisabled = DISABLED
- * otherwise = UP (all members UP or UNKNOWN)
+ * otherwise = UP (all members UP)
* </pre>
*
* @return the group availability type, null for an empty group
@@ -196,6 +214,7 @@ public class ResourceGroupComposite implements Serializable {
long count = isExplicit ? explicitCount : implicitCount;
long down = isExplicit ? explicitDown : implicitDown;
long disabled = isExplicit ? explicitDisabled : implicitDisabled;
+ long unknown = isExplicit ? explicitUnknown : implicitUnknown;
if (0 == count) {
return GroupAvailabilityType.EMPTY;
@@ -205,7 +224,7 @@ public class ResourceGroupComposite implements Serializable {
return GroupAvailabilityType.DOWN;
}
- if (down > 0) {
+ if (down > 0 || unknown > 0) {
return GroupAvailabilityType.WARN;
}
@@ -252,13 +271,15 @@ public class ResourceGroupComposite implements Serializable {
// remove once the old UI is killed, for now this is still needed
@Deprecated
public String getExplicitFormatted() {
- return getAlignedAvailabilityResults(getExplicitUpAndUnknown() + getExplicitDisabled(), getExplicitDown());
+ return getAlignedAvailabilityResults(getExplicitUp() + getExplicitUnknown() + getExplicitDisabled(),
+ getExplicitDown());
}
// remove once the old UI is killed, for now this is still needed
@Deprecated
public String getImplicitFormatted() {
- return getAlignedAvailabilityResults(getImplicitUpAndUnknown() + getImplicitDisabled(), getImplicitDown());
+ return getAlignedAvailabilityResults(getImplicitUp() + getImplicitUnknown() + getImplicitDisabled(),
+ getImplicitDown());
}
// remove once the old UI is killed, for now this is still needed
@@ -317,9 +338,10 @@ public class ResourceGroupComposite implements Serializable {
public String toString() {
return "ResourceGroupComposite[name="
+ this.resourceGroup.getName() //
- + ", implicit[count/down/disabled=," + this.implicitCount + "/" + this.implicitDown + "/"
- + this.implicitDisabled + "]" + ", explicit[count/down/disabled=," + this.explicitCount + "/"
- + this.explicitDown + "/" + this.explicitDisabled + "]" + ", facets="
+ + ", implicit[count/down/disabled/unknown=," + this.implicitCount + "/" + this.implicitDown + "/"
+ + this.implicitDisabled + "/" + this.implicitUnknown + "]" + ", explicit[count/down/disabled/unknown=,"
+ + this.explicitCount + "/" + this.explicitDown + "/" + this.explicitDisabled + "/" + this.explicitUnknown
+ + "]" + ", facets="
+ ((this.resourceFacets == null) ? "none" : this.resourceFacets.getFacets()) + "]";
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
index 19832a5..d3f49a3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupConfigurationUpdatesPortlet.java
@@ -325,7 +325,8 @@ public class GroupConfigurationUpdatesPortlet extends LocatableVLayout implement
ResourceGroup emptyGroup = new ResourceGroup("");
emptyGroup.setId(-1);
Long zero = new Long(0);
- groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, zero, zero, emptyGroup);
+ groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, zero, zero, zero, zero,
+ emptyGroup);
groupHistoryTable = new GroupConfigurationHistoryCriteriaTable(extendLocatorId("Table"),
groupComposite);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index 8288dc4..edcc72e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -177,7 +177,8 @@ public class GroupOperationsPortlet extends LocatableVLayout implements CustomSe
ResourceGroup emptyGroup = new ResourceGroup("");
emptyGroup.setId(-1);
Long zero = new Long(0);
- groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, zero, zero, emptyGroup);
+ groupComposite = new ResourceGroupComposite(zero, zero, zero, zero, zero, zero, zero, zero,
+ emptyGroup);
groupOperations = new GroupOperationsCriteriaHistoryListView(locatorId,
new GroupOperationsCriteriaDataSource(portletConfig), null, criteria, groupComposite);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
index d334cd7..2abefa1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupCompositeDataSource.java
@@ -165,13 +165,15 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
Long explicitCount = Long.valueOf(from.getAttribute("explicitCount"));
Long explicitDown = Long.valueOf(from.getAttribute("explicitDown"));
+ Long explicitUnknown = Long.valueOf(from.getAttribute("explicitUnknown"));
Long explicitDisabled = Long.valueOf(from.getAttribute("explicitDisabled"));
Long implicitCount = Long.valueOf(from.getAttribute("implicitCount"));
Long implicitDown = Long.valueOf(from.getAttribute("implicitDown"));
+ Long implicitUnknown = Long.valueOf(from.getAttribute("implicitUnknown"));
Long implicitDisabled = Long.valueOf(from.getAttribute("implicitDisabled"));
- ResourceGroupComposite composite = new ResourceGroupComposite(explicitCount, explicitDown, explicitDisabled,
- implicitCount, implicitDown, implicitDisabled, rg);
+ ResourceGroupComposite composite = new ResourceGroupComposite(explicitCount, explicitDown, explicitUnknown,
+ explicitDisabled, implicitCount, implicitDown, implicitUnknown, implicitDisabled, rg);
return composite;
}
@@ -205,19 +207,19 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
}
private String getExplicitFormatted(ResourceGroupComposite from) {
- return getAlignedAvailabilityResults(from.getExplicitCount(), from.getExplicitUpAndUnknown(),
- from.getExplicitDown(), from.getExplicitDisabled());
+ return getAlignedAvailabilityResults(from.getExplicitCount(), from.getExplicitUp(), from.getExplicitDown(),
+ from.getExplicitUnknown(), from.getExplicitDisabled());
}
private String getImplicitFormatted(ResourceGroupComposite from) {
- return getAlignedAvailabilityResults(from.getImplicitCount(), from.getImplicitUpAndUnknown(),
- from.getImplicitDown(), from.getImplicitDisabled());
+ return getAlignedAvailabilityResults(from.getImplicitCount(), from.getImplicitUp(), from.getImplicitDown(),
+ from.getImplicitUnknown(), from.getImplicitDisabled());
}
- private String getAlignedAvailabilityResults(long total, long up, long down, long disabled) {
+ private String getAlignedAvailabilityResults(long total, long up, long down, long unknown, long disabled) {
StringBuilder results = new StringBuilder();
- results.append("<table width=\"180px\"><tr>");
+ results.append("<table><tr>");
if (0 == total) {
results.append(getColumn(false,
"<img src=\"" + ImageManager.getFullImagePath(ImageManager.getAvailabilityIcon(null)) + "\" /> 0"));
@@ -228,28 +230,39 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
if (up > 0) {
String imagePath = ImageManager.getFullImagePath(ImageManager
.getAvailabilityIconFromAvailType(AvailabilityType.UP));
- results.append(getColumn(false, " <img src=\"" + imagePath + "\" />", up));
+ results.append(getColumn(false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />", up));
} else {
results.append(getColumn(false,
- " <img src=\"/images/blank.png\" width=\"16px\" height=\"16px\" />"));
+ " <img src=\"/images/blank.png\" width=\"12px\" height=\"12px\" />"));
}
if (down > 0) {
String imagePath = ImageManager.getFullImagePath(ImageManager
.getAvailabilityIconFromAvailType(AvailabilityType.DOWN));
- results.append(getColumn(false, " <img src=\"" + imagePath + "\" />", down));
+ results.append(getColumn(false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />", down));
} else {
results.append(getColumn(false,
- " <img src=\"/images/blank.png\" width=\"16px\" height=\"16px\" />"));
+ " <img src=\"/images/blank.png\" width=\"12px\" height=\"12px\" />"));
}
if (disabled > 0) {
String imagePath = ImageManager.getFullImagePath(ImageManager
.getAvailabilityIconFromAvailType(AvailabilityType.DISABLED));
- results.append(getColumn(false, " <img src=\"" + imagePath + "\" />", disabled));
+ results.append(getColumn(false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />",
+ disabled));
} else {
results.append(getColumn(false,
- " <img src=\"/images/blank.png\" width=\"16px\" height=\"16px\" />"));
+ " <img src=\"/images/blank.png\" width=\"12px\" height=\"12px\" />"));
+ }
+
+ if (unknown > 0) {
+ String imagePath = ImageManager.getFullImagePath(ImageManager
+ .getAvailabilityIconFromAvailType(AvailabilityType.UNKNOWN));
+ results.append(getColumn(false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />",
+ unknown));
+ } else {
+ results.append(getColumn(false,
+ " <img src=\"/images/blank.png\" width=\"1px\" height=\"1px\" />"));
}
}
results.append("</tr></table>");
@@ -261,7 +274,7 @@ public class ResourceGroupCompositeDataSource extends RPCDataSource<ResourceGrou
if (isSpacerColumn) {
results.append("<td nowrap=\"nowrap\" style=\"white-space:nowrap;\" width=\"10px\" align=\"left\" >");
} else {
- results.append("<td nowrap=\"nowrap\" style=\"white-space:nowrap;\" width=\"55px\" align=\"left\" >");
+ results.append("<td nowrap=\"nowrap\" style=\"white-space:nowrap;\" width=\"45px\" align=\"left\" >");
}
if (data == null) {
results.append(" ");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
index 6b1a9a9..2947bce 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/ResourceGroupListView.java
@@ -164,18 +164,18 @@ public class ResourceGroupListView extends Table<ResourceGroupCompositeDataSourc
pluginNameField.setWidth("8%");
ListGridField availabilityChildrenField = new ListGridField(AVAIL_CHILDREN.propertyName(),
- AVAIL_CHILDREN.title(), 170); // 170 due to the html in ResourceGroupCompositeDataSource.getAlignedAvailabilityResults
+ AVAIL_CHILDREN.title(), 185); // 185 due to the html in ResourceGroupCompositeDataSource.getAlignedAvailabilityResults
availabilityChildrenField.setCanSortClientOnly(true);
availabilityChildrenField.setCanGroupBy(false);
availabilityChildrenField.setWrap(false);
- availabilityChildrenField.setAlign(Alignment.CENTER);
+ availabilityChildrenField.setAlign(Alignment.LEFT);
ListGridField availabilityDescendantsField = new ListGridField(AVAIL_DESCENDANTS.propertyName(),
- AVAIL_DESCENDANTS.title(), 170); // 110 due to the html in ResourceGroupCompositeDataSource.getAlignedAvailabilityResults
+ AVAIL_DESCENDANTS.title(), 185); // 185 due to the html in ResourceGroupCompositeDataSource.getAlignedAvailabilityResults
availabilityDescendantsField.setCanSortClientOnly(true);
availabilityDescendantsField.setCanGroupBy(false);
availabilityDescendantsField.setWrap(false);
- availabilityDescendantsField.setAlign(Alignment.CENTER);
+ availabilityDescendantsField.setAlign(Alignment.LEFT);
setListGridFields(idField, categoryField, nameField, descriptionField, typeNameField, pluginNameField,
availabilityChildrenField, availabilityDescendantsField);
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java
index 9ad5969..2352b29 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/ResourceGroupUIBean.java
@@ -67,7 +67,7 @@ public class ResourceGroupUIBean {
public ResourceGroupUIBean(ResourceGroupComposite resourceGroupComposite, Subject subject) {
this.resourceGroup = resourceGroupComposite.getResourceGroup();
- this.upCount = resourceGroupComposite.getExplicitUpAndUnknown();
+ this.upCount = resourceGroupComposite.getExplicitUp() + resourceGroupComposite.getExplicitUnknown();
this.downCount = resourceGroupComposite.getExplicitDown();
this.count = upCount + downCount;
this.availability = resourceGroupComposite.getExplicitAvail();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
index 92d4723..b386bcd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
@@ -1191,13 +1191,15 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
while (rs.next()) {
long explicitCount = rs.getLong(1);
long explicitDown = rs.getLong(2);
- long explicitDisabled = rs.getLong(3);
- long implicitCount = rs.getLong(4);
- long implicitDown = rs.getLong(5);
- long implicitDisabled = rs.getLong(6);
- int groupKey = rs.getInt(5);
- Object[] next = new Object[] { explicitCount, explicitDown, explicitDisabled, implicitCount,
- implicitDown, implicitDisabled, groupKey };
+ long explicitUnknown = rs.getLong(3);
+ long explicitDisabled = rs.getLong(4);
+ long implicitCount = rs.getLong(5);
+ long implicitDown = rs.getLong(6);
+ long implicitUnknown = rs.getLong(7);
+ long implicitDisabled = rs.getLong(8);
+ int groupKey = rs.getInt(9);
+ Object[] next = new Object[] { explicitCount, explicitDown, explicitUnknown, explicitDisabled,
+ implicitCount, implicitDown, implicitUnknown, implicitDisabled, groupKey };
rawResults.add(next);
}
} finally {
@@ -1239,10 +1241,12 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
for (Object[] row : rawResults) {
long explicitCount = (Long) row[0];
long explicitDown = (Long) row[1];
- long explicitDisabled = (Long) row[2];
- long implicitCount = (Long) row[3];
- long implicitDown = (Long) row[4];
- long implicitDisabled = (Long) row[5];
+ long explicitUnknown = (Long) row[2];
+ long explicitDisabled = (Long) row[3];
+ long implicitCount = (Long) row[4];
+ long implicitDown = (Long) row[5];
+ long implicitUnknown = (Long) row[6];
+ long implicitDisabled = (Long) row[7];
ResourceGroup group = groupMap.get(groupIds.get(i++));
ResourceType type = group.getResourceType();
ResourceFacets facets;
@@ -1253,8 +1257,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
// compatible group
facets = resourceTypeManager.getResourceFacets(type.getId());
}
- ResourceGroupComposite composite = new ResourceGroupComposite(explicitCount, explicitDown,
- explicitDisabled, implicitCount, implicitDown, implicitDisabled, group, facets);
+ ResourceGroupComposite composite = new ResourceGroupComposite(explicitCount, explicitDown, explicitUnknown,
+ explicitDisabled, implicitCount, implicitDown, implicitUnknown, implicitDisabled, group, facets);
Set<Permission> perms = authorizationManager.getImplicitGroupPermissions(subject, group.getId());
composite.setResourcePermission(new ResourcePermission(perms));
results.add(composite);
@@ -1403,6 +1407,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
+ " (SELECT count(er) " // DOWN explicit
+ " FROM ResourceGroup g JOIN g.explicitResources er where g.id = :groupId"
+ " AND er.currentAvailability.availabilityType = 0 ),\n"
+ + " (SELECT count(er) " // UNKNOWN explicit
+ + " FROM ResourceGroup g JOIN g.explicitResources er where g.id = :groupId"
+ + " AND er.currentAvailability.availabilityType = 2 ),\n"
+ " (SELECT count(er) " // DISABLED explicit
+ " FROM ResourceGroup g JOIN g.explicitResources er where g.id = :groupId"
+ " AND er.currentAvailability.availabilityType = 3 ),\n"
@@ -1411,6 +1418,9 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
+ " (SELECT count(ir) " // DOWN implicit
+ " FROM ResourceGroup g JOIN g.implicitResources ir where g.id = :groupId"
+ " AND ir.currentAvailability.availabilityType = 0 ),\n"
+ + " (SELECT count(ir) " // UNKNOWN implicit
+ + " FROM ResourceGroup g JOIN g.implicitResources ir where g.id = :groupId"
+ + " AND ir.currentAvailability.availabilityType = 2 ),\n"
+ " (SELECT count(ir) " // DISABLED implicit
+ " FROM ResourceGroup g JOIN g.implicitResources ir where g.id = :groupId"
+ " AND ir.currentAvailability.availabilityType = 3 )\n,"
@@ -1427,7 +1437,7 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
Object[] data = results.get(0);
- ResourceGroup group = (ResourceGroup) data[6];
+ ResourceGroup group = (ResourceGroup) data[8];
ResourceType type = group.getResourceType();
ResourceFacets facets;
if (type == null) {
@@ -1439,21 +1449,23 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
}
ResourceGroupComposite composite = null;
- if (((Number) data[3]).longValue() > 0) {
+ if (((Number) data[4]).longValue() > 0) {
long explicitCount = ((Number) data[0]).longValue();
long explicitDown = ((Number) data[1]).longValue();
- long explicitDisabled = ((Number) data[2]).longValue();
- long implicitCount = ((Number) data[3]).longValue();
- long implicitDown = ((Number) data[4]).longValue();
- long implicitDisabled = ((Number) data[5]).longValue();
+ long explicitUnknown = ((Number) data[2]).longValue();
+ long explicitDisabled = ((Number) data[3]).longValue();
+ long implicitCount = ((Number) data[4]).longValue();
+ long implicitDown = ((Number) data[5]).longValue();
+ long implicitUnknown = ((Number) data[6]).longValue();
+ long implicitDisabled = ((Number) data[7]).longValue();
// In the past we had only DOWN/0 and UP/1 avails/ordinal and and the avails were just averages.
// Now we have DISABLED and UNKNOWN. So group avail is done differently, instead of a ratio of
// of UP vs DOWN it is now handled with counts. This is handled in the composite.
- composite = new ResourceGroupComposite(explicitCount, explicitDown, explicitDisabled,
- implicitCount, implicitDown, implicitDisabled, group, facets);
+ composite = new ResourceGroupComposite(explicitCount, explicitDown, explicitUnknown, explicitDisabled,
+ implicitCount, implicitDown, implicitUnknown, implicitDisabled, group, facets);
} else {
- composite = new ResourceGroupComposite(0L, 0L, 0L, 0L, 0L, 0L, group, facets);
+ composite = new ResourceGroupComposite(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, group, facets);
}
return composite;
@@ -1543,9 +1555,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
+ " new org.rhq.core.domain.resource.group.composite.ResourceGroupComposite( "
+ " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail ) AS explicitCount," // explicit member count
+ " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 0 ) AS explicitDown," // explicit member count with DOWN avail
+ + " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 2 ) AS explicitUnknown," // explicit member count with UNKNOWN avail
+ " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 3 ) AS explicitDisabled," // explicit member count with DISABLED avail
+ " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail ) AS implicitCount," // implicit member count
+ " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 0 ) AS implicitDown," // implicit member count with DOWN avail
+ + " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 2 ) AS implicitUnknown," // implicit member count with UNKNOWN avail
+ " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 3 ) AS implicitDisabled," // implicit member count with DISABLED avail
+ " %alias% ) "; // ResourceGroup
break;
@@ -1555,9 +1569,11 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
+ " new org.rhq.core.domain.resource.group.composite.ResourceGroupComposite( "
+ " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail ) AS explicitCount," // explicit member count
+ " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 0 ) AS explicitDown," // explicit member count with DOWN avail
+ + " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 2 ) AS explicitUnknown," // explicit member count with UNKNOWN avail
+ " ( SELECT COUNT(avail) FROM %alias%.explicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 3 ) AS explicitDisabled," // explicit member count with DISABLED avail
+ " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail ) AS implicitCount," // implicit member count
+ " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 0 ) AS implicitDown," // implicit member count with DOWN avail
+ + " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 2 ) AS implicitUnknown," // implicit member count with UNKNOWN avail
+ " ( SELECT COUNT(avail) FROM %alias%.implicitResources res JOIN res.currentAvailability avail WHERE avail.availabilityType = 3 ) AS implicitDisabled," // implicit member count with DISABLED avail
+ " %alias%, " // ResourceGroup
+ " ( SELECT count(p) FROM %permAlias%.roles r JOIN r.subjects s JOIN r.permissions p WHERE s.id = %subjectId% AND p = 8 ), " // MANAGE_MEASUREMENTS